claude-dev-env 2.0.2 → 2.1.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.
Files changed (88) hide show
  1. package/CLAUDE.md +1 -1
  2. package/hooks/blocking/CLAUDE.md +1 -0
  3. package/hooks/blocking/code_rules_shared.py +126 -47
  4. package/hooks/blocking/config/CLAUDE.md +2 -0
  5. package/hooks/blocking/config/verified_commit_context_constants.py +21 -0
  6. package/hooks/blocking/config/verified_commit_gate_output_constants.py +14 -0
  7. package/hooks/blocking/conftest.py +36 -30
  8. package/hooks/blocking/convergence_gate_blocker.py +76 -8
  9. package/hooks/blocking/plain_language_blocker.py +8 -0
  10. package/hooks/blocking/state_description_blocker.py +4 -1
  11. package/hooks/blocking/test_code_rules_shared.py +120 -20
  12. package/hooks/blocking/test_convergence_gate_blocker.py +146 -0
  13. package/hooks/blocking/test_plain_language_blocker.py +15 -0
  14. package/hooks/blocking/test_state_description_blocker.py +15 -0
  15. package/hooks/blocking/test_verified_commit_config_bootstrap.py +18 -0
  16. package/hooks/blocking/test_verified_commit_gate_additional_context.py +134 -0
  17. package/hooks/blocking/tests/test_verified_commit_gate.py +41 -0
  18. package/hooks/blocking/verified_commit_config_bootstrap.py +22 -10
  19. package/hooks/blocking/verified_commit_gate.py +113 -568
  20. package/hooks/blocking/verified_commit_gate_parts/CLAUDE.md +28 -0
  21. package/hooks/blocking/verified_commit_gate_parts/__init__.py +1 -0
  22. package/hooks/blocking/verified_commit_gate_parts/command_tokenization.py +174 -0
  23. package/hooks/blocking/verified_commit_gate_parts/deny_payload.py +53 -0
  24. package/hooks/blocking/verified_commit_gate_parts/deny_reason.py +80 -0
  25. package/hooks/blocking/verified_commit_gate_parts/directory_resolution.py +170 -0
  26. package/hooks/blocking/verified_commit_gate_parts/gated_invocations.py +205 -0
  27. package/hooks/blocking/verified_commit_gate_parts/tests/conftest.py +10 -0
  28. package/hooks/blocking/verified_commit_gate_parts/tests/test_command_tokenization.py +94 -0
  29. package/hooks/blocking/verified_commit_gate_parts/tests/test_deny_payload.py +17 -0
  30. package/hooks/blocking/verified_commit_gate_parts/tests/test_deny_reason.py +38 -0
  31. package/hooks/blocking/verified_commit_gate_parts/tests/test_directory_resolution.py +71 -0
  32. package/hooks/blocking/verified_commit_gate_parts/tests/test_gated_invocations.py +61 -0
  33. package/hooks/hooks_constants/CLAUDE.md +4 -1
  34. package/hooks/hooks_constants/code_rules_path_utils_constants.py +1 -0
  35. package/hooks/hooks_constants/convergence_gate_blocker_constants.py +36 -0
  36. package/hooks/hooks_constants/harness_scratchpad_constants.py +10 -9
  37. package/hooks/hooks_constants/mypy_integration_constants.py +16 -0
  38. package/hooks/validators/mypy_integration.py +145 -24
  39. package/hooks/validators/python_antipattern_checks.py +16 -0
  40. package/hooks/validators/run_all_validators.py +9 -3
  41. package/hooks/validators/test_mypy_integration.py +154 -0
  42. package/hooks/validators/test_python_antipattern_checks.py +112 -1
  43. package/hooks/validators/test_run_all_validators_pretooluse.py +16 -0
  44. package/package.json +1 -1
  45. package/rules/CLAUDE.md +1 -0
  46. package/rules/verified-commit-gate-skip.md +28 -0
  47. package/skills/auditing-claude-config/CLAUDE.md +2 -1
  48. package/skills/auditing-claude-config/SKILL.md +114 -176
  49. package/skills/auditing-claude-config/reference/probe-hook.md +74 -0
  50. package/skills/autoconverge/CLAUDE.md +1 -0
  51. package/skills/autoconverge/SKILL.md +310 -346
  52. package/skills/autoconverge/reference/CLAUDE.md +1 -0
  53. package/skills/autoconverge/reference/copilot-findings.md +51 -0
  54. package/skills/closeout/SKILL.md +7 -9
  55. package/skills/copilot-finding-triage/SKILL.md +5 -7
  56. package/skills/copilot-review/CLAUDE.md +3 -2
  57. package/skills/copilot-review/SKILL.md +119 -155
  58. package/skills/copilot-review/templates/subagent-prompt.md +49 -0
  59. package/skills/fresh-branch/CLAUDE.md +6 -9
  60. package/skills/fresh-branch/SKILL.md +84 -33
  61. package/skills/fresh-branch/scripts/create_fresh_branch.py +445 -0
  62. package/skills/fresh-branch/scripts/fresh_branch_scripts_constants/__init__.py +1 -0
  63. package/skills/fresh-branch/scripts/fresh_branch_scripts_constants/fresh_branch_cli_constants.py +74 -0
  64. package/skills/fresh-branch/scripts/test_create_fresh_branch.py +670 -0
  65. package/skills/pr-converge/SKILL.md +277 -422
  66. package/skills/pr-converge/reference/CLAUDE.md +1 -0
  67. package/skills/pr-converge/reference/progress-checklist.md +168 -0
  68. package/skills/pr-converge/test_step5_host_branch.py +8 -6
  69. package/skills/pr-loop-cloud-transport/SKILL.md +1 -1
  70. package/skills/privacy-hygiene/SKILL.md +68 -115
  71. package/skills/privacy-hygiene/reference/sweep-procedure.md +62 -0
  72. package/skills/session-log/CLAUDE.md +2 -1
  73. package/skills/session-log/SKILL.md +4 -26
  74. package/skills/session-log/templates/frontmatter.md +40 -0
  75. package/skills/skill-builder/CLAUDE.md +8 -7
  76. package/skills/skill-builder/SKILL.md +26 -11
  77. package/skills/skill-builder/references/CLAUDE.md +3 -1
  78. package/skills/skill-builder/references/delegation-map.md +21 -12
  79. package/skills/skill-builder/references/description-field.md +9 -11
  80. package/skills/skill-builder/references/deterministic-elements.md +218 -0
  81. package/skills/skill-builder/references/self-audit-checklist.md +62 -45
  82. package/skills/skill-builder/references/skill-modularity.md +8 -9
  83. package/skills/skill-builder/templates/CLAUDE.md +2 -2
  84. package/skills/skill-builder/templates/gap-analysis.md +15 -0
  85. package/skills/skill-builder/workflows/CLAUDE.md +5 -5
  86. package/skills/skill-builder/workflows/improve-skill.md +18 -9
  87. package/skills/skill-builder/workflows/new-skill.md +23 -15
  88. package/skills/skill-builder/workflows/polish-skill.md +28 -21
@@ -1,346 +1,310 @@
1
- ---
2
- name: autoconverge
3
- description: >-
4
- Drives one draft PR to convergence in one autonomous run: a deterministic static
5
- sweep, then code review, bug audit, and self-review on one HEAD, all fixes in one
6
- commit, then Bugbot, Copilot, and Codex as terminal confirmation gates before ready.
7
- Use when the user says '/autoconverge', 'autoconverge this PR', 'converge this
8
- PR in one run', 'run the converge workflow', or 'drive the PR to ready
9
- autonomously'.
10
- ---
11
-
12
- # Autoconverge
13
-
14
- One launch drives the whole loop to convergence. The `/autoconverge` skill
15
- resolves PR scope, enters a worktree, grants project permissions, then hands
16
- the loop to the **`converge.mjs` workflow**, which runs every round and every
17
- reviewer wait inside one background pass no ticks, no `ScheduleWakeup`, no
18
- state file. State lives in the workflow's own variables; resume is handled by
19
- the workflow journal.
20
-
21
- `pr-converge` paces the same four-reviewer loop across `ScheduleWakeup` ticks;
22
- autoconverge runs it as a deterministic workflow. The two skills share the same
23
- helper scripts and the same convergence gate.
24
-
25
- ## Run scope: one PR or several
26
-
27
- Decide the scope from how many PRs the user named, then follow that path:
28
-
29
- 1. **One PR** the single-PR run described below (`workflow/converge.mjs`): one
30
- worktree, one workflow launch, one teardown.
31
- 2. **Several PRs** the [Multiple PRs](reference/multi-pr.md) run
32
- (`workflow/converge_multi.mjs`): one worktree per PR and a single workflow
33
- launch that drives every PR's converge run in parallel, then one teardown per
34
- PR.
35
-
36
- The single-PR sections (Requirements, Pre-flight, Run the workflow, Teardown)
37
- each describe one converge run. The multi-PR reference reuses them once per PR
38
- and adds only what fanning out needs: a per-PR worktree and a per-PR teardown
39
- loop.
40
-
41
- ## Requirements
42
-
43
- Scan the tool list at the top of this conversation for the literal string
44
- `Workflow`. If it is absent, report `autoconverge requires the Workflow tool;
45
- aborting` and stop. The workflow also needs the `gh` CLI authenticated for the
46
- PR's owner.
47
-
48
- ## Review-lens boundary
49
-
50
- The code-review lens boundary (workflow agent versus the built-in `/code-review`
51
- command) is defined on the **Code-review lens** bullet in
52
- [`reference/convergence.md`](reference/convergence.md).
53
-
54
- ## Transport check (before any GitHub step)
55
-
56
- Run `command -v gh`; when it succeeds, run `gh auth status`; once the PR
57
- scope is resolved, run `gh api repos/<owner>/<repo> --jq .permissions.push`
58
- and take `true` as the pass. When any check fails, run the
59
- `pr-loop-cloud-transport` skill first and route every `gh` operation in this
60
- skill through its substitution matrix. The workflow script
61
- (`workflow/converge.mjs`) embeds `gh` commands and gh-backed helper scripts in
62
- its agent prompts, so a cloud run also applies the same substitution to those
63
- agent prompts when it authors the launch the transport skill covers the
64
- orchestrating session's own steps, and the script's agent-prompt text carries
65
- `gh` calls the spawned agents cannot run in a cloud session.
66
-
67
- ## Pre-flight (main session)
68
-
69
- 1. **Enter a worktree.** Call `EnterWorktree` with no arguments before any
70
- `gh`, `git`, file read, or edit. `gh`/`git` Bash calls do not auto-isolate,
71
- so this is mandatory. If it fails, report and stop. A bare `EnterWorktree`
72
- branches from `origin/main`; step 2 positions the worktree on the PR's head
73
- ref, which the workflow needs.
74
-
75
- 2. **Resolve PR scope.** When the user passed a PR URL or number, parse owner,
76
- repo, and number from it. Otherwise read the current branch's PR:
77
- `gh pr view --json number,headRefName,url,isDraft,baseRefName`. Capture
78
- `owner`, `repo`, `prNumber`. Confirm the PR is a draft; if it is already
79
- ready, mark it draft first (`gh pr ready <n> --repo <o>/<r> --undo`) so the
80
- loop owns the ready transition.
81
-
82
- **Position the worktree on the PR branch.** The workflow reviews
83
- `git diff origin/main...HEAD` against this worktree's local `HEAD` and pushes
84
- each fix to the PR branch, so the worktree sits on the PR's head ref at the PR
85
- HEAD before the workflow launches. A worktree fresh off `origin/main` has
86
- `HEAD == origin/main`, shows an empty diff, and reports a false convergence
87
- with zero findings. When a local worktree already tracks the PR branch, enter
88
- that one by passing its path to `EnterWorktree`; otherwise put the entered
89
- worktree on the branch with `gh pr checkout <number> --repo <owner>/<repo>`
90
- (or `git fetch origin <headRefName>` then `git switch <headRefName>`). Confirm
91
- before launching: `git rev-parse --abbrev-ref HEAD` equals the PR's head ref
92
- and local `HEAD` equals the PR head SHA.
93
-
94
- 3. **Verify the worktree is the PR's repo (strict pre-flight).** Run
95
- `python "$HOME/.claude/skills/_shared/pr-loop/scripts/preflight_worktree.py" --owner <owner> --repo <repo> --mode strict`.
96
- It confirms the working directory is a checkout of the PR's own repo and
97
- that `git worktree` machinery is healthy, so `EnterWorktree` can create and
98
- enter the branch worktree. A non-zero exit prints a `PREFLIGHT_OUTCOME` line
99
- and an `ABORT` line: report that line and stop. Autoconverge runs inside the
100
- PR's own repo, so a working directory rooted in a different repo (for
101
- example, `claude-dev-env` while the PR lives in `llm-settings`) or in no
102
- git checkout at all cannot continue.
103
-
104
- 4. **Grant project permissions.** Apply the `pr-loop-lifecycle` skill's Open
105
- section (`../pr-loop-lifecycle/SKILL.md`) the grant command
106
- (`grant_project_claude_permissions.py`) and the auto-mode `AskUserQuestion`
107
- escalation for a blocked grant both live there.
108
-
109
- 5. **Copilot quota pre-check.** Before the `Workflow` call, apply the
110
- `reviewer-gates` skill's Copilot quota gate (`../reviewer-gates/SKILL.md`)
111
- once. Exit 0 maps to `copilotDisabled: false` in the Workflow call; any
112
- non-zero exit maps to `copilotDisabled: true`, and the workflow then skips
113
- the Copilot gate with no agent spawned.
114
-
115
- ## Run the workflow
116
-
117
- Call the `Workflow` tool against the colocated script:
118
-
119
- ```
120
- Workflow({
121
- scriptPath: "<this skill dir>/workflow/converge.mjs",
122
- args: { owner: "<O>", repo: "<R>", prNumber: <N>, bugbotDisabled: false, copilotDisabled: false }
123
- })
124
- ```
125
-
126
- `scriptPath` is the absolute path to `workflow/converge.mjs` inside this skill's
127
- own directory (on this install,
128
- `<home>/.claude/skills/autoconverge/workflow/converge.mjs`). Set
129
- `bugbotDisabled: true` only when the user has opted Cursor Bugbot out for the
130
- run; otherwise the workflow detects an opt-out or an unreachable Bugbot on its
131
- own. Set `copilotDisabled: true` when the step 5 quota pre-check exits non-zero,
132
- and `false` when it exits 0; on `true` the workflow skips the Copilot gate with
133
- no agent spawned. The workflow runs in the background and notifies this session
134
- on completion. Watch live progress with `/workflows`.
135
-
136
- The moment the `Workflow` call returns its run id, write the durable handoff so a
137
- fresh session can resume the same run:
138
-
139
- ```
140
- python "$HOME/.claude/skills/_shared/pr-loop/scripts/write_handoff.py" \
141
- --pr-number <N> --head-ref <branch> --phase workflow \
142
- --resume-command "Workflow({scriptPath, resumeFromRunId: '<runId>'})" \
143
- --run-id <runId>
144
- ```
145
-
146
- Write it again when the result lands, so the handoff carries the final run id and
147
- names the teardown phase the fresh session picks up from.
148
-
149
- The workflow returns
150
- `{ converged, rounds, finalSha, blocker, standardsNote, copilotNote, cleanAuditNote, reuseNote, deferredPrs }`,
151
- plus a `userReview` field on a `blocker: "user-review"` return. `cleanAuditNote` is
152
- non-null when the environment refused the CLEAN bugteam review post and the run
153
- recorded the bypass — see
154
- [`reference/stop-conditions.md`](reference/stop-conditions.md) § Clean-audit post
155
- bypassed.
156
- `deferredPrs` is the list of draft environment-hardening PRs the standards-deferral
157
- path opened this run, each as `{ owner, repo, prNumber, copilotDisabled, bugbotDisabled }`.
158
- The two flags carry this run's Copilot and Bugbot availability, so the next generation
159
- skips a reviewer that is down or out of quota without re-probing. This list is the seed the
160
- [self-closing loop](reference/self-closing-loop.md) converges next.
161
-
162
- ## Copilot findings — tier, verify, then route
163
-
164
- The Copilot gate tiers each finding: a **self-healing** finding (style, type
165
- hints, imports, formatting, magic-value extraction, test-only or doc-vs-code
166
- fixes nothing that changes observable runtime behavior) flows into the fix
167
- round with no user notification. A **code-concern** finding (logic, security,
168
- data handling, error-handling semantics, concurrency the tier whenever in
169
- doubt) goes to a verification stage before any routing.
170
-
171
- Each code-concern finding gets its own verifier agent, all in parallel, inside
172
- the workflow. A verdict is conclusive only when an actual check ran: the verifier
173
- executes a command against the flagged HEAD — running the code path with crafted
174
- inputs, forcing the claimed error condition, or running a purpose-built test
175
- and captures its output. The verdict carries
176
- `{ verdict, checkCommand, checkOutput, evidence }`; a conclusive verdict with an
177
- empty `checkCommand` or `checkOutput` downgrades to inconclusive.
178
-
179
- - **confirmed** the check reproduces the defect. The finding becomes
180
- self-healing: it joins the fix round carrying its repro, and the fix re-runs
181
- that same check, adds a regression test where the suite covers the surface,
182
- lands in one commit, pushes, and replies on the thread with the fix SHA and the
183
- before/after output. No page.
184
- - **refuted** the check shows the code already behaves correctly in the exact
185
- scenario the finding claims is broken. The workflow replies on the thread with
186
- the command and output, resolves it, and counts it clean. No page.
187
- - **inconclusive** everything else, and the verifier's default: no runnable
188
- check exists, the check is infeasible here, the results are ambiguous, or the
189
- fix needs a product decision. Any doubt sorts here. Only inconclusive findings
190
- page the user.
191
-
192
- A round whose code concerns all confirm or refute never returns
193
- `blocker: "user-review"`. On one or more inconclusive findings, the workflow
194
- stops with `converged: false`, `blocker: "user-review"`, and a `userReview`
195
- field carrying
196
- `{ reviewUrl, findings: [{ file, line, severity, tier, title, evidence }] }` —
197
- `evidence` is the verifier's one-line note stating what check was attempted and
198
- why it was not decisive.
199
-
200
- A background workflow cannot hold for a human, so the wait belongs to the
201
- orchestrating session. On a `blocker: "user-review"` return, run the
202
- [`copilot-finding-triage`](../copilot-finding-triage/SKILL.md) skill: send the
203
- ntfy notification (the per-finding summary and evidence note plus the `reviewUrl`
204
- Copilot review link), then hold with a 45-minute `ScheduleWakeup` for the user's
205
- response. When the user answers within the window, follow their direction. When
206
- the window closes with no response, run normal teardown and report the
207
- inconclusive findings un-reviewed.
208
-
209
- ## Budget stop
210
-
211
- `converge.mjs` paces itself against the workflow `budget` API and stops at a
212
- round boundary when a full round does not fit —
213
- [`reference/stop-conditions.md`](reference/stop-conditions.md) § Budget stop
214
- gives the rule. On a `blocker: "budget"` return, write the durable handoff with
215
- the run id and the `Workflow({scriptPath, resumeFromRunId})` resume command
216
- before stopping, so a fresh session resumes the paced run without the stopped
217
- session's transcript.
218
-
219
- ## Teardown (on workflow completion)
220
-
221
- Teardown runs as an ordered checkpoint list. After each checkpoint finishes,
222
- re-write the durable handoff with `--phase teardown`, the run id, and the
223
- checkpoints done so far, so a fresh session that resumes reads `handoff.json`
224
- `completed_steps` and skips the checkpoints already done:
225
-
226
- ```
227
- python "$HOME/.claude/skills/_shared/pr-loop/scripts/write_handoff.py" \
228
- --pr-number <N> --head-ref <branch> --phase teardown \
229
- --resume-command "/autoconverge <PR URL>" \
230
- --run-id <runId> \
231
- --completed-steps "<checkpoints done so far>"
232
- ```
233
-
234
- The checkpoints run in this order: `report`, `close`. Write the
235
- handoff after each one finishes.
236
-
237
- On teardown entry, when `~/.claude/runtime/pr-loop/bugteam-pr-<N>/handoff.json`
238
- exists, read its `completed_steps` and skip any checkpoint the list already
239
- names, so a resumed run performs only the checkpoints left.
240
-
241
- On a `blocker: "user-review"` return, the workflow held one or more code-concern
242
- findings that stayed inconclusive after the executed-check verification stage.
243
- Run the [`copilot-finding-triage`](../copilot-finding-triage/SKILL.md) gate before
244
- teardown: send the ntfy alert with the per-finding summary and evidence note and
245
- the `userReview.reviewUrl` link, then hold with a 45-minute `ScheduleWakeup`. Act
246
- on the user's direction when it arrives inside the window; when the window closes
247
- with no response, fall through to normal teardown and report the
248
- `userReview.findings` un-reviewed. The PR stays a draft in this path — the
249
- workflow marked nothing ready.
250
-
251
- Before the checkpoints, when the workflow returned a non-null `copilotNote`
252
- (the Copilot gate was bypassed), query the PR's reviews once more for a
253
- `copilot-pull-request-reviewer[bot]` review on the final HEAD
254
- (`fetch_copilot_reviews.py`, or the GitHub MCP `pull_request_read` method
255
- `get_reviews`). Copilot typically posts within 10–15 minutes of a request, so
256
- a review can land between the bypass and teardown. When one exists and
257
- carries findings, mark the PR draft, route the findings through one fix
258
- round per the `pr-fix-protocol` skill, re-verify, push, and mark the PR
259
- ready again then run the checkpoints.
260
-
261
- 1. **When `converged` is true build and publish the closing report.**
262
- Skip this entire step (report, artifact publish, comment, Chrome open) when
263
- the workflow returned a non-null `blocker`. Follow
264
- [`reference/closing-report.md`](reference/closing-report.md) § Building the
265
- report and § Publishing: resolve the seed journal from the run id, merge the
266
- PR's runs with `aggregate_runs.py`, spawn the `convergence-summary` agent
267
- (a `general-purpose` subagent) on the prompt it builds, draw the report with
268
- `render_report.py`, publish the HTML via the `Artifact` tool, post the
269
- one marker-keyed `<!-- autoconverge-report -->` PR comment, and open the
270
- artifact URL in Chrome. After the report is published, write the handoff
271
- with `--completed-steps "report"`.
272
-
273
- 2. **Close the run.** Apply the `pr-loop-lifecycle` skill's Close section
274
- (`../pr-loop-lifecycle/SKILL.md`): when `converged` is true, rewrite the PR
275
- description and clean the working tree — see
276
- [`pr-loop-lifecycle/reference/teardown-publish-permissions.md` § Clean working tree and § Publish the final PR description](../pr-loop-lifecycle/reference/teardown-publish-permissions.md);
277
- the workflow already marked the PR ready. The permission revoke always runs,
278
- including on a blocker exit. Write the handoff with
279
- `--completed-steps "report,close"`.
280
-
281
- 3. **Print the final report:**
282
-
283
- ```
284
- /autoconverge exit: <converged | blocked>
285
- Rounds: <N>
286
- Final commit: <finalSha>
287
- Blocker: <blocker> # only when blocked
288
- Standards: <standardsNote> # only when a round deferred code-standard findings
289
- Copilot: <copilotNote> # only when Copilot was down or out of quota
290
- Clean-audit: <cleanAuditNote> # only when the CLEAN bugteam post was bypassed
291
- Reuse: <reuseNote> # only when the reuse pass identified an improvement
292
- ```
293
-
294
- ## What the workflow does each round
295
-
296
- [`reference/convergence.md`](reference/convergence.md) defines the whole loop:
297
- the merge-conflict pre-flight, the reuse pass and its three landing criteria,
298
- the round shape (static sweep, the three parallel reading lenses, dedup, the
299
- one-commit fix flow, the standards-deferral path), the terminal Bugbot, Copilot,
300
- and Codex gates, the per-role model tiers, the full-diff rule, and the exact
301
- ready definition `check_convergence.py` enforces.
302
- [`reference/stop-conditions.md`](reference/stop-conditions.md) lists every way
303
- the run ends short of ready. Hard-won failure lessons live in
304
- [`reference/gotchas.md`](reference/gotchas.md).
305
-
306
- Every agent prompt the workflow authors carries a headless-safety preamble
307
- read-only agents get a trimmed form, edit agents the full form with the rm
308
- auto-allow pathsspecified in
309
- [`reference/headless-safety.md`](reference/headless-safety.md).
310
-
311
- ## Multiple PRs
312
-
313
- When the user names several PRs, run the multi-PR path in
314
- [`reference/multi-pr.md`](reference/multi-pr.md): one worktree per PR
315
- (`git worktree add` on each head ref, strict pre-flight per worktree, one
316
- permission grant per repository, one Copilot quota check for the whole run),
317
- then a single `workflow/converge_multi.mjs` launch with one entry per PR, then
318
- the single-PR teardown once per `results` entry and a one-line-per-PR summary.
319
-
320
- ## Self-closing loop: converge the deferred PRs
321
-
322
- Every autoconverge run — single-PR and multi-PR alike — ends with the
323
- self-closing loop in
324
- [`reference/self-closing-loop.md`](reference/self-closing-loop.md): the
325
- orchestrating session converges the draft environment-hardening PRs the run
326
- deferred (`deferredPrs` on a single-PR run, `allDeferredPrs` on a multi-PR
327
- run), then the PRs those runs defer, generation by generation, until a
328
- generation opens none. An empty seed list ends the loop at once. The reference
329
- also carries the Conventional-Commit title rule each hardening PR must meet.
330
-
331
- ## Folder map
332
-
333
- - `SKILL.md` — this hub.
334
- - `workflow/converge.mjs` — the convergence workflow script.
335
- - `workflow/converge_multi.mjs` — the multi-PR fan-out driver: one `converge.mjs` child run per PR in parallel, each pinned to its PR worktree via `repoPath`.
336
- - `workflow/aggregate_runs.py` — merges every autoconverge journal for a PR into one journal and returns its deduped findings, fix summaries, round count, and final SHA.
337
- - `workflow/convergence_summary.py` — builds the convergence-summary agent prompt over a PR's merged findings.
338
- - `workflow/render_report.py` — builds the closing convergence insights HTML report, taking the summary from `--summary-file`.
339
- - `workflow/autoconverge_report_constants/` — named constants for the report builder and the summary prompt.
340
- - `reference/convergence.md` — the whole loop: reuse pass, round shape, terminal gates, model tiers, ready definition.
341
- - `reference/stop-conditions.md` — every way the run ends short of ready, including the budget stop.
342
- - `reference/gotchas.md` — hard-won failure lessons.
343
- - `reference/closing-report.md` — the closing HTML report: data source, build steps, publishing.
344
- - `reference/multi-pr.md` — the several-PRs path: per-PR worktrees, the `converge_multi.mjs` launch, per-PR teardown.
345
- - `reference/self-closing-loop.md` — the deferred-PR generations and the Conventional-Commit title rule.
346
- - `reference/headless-safety.md` — the agent-prompt preamble and the rm auto-allow paths.
1
+ ---
2
+ name: autoconverge
3
+ description: >-
4
+ Drives one draft PR to convergence in one autonomous run: static sweep, then
5
+ code review, bug audit, and self-review on one HEAD, fixes in one commit, then
6
+ Bugbot, Copilot, and Codex as terminal gates before ready. Use when the user
7
+ says '/autoconverge', 'autoconverge this PR', 'converge this PR in one run',
8
+ 'run the converge workflow', or 'drive the PR to ready autonomously'.
9
+ ---
10
+
11
+ # Autoconverge
12
+
13
+ One launch drives the whole loop to convergence. The `/autoconverge` skill
14
+ resolves PR scope, enters a worktree, grants project permissions, then hands
15
+ the loop to the **`converge.mjs` workflow**, which runs every round and every
16
+ reviewer wait inside one background pass no ticks, no `ScheduleWakeup`, no
17
+ state file. State lives in the workflow's own variables; resume is handled by
18
+ the workflow journal.
19
+
20
+ `pr-converge` paces the same four-reviewer loop across `ScheduleWakeup` ticks;
21
+ autoconverge runs it as a deterministic workflow. The two skills share the same
22
+ helper scripts and the same convergence gate.
23
+
24
+ ## Run scope: one PR or several
25
+
26
+ Decide the scope from how many PRs the user named, then follow that path:
27
+
28
+ 1. **One PR** → the single-PR run described below (`workflow/converge.mjs`): one
29
+ worktree, one workflow launch, one teardown.
30
+ 2. **Several PRs** the [Multiple PRs](reference/multi-pr.md) run
31
+ (`workflow/converge_multi.mjs`): one worktree per PR and a single workflow
32
+ launch that drives every PR's converge run in parallel, then one teardown per
33
+ PR.
34
+
35
+ The single-PR sections (Requirements, Pre-flight, Run the workflow, Teardown)
36
+ each describe one converge run. The multi-PR reference reuses them once per PR
37
+ and adds only what fanning out needs: a per-PR worktree and a per-PR teardown
38
+ loop.
39
+
40
+ ## Requirements
41
+
42
+ Scan the tool list at the top of this conversation for the literal string
43
+ `Workflow`. If it is absent, report `autoconverge requires the Workflow tool;
44
+ aborting` and stop. The workflow also needs the `gh` CLI authenticated for the
45
+ PR's owner.
46
+
47
+ ## Review-lens boundary
48
+
49
+ The code-review lens boundary (workflow agent versus the built-in `/code-review`
50
+ command) is defined on the **Code-review lens** bullet in
51
+ [`reference/convergence.md`](reference/convergence.md).
52
+
53
+ ## Transport check (before any GitHub step)
54
+
55
+ Run `command -v gh`; when it succeeds, run `gh auth status`; once the PR
56
+ scope is resolved, run `gh api repos/<owner>/<repo> --jq .permissions.push`
57
+ and take `true` as the pass. When any check fails, run the
58
+ `pr-loop-cloud-transport` skill first and route every `gh` operation in this
59
+ skill through its substitution matrix. The workflow script
60
+ (`workflow/converge.mjs`) embeds `gh` commands and gh-backed helper scripts in
61
+ its agent prompts, so a cloud run also applies the same substitution to those
62
+ agent prompts when it authors the launch the transport skill covers the
63
+ orchestrating session's own steps, and the script's agent-prompt text carries
64
+ `gh` calls the spawned agents cannot run in a cloud session.
65
+
66
+ ## Pre-flight (main session)
67
+
68
+ 1. **Enter a worktree.** Call `EnterWorktree` with no arguments before any
69
+ `gh`, `git`, file read, or edit. `gh`/`git` Bash calls do not auto-isolate,
70
+ so this is mandatory. If it fails, report and stop. A bare `EnterWorktree`
71
+ branches from `origin/main`; step 2 positions the worktree on the PR's head
72
+ ref, which the workflow needs.
73
+
74
+ 2. **Resolve PR scope.** When the user passed a PR URL or number, parse owner,
75
+ repo, and number from it. Otherwise read the current branch's PR:
76
+ `gh pr view --json number,headRefName,url,isDraft,baseRefName`. Capture
77
+ `owner`, `repo`, `prNumber`. Confirm the PR is a draft; if it is already
78
+ ready, mark it draft first (`gh pr ready <n> --repo <o>/<r> --undo`) so the
79
+ loop owns the ready transition.
80
+
81
+ **Position the worktree on the PR branch.** The workflow reviews
82
+ `git diff origin/main...HEAD` against this worktree's local `HEAD` and pushes
83
+ each fix to the PR branch, so the worktree sits on the PR's head ref at the PR
84
+ HEAD before the workflow launches. A worktree fresh off `origin/main` has
85
+ `HEAD == origin/main`, shows an empty diff, and reports a false convergence
86
+ with zero findings. When a local worktree already tracks the PR branch, enter
87
+ that one by passing its path to `EnterWorktree`; otherwise put the entered
88
+ worktree on the branch with `gh pr checkout <number> --repo <owner>/<repo>`
89
+ (or `git fetch origin <headRefName>` then `git switch <headRefName>`). Confirm
90
+ before launching: `git rev-parse --abbrev-ref HEAD` equals the PR's head ref
91
+ and local `HEAD` equals the PR head SHA.
92
+
93
+ 3. **Verify the worktree is the PR's repo (strict pre-flight).** Run
94
+ `python "$HOME/.claude/skills/_shared/pr-loop/scripts/preflight_worktree.py" --owner <owner> --repo <repo> --mode strict`.
95
+ It confirms the working directory is a checkout of the PR's own repo and
96
+ that `git worktree` machinery is healthy, so `EnterWorktree` can create and
97
+ enter the branch worktree. A non-zero exit prints a `PREFLIGHT_OUTCOME` line
98
+ and an `ABORT` line: report that line and stop. Autoconverge runs inside the
99
+ PR's own repo, so a working directory rooted in a different repo (for
100
+ example, `claude-dev-env` while the PR lives in `llm-settings`) or in no
101
+ git checkout at all cannot continue.
102
+
103
+ 4. **Grant project permissions.** Apply the `pr-loop-lifecycle` skill's Open
104
+ section (`../pr-loop-lifecycle/SKILL.md`) the grant command
105
+ (`grant_project_claude_permissions.py`) and the auto-mode `AskUserQuestion`
106
+ escalation for a blocked grant both live there.
107
+
108
+ 5. **Copilot quota pre-check.** Before the `Workflow` call, apply the
109
+ `reviewer-gates` skill's Copilot quota gate (`../reviewer-gates/SKILL.md`)
110
+ once. Exit 0 maps to `copilotDisabled: false` in the Workflow call; any
111
+ non-zero exit maps to `copilotDisabled: true`, and the workflow then skips
112
+ the Copilot gate with no agent spawned.
113
+
114
+ ## Run the workflow
115
+
116
+ Call the `Workflow` tool against the colocated script:
117
+
118
+ ```
119
+ Workflow({
120
+ scriptPath: "<this skill dir>/workflow/converge.mjs",
121
+ args: { owner: "<O>", repo: "<R>", prNumber: <N>, bugbotDisabled: false, copilotDisabled: false }
122
+ })
123
+ ```
124
+
125
+ `scriptPath` is the absolute path to `workflow/converge.mjs` inside this skill's
126
+ own directory (on this install,
127
+ `<home>/.claude/skills/autoconverge/workflow/converge.mjs`). Set
128
+ `bugbotDisabled: true` only when the user has opted Cursor Bugbot out for the
129
+ run; otherwise the workflow detects an opt-out or an unreachable Bugbot on its
130
+ own. Set `copilotDisabled: true` when the step 5 quota pre-check exits non-zero,
131
+ and `false` when it exits 0; on `true` the workflow skips the Copilot gate with
132
+ no agent spawned. The workflow runs in the background and notifies this session
133
+ on completion. Watch live progress with `/workflows`.
134
+
135
+ The moment the `Workflow` call returns its run id, write the durable handoff so a
136
+ fresh session can resume the same run:
137
+
138
+ ```
139
+ python "$HOME/.claude/skills/_shared/pr-loop/scripts/write_handoff.py" \
140
+ --pr-number <N> --head-ref <branch> --phase workflow \
141
+ --resume-command "Workflow({scriptPath, resumeFromRunId: '<runId>'})" \
142
+ --run-id <runId>
143
+ ```
144
+
145
+ Write it again when the result lands, so the handoff carries the final run id and
146
+ names the teardown phase the fresh session picks up from.
147
+
148
+ The workflow returns
149
+ `{ converged, rounds, finalSha, blocker, standardsNote, copilotNote, cleanAuditNote, reuseNote, deferredPrs }`,
150
+ plus a `userReview` field on a `blocker: "user-review"` return. `cleanAuditNote` is
151
+ non-null when the environment refused the CLEAN bugteam review post and the run
152
+ recorded the bypass see
153
+ [`reference/stop-conditions.md`](reference/stop-conditions.md) § Clean-audit post
154
+ bypassed.
155
+ `deferredPrs` is the list of draft environment-hardening PRs the standards-deferral
156
+ path opened this run, each as `{ owner, repo, prNumber, copilotDisabled, bugbotDisabled }`.
157
+ The two flags carry this run's Copilot and Bugbot availability, so the next generation
158
+ skips a reviewer that is down or out of quota without re-probing. This list is the seed the
159
+ [self-closing loop](reference/self-closing-loop.md) converges next.
160
+
161
+ ## Copilot findings — tier, verify, then route
162
+
163
+ The Copilot gate tiers each finding (self-healing vs code-concern), verifies
164
+ each code concern with an executed check against the flagged HEAD, and returns a
165
+ confirmed / refuted / inconclusive verdict full semantics and the `userReview`
166
+ return contract in
167
+ [`reference/copilot-findings.md`](reference/copilot-findings.md). Only
168
+ inconclusive findings return `blocker: "user-review"`; the orchestrating session
169
+ handles that hold in Teardown via the
170
+ [`copilot-finding-triage`](../copilot-finding-triage/SKILL.md) skill.
171
+
172
+ ## Budget stop
173
+
174
+ `converge.mjs` paces itself against the workflow `budget` API and stops at a
175
+ round boundary when a full round does not fit —
176
+ [`reference/stop-conditions.md`](reference/stop-conditions.md) § Budget stop
177
+ gives the rule. On a `blocker: "budget"` return, write the durable handoff with
178
+ the run id and the `Workflow({scriptPath, resumeFromRunId})` resume command
179
+ before stopping, so a fresh session resumes the paced run without the stopped
180
+ session's transcript.
181
+
182
+ ## Teardown (on workflow completion)
183
+
184
+ Teardown runs as an ordered checkpoint list. After each checkpoint finishes,
185
+ re-write the durable handoff with `--phase teardown`, the run id, and the
186
+ checkpoints done so far, so a fresh session that resumes reads `handoff.json`
187
+ `completed_steps` and skips the checkpoints already done:
188
+
189
+ ```
190
+ python "$HOME/.claude/skills/_shared/pr-loop/scripts/write_handoff.py" \
191
+ --pr-number <N> --head-ref <branch> --phase teardown \
192
+ --resume-command "/autoconverge <PR URL>" \
193
+ --run-id <runId> \
194
+ --completed-steps "<checkpoints done so far>"
195
+ ```
196
+
197
+ The checkpoints run in this order: `report`, `close`. Write the
198
+ handoff after each one finishes.
199
+
200
+ On teardown entry, when `~/.claude/runtime/pr-loop/bugteam-pr-<N>/handoff.json`
201
+ exists, read its `completed_steps` and skip any checkpoint the list already
202
+ names, so a resumed run performs only the checkpoints left.
203
+
204
+ On a `blocker: "user-review"` return, the workflow held one or more code-concern
205
+ findings that stayed inconclusive after the executed-check verification stage.
206
+ Run the [`copilot-finding-triage`](../copilot-finding-triage/SKILL.md) gate before
207
+ teardown: send the ntfy alert with the per-finding summary and evidence note and
208
+ the `userReview.reviewUrl` link, then hold with a 45-minute `ScheduleWakeup`. Act
209
+ on the user's direction when it arrives inside the window; when the window closes
210
+ with no response, fall through to normal teardown and report the
211
+ `userReview.findings` un-reviewed. The PR stays a draft in this path the
212
+ workflow marked nothing ready.
213
+
214
+ Before the checkpoints, when the workflow returned a non-null `copilotNote`
215
+ (the Copilot gate was bypassed), query the PR's reviews once more for a
216
+ `copilot-pull-request-reviewer[bot]` review on the final HEAD
217
+ (`fetch_copilot_reviews.py`, or the GitHub MCP `pull_request_read` method
218
+ `get_reviews`). Copilot typically posts within 10–15 minutes of a request, so
219
+ a review can land between the bypass and teardown. When one exists and
220
+ carries findings, mark the PR draft, route the findings through one fix
221
+ round per the `pr-fix-protocol` skill, re-verify, push, and mark the PR
222
+ ready again then run the checkpoints.
223
+
224
+ 1. **When `converged` is true — build and publish the closing report.**
225
+ Skip this entire step (report, artifact publish, comment, Chrome open) when
226
+ the workflow returned a non-null `blocker`. Follow
227
+ [`reference/closing-report.md`](reference/closing-report.md) § Building the
228
+ report and § Publishing: resolve the seed journal from the run id, merge the
229
+ PR's runs with `aggregate_runs.py`, spawn the `convergence-summary` agent
230
+ (a `general-purpose` subagent) on the prompt it builds, draw the report with
231
+ `render_report.py`, publish the HTML via the `Artifact` tool, post the
232
+ one marker-keyed `<!-- autoconverge-report -->` PR comment, and open the
233
+ artifact URL in Chrome. After the report is published, write the handoff
234
+ with `--completed-steps "report"`.
235
+
236
+ 2. **Close the run.** Apply the `pr-loop-lifecycle` skill's Close section
237
+ (`../pr-loop-lifecycle/SKILL.md`): when `converged` is true, rewrite the PR
238
+ description and clean the working tree see
239
+ [`pr-loop-lifecycle/reference/teardown-publish-permissions.md` § Clean working tree and § Publish the final PR description](../pr-loop-lifecycle/reference/teardown-publish-permissions.md);
240
+ the workflow already marked the PR ready. The permission revoke always runs,
241
+ including on a blocker exit. Write the handoff with
242
+ `--completed-steps "report,close"`.
243
+
244
+ 3. **Print the final report:**
245
+
246
+ ```
247
+ /autoconverge exit: <converged | blocked>
248
+ Rounds: <N>
249
+ Final commit: <finalSha>
250
+ Blocker: <blocker> # only when blocked
251
+ Standards: <standardsNote> # only when a round deferred code-standard findings
252
+ Copilot: <copilotNote> # only when Copilot was down or out of quota
253
+ Clean-audit: <cleanAuditNote> # only when the CLEAN bugteam post was bypassed
254
+ Reuse: <reuseNote> # only when the reuse pass identified an improvement
255
+ ```
256
+
257
+ ## What the workflow does each round
258
+
259
+ [`reference/convergence.md`](reference/convergence.md) defines the whole loop:
260
+ the merge-conflict pre-flight, the reuse pass and its three landing criteria,
261
+ the round shape (static sweep, the three parallel reading lenses, dedup, the
262
+ one-commit fix flow, the standards-deferral path), the terminal Bugbot, Copilot,
263
+ and Codex gates, the per-role model tiers, the full-diff rule, and the exact
264
+ ready definition `check_convergence.py` enforces.
265
+ [`reference/stop-conditions.md`](reference/stop-conditions.md) lists every way
266
+ the run ends short of ready. Hard-won failure lessons live in
267
+ [`reference/gotchas.md`](reference/gotchas.md).
268
+
269
+ Every agent prompt the workflow authors carries a headless-safety preamble —
270
+ read-only agents get a trimmed form, edit agents the full form with the rm
271
+ auto-allow paths — specified in
272
+ [`reference/headless-safety.md`](reference/headless-safety.md).
273
+
274
+ ## Multiple PRs
275
+
276
+ When the user names several PRs, run the multi-PR path in
277
+ [`reference/multi-pr.md`](reference/multi-pr.md): one worktree per PR
278
+ (`git worktree add` on each head ref, strict pre-flight per worktree, one
279
+ permission grant per repository, one Copilot quota check for the whole run),
280
+ then a single `workflow/converge_multi.mjs` launch with one entry per PR, then
281
+ the single-PR teardown once per `results` entry and a one-line-per-PR summary.
282
+
283
+ ## Self-closing loop: converge the deferred PRs
284
+
285
+ Every autoconverge run — single-PR and multi-PR alike — ends with the
286
+ self-closing loop in
287
+ [`reference/self-closing-loop.md`](reference/self-closing-loop.md): the
288
+ orchestrating session converges the draft environment-hardening PRs the run
289
+ deferred (`deferredPrs` on a single-PR run, `allDeferredPrs` on a multi-PR
290
+ run), then the PRs those runs defer, generation by generation, until a
291
+ generation opens none. An empty seed list ends the loop at once. The reference
292
+ also carries the Conventional-Commit title rule each hardening PR must meet.
293
+
294
+ ## Folder map
295
+
296
+ - `SKILL.md` this hub.
297
+ - `workflow/converge.mjs` the convergence workflow script.
298
+ - `workflow/converge_multi.mjs` — the multi-PR fan-out driver: one `converge.mjs` child run per PR in parallel, each pinned to its PR worktree via `repoPath`.
299
+ - `workflow/aggregate_runs.py` merges every autoconverge journal for a PR into one journal and returns its deduped findings, fix summaries, round count, and final SHA.
300
+ - `workflow/convergence_summary.py` builds the convergence-summary agent prompt over a PR's merged findings.
301
+ - `workflow/render_report.py` — builds the closing convergence insights HTML report, taking the summary from `--summary-file`.
302
+ - `workflow/autoconverge_report_constants/` named constants for the report builder and the summary prompt.
303
+ - `reference/convergence.md` — the whole loop: reuse pass, round shape, terminal gates, model tiers, ready definition.
304
+ - `reference/copilot-findings.md` — the Copilot gate tiering, per-finding verification, and the `userReview` return contract.
305
+ - `reference/stop-conditions.md` — every way the run ends short of ready, including the budget stop.
306
+ - `reference/gotchas.md` hard-won failure lessons.
307
+ - `reference/closing-report.md` the closing HTML report: data source, build steps, publishing.
308
+ - `reference/multi-pr.md`the several-PRs path: per-PR worktrees, the `converge_multi.mjs` launch, per-PR teardown.
309
+ - `reference/self-closing-loop.md` — the deferred-PR generations and the Conventional-Commit title rule.
310
+ - `reference/headless-safety.md` — the agent-prompt preamble and the rm auto-allow paths.