claude-dev-env 1.21.1 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,194 @@
1
+ ---
2
+ name: findbugs
3
+ description: >-
4
+ Audits the current branch's pull request as a whole for bugs by spawning the
5
+ code-quality-agent against the full PR diff with zero conversation context.
6
+ Returns P0/P1/P2 findings with file:line evidence and a verified-clean
7
+ coverage list. Read-only — never modifies code. Triggers: '/findbugs',
8
+ 'find bugs in this PR', 'audit the PR', 'bug audit on the branch'.
9
+ ---
10
+
11
+ # Findbugs
12
+
13
+ **Core principle:** A clean-room bug audit on the entire pull request. The audit agent receives the PR diff and nothing else — no chat history, no prior framing, no implicit "we already looked at this." Independence is the point.
14
+
15
+ ## When this skill applies
16
+
17
+ User types `/findbugs` or asks for a bug audit on the current branch's PR. Typical moment: PR is up (draft or ready), and the user wants an independent second pair of eyes before merge or before requesting human review.
18
+
19
+ If the current branch has no associated PR and no diff against the default branch, say so and stop. Do not invent scope.
20
+
21
+ ## The Process
22
+
23
+ ### Step 1: Resolve PR scope
24
+
25
+ Determine the audit target in this order:
26
+
27
+ 1. **Open PR for current branch.** Run `gh pr view --json number,baseRefName,headRefName,url` from the working directory. If a PR exists, capture its number, base ref, head ref, and URL.
28
+ 2. **No PR but a remote default branch exists.** Diff against the default branch's merge-base: `git merge-base HEAD origin/<default>` then `git diff <merge-base>...HEAD`. Treat this as the audit scope.
29
+ 3. **Neither.** Respond exactly: `No PR or upstream diff found. Push the branch or open a PR first.` and stop.
30
+
31
+ ### Step 2: Capture the full PR diff
32
+
33
+ When a PR exists: `gh pr diff <number> -R <owner>/<repo> > .findbugs-pr.patch`.
34
+
35
+ When falling back to merge-base diff: `git diff <merge-base>...HEAD > .findbugs-pr.patch`.
36
+
37
+ The audit's authoritative scope is this single diff file. Do not inject extra files, related history, or "files Claude edited this session" — those introduce anchoring bias.
38
+
39
+ ### Step 3: Spawn the code-quality-agent — clean room
40
+
41
+ Call the Agent tool with:
42
+
43
+ - `subagent_type: code-quality-agent`
44
+ - `model: sonnet`
45
+ - `description: "PR bug audit"`
46
+ - `run_in_background: false` — the user invoked `/findbugs` to get a result on this turn
47
+
48
+ **The agent prompt must be self-contained and context-free.** Specifically:
49
+
50
+ - **No references to the orchestrator's conversation.** Forbidden phrases: "as we discussed," "the earlier issue," "given our prior work," "the bug from last turn," "you previously identified."
51
+ - **No hints about expected outcomes.** Do not pre-stage findings, do not suggest where bugs probably are, do not name files as "the suspicious one." The agent forms its own hypotheses.
52
+ - **No instructions to favor or skip particular categories** beyond the standard category list. No "skip the typing stuff" or "focus on the clipboard logic" — those bias the audit.
53
+ - **Minimal background.** Identify the repo, branch, base branch, and PR URL only. Do not summarize what the PR does.
54
+
55
+ The XML prompt skeleton:
56
+
57
+ ```xml
58
+ <context>
59
+ <repo>owner/repo</repo>
60
+ <branch>head ref</branch>
61
+ <base_branch>base ref</base_branch>
62
+ <pr_url>url or "none"</pr_url>
63
+ </context>
64
+
65
+ <scope>
66
+ <diff_path>.findbugs-pr.patch (absolute path)</diff_path>
67
+ <scope_rule>Audit only lines added or modified in the diff. Pre-existing code on untouched lines is out of scope.</scope_rule>
68
+ </scope>
69
+
70
+ <bug_categories>
71
+ Investigate each explicitly:
72
+ A. API contract verification (signatures, return types, async/await correctness)
73
+ B. Selector / query / engine compatibility
74
+ C. Resource cleanup and lifecycle (file handles, connections, processes, locks)
75
+ D. Variable scoping, ordering, and unbound references
76
+ E. Dead code and unused imports
77
+ F. Silent failures (catch-all excepts, unconditional success returns, missing error propagation)
78
+ G. Off-by-one, bounds, and integer overflow
79
+ H. Security boundaries (injection, path traversal, auth bypass, secret leakage)
80
+ I. Concurrency hazards (race conditions, missing awaits, shared mutable state)
81
+ J. Magic values and configuration drift
82
+ </bug_categories>
83
+
84
+ <constraints>
85
+ Read-only. Report findings only. Do not modify code, do not propose
86
+ full diffs, do not commit, do not push. Cite file:line for every claim.
87
+ When the diff alone does not provide enough context to confirm or deny
88
+ a bug, list it under "Open questions" rather than asserting.
89
+ </constraints>
90
+
91
+ <output_format>
92
+ P0 = will not run / data corruption
93
+ P1 = regression or silent failure
94
+ P2 = dead code, minor smell
95
+
96
+ ## Summary
97
+ Total: N (P0=N, P1=N, P2=N)
98
+
99
+ ## Findings
100
+ ### [P_] short title
101
+ File: file/path:line
102
+ Category: A-J
103
+ Issue: 2-3 sentence description with concrete trace
104
+ Evidence: code excerpt or grep result
105
+
106
+ ## Verified clean
107
+ Per category investigated, name the evidence and the conclusion.
108
+
109
+ ## Open questions
110
+ Anything ambiguous from the diff alone.
111
+ </output_format>
112
+ ```
113
+
114
+ ### Step 4: Surface findings, then clean up
115
+
116
+ When the agent returns, report concisely:
117
+
118
+ - One-line totals: `N P0 / N P1 / N P2 — K categories cleared`
119
+ - Each finding's `file:line`, category, and one-sentence description
120
+ - The cleared categories so the user can see coverage breadth
121
+ - Any open questions the agent could not resolve from the diff alone
122
+
123
+ Offer the next step without auto-executing it: `Want me to spawn clean-coder to fix the P0/P1 findings?`
124
+
125
+ Delete `.findbugs-pr.patch` after the audit completes (or moves to a fix flow). Temporary diff files do not belong in the working tree.
126
+
127
+ Do not paste the full agent transcript or the XML prompt unless the user asks.
128
+
129
+ ## Output Format
130
+
131
+ ```
132
+ N P0 / N P1 / N P2 — K categories cleared
133
+
134
+ P1 — short title
135
+ file/path.py:NN — one-sentence description (category: <name>)
136
+
137
+ P2 — short title
138
+ file/path.py:NN — one-sentence description (category: <name>)
139
+
140
+ Verified clean: <category>, <category>, <category>
141
+
142
+ Open questions:
143
+ <if any>
144
+
145
+ Want me to spawn clean-coder to fix the P0/P1 findings?
146
+ ```
147
+
148
+ ## Constraints
149
+
150
+ - **Read-only.** The skill never edits code, never pushes, never commits.
151
+ - **Foreground spawn.** The user is waiting for the result on this turn.
152
+ - **PR-scoped, not session-scoped.** The audit covers the entire PR diff regardless of which files were edited in this conversation.
153
+ - **Clean-room prompt.** The agent's prompt is self-contained — no references to chat history, no anchoring hints, no expected outcomes.
154
+ - **No clean-coder auto-spawn.** Always ask before fixing.
155
+ - **Trust the agent's verdict.** Pass through P0/P1/P2 categorizations as the agent assigned them; do not re-rank.
156
+ - **Temp file cleanup.** Delete `.findbugs-pr.patch` when the audit ends.
157
+
158
+ ## Examples
159
+
160
+ <example>
161
+ User: `/findbugs`
162
+ Claude: [resolves PR #42 from current branch, fetches full diff, spawns code-quality-agent foreground with self-contained prompt, returns]
163
+
164
+ `1 P0 / 2 P1 / 0 P2 — 7 categories cleared`
165
+
166
+ `P0 — race condition on shared cache write`
167
+ ` src/cache.py:88 — concurrent writers can both pass the existence check before either writes (category: concurrency)`
168
+
169
+ `P1 — silent paste failure`
170
+ ` utils/clipboard.py:33 — validated_paste returns success without verifying the post-paste state (category: silent failure)`
171
+
172
+ `P1 — unbound variable on early-exception path`
173
+ ` src/processor.py:283 — scheduling_log referenced after try/finally where it may be unbound (category: scoping)`
174
+
175
+ `Verified clean: API contract, selector compatibility, resource cleanup, dead code, off-by-one, security boundaries, magic values`
176
+
177
+ `Open questions: none`
178
+
179
+ `Want me to spawn clean-coder to fix the P0 + P1s?`
180
+ </example>
181
+
182
+ <example>
183
+ User: `/findbugs`
184
+ Claude: `No PR or upstream diff found. Push the branch or open a PR first.`
185
+ </example>
186
+
187
+ <example>
188
+ User: `/findbugs` (branch with no PR but commits ahead of main)
189
+ Claude: [falls back to `git diff origin/main...HEAD`, runs audit on that diff scope]
190
+ </example>
191
+
192
+ ## Why this design
193
+
194
+ Anchoring bias is the failure mode of context-rich audits. An agent that inherits "we just fixed three bugs in clipboard_utils.py" subconsciously scopes its hunt around clipboard_utils.py and pattern-matches on the same bug shapes. A clean-room audit on the full PR diff treats every file equally, considers every category, and surfaces things the orchestrator session never looked at. The diff is the contract; everything else is noise.
@@ -0,0 +1,142 @@
1
+ ---
2
+ name: fixbugs
3
+ description: >-
4
+ Fixes the bugs surfaced by the most recent /findbugs invocation by handing
5
+ the findings to /agent-prompt, which authors a structured XML prompt and
6
+ spawns a background sonnet clean-coder agent to implement every fix in one
7
+ commit on the existing branch. Default scope: all severities. Optional
8
+ argument filters by severity (e.g. /fixbugs P0, /fixbugs P0+P1).
9
+ Triggers: '/fixbugs', 'fix all the bugs', 'apply the audit fixes',
10
+ 'implement the findbugs results'.
11
+ ---
12
+
13
+ # Fixbugs
14
+
15
+ **Core principle:** A thin bridge between `/findbugs` (read-only audit) and `/agent-prompt` (structured prompt authoring + spawn). /fixbugs recovers the prior findings, packages them as a goal, and hands off. It does not author prompts itself, does not spawn agents directly, and does not run audits.
16
+
17
+ ## When this skill applies
18
+
19
+ Right after `/findbugs` returned findings on the current branch and the user wants the bugs fixed without further triage. Bare `/fixbugs` defaults to all severities (P0 + P1 + P2). Argument-filtered invocations (e.g. `/fixbugs P0`, `/fixbugs P0+P1`, `/fixbugs P0 P1`) narrow the target set.
20
+
21
+ Refusal cases:
22
+
23
+ - **No findings in session.** Respond exactly: `No findings in this session. Run /findbugs first.` and stop.
24
+ - **Most recent /findbugs returned zero bugs.** Respond exactly: `No bugs to fix.` and stop.
25
+ - **Filter excludes every finding.** Respond: `No bugs match the filter <args>.` and stop.
26
+
27
+ ## The Process
28
+
29
+ ### Step 1: Recover the findings
30
+
31
+ Locate the most recent `/findbugs` output in the current conversation. For each finding, capture:
32
+
33
+ - Severity (`P0` / `P1` / `P2`)
34
+ - `file:line`
35
+ - Category (the A–J letter or category name `/findbugs` reported)
36
+ - One-sentence description as `/findbugs` wrote it
37
+
38
+ Apply the severity filter from `$ARGUMENTS` if present:
39
+
40
+ - `P0` → P0 only
41
+ - `P0+P1` or `P0 P1` → P0 and P1
42
+ - `P1` → P1 only
43
+ - absent → all severities
44
+
45
+ If the filtered set is empty, refuse per the refusal cases above.
46
+
47
+ ### Step 2: Re-resolve PR scope
48
+
49
+ Re-establish the same PR target `/findbugs` used:
50
+
51
+ 1. `gh pr view --json number,baseRefName,headRefName,url` from the working directory.
52
+ 2. Fall back to `git merge-base HEAD origin/<default>` then `git diff <merge-base>...HEAD`.
53
+ 3. Neither → respond `No PR or upstream diff. Cannot scope fixes.` and stop.
54
+
55
+ Capture: `<owner>/<repo>`, head branch, base branch, PR number, PR URL.
56
+
57
+ ### Step 3: Hand off to /agent-prompt
58
+
59
+ Invoke the `agent-prompt` skill with a goal string of this exact shape:
60
+
61
+ ```
62
+ Fix the following bugs surfaced by /findbugs on
63
+ <owner>/<repo> @ <head_branch> (PR #<number>, base <base_branch>):
64
+
65
+ [for each filtered finding, one bullet:]
66
+ - [<severity>] <file:line> (<category>): <description>
67
+
68
+ Deploy a clean-coder background agent (model: sonnet) to implement all fixes
69
+ in one commit on the existing branch and push. Constraints:
70
+ - Modify only the files referenced in the bug list above.
71
+ - Do NOT change the PR base, do NOT rebase, do NOT amend, do NOT --force.
72
+ - Do NOT skip git hooks (no --no-verify, no --no-gpg-sign).
73
+ - Use git add by explicit path; never `git add .` or `git add -A`.
74
+ - Preserve existing comments on lines you do not modify.
75
+ - Type hints on every signature you touch.
76
+
77
+ After push, report: commit SHA, per-file lines added/removed, hook output
78
+ summary, and confirmation that each bug above was addressed.
79
+ ```
80
+
81
+ `/agent-prompt` then runs its own workflow end-to-end: prompt-generator authoring, Outcome preview, AskUserQuestion confirmation gate, background spawn. The confirmation gate is preserved — fixes are write operations and the user must approve the final XML before the agent runs.
82
+
83
+ ### Step 4: Hand-off complete
84
+
85
+ `/fixbugs` produces no further output. `/agent-prompt` owns the visible chat from this point: the XML fence, the Outcome digest, the AskUserQuestion, and the spawn confirmation. Do not duplicate any of those, do not summarize them, do not add commentary.
86
+
87
+ ## Output Format
88
+
89
+ When `/fixbugs` proceeds, the visible output is `/agent-prompt`'s output — nothing from `/fixbugs` itself.
90
+
91
+ When `/fixbugs` short-circuits (no findings, no PR, empty filter, zero bugs), the visible output is the single-line refusal message and nothing else.
92
+
93
+ ## Constraints
94
+
95
+ - **Sequencing.** `/fixbugs` runs AFTER `/findbugs`. It does not perform audits.
96
+ - **Scope inheritance.** Fixes target only files referenced in the prior `/findbugs` findings — the PR diff scope. Do not expand to unrelated files.
97
+ - **No silent spawn.** `/agent-prompt`'s confirmation gate is preserved on every run.
98
+ - **One commit per `/fixbugs` run.** All filtered fixes batch into a single commit.
99
+ - **No `--force`, no `--amend`, no rebase, no base change.** Standard git workflow applies to the spawned agent.
100
+ - **Sonnet for the implementer.** Always pass `model: sonnet` to the spawn — keeps cost predictable and matches the agent's training fit for code edits.
101
+ - **Background spawn.** The user typed `/fixbugs` to delegate, not to wait. The agent runs in the background and notifies on completion.
102
+
103
+ ## Examples
104
+
105
+ <example>
106
+ User: `/findbugs` → returns `1 P0 / 2 P1 / 0 P2`
107
+ User: `/fixbugs`
108
+ Claude: [recovers all 3 findings, resolves PR scope, invokes /agent-prompt with a goal targeting all 3 bugs; /agent-prompt presents the XML + Outcome digest + AskUserQuestion; on Launch it, the background sonnet clean-coder spawns]
109
+ </example>
110
+
111
+ <example>
112
+ User: `/findbugs` → returns `1 P0 / 2 P1 / 1 P2`
113
+ User: `/fixbugs P0+P1`
114
+ Claude: [filters to 3 findings (the P2 is dropped), hands the filtered set to /agent-prompt]
115
+ </example>
116
+
117
+ <example>
118
+ User: `/fixbugs` (no prior /findbugs in session)
119
+ Claude: `No findings in this session. Run /findbugs first.`
120
+ </example>
121
+
122
+ <example>
123
+ User: `/findbugs` → returns `0 P0 / 0 P1 / 0 P2`
124
+ User: `/fixbugs`
125
+ Claude: `No bugs to fix.`
126
+ </example>
127
+
128
+ <example>
129
+ User: `/findbugs` → returns `0 P0 / 0 P1 / 1 P2`
130
+ User: `/fixbugs P0`
131
+ Claude: `No bugs match the filter P0.`
132
+ </example>
133
+
134
+ ## Why this design
135
+
136
+ Three skills, three responsibilities:
137
+
138
+ - `/findbugs` audits in a clean room, returns findings.
139
+ - `/fixbugs` packages findings as a goal, delegates.
140
+ - `/agent-prompt` authors the XML and spawns the agent (with confirmation).
141
+
142
+ Each skill stays small and reuses what already exists. `/fixbugs` adds value by recovering findings from chat, filtering by severity, and writing the goal in `/agent-prompt`'s expected shape — not by reimplementing prompt authoring or spawn logic. The `/agent-prompt` confirmation gate is non-negotiable because fixes write code, push to a PR, and are visible to reviewers; the friction is the safety.