claude-dev-env 1.92.0 → 1.93.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 (216) hide show
  1. package/CLAUDE.md +5 -39
  2. package/_shared/CLAUDE.md +2 -1
  3. package/_shared/advisor/CLAUDE.md +21 -0
  4. package/_shared/advisor/advisor-protocol.md +142 -0
  5. package/_shared/advisor/scripts/config/advisor_scripts_constants/__init__.py +1 -0
  6. package/_shared/advisor/scripts/config/advisor_scripts_constants/model_tier_run_validator_constants.py +86 -0
  7. package/_shared/advisor/scripts/model_tier_run_validator.py +246 -0
  8. package/_shared/advisor/scripts/pyproject.toml +3 -0
  9. package/_shared/advisor/scripts/tests/test_model_tier_run_validator.py +302 -0
  10. package/_shared/advisor/scripts/tests/test_tier_model_ids.py +180 -0
  11. package/_shared/advisor/scripts/tier_model_ids.py +164 -0
  12. package/_shared/pr-loop/CLAUDE.md +1 -0
  13. package/_shared/pr-loop/precatch-rubric.md +65 -0
  14. package/_shared/pr-loop/scripts/CLAUDE.md +1 -1
  15. package/_shared/pr-loop/scripts/code_rules_gate.py +137 -5
  16. package/_shared/pr-loop/scripts/post_audit_thread.py +1 -1
  17. package/_shared/pr-loop/scripts/pr_loop_shared_constants/CLAUDE.md +1 -1
  18. package/_shared/pr-loop/scripts/pr_loop_shared_constants/code_rules_gate_constants.py +16 -0
  19. package/_shared/pr-loop/scripts/pr_loop_shared_constants/reviews_disabled_constants.py +2 -1
  20. package/_shared/pr-loop/scripts/reviewer_availability.py +42 -12
  21. package/_shared/pr-loop/scripts/reviews_disabled.py +65 -21
  22. package/_shared/pr-loop/scripts/terminology_sweep.py +69 -21
  23. package/_shared/pr-loop/scripts/tests/CLAUDE.md +1 -1
  24. package/_shared/pr-loop/scripts/tests/fixtures/{copilot_internal_user_jonecho.json → copilot_internal_user_example.json} +1 -1
  25. package/_shared/pr-loop/scripts/tests/test_agent_config_carveout.py +1 -1
  26. package/_shared/pr-loop/scripts/tests/test_code_rules_gate.py +146 -2
  27. package/_shared/pr-loop/scripts/tests/test_copilot_quota.py +8 -8
  28. package/_shared/pr-loop/scripts/tests/test_reviewer_availability.py +18 -5
  29. package/_shared/pr-loop/scripts/tests/test_reviews_disabled.py +56 -5
  30. package/_shared/pr-loop/scripts/tests/test_terminology_sweep.py +104 -17
  31. package/agents/CLAUDE.md +3 -2
  32. package/agents/clasp-deployment-orchestrator.md +2 -2
  33. package/agents/code-advisor.md +7 -5
  34. package/agents/code-verifier.md +6 -2
  35. package/agents/session-advisor.md +27 -0
  36. package/audit-rubrics/category_rubrics/category-j-code-rules-compliance.md +1 -1
  37. package/audit-rubrics/category_rubrics/category-k-codebase-conflicts.md +1 -1
  38. package/audit-rubrics/prompts/category-a-api-contracts.md +2 -2
  39. package/audit-rubrics/prompts/category-b-selector-engine-compat.md +2 -2
  40. package/audit-rubrics/prompts/category-c-resource-cleanup.md +2 -2
  41. package/audit-rubrics/prompts/category-d-scoping-and-ordering.md +2 -2
  42. package/audit-rubrics/prompts/category-e-dead-code.md +2 -2
  43. package/audit-rubrics/prompts/category-f-silent-failures.md +2 -2
  44. package/audit-rubrics/prompts/category-g-bounds-and-overflow.md +2 -2
  45. package/audit-rubrics/prompts/category-h-security-boundaries.md +2 -2
  46. package/audit-rubrics/prompts/category-i-concurrency.md +2 -2
  47. package/audit-rubrics/prompts/category-j-code-rules-compliance.md +2 -2
  48. package/audit-rubrics/prompts/category-k-codebase-conflicts.md +2 -2
  49. package/audit-rubrics/prompts/category-l-behavior-equivalence.md +2 -2
  50. package/audit-rubrics/prompts/category-m-producer-consumer-cardinality.md +2 -2
  51. package/audit-rubrics/prompts/category-n-test-name-scenario-verifier.md +2 -2
  52. package/audit-rubrics/prompts/category-o-docstring-vs-impl-drift.md +2 -2
  53. package/audit-rubrics/prompts/category-p-name-vs-behavior-contract.md +2 -2
  54. package/bin/CLAUDE.md +1 -0
  55. package/bin/expand_home_directory_tokens.mjs +75 -0
  56. package/bin/install.mjs +21 -7
  57. package/bin/install.test.mjs +220 -10
  58. package/hooks/CLAUDE.md +1 -1
  59. package/hooks/blocking/CLAUDE.md +4 -1
  60. package/hooks/blocking/_path_setup.py +13 -0
  61. package/hooks/blocking/bash_pre_tool_use_dispatcher.py +281 -0
  62. package/hooks/blocking/code_rules_dead_module_constant.py +88 -16
  63. package/hooks/blocking/code_rules_enforcer.py +6 -0
  64. package/hooks/blocking/code_rules_imports_logging.py +34 -1
  65. package/hooks/blocking/code_rules_paths_syspath.py +1 -1
  66. package/hooks/blocking/code_rules_test_layout.py +272 -0
  67. package/hooks/blocking/nas_ssh_binary_enforcer.py +22 -12
  68. package/hooks/blocking/pii_prevention_blocker.py +781 -0
  69. package/hooks/blocking/pii_scanner.py +340 -0
  70. package/hooks/blocking/pre_tool_use_dispatcher.py +3 -3
  71. package/hooks/blocking/stop_dispatcher.py +84 -0
  72. package/hooks/blocking/test__path_setup.py +39 -0
  73. package/hooks/blocking/test_bash_dispatcher_interpreter_starts.py +61 -0
  74. package/hooks/blocking/test_bash_pre_tool_use_dispatcher.py +294 -0
  75. package/hooks/blocking/test_code_rules_enforcer_cross_skill_duplicate.py +1 -1
  76. package/hooks/blocking/test_code_rules_enforcer_dead_module_constant.py +51 -0
  77. package/hooks/blocking/test_code_rules_enforcer_dead_module_constant_read_cap.py +103 -0
  78. package/hooks/blocking/test_code_rules_enforcer_dot_test_pattern.py +1 -1
  79. package/hooks/blocking/test_code_rules_enforcer_file_global_constants.py +1 -1
  80. package/hooks/blocking/test_code_rules_enforcer_hardcoded_user_path.py +11 -11
  81. package/hooks/blocking/test_code_rules_enforcer_naive_datetime.py +1 -1
  82. package/hooks/blocking/test_code_rules_enforcer_same_file_inline_duplicate.py +1 -1
  83. package/hooks/blocking/test_code_rules_enforcer_test_layout.py +111 -0
  84. package/hooks/blocking/test_code_rules_enforcer_type_checking_scope.py +76 -0
  85. package/hooks/blocking/test_destructive_command_blocker.py +29 -9
  86. package/hooks/blocking/test_gh_body_arg_blocker.py +3 -3
  87. package/hooks/blocking/test_nas_ssh_binary_enforcer.py +96 -39
  88. package/hooks/blocking/test_pii_prevention_blocker.py +905 -0
  89. package/hooks/blocking/test_pii_prevention_windows_git_path.py +41 -0
  90. package/hooks/blocking/test_pii_scanner.py +165 -0
  91. package/hooks/blocking/test_pr_description_enforcer_pr_number.py +1 -1
  92. package/hooks/blocking/test_pre_tool_use_dispatcher.py +14 -13
  93. package/hooks/blocking/test_stop_dispatcher.py +187 -0
  94. package/hooks/blocking/test_verdict_directory_write_blocker.py +1 -1
  95. package/hooks/blocking/test_volatile_path_in_post_blocker.py +3 -3
  96. package/hooks/blocking/volatile_path_in_post_blocker.py +54 -5
  97. package/hooks/diagnostic/migrations/README.md +25 -26
  98. package/hooks/diagnostic/test_hook_log_extractor.py +10 -10
  99. package/hooks/hooks.json +10 -120
  100. package/hooks/hooks_constants/CLAUDE.md +12 -3
  101. package/hooks/hooks_constants/bash_pre_tool_use_dispatcher_constants.py +78 -0
  102. package/hooks/hooks_constants/dead_module_constant_constants.py +1 -0
  103. package/hooks/hooks_constants/hosted_hook_runner.py +73 -0
  104. package/hooks/hooks_constants/local_identity.py +182 -0
  105. package/hooks/hooks_constants/nas_ssh_binary_enforcer_constants.py +4 -37
  106. package/hooks/hooks_constants/pii_prevention_constants.py +299 -0
  107. package/hooks/hooks_constants/pre_tool_use_dispatcher_constants.py +4 -0
  108. package/hooks/hooks_constants/python_style_checks_constants.py +15 -0
  109. package/hooks/hooks_constants/stop_dispatcher_constants.py +26 -0
  110. package/hooks/hooks_constants/test_bash_pre_tool_use_dispatcher_constants.py +87 -0
  111. package/hooks/hooks_constants/test_hardcoded_user_path_constants.py +2 -2
  112. package/hooks/hooks_constants/test_hosted_hook_runner.py +101 -0
  113. package/hooks/hooks_constants/test_layout_constants.py +28 -0
  114. package/hooks/hooks_constants/test_local_identity.py +88 -0
  115. package/hooks/hooks_constants/test_session_env_cleanup_constants.py +1 -1
  116. package/hooks/hooks_constants/test_stop_dispatcher_constants.py +32 -0
  117. package/hooks/validators/README.md +5 -6
  118. package/hooks/validators/__init__.py +2 -2
  119. package/hooks/validators/python_style_checks.py +298 -243
  120. package/hooks/validators/run_all_validators.py +6 -0
  121. package/hooks/validators/test_python_style_checks.py +278 -163
  122. package/package.json +2 -2
  123. package/rules/CLAUDE.md +7 -1
  124. package/rules/bdd.md +1 -1
  125. package/rules/nas-ssh-invocation.md +6 -4
  126. package/rules/no-justification-noise.md +61 -0
  127. package/rules/testing.md +0 -2
  128. package/scripts/test_setup_project_paths.py +1 -1
  129. package/skills/CLAUDE.md +6 -3
  130. package/skills/_shared/pr-loop/scripts/_path_resolver.py +2 -2
  131. package/skills/_shared/pr-loop/scripts/build_audit_prompt.py +1 -1
  132. package/skills/_shared/pr-loop/scripts/build_fix_prompt.py +1 -1
  133. package/skills/_shared/pr-loop/scripts/test__path_resolver.py +42 -3
  134. package/skills/_shared/pr-loop/scripts/test_build_audit_prompt.py +11 -11
  135. package/skills/_shared/pr-loop/scripts/test_build_fix_prompt.py +26 -3
  136. package/skills/_shared/pr-loop/scripts/test_preflight_worktree.py +49 -25
  137. package/skills/autoconverge/CLAUDE.md +3 -3
  138. package/skills/autoconverge/SKILL.md +113 -35
  139. package/skills/autoconverge/reference/CLAUDE.md +2 -2
  140. package/skills/autoconverge/reference/convergence.md +44 -22
  141. package/skills/autoconverge/reference/gotchas.md +11 -0
  142. package/skills/autoconverge/reference/stop-conditions.md +23 -13
  143. package/skills/autoconverge/workflow/CLAUDE.md +2 -1
  144. package/skills/autoconverge/workflow/converge.clean-audit.test.mjs +15 -19
  145. package/skills/autoconverge/workflow/converge.contract.test.mjs +43 -42
  146. package/skills/autoconverge/workflow/converge.copilot-gate.test.mjs +141 -16
  147. package/skills/autoconverge/workflow/converge.fix-recovery.test.mjs +2 -2
  148. package/skills/autoconverge/workflow/converge.mjs +329 -68
  149. package/skills/autoconverge/workflow/converge.path-aware.test.mjs +1 -1
  150. package/skills/autoconverge/workflow/converge.precatch.test.mjs +152 -0
  151. package/skills/autoconverge/workflow/converge.run-input.test.mjs +3 -3
  152. package/skills/autoconverge/workflow/converge_multi.run-input.test.mjs +15 -15
  153. package/skills/autoconverge/workflow/test_convergence_summary.py +6 -6
  154. package/skills/bdd-protocol/SKILL.md +4 -5
  155. package/skills/bdd-protocol/references/anti-patterns.md +1 -1
  156. package/skills/bugteam/SKILL.md +8 -0
  157. package/skills/bugteam/reference/copilot-gap-analysis.md +20 -20
  158. package/skills/bugteam/reference/obstacles/audit-walk-categories.md +1 -1
  159. package/skills/bugteam/reference/team-setup.md +7 -5
  160. package/skills/bugteam/scripts/reflow_skill_md.py +1 -1
  161. package/skills/copilot-finding-triage/SKILL.md +124 -0
  162. package/skills/copilot-finding-triage/reference/tier-rubric.md +49 -0
  163. package/skills/copilot-finding-triage/scripts/conftest.py +8 -0
  164. package/skills/copilot-finding-triage/scripts/copilot_finding_triage_constants/__init__.py +0 -0
  165. package/skills/copilot-finding-triage/scripts/copilot_finding_triage_constants/config/__init__.py +0 -0
  166. package/skills/copilot-finding-triage/scripts/copilot_finding_triage_constants/config/notify_ntfy_constants.py +32 -0
  167. package/skills/copilot-finding-triage/scripts/notify_ntfy.py +192 -0
  168. package/skills/copilot-finding-triage/scripts/test_notify_ntfy.py +141 -0
  169. package/skills/copilot-finding-triage/templates/notification.md +34 -0
  170. package/skills/copilot-review/SKILL.md +8 -6
  171. package/skills/findbugs/SKILL.md +4 -0
  172. package/skills/fixbugs/SKILL.md +8 -7
  173. package/skills/gotcha/CLAUDE.md +2 -2
  174. package/skills/gotcha/SKILL.md +4 -4
  175. package/skills/log-audit/SKILL.md +4 -6
  176. package/skills/monitor-open-prs/CLAUDE.md +1 -1
  177. package/skills/monitor-open-prs/SKILL.md +6 -1
  178. package/skills/orchestrator/SKILL.md +184 -0
  179. package/skills/orchestrator-refresh/SKILL.md +37 -0
  180. package/skills/post-audit-findings/SKILL.md +5 -9
  181. package/skills/pr-consistency-audit/SKILL.md +5 -1
  182. package/skills/pr-converge/CLAUDE.md +1 -1
  183. package/skills/pr-converge/SKILL.md +86 -47
  184. package/skills/pr-converge/reference/CLAUDE.md +1 -1
  185. package/skills/pr-converge/reference/convergence-gates.md +20 -17
  186. package/skills/pr-converge/reference/examples.md +63 -47
  187. package/skills/pr-converge/reference/fix-protocol.md +15 -15
  188. package/skills/pr-converge/reference/ground-rules.md +11 -7
  189. package/skills/pr-converge/reference/multi-pr-orchestration.md +6 -5
  190. package/skills/pr-converge/reference/per-tick.md +129 -107
  191. package/skills/pr-converge/reference/state-schema.md +15 -10
  192. package/skills/pr-converge/scripts/check_convergence.py +5 -4
  193. package/skills/pr-converge/scripts/test_check_convergence.py +6 -4
  194. package/skills/pr-fix-protocol/SKILL.md +3 -8
  195. package/skills/pr-loop-cloud-transport/SKILL.md +102 -0
  196. package/skills/pr-loop-cloud-transport/reference/identity-and-hooks.md +40 -0
  197. package/skills/pr-loop-cloud-transport/reference/substitution-matrix.md +48 -0
  198. package/skills/pr-loop-lifecycle/SKILL.md +5 -9
  199. package/skills/pr-scope-resolve/SKILL.md +3 -6
  200. package/skills/privacy-hygiene/SKILL.md +114 -0
  201. package/skills/qbug/SKILL.md +8 -8
  202. package/skills/rebase/SKILL.md +5 -1
  203. package/skills/refine/SKILL.md +4 -5
  204. package/skills/reviewer-gates/SKILL.md +7 -11
  205. package/skills/session-log/SKILL.md +4 -1
  206. package/skills/skill-builder/SKILL.md +3 -6
  207. package/skills/structure-prompt/SKILL.md +4 -5
  208. package/skills/team-advisor/SKILL.md +32 -164
  209. package/skills/test_markdown_link_integrity.py +10 -6
  210. package/skills/update/SKILL.md +5 -1
  211. package/skills/usage-pause/SKILL.md +14 -5
  212. package/skills/usage-pause/scripts/resolve_usage_window.py +83 -5
  213. package/skills/usage-pause/scripts/test_resolve_usage_window.py +185 -17
  214. package/skills/usage-pause/scripts/usage_pause_constants/resolve_usage_window_constants.py +4 -3
  215. package/skills/verified-build/SKILL.md +4 -9
  216. package/skills/team-advisor-refresh/SKILL.md +0 -25
@@ -22,7 +22,7 @@ The caller provides the obstacle context. Distill it into:
22
22
  - **What the user had to do** to resolve it.
23
23
  - **What to do differently next time** (the actionable gotcha).
24
24
 
25
- Determine which repo the skill lives in. Usually this is `claude-code-config`, but if the skill is in another repo (e.g. a project-specific `.claude/skills/` directory), use that repo instead.
25
+ Determine which repo the skill lives in. Usually this is `claude-dev-env`, but if the skill is in another repo (e.g. a project-specific `.claude/skills/` directory), use that repo instead.
26
26
 
27
27
  ### Step 2 — Delegate to bg-agent
28
28
 
@@ -62,11 +62,11 @@ If a `## Gotchas` section already exists, append to it. If not, create it at the
62
62
 
63
63
  | Skill location | Repo |
64
64
  |---|---|
65
- | `packages/claude-dev-env/skills/<name>/` | `jl-cmd/claude-code-config` |
66
- | `~/.claude/skills/<name>/` | `jl-cmd/claude-code-config` (user skills) |
65
+ | `packages/claude-dev-env/skills/<name>/` | `jl-cmd/claude-dev-env` |
66
+ | `~/.claude/skills/<name>/` | `jl-cmd/claude-dev-env` (user skills) |
67
67
  | Project `.claude/skills/<name>/` | That project's repo |
68
68
 
69
- When unsure, ask the user which repo. Otherwise, default to `claude-code-config`.
69
+ When unsure, ask the user which repo. Otherwise, default to `claude-dev-env`.
70
70
 
71
71
  ## Gotchas
72
72
 
@@ -1,12 +1,10 @@
1
1
  ---
2
2
  name: log-audit
3
3
  description: >-
4
- Watches this repo's own logs for patterns worth acting on. Use for /log-audit,
5
- "audit the logs", "what keeps failing", or "what's getting slower". Reads the
6
- hook block log and the diagnostic extractor pipeline, clusters recurring errors
7
- and timing regressions, opens a grouped fix PR or a tracked optimization issue
8
- per real finding, and mines the defects Copilot and Bugbot keep catching into
9
- skill-edit proposals. Runs as a background agent that resumes after a restart.
4
+ Watches this repo's own logs for patterns worth acting on: clusters recurring
5
+ errors and timing regressions, then opens a grouped fix PR or a tracked
6
+ optimization issue per real finding. Use for /log-audit, 'audit the logs',
7
+ 'what keeps failing', or 'what's getting slower'.
10
8
  ---
11
9
 
12
10
  # log-audit
@@ -22,7 +22,7 @@ Discovers every open pull request across the `jl-cmd/*` and `JonEcho/*` owner sc
22
22
  ## Workflow summary
23
23
 
24
24
  1. Call `discover_open_prs.discover_open_prs(all_owners=["jl-cmd", "JonEcho"])` to get the full open-PR list.
25
- 2. For each PR, invoke `/bugteam --bugbot-retrigger <pr_number>` (omit `--bugbot-retrigger` if `CLAUDE_REVIEWS_DISABLED` has `bugbot`).
25
+ 2. For each PR, invoke `/bugteam <pr_number>`; include `--bugbot-retrigger` only when bugbot is enabled (`reviews_disabled.py --reviewer bugbot` exits 1).
26
26
  3. After each bugteam run, poll for new bugbot comments on a 60s → 120s → 240s → 480s → 960s backoff. Re-invoke bugteam if new findings appear.
27
27
  4. Emit a sweep summary when all PRs exit polling.
28
28
 
@@ -15,12 +15,17 @@ description: >-
15
15
 
16
16
  ## Contents
17
17
 
18
+ - Transport check — gh presence and auth route the sweep local or through the cloud transport
18
19
  - When this skill applies — refusal cases and trigger conditions
19
20
  - Discovery — `scripts/discover_open_prs.py` queries via `gh search prs` across both owner scopes
20
21
  - Dispatch — `/bugteam --bugbot-retrigger <pr_numbers...>`
21
22
  - Post-convergence polling — bugbot replies and re-invocation
22
23
  - `scripts/discover_open_prs.py` — the discovery helper
23
24
 
25
+ ## Transport check (before any GitHub step)
26
+
27
+ Run `command -v gh`; when it succeeds, run `gh auth status`; for each PR the sweep dispatches, `gh api repos/<owner>/<repo> --jq .permissions.push` must print `true`. When any check fails, run the `pr-loop-cloud-transport` skill first and route every `gh` operation in this skill through its substitution matrix, including the discovery query (`mcp__github__search_pull_requests` with `perPage` in place of `gh search prs`).
28
+
24
29
  ## When this skill applies
25
30
 
26
31
  `/monitor-open-prs` authorizes one full sweep over all open PRs in both owner scopes.
@@ -41,7 +46,7 @@ Call `scripts/discover_open_prs.discover_open_prs(all_owners=["jl-cmd", "JonEcho
41
46
  For each discovered PR:
42
47
 
43
48
  1. Resolve the PR's repo checkout (existing worktree or fresh `git clone`).
44
- 2. From that checkout, invoke `/bugteam --bugbot-retrigger <pr_number>`. When `python "$HOME/.claude/_shared/pr-loop/scripts/reviews_disabled.py" --reviewer bugbot` exits 0 (bugbot disabled), omit `--bugbot-retrigger` from the dispatched command so the bugbot leg sits out the run.
49
+ 2. From that checkout, invoke `/bugteam <pr_number>`. Include `--bugbot-retrigger` only when bugbot is enabled for the run — when `python "$HOME/.claude/_shared/pr-loop/scripts/reviews_disabled.py" --reviewer bugbot` exits 1. On exit 0 (bugbot disabled — the default) omit `--bugbot-retrigger` so the bugbot leg sits out the run.
45
50
  3. The `--bugbot-retrigger` flag tells bugteam to post `bugbot run` as an issue comment after every successful FIX push so Cursor's bugbot re-evaluates the new commit.
46
51
  4. Bugteam runs its own 20-loop audit/fix cycle per PR; this skill waits for each bugteam invocation to return before dispatching the next (or fanning out — see below).
47
52
 
@@ -0,0 +1,184 @@
1
+ ---
2
+ name: orchestrator
3
+ description: >-
4
+ Advisor-orchestrator mode: plan and delegate while workflow-backed agents
5
+ execute; a shared session-advisor answers hard decisions with endorse,
6
+ correction, plan, or stop. Triggers: '/orchestrator', 'orchestrator
7
+ strategy', 'run with an orchestrator', 'executor-advisor mode',
8
+ 'orchestrator enforcement', 'agent routing', 'orchestrate'.
9
+ ---
10
+
11
+ # Orchestrator Strategy
12
+
13
+ ## Principle
14
+
15
+ A frontier model plans and synthesizes while cheap workers do the
16
+ token-heavy reading and doing — Anthropic's coordinator pattern, source:
17
+ https://github.com/anthropics/claude-cookbooks/blob/main/managed_agents/CMA_plan_big_execute_small.ipynb
18
+ ("Coordinator pattern: big models for planning, small models for
19
+ execution"). On the cookbook's own measured run, a coordinator
20
+ delegating to Sonnet-5 workers came out cheaper and faster
21
+ than a solo frontier agent held to the same verification rigor, with
22
+ 84-98% of the team's input tokens billed at the worker rate.
23
+
24
+ Claude Code has no `multiagent` coordinator field or Managed-Agents-style
25
+ `create_agent`/`send_to_agent` primitives; this skill reaches the same
26
+ shape with the tools Claude Code already has. Under this skill the session
27
+ is the advisor-orchestrator. In Claude Code the user always talks to the session and never to a
28
+ subagent, so the session is the user's sole interface: all user-facing
29
+ communication flows through it. It spawns and resumes executor subagents
30
+ — `clean-coder` and the like — and those executors do every bit of the
31
+ execution: the code edits, the build runs, the test runs. The orchestrating
32
+ session drives the plan and routes hard decisions to the shared advisor
33
+ (Claude: warm `session-advisor`; Grok: this session self-as-advisor).
34
+
35
+ ## Gotchas
36
+
37
+ - **Double invocation duplicates the reminder loop.** A second `/orchestrator`
38
+ in the same session schedules a second refresh loop. Check whether the loop
39
+ is already running before you schedule one (see the invocation guard in
40
+ Process step 1).
41
+ - **The orchestrating session never executes.** The moment it edits a file or
42
+ runs the tests itself, the pairing breaks and the executor's warm context is
43
+ wasted. Hand every code edit and every build or test run to an executor; keep
44
+ the orchestrating session's own tool use to orchestration and light
45
+ verification reads. Hard decisions go to the shared advisor (Claude:
46
+ `session-advisor` via SendMessage; Grok: this session inline).
47
+ - **Flat ad hoc spawns bypass routing.** Every execution task goes through a
48
+ workflow-backed spawn or workflow resume so the required agent type, model,
49
+ prompt packet, and sidecar metadata stay attached to the work.
50
+ - **Wrong agent or model is an enforcement failure.** If a task category maps
51
+ to `clean-coder` on `opus`, a `general-purpose` Sonnet spawn is not a cost
52
+ optimization; it is the wrong executor for the contract.
53
+ - **Resuming an unnamed background agent needs its agentId.** A background
54
+ spawn returns an `agentId` (format `a...-...`); keep it so `SendMessage` can
55
+ reach that agent later. A named agent is reachable by name.
56
+ - **Only the orchestrating session owns the shared advisor's lifecycle.** An
57
+ executor that finds the advisor unreachable (Claude warm agent, or this
58
+ session on Grok) reports that upward; it never spawns a replacement itself.
59
+
60
+ ## Process
61
+
62
+ 1. **Check whether the refresh loop is already running this
63
+ session.** If it is, do not schedule a second loop. Reuse any live
64
+ shared advisor bind (Claude warm `session-advisor`, or Grok self-bind —
65
+ run step 3 only when none exists yet), then skip straight to step 4.
66
+
67
+ 2. **Register the discipline reminder.** By default, schedule it with
68
+ `ScheduleWakeup` at `delaySeconds: 1200`, prompt `/orchestrator-refresh`,
69
+ where each refresh re-schedules the next one — a 1200-second wakeup costs
70
+ one prompt-cache miss per firing and nothing more (see Gotchas). The loop
71
+ mechanism (`/loop 20m /orchestrator-refresh`) is the escape hatch when
72
+ `ScheduleWakeup` is not available. Either way the reminder is the
73
+ enforcement surface: each firing re-asserts the discipline while the run is
74
+ in flight.
75
+
76
+ 3. **Bind the shared advisor before any executor.** Detect the host profile
77
+ first (see Host profiles in
78
+ [`_shared/advisor/advisor-protocol.md`](../../_shared/advisor/advisor-protocol.md)).
79
+ On a **Claude host**, follow the Warm-up procedure in that doc (Agent spawn
80
+ of `session-advisor`). Compute the model floor as the max of the
81
+ orchestrating session's own tier and the highest model in the Workflow Agent
82
+ Routing table below (today: max(Sonnet, Opus) = Opus). Paste the **Claude
83
+ host** Advisor block from that doc, with the resolved agent name filled in,
84
+ into every executor's spawn prompt. On a **Grok host**, skip that spawn —
85
+ use the protocol's self-as-advisor path (this session *is* the advisor;
86
+ single tier `Grok`, attempt result `self`). Paste the **Grok host** Advisor
87
+ block from that doc into every executor's spawn prompt — never the Claude
88
+ SendMessage block. Every row in the routing table is a consumer of the
89
+ shared advisor, not just this session. The orchestrating session owns the
90
+ shared advisor's lifecycle end to end (spawn or self-bind, drift handling
91
+ per the shared doc, shutdown at task end); executors only ever SendMessage
92
+ the warm agent (Claude) or report to this session (Grok).
93
+
94
+ 4. **Orchestrate the task.** Hold the plan and the user conversation. Execute
95
+ workflow-backed spawns or resumes using the routing table below, and keep
96
+ driving while they work. Every executor spawn includes the host-matched
97
+ Advisor block from step 3. Your own tool use stays orchestration and light
98
+ verification reads. Keep your task list updated religiously.
99
+
100
+ 5. **Consult the shared advisor at hard decisions.** Every consumer — each
101
+ executor and this session — consults when one of these holds (same list as
102
+ the protocol and Advisor block):
103
+ - A nontrivial plan is about to be locked in and acted on.
104
+ - The consumer believes its assigned work is finished.
105
+ - A commit, push, or other hard-to-reverse action is about to run.
106
+ - The same failure has come back more than once, or progress has stalled.
107
+ - The chosen approach is being reconsidered.
108
+
109
+ **Claude host:** consult the shared `session-advisor` via `SendMessage`.
110
+ **Grok host:** executors report to this orchestrating session; this session
111
+ answers the four signals inline (self-as-advisor — no Agent, no
112
+ SendMessage-to-`session-advisor`). Every consult gets back one of four
113
+ signals (ENDORSE, CORRECTION, PLAN, or STOP). See
114
+ `agents/session-advisor.md` for what each signal means and
115
+ [`_shared/advisor/advisor-protocol.md`](../../_shared/advisor/advisor-protocol.md)
116
+ for the consult format.
117
+
118
+ ## Workflow Agent Routing
119
+
120
+ Every delegated task runs through a workflow-backed agent invocation. Do not
121
+ spawn a flat subagent directly when a workflow invocation or workflow resume is
122
+ available.
123
+
124
+ | Work | Agent type | Model |
125
+ |---|---|---|
126
+ | Feature, bug, and refactor coding | `clean-coder` | `opus` |
127
+ | Verification passes | `code-verifier` | `sonnet` |
128
+ | Script runs, GitHub posting, and backfill driving | `general-purpose` runner | `sonnet` |
129
+ | PR descriptions | `pr-description-writer` | `haiku`, with file-list grounding check |
130
+ | Fan-out searches and checklist verification reads | `Explore` | `haiku`; use `sonnet` when judgment-heavy |
131
+
132
+ Routing rules:
133
+
134
+ - Use a workflow invocation or resume for each row above. The workflow prompt
135
+ must name the selected agent type, model, work category, task scope, and
136
+ expected output.
137
+ - Resume a warm workflow agent before creating a new workflow run when the warm
138
+ agent holds the relevant context.
139
+ - `clean-coder` owns code edits. `code-verifier` owns verification. The same
140
+ workflow agent never grades work it wrote.
141
+ - PR-description workflows include the actual changed-file list in the prompt
142
+ and verify the final body against that file list before posting or returning
143
+ it.
144
+ - Exploration workflows return file paths, line numbers, and direct evidence;
145
+ they do not write code or mutate repo state.
146
+
147
+ ## Agent reuse (non-negotiable)
148
+
149
+ - **Resume before you spawn, always.** A warm agent carries its context and
150
+ cached tokens; a fresh spawn starts cold and pays to rebuild both.
151
+ Resume the existing workflow agent by name or `agentId` when it holds
152
+ relevant context. Prefer that path every time an existing workflow agent
153
+ matches the routing table.
154
+ - **Spawn a fresh agent only when** no existing agent holds relevant context,
155
+ or a genuine task switch needs a clean context.
156
+ - **Name the agent to resume.** When a PLAN from the shared advisor fits a warm
157
+ agent, name which agent to resume and where.
158
+
159
+ ## Constraints
160
+
161
+ - One `/orchestrator` per session; the invocation guard blocks a second
162
+ reminder loop.
163
+ - The orchestrating session orchestrates and routes hard decisions to the
164
+ shared advisor (host-matched path in step 5), but never edits code or runs a
165
+ build or test itself — executors do that.
166
+ - Delegated execution uses workflow-backed agent invocations and follows the
167
+ Workflow Agent Routing table exactly.
168
+ - One shared advisor per orchestrated session, owned by the orchestrating
169
+ session (see
170
+ [`_shared/advisor/advisor-protocol.md`](../../_shared/advisor/advisor-protocol.md))
171
+ — on Claude, executors consult a warm `session-advisor` via SendMessage; on
172
+ Grok, this session is the advisor and executors report here. Executors never
173
+ spawn or respawn the advisor.
174
+ - Reuse a warm agent over a cold spawn whenever one holds relevant context.
175
+
176
+ ## File Index
177
+
178
+ | File | Purpose |
179
+ |---|---|
180
+ | `SKILL.md` | Orchestrator strategy, workflow routing contract, shared-advisor consult protocol, reuse rules, and constraints. |
181
+
182
+ ## Folder Map
183
+
184
+ - `SKILL.md` — complete orchestrator workflow instructions.
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: orchestrator-refresh
3
+ description: >-
4
+ Fired by the /orchestrator loop reminder about every 20 minutes to
5
+ re-assert the advisor discipline mid-run: orchestrate, route hard decisions
6
+ to the shared advisor (ENDORSE / CORRECTION / PLAN / STOP — SendMessage on
7
+ Claude, self-as-advisor on Grok), reuse warm agents. Triggers:
8
+ '/orchestrator-refresh'.
9
+ ---
10
+
11
+ # Orchestrator Refresh
12
+
13
+ Detect the host profile first (see Host profiles in
14
+ [`_shared/advisor/advisor-protocol.md`](../../_shared/advisor/advisor-protocol.md)).
15
+ Re-assert the discipline for that host only — do not invent a Claude
16
+ `session-advisor` spawn on a Grok host.
17
+
18
+ 1. **You are the advisor-orchestrator.** Orchestrate and hold the user
19
+ conversation; spawn executor subagents to do all the work — every code edit
20
+ and build or test run.
21
+ 2. **Hard decisions go to the shared advisor.**
22
+ - **Claude host:** executors consult the warm `session-advisor` via
23
+ `SendMessage` and receive one of four signals — ENDORSE, CORRECTION, PLAN,
24
+ or STOP. The orchestrating session routes its own hard decisions the same
25
+ way and keeps its tool use to orchestration and light verification reads.
26
+ - **Grok host:** this session *is* the advisor (self-as-advisor). Do **not**
27
+ spawn `session-advisor` and do **not** tell executors to SendMessage a
28
+ separate advisor agent. Executors report blockers to this session; answer
29
+ with ENDORSE / CORRECTION / PLAN / STOP inline.
30
+ 3. **Resume before you spawn.** `SendMessage` an existing *executor* agent by
31
+ name or `agentId` to reuse its warm context; prefer that over a cold spawn.
32
+ (On Grok this is executor reuse only — not an advisor spawn.)
33
+ 4. **Fresh spawn only for a genuine task switch.** No tool compacts or clears a
34
+ subagent's context, so a clean context comes from a fresh spawn — never tell
35
+ an agent to compact.
36
+ 5. **Re-schedule the next refresh** (about 1200 seconds out) when the loop
37
+ mechanism needs each firing to queue the following one.
@@ -1,15 +1,11 @@
1
1
  ---
2
2
  name: post-audit-findings
3
3
  description: >-
4
- Publishes an audit pass as one GitHub PR review via the shared
5
- post_audit_thread.py: maps audit findings to the {path, line, side,
6
- severity, description, fix_summary} JSON shape (splitting failure_mode at
7
- the literal `Fix:` heading), partitions anchored vs unanchored findings so
8
- one bad anchor cannot reject the whole POST, handles the self-PR reviewer
9
- toggle via BUGTEAM_REVIEWER_ACCOUNT, and harvests finding comment ids and
10
- PRRT thread node ids for the fix loop. Invoked by audit skills (bugteam,
11
- qbug, findbugs) after each audit pass, CLEAN or DIRTY; not for ad-hoc PR
12
- comments or review replies.
4
+ Publishes an audit pass as a GitHub PR review through post_audit_thread.py:
5
+ maps findings to the review-comment JSON shape, splits anchored from
6
+ unanchored, and collects the comment and thread ids for the fix loop. Invoked
7
+ by audit skills (bugteam, qbug, findbugs) after each pass; not for ad-hoc
8
+ comments.
13
9
  ---
14
10
 
15
11
  # Post Audit Findings
@@ -1,7 +1,11 @@
1
1
  ---
2
2
  name: pr-consistency-audit
3
3
  description: >-
4
- Audits a PR for cross-file inconsistencies. Finds wrong argument names, missing required args, references to files or scripts that do not exist, stale feature remnants, docstring-vs-implementation mismatches, placeholder text, cross-file contradictions, parameter naming convention violations, and cross-platform bugs. Use when the user says "audit this PR", "find inconsistencies", "cross-reference docs against scripts", "check for stale references", "PR consistency audit".
4
+ Audits a PR for cross-file inconsistencies: wrong arguments, missing files or
5
+ scripts, stale remnants, docstring mismatches, and cross-platform bugs. Use
6
+ when the user says 'audit this PR', 'find inconsistencies', 'cross-reference
7
+ docs against scripts', 'check for stale references', or 'PR consistency
8
+ audit'.
5
9
  ---
6
10
 
7
11
  # PR Consistency Audit
@@ -1,6 +1,6 @@
1
1
  # pr-converge skill
2
2
 
3
- Drives a draft PR to convergence by looping Cursor Bugbot, a code-review pass, a second-opinion bug audit (`bugteam`), and Copilot applying TDD fixes, posting inline replies, and re-triggering reviewers each tick until all reviewers are clean on the same HEAD and the PR is mergeable.
3
+ Drives a draft PR to convergence by driving the internal passes to clean first — a code-review pass and a bugteam audit then running Cursor Bugbot and Copilot as terminal confirmation gates, applying TDD fixes, posting inline replies, and re-triggering the external reviewers each tick until all are clean on the same HEAD and the PR is mergeable.
4
4
 
5
5
  **Trigger:** `/pr-converge`, "drive PR to convergence", "loop bugbot and bugteam", "babysit bugbot and bugteam", "until both are clean", "converge this PR".
6
6
 
@@ -1,20 +1,26 @@
1
1
  ---
2
2
  name: pr-converge
3
3
  description: >-
4
- Drives the current PR to convergence by looping Cursor Bugbot, a
5
- code-review pass, a second-opinion bug audit, and Copilot applying
6
- TDD fixes, posting inline replies, and re-triggering reviewers each
7
- tick until all reviewers are clean on the same HEAD. Use when the user
8
- says
9
- '/pr-converge', 'drive PR to convergence', 'loop bugbot and bugteam',
10
- 'babysit bugbot and bugteam', 'until both are clean', or 'converge this
11
- PR'.
4
+ Loops Cursor Bugbot, a code review, a bug audit, and Copilot on the current
5
+ PR, applying TDD fixes until all are clean on one HEAD. Use when the user says
6
+ '/pr-converge', 'drive PR to convergence', 'loop bugbot and bugteam', 'babysit
7
+ bugbot and bugteam', 'until both are clean', or 'converge this PR'.
12
8
  ---
13
9
 
14
10
  # PR Converge
15
11
 
16
- One tick per invocation. Bugbot code-review ↔ bugteam ↔ Copilot loop on
17
- a draft PR until all are clean on the same `HEAD` and mergeable.
12
+ One tick per invocation. A code-review ↔ bugteam ↔ Bugbot ↔ Copilot loop on
13
+ a draft PR: the internal code-review and bugteam passes drive the code to clean
14
+ first, then Cursor Bugbot and Copilot run as terminal confirmation gates, until
15
+ all are clean on the same `HEAD` and mergeable.
16
+
17
+ ## Transport check (before any GitHub step)
18
+
19
+ Run `command -v gh`; when it succeeds, run `gh auth status`; once the PR
20
+ scope is resolved, run `gh api repos/<owner>/<repo> --jq .permissions.push`
21
+ and take `true` as the pass. When any check fails, run the
22
+ `pr-loop-cloud-transport` skill first and route every `gh` operation in this
23
+ skill through its substitution matrix.
18
24
 
19
25
  ## Pre-flight
20
26
 
@@ -50,7 +56,7 @@ Before Step 0, check
50
56
  `$CLAUDE_JOB_DIR/pr-converge-state.json` is absent but that handoff exists, seed
51
57
  `phase`, `tick_count`, and the clean-at SHAs from the run's `state-copy.json`, so
52
58
  a fresh session continues where the last one stopped rather than restarting at
53
- BUGBOT.
59
+ CODE_REVIEW.
54
60
 
55
61
  ## Copilot quota pre-check (start of run)
56
62
 
@@ -64,6 +70,29 @@ no request, no poll, no agent — and exports
64
70
  pending-requested-reviews gate and the run still marks ready on the remaining
65
71
  signals.
66
72
 
73
+ ## Copilot findings — two-tier triage
74
+
75
+ The Copilot step tiers each finding it surfaces. A **self-healing** finding is
76
+ pure style, type hints, misplaced or unused imports, formatting, magic-value
77
+ extraction, a test-only change, a doc-or-description vs code mismatch, or code
78
+ de-duplication — a fix that cannot change observable runtime behavior for
79
+ production callers. Self-healing findings flow into the existing fix tick and
80
+ count toward convergence, with no user alert. The tick-paced loop holds them
81
+ naturally: the fix lands on `current_head`, the next tick re-checks, and the run
82
+ converges when the Copilot step is clean.
83
+
84
+ A **code-concern** finding is behavior-changing or needs a product decision:
85
+ logic or correctness, security, data handling, error-handling semantics, or
86
+ concurrency. Tier a finding as code-concern whenever the tier is in doubt. On
87
+ one or more code-concern findings, do not auto-fix them and do not let the tick
88
+ mark the PR ready. Run the
89
+ [`copilot-finding-triage`](../copilot-finding-triage/SKILL.md) gate: send the
90
+ ntfy alert with the finding summary and the Copilot review link, then hold for
91
+ the user's response on a 45-minute deadline that spans ticks — carry the
92
+ deadline in the run's persisted state so each tick reads it on entry. Act on the
93
+ user's direction when it arrives inside the window; when the deadline passes
94
+ with no response, run teardown and report the code-concern findings un-reviewed.
95
+
67
96
  ## Budget-aware tick boundaries
68
97
 
69
98
  Before starting any tick, estimate whether the remaining session/usage
@@ -137,7 +166,7 @@ the `persistent_agents` map
137
166
  within one bounded wait, drop the map entry, spawn a fresh named agent,
138
167
  record it, and continue the tick. Never abort a tick on a stale id;
139
168
  never retry the same dead id.
140
- - **Fresh every round (never persisted):** the Step 5 `/code-review --fix`
169
+ - **Fresh every round (never persisted):** the Step 5 `/code-review high --fix`
141
170
  pass and the Step 6 bugteam audit (unbiased eyes each round; the
142
171
  enforcer needs the formal Skill call), and every `code-verifier` — a
143
172
  named code-verifier never fires `SubagentStop`, so no verdict mints (see
@@ -188,7 +217,7 @@ post a fresh PR in a fresh branch based on origin main to the user.
188
217
  Windows is Git Bash which cannot execute PowerShell cmdlets. Route all
189
218
  PowerShell work through the PowerShell tool or `pwsh -NoProfile -File`.
190
219
  - **Cross-repo PR: route cwd into the PR worktree before `/code-review`** —
191
- `/code-review --fix` (Step 5) audits the repo of the current working
220
+ `/code-review high --fix` (Step 5) audits the repo of the current working
192
221
  directory. When the session is rooted in a different repo than the PR,
193
222
  `EnterWorktree` cannot re-root (it is scoped to the session's repo);
194
223
  resolve the PR worktree and `cd` into it per
@@ -237,7 +266,7 @@ round as converged. This rule holds every tick, every loop, every PR.
237
266
  and [§ Step 1.5](reference/per-tick.md)
238
267
 
239
268
  - [ ] **Step 2: Initialize loop state**
240
- `phase = BUGBOT`; all counters at zero; `run_name` resolved.
269
+ `phase = CODE_REVIEW`; all counters at zero; `run_name` resolved.
241
270
 
242
271
  - [ ] **Step 3: Mergeability check**
243
272
  See: [`reference/convergence-gates.md` § (c)](reference/convergence-gates.md)
@@ -249,37 +278,38 @@ round as converged. This rule holds every tick, every loop, every PR.
249
278
  - [ ] mergeable → advance to Step 4
250
279
  - [ ] not mergeable → rebase → force-push → return to Step 1
251
280
 
252
- - [ ] **Step 4: BUGBOT — fetch, decide, fix, reply, resolve**
253
- See: [`reference/per-tick.md` § Step 2 BUGBOT + Step 3](reference/per-tick.md)
281
+ - [ ] **Step 4: BUGBOT — terminal Bugbot confirmation gate**
282
+ The terminal external gate. Step 6 routes here after BUGTEAM converges, so
283
+ Bugbot confirms code the internal passes already drove to clean.
284
+ See: [`reference/per-tick.md` § BUGBOT terminal gate + Step 3](reference/per-tick.md)
254
285
 
255
- - [ ] **Opt-out gate (runs first, every BUGBOT entry).**
286
+ - [ ] **Availability gate (runs first, every BUGBOT entry).**
256
287
  Gate semantics live in the `reviewer-gates` skill
257
- (`../reviewer-gates/SKILL.md` § Gate 1).
288
+ (`../reviewer-gates/SKILL.md` § Gate 1). Cursor Bugbot is off by default and runs only when `CLAUDE_REVIEWS_ENABLED` lists `bugbot`; a `bugbot` token in `CLAUDE_REVIEWS_DISABLED` keeps it off even then.
258
289
  `python "$HOME/.claude/_shared/pr-loop/scripts/reviews_disabled.py" --reviewer bugbot`
259
- - [ ] Exit 0 (`CLAUDE_REVIEWS_DISABLED` lists `bugbot`) → set `bugbot_down = true`, `phase = CODE_REVIEW`, advance to Step 5 (bypass). Cursor Bugbot is skipped for the entire run.
290
+ - [ ] Exit 0 (Bugbot disabled for this run — the default) → set `bugbot_down = true`, advance to the Step 7 convergence gates (no trigger, no wait, no agent). Cursor Bugbot is skipped for the entire run.
260
291
  - [ ] Exit 1 → continue below.
261
292
 
262
293
  Fetch bugbot reviews + inline comments on `current_head`.
263
294
 
264
295
  - [ ] **dirty** (findings on `current_head`) →
265
296
  - [ ] Apply the `pr-fix-protocol` skill (`../pr-fix-protocol/SKILL.md`) to this tick's findings
266
- - [ ] Push → return to Step 4
297
+ - [ ] Push → reset `bugbot_clean_at = null`, `code_review_clean_at = null` → `phase = CODE_REVIEW` → return to Step 5
267
298
  - [ ] **clean** (no findings on `current_head`) →
268
299
  - [ ] Count ALL unresolved threads on PR (`is_resolved == false`) → zero? advance; >0? fix + resolve first
269
300
  - [ ] `bugbot_clean_at = current_head`
270
- - [ ] `phase = CODE_REVIEW`
271
- - [ ] Advance to Step 5
301
+ - [ ] Advance to the Step 7 convergence gates
272
302
  - [ ] **no review yet / commit_id mismatch** →
273
303
  Apply the `reviewer-gates` skill's Bugbot flow
274
304
  (`../reviewer-gates/SKILL.md` § Gate 3) against `current_head`,
275
305
  then map its outcomes:
276
- - [ ] Silent pass → `bugbot_clean_at = current_head` → `phase = CODE_REVIEW` advance to Step 5
306
+ - [ ] Silent pass → `bugbot_clean_at = current_head` → advance to the Step 7 convergence gates
277
307
  - [ ] Already queued, or trigger acknowledged → schedule 360s wakeup → return to Step 4 next tick
278
- - [ ] Bugbot down → `bugbot_down = true` → `phase = CODE_REVIEW` advance to Step 5 (bypass)
279
- - [ ] **Step 5: CODE-REVIEW — run, fix, reset, advance**
280
- See: [`reference/per-tick.md` § Step 2 CODE_REVIEW](reference/per-tick.md)
281
-
282
- Pre-condition: `bugbot_clean_at == current_head` (or `bugbot_down == true`).
308
+ - [ ] Bugbot down → `bugbot_down = true` → advance to the Step 7 convergence gates (bypass)
309
+ - [ ] **Step 5: CODE-REVIEW — entry phase: static sweep, review, fix, advance**
310
+ The first internal step of every convergence tick (Step 2 seeds
311
+ `phase = CODE_REVIEW`), re-entered after any fix push.
312
+ See: [`reference/per-tick.md` § CODE_REVIEW entry](reference/per-tick.md)
283
313
 
284
314
  Pre-condition: the working directory is the Step 1.5 PR worktree on
285
315
  `current_head` (`git rev-parse --show-toplevel` is that checkout).
@@ -288,18 +318,28 @@ round as converged. This rule holds every tick, every loop, every PR.
288
318
  current working directory, so this routing targets the real PR
289
319
  diff. This `cd` is routine and automatic.
290
320
 
291
- Run Claude Code's built-in `/code-review --fix` on the full
321
+ - [ ] **Static sweep — runs first, before `/code-review`.** Run the
322
+ deterministic gates over the full `origin/main...HEAD` changed files:
323
+ `python "$HOME/.claude/_shared/pr-loop/scripts/code_rules_gate.py" --base origin/main`,
324
+ `ruff`, `mypy`, and stem-matched `pytest`.
325
+ - [ ] Any failure → apply the `pr-fix-protocol` skill
326
+ (`../pr-fix-protocol/SKILL.md`), commit/push, reset
327
+ `bugbot_clean_at = null` and `code_review_clean_at = null`, stay
328
+ `phase = CODE_REVIEW`, and re-run (return to Step 5).
329
+ - [ ] Clean → run `/code-review` below.
330
+
331
+ Run Claude Code's built-in `/code-review high --fix` on the full
292
332
  `origin/main...HEAD` diff —
293
333
  the [local diff review](https://code.claude.com/docs/en/code-review#review-a-diff-locally)
294
334
  — so it reviews the diff and applies its findings to the working
295
- tree. Pass no effort argument, so the review uses the session's
296
- current effort.
335
+ tree. Invoke `/code-review high --fix` so the pre-catch pass gets broad
336
+ coverage regardless of the session's current effort.
297
337
 
298
338
  **Scope: the FULL `origin/main...HEAD` diff every tick** — every file
299
339
  the PR touches. Do not delta-scope to commits added since the prior
300
340
  clean SHA, do not scope to a single file, do not scope to bugbot's
301
341
  flagged paths. Before running, confirm the working tree is on the
302
- PR's HEAD with no uncommitted edits, then invoke `/code-review --fix`
342
+ PR's HEAD with no uncommitted edits, then invoke `/code-review high --fix`
303
343
  with no path arguments so it audits the whole branch diff against
304
344
  `origin/main`. A partial-scope round does not count and cannot set
305
345
  `code_review_clean_at`.
@@ -307,8 +347,7 @@ round as converged. This rule holds every tick, every loop, every PR.
307
347
  - [ ] **fixes applied** (working tree changed) →
308
348
  - [ ] Commit the applied fixes (one commit) → push
309
349
  - [ ] reset `bugbot_clean_at = null`, `code_review_clean_at = null`
310
- - [ ] Re-trigger bugbot (Step 4 "no review yet" checklist)
311
- - [ ] `phase = BUGBOT` → schedule 360s wakeup → return to Step 4
350
+ - [ ] stay `phase = CODE_REVIEW` return to Step 5 (internal-first)
312
351
  - [ ] **clean** (no changes applied) →
313
352
  - [ ] Zero unresolved threads per the `pr-fix-protocol` sweep (`../pr-fix-protocol/SKILL.md`) → advance; else fix + resolve first (same skill)
314
353
  - [ ] `code_review_clean_at = current_head`
@@ -338,21 +377,21 @@ round as converged. This rule holds every tick, every loop, every PR.
338
377
 
339
378
  - [ ] **bugteam pushed new commits** →
340
379
  - [ ] Verify all bugteam review threads replied + resolved
341
- - [ ] Re-trigger bugbot (Step 4 "no review yet" checklist)
342
- - [ ] `phase = BUGBOT` → schedule 360s wakeup → return to Step 4
343
- - [ ] **converged (zero findings) + `bugbot_clean_at == current_head`**
380
+ - [ ] reset `bugbot_clean_at = null`, `code_review_clean_at = null`
381
+ - [ ] `phase = CODE_REVIEW` → schedule 360s wakeup → return to Step 5
382
+ - [ ] **converged (zero findings), no push**
344
383
  - [ ] Count ALL unresolved threads on PR (`is_resolved == false`) → zero? advance; >0? fix + resolve first
345
- - [ ] Advance to Step 7
346
- - [ ] **converged + `bugbot_clean_at ≠ current_head`** →
347
- `phase = BUGBOT` → schedule 360s wakeup → return to Step 4
384
+ - [ ] `phase = BUGBOT` → advance to Step 4 (terminal Bugbot gate)
348
385
  - [ ] **findings without committed fixes** →
349
386
  - [ ] Apply the `pr-fix-protocol` skill (`../pr-fix-protocol/SKILL.md`) to the findings
350
- - [ ] Push → `phase = BUGBOT` → return to Step 4
387
+ - [ ] Push → reset `bugbot_clean_at = null`, `code_review_clean_at = null` → `phase = CODE_REVIEW` → return to Step 5
351
388
 
352
389
  - [ ] **Step 7: Convergence gates**
353
390
  See: [`reference/convergence-gates.md`](reference/convergence-gates.md)
354
391
 
355
- Pre-condition: Step 6 converged AND `bugbot_clean_at == current_head`.
392
+ Pre-condition: Step 6 converged AND (`bugbot_clean_at == current_head` OR
393
+ `bugbot_down`). The terminal Bugbot gate (Step 4) sets that state just
394
+ before these gates run.
356
395
  Count unresolved threads before each gate.
357
396
 
358
397
  **(a) Universal unresolved-thread sweep**
@@ -361,13 +400,13 @@ round as converged. This rule holds every tick, every loop, every PR.
361
400
  pull_request_read(method="get_review_comments")
362
401
  → filter threads where is_resolved == false
363
402
  ```
364
- - [ ] Any unresolved? → apply the `pr-fix-protocol` skill's unresolved-thread sweep (`../pr-fix-protocol/SKILL.md`). Push if any code changed → return to Step 4
403
+ - [ ] Any unresolved? → apply the `pr-fix-protocol` skill's unresolved-thread sweep (`../pr-fix-protocol/SKILL.md`). Push if any code changed → reset markers → `phase = CODE_REVIEW` → return to Step 5
365
404
  - [ ] When `copilot_down == true` (start-of-run quota pre-check), skip the Copilot fetch below — no request, no poll, no agent — and continue to gate (b); the Copilot gate is bypassed for the whole run.
366
405
  - [ ] Fetch Copilot review on `current_head` (top-level review state — uses get_reviews, identifies by reviewer):
367
406
  ```
368
407
  python ~/.claude/skills/pr-converge/scripts/fetch_copilot_reviews.py --owner <O> --repo <R> --pr-number <N>
369
408
  ```
370
- - [ ] dirty → apply the `pr-fix-protocol` skill (`../pr-fix-protocol/SKILL.md`) → push → return to Step 4
409
+ - [ ] dirty → apply the `pr-fix-protocol` skill (`../pr-fix-protocol/SKILL.md`) → push → reset markers → `phase = CODE_REVIEW` → return to Step 5
371
410
  - [ ] clean (no findings) → `copilot_clean_at = current_head` → gate (b)
372
411
  - [ ] no review yet → gate (b)
373
412
 
@@ -399,7 +438,7 @@ round as converged. This rule holds every tick, every loop, every PR.
399
438
  → count threads where is_resolved == false
400
439
  ```
401
440
  - [ ] zero unresolved → gate (e)
402
- - [ ] unresolved → apply the `pr-fix-protocol` skill's unresolved-thread sweep (`../pr-fix-protocol/SKILL.md`). Push if code changed → return to Step 4
441
+ - [ ] unresolved → apply the `pr-fix-protocol` skill's unresolved-thread sweep (`../pr-fix-protocol/SKILL.md`). Push if code changed → reset markers → `phase = CODE_REVIEW` → return to Step 5
403
442
 
404
443
  **(e) Mark ready**
405
444
  - [ ] When `copilot_down == true`, export `CLAUDE_REVIEWS_DISABLED="copilot"` in this tick's shell before the check below, so it bypasses the Copilot review gate and the pending-requested-reviews gate.
@@ -409,7 +448,7 @@ round as converged. This rule holds every tick, every loop, every PR.
409
448
  --owner <O> --repo <R> --pr-number <N>
410
449
  ```
411
450
  - [ ] Exit 0 (all pass) → `update_pull_request(draft=false)` → advance to Step 8
412
- - [ ] Exit 1 (FAIL lines) → address each failure → return to Step 4
451
+ - [ ] Exit 1 (FAIL lines) → address each failure → reset markers → `phase = CODE_REVIEW` → return to Step 5
413
452
  - [ ] Exit 2 (gh error) → retry once; persistent → stop
414
453
 
415
454
  - [ ] **Step 7a: COPILOT_WAIT — fetch Copilot, decide**
@@ -424,7 +463,7 @@ round as converged. This rule holds every tick, every loop, every PR.
424
463
  `copilot_clean_at = current_head` → return to Step 7 (re-validate gates b, d, e)
425
464
  - [ ] **dirty (findings present)** →
426
465
  - [ ] Apply the `pr-fix-protocol` skill (`../pr-fix-protocol/SKILL.md`) to the findings
427
- - [ ] Push → `phase = BUGBOT` → return to Step 4
466
+ - [ ] Push → reset markers → `phase = CODE_REVIEW` → return to Step 5
428
467
  - [ ] **no review yet** →
429
468
  increment `copilot_wait_count` → ≥ 3 = hard blocker → stop
430
469
  schedule 360s wakeup → return to Step 7a next tick
@@ -6,7 +6,7 @@ Reference documents for the `pr-converge` skill. These files define the per-tick
6
6
 
7
7
  | File | Purpose |
8
8
  |---|---|
9
- | `per-tick.md` | Step-by-step procedure for one tick (resolve HEAD, run BUGBOT, CODE_REVIEW, BUGTEAM, COPILOT_WAIT phases, schedule next wakeup) |
9
+ | `per-tick.md` | Step-by-step procedure for one tick (resolve HEAD, run the internal CODE_REVIEW and BUGTEAM phases, then the terminal BUGBOT and COPILOT_WAIT gates, schedule next wakeup) |
10
10
  | `convergence-gates.md` | Six gates that must all pass before the PR is marked ready for review |
11
11
  | `fix-protocol.md` | pr-converge deltas on the `pr-fix-protocol` skill: multi-PR teammate obligations and the same-tick bugbot re-trigger rule |
12
12
  | `ground-rules.md` | Non-negotiable constraints for the convergence loop |