claude-dev-env 1.38.0 → 1.39.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 (271) hide show
  1. package/CLAUDE.md +10 -36
  2. package/_shared/pr-loop/audit-reply-template.md +147 -0
  3. package/_shared/pr-loop/fix-protocol.md +25 -4
  4. package/_shared/pr-loop/gh-payloads.md +37 -50
  5. package/_shared/pr-loop/scripts/code_rules_gate.py +0 -60
  6. package/_shared/pr-loop/scripts/config/post_audit_thread_constants.py +189 -0
  7. package/_shared/pr-loop/scripts/post_audit_thread.py +947 -0
  8. package/_shared/pr-loop/scripts/tests/test_code_rules_gate.py +0 -19
  9. package/_shared/pr-loop/scripts/tests/test_post_audit_thread.py +923 -0
  10. package/_shared/pr-loop/scripts/tests/test_post_audit_thread_constants.py +127 -0
  11. package/_shared/pr-loop/state-schema.md +1 -1
  12. package/agents/clean-coder.md +2 -2
  13. package/bin/install.mjs +6 -7
  14. package/bin/install.test.mjs +8 -0
  15. package/commands/doc-gist.md +16 -0
  16. package/commands/plan.md +0 -2
  17. package/commands/review-plan.md +1 -1
  18. package/docs/CODE_RULES.md +122 -2
  19. package/hooks/blocking/bot_mention_comment_blocker.py +75 -0
  20. package/hooks/blocking/code_rules_enforcer.py +1236 -161
  21. package/hooks/blocking/convergence_gate_blocker.py +130 -0
  22. package/hooks/blocking/destructive_command_blocker.py +74 -0
  23. package/hooks/blocking/gh_body_arg_blocker.py +30 -0
  24. package/hooks/blocking/md_to_html_blocker.py +119 -0
  25. package/hooks/blocking/test_bot_mention_comment_blocker.py +131 -0
  26. package/hooks/blocking/test_code_rules_enforcer.py +21 -0
  27. package/hooks/blocking/test_code_rules_enforcer_any_exempt_files.py +70 -0
  28. package/hooks/blocking/test_code_rules_enforcer_any_imports_and_cast.py +92 -0
  29. package/hooks/blocking/test_code_rules_enforcer_banned_import_alias.py +143 -0
  30. package/hooks/blocking/test_code_rules_enforcer_banned_prefixes.py +152 -0
  31. package/hooks/blocking/test_code_rules_enforcer_bare_except.py +120 -0
  32. package/hooks/blocking/test_code_rules_enforcer_boundary_types.py +175 -0
  33. package/hooks/blocking/test_code_rules_enforcer_cap_meta.py +0 -1
  34. package/hooks/blocking/test_code_rules_enforcer_collection_prefix.py +50 -0
  35. package/hooks/blocking/test_code_rules_enforcer_docstring_format.py +255 -0
  36. package/hooks/blocking/test_code_rules_enforcer_inline_tuple_string_magic.py +130 -0
  37. package/hooks/blocking/test_code_rules_enforcer_stub_implementations.py +141 -0
  38. package/hooks/blocking/test_code_rules_enforcer_test_branching.py +143 -0
  39. package/hooks/blocking/test_code_rules_enforcer_thin_wrapper_files.py +169 -0
  40. package/hooks/blocking/test_code_rules_enforcer_todo_markers.py +99 -0
  41. package/hooks/blocking/test_code_rules_enforcer_typed_dict_pairs.py +141 -0
  42. package/hooks/blocking/test_code_rules_enforcer_unused_imports.py +158 -0
  43. package/hooks/blocking/test_convergence_gate_blocker.py +63 -0
  44. package/hooks/blocking/test_destructive_command_blocker.py +146 -0
  45. package/hooks/blocking/test_destructive_command_blocker_no_verify.py +102 -0
  46. package/hooks/blocking/test_gh_body_arg_blocker.py +45 -0
  47. package/hooks/blocking/test_md_to_html_blocker.py +317 -0
  48. package/hooks/config/any_type_config.py +7 -0
  49. package/hooks/config/banned_identifiers_constants.py +11 -0
  50. package/hooks/config/blocking_check_limits.py +38 -0
  51. package/hooks/config/bot_mention_comment_blocker_constants.py +20 -0
  52. package/hooks/config/code_rules_enforcer_constants.py +53 -0
  53. package/hooks/config/convergence_branch_constants.py +9 -0
  54. package/hooks/config/doc_gist_auto_publish_constants.py +18 -0
  55. package/hooks/config/html_companion_constants.py +20 -0
  56. package/hooks/config/inline_tuple_string_magic_constants.py +22 -0
  57. package/hooks/config/test_banned_identifiers_constants.py +17 -0
  58. package/hooks/hooks.json +28 -20
  59. package/hooks/pyproject.toml +69 -0
  60. package/hooks/validators/mypy_integration.py +47 -1
  61. package/hooks/validators/run_all_validators.py +3 -3
  62. package/hooks/validators/test_mypy_integration.py +50 -1
  63. package/hooks/workflow/doc_gist_auto_publish.py +144 -0
  64. package/hooks/workflow/md_to_html_companion.py +365 -0
  65. package/hooks/workflow/test_doc_gist_auto_publish.py +117 -0
  66. package/hooks/workflow/test_md_to_html_companion.py +452 -0
  67. package/package.json +1 -1
  68. package/rules/gh-body-file.md +2 -0
  69. package/scripts/Install-SweepEmptyDirs.ps1 +111 -0
  70. package/scripts/check.ps1 +106 -0
  71. package/scripts/config/timing.py +11 -0
  72. package/scripts/sweep_empty_dirs.py +138 -0
  73. package/scripts/sync_to_cursor/rules.py +1 -1
  74. package/scripts/test_sweep_empty_dirs.py +183 -0
  75. package/skills/_shared/pr-loop/prompts/pr-consistency-audit.xml +323 -0
  76. package/skills/_shared/pr-loop/scripts/_cli_utils.py +22 -0
  77. package/skills/_shared/pr-loop/scripts/_path_resolver.py +165 -0
  78. package/skills/_shared/pr-loop/scripts/_xml_utils.py +20 -0
  79. package/skills/_shared/pr-loop/scripts/build_audit_prompt.py +182 -0
  80. package/skills/_shared/pr-loop/scripts/build_fix_prompt.py +185 -0
  81. package/skills/_shared/pr-loop/scripts/config/__init__.py +0 -0
  82. package/skills/_shared/pr-loop/scripts/config/path_resolver_constants.py +78 -0
  83. package/skills/_shared/pr-loop/scripts/init_loop_state.py +135 -0
  84. package/skills/_shared/pr-loop/scripts/teardown_worktrees.py +175 -0
  85. package/skills/_shared/pr-loop/scripts/write_audit_outcomes.py +182 -0
  86. package/skills/_shared/pr-loop/scripts/write_fix_outcomes.py +206 -0
  87. package/skills/bugteam/CONSTRAINTS.md +21 -22
  88. package/skills/bugteam/EXAMPLES.md +3 -3
  89. package/skills/bugteam/PROMPTS.md +227 -67
  90. package/skills/bugteam/SKILL.md +114 -455
  91. package/skills/bugteam/reference/README.md +1 -1
  92. package/skills/bugteam/reference/audit-and-teammates.md +112 -39
  93. package/skills/bugteam/reference/audit-contract.md +4 -22
  94. package/skills/bugteam/reference/copilot-gap-analysis.md +8 -5
  95. package/skills/bugteam/reference/design-rationale.md +2 -2
  96. package/skills/bugteam/reference/github-pr-reviews.md +50 -57
  97. package/skills/bugteam/reference/obstacles/audit-assign-ids.md +13 -0
  98. package/skills/bugteam/reference/obstacles/audit-capture-excerpts.md +13 -0
  99. package/skills/bugteam/reference/obstacles/audit-walk-categories.md +13 -0
  100. package/skills/bugteam/reference/obstacles/audit-write-xml.md +13 -0
  101. package/skills/bugteam/reference/obstacles/fix-append-summary.md +13 -0
  102. package/skills/bugteam/reference/obstacles/fix-apply-fixes.md +13 -0
  103. package/skills/bugteam/reference/obstacles/fix-git-add-commit.md +13 -0
  104. package/skills/bugteam/reference/obstacles/fix-git-push.md +13 -0
  105. package/skills/bugteam/reference/obstacles/fix-post-reply.md +13 -0
  106. package/skills/bugteam/reference/obstacles/fix-publish-summary.md +13 -0
  107. package/skills/bugteam/reference/obstacles/fix-py-compile.md +13 -0
  108. package/skills/bugteam/reference/obstacles/fix-read-files.md +13 -0
  109. package/skills/bugteam/reference/obstacles/fix-resolve-thread.md +13 -0
  110. package/skills/bugteam/reference/obstacles/fix-test-suite.md +13 -0
  111. package/skills/bugteam/reference/obstacles/fix-violation-count.md +13 -0
  112. package/skills/bugteam/reference/obstacles/fix-write-xml.md +13 -0
  113. package/skills/bugteam/reference/team-setup.md +106 -9
  114. package/skills/bugteam/reference/teardown-publish-permissions.md +39 -8
  115. package/skills/bugteam/scripts/README.md +60 -0
  116. package/skills/bugteam/scripts/_claude_permissions_common.py +358 -0
  117. package/skills/bugteam/scripts/bugteam_code_rules_gate.py +976 -0
  118. package/skills/bugteam/scripts/bugteam_fix_hookspath.py +375 -0
  119. package/skills/bugteam/scripts/bugteam_preflight.py +294 -0
  120. package/skills/bugteam/scripts/config/bugteam_code_rules_gate_constants.py +25 -0
  121. package/skills/bugteam/scripts/config/bugteam_fix_hookspath_constants.py +26 -0
  122. package/skills/bugteam/scripts/config/bugteam_preflight_constants.py +35 -0
  123. package/skills/bugteam/scripts/config/claude_permissions_common_constants.py +20 -0
  124. package/skills/bugteam/scripts/config/probe_code_rules_enforcer_check_constants.py +12 -0
  125. package/skills/bugteam/scripts/config/windows_safe_rmtree_constants.py +7 -0
  126. package/skills/bugteam/scripts/grant_project_claude_permissions.py +175 -0
  127. package/skills/bugteam/scripts/probe_code_rules_enforcer_check.py +107 -0
  128. package/skills/bugteam/scripts/revoke_project_claude_permissions.py +220 -0
  129. package/skills/bugteam/scripts/test__claude_permissions_common.py +112 -0
  130. package/skills/bugteam/scripts/test_bugteam_code_rules_gate.py +400 -0
  131. package/skills/bugteam/scripts/test_bugteam_fix_hookspath.py +384 -0
  132. package/skills/bugteam/scripts/test_bugteam_preflight.py +268 -0
  133. package/skills/bugteam/scripts/test_claude_permissions_common.py +195 -0
  134. package/skills/bugteam/scripts/test_grant_project_claude_permissions.py +55 -0
  135. package/skills/bugteam/scripts/test_probe_code_rules_enforcer_check.py +76 -0
  136. package/skills/bugteam/scripts/test_revoke_project_claude_permissions.py +55 -0
  137. package/skills/bugteam/scripts/test_windows_safe_rmtree.py +108 -0
  138. package/skills/bugteam/scripts/windows_safe_rmtree.py +100 -0
  139. package/skills/bugteam/test_skill_additions.py +1 -11
  140. package/skills/code/SKILL.md +176 -0
  141. package/skills/doc-gist/SKILL.md +99 -0
  142. package/skills/doc-gist/references/examples/01-exploration-code-approaches.html +453 -0
  143. package/skills/doc-gist/references/examples/02-exploration-visual-designs.html +515 -0
  144. package/skills/doc-gist/references/examples/03-code-review-pr.html +638 -0
  145. package/skills/doc-gist/references/examples/04-code-understanding.html +491 -0
  146. package/skills/doc-gist/references/examples/05-design-system.html +629 -0
  147. package/skills/doc-gist/references/examples/06-component-variants.html +605 -0
  148. package/skills/doc-gist/references/examples/07-prototype-animation.html +455 -0
  149. package/skills/doc-gist/references/examples/08-prototype-interaction.html +396 -0
  150. package/skills/doc-gist/references/examples/09-slide-deck.html +592 -0
  151. package/skills/doc-gist/references/examples/10-svg-illustrations.html +492 -0
  152. package/skills/doc-gist/references/examples/11-status-report.html +528 -0
  153. package/skills/doc-gist/references/examples/12-incident-report.html +596 -0
  154. package/skills/doc-gist/references/examples/13-flowchart-diagram.html +395 -0
  155. package/skills/doc-gist/references/examples/14-research-feature-explainer.html +381 -0
  156. package/skills/doc-gist/references/examples/15-research-concept-explainer.html +368 -0
  157. package/skills/doc-gist/references/examples/16-implementation-plan.html +702 -0
  158. package/skills/doc-gist/references/examples/17-pr-writeup.html +595 -0
  159. package/skills/doc-gist/references/examples/18-editor-triage-board.html +573 -0
  160. package/skills/doc-gist/references/examples/19-editor-feature-flags.html +663 -0
  161. package/skills/doc-gist/references/examples/20-editor-prompt-tuner.html +722 -0
  162. package/skills/doc-gist/references/examples/README.md +5 -0
  163. package/skills/doc-gist/scripts/config/__init__.py +0 -0
  164. package/skills/doc-gist/scripts/config/gist_upload_constants.py +16 -0
  165. package/skills/doc-gist/scripts/gist_upload.py +177 -0
  166. package/skills/doc-gist/scripts/test_gist_upload.py +51 -0
  167. package/skills/findbugs/SKILL.md +68 -2
  168. package/skills/monitor-open-prs/SKILL.md +13 -32
  169. package/skills/monitor-open-prs/test_skill_contract.py +0 -11
  170. package/skills/pr-consistency-audit/SKILL.md +112 -0
  171. package/skills/pr-consistency-audit/reference/detection-rules.md +96 -0
  172. package/skills/pr-consistency-audit/reference/illustrations.md +78 -0
  173. package/skills/pr-converge/SKILL.md +227 -23
  174. package/skills/pr-converge/config/__init__.py +0 -0
  175. package/skills/pr-converge/config/constants.py +62 -0
  176. package/skills/pr-converge/reference/convergence-gates.md +138 -44
  177. package/skills/pr-converge/reference/examples.md +43 -11
  178. package/skills/pr-converge/reference/fix-protocol.md +6 -5
  179. package/skills/pr-converge/reference/ground-rules.md +5 -3
  180. package/skills/pr-converge/reference/multi-pr-orchestration.md +44 -19
  181. package/skills/pr-converge/reference/obstacles/fix-post-replies.md +13 -0
  182. package/skills/pr-converge/reference/obstacles/fix-publish-summary.md +13 -0
  183. package/skills/pr-converge/reference/obstacles/fix-push.md +13 -0
  184. package/skills/pr-converge/reference/obstacles/fix-read-filelines.md +13 -0
  185. package/skills/pr-converge/reference/obstacles/fix-reset-state.md +13 -0
  186. package/skills/pr-converge/reference/obstacles/fix-resolve-threads.md +13 -0
  187. package/skills/pr-converge/reference/obstacles/fix-spawn-clean-coder.md +13 -0
  188. package/skills/pr-converge/reference/obstacles/fix-stage-commit.md +13 -0
  189. package/skills/pr-converge/reference/obstacles/fix-trigger-bugbot.md +13 -0
  190. package/skills/pr-converge/reference/obstacles/fix-write-test.md +13 -0
  191. package/skills/pr-converge/reference/per-tick.md +90 -31
  192. package/skills/pr-converge/reference/state-schema.md +22 -1
  193. package/skills/pr-converge/reference/stop-conditions.md +9 -7
  194. package/skills/pr-converge/scripts/README.md +34 -46
  195. package/skills/pr-converge/scripts/check_bugbot_ci.py +174 -0
  196. package/skills/pr-converge/scripts/check_convergence.py +497 -0
  197. package/skills/pr-converge/scripts/check_pending_reviews.py +154 -0
  198. package/skills/pr-converge/scripts/config/pr_converge_constants.py +118 -0
  199. package/skills/pr-converge/scripts/fetch_copilot_reviews.py +134 -0
  200. package/skills/pr-converge/scripts/post_fix_reply.py +168 -0
  201. package/skills/pr-converge/workflows/schedule-wakeup-loop.md +5 -12
  202. package/skills/qbug/SKILL.md +132 -27
  203. package/skills/session-log/SKILL.md +216 -114
  204. package/skills/session-tidy/SKILL.md +1 -1
  205. package/skills/skill-builder/SKILL.md +138 -56
  206. package/skills/skill-builder/references/delegation-map.md +72 -113
  207. package/skills/skill-builder/references/progressive-disclosure.md +122 -0
  208. package/skills/skill-builder/references/self-audit-checklist.md +92 -0
  209. package/skills/skill-builder/references/skill-types.md +228 -0
  210. package/skills/skill-builder/references/thariq-x-post-skills.json +33 -0
  211. package/skills/skill-builder/templates/gap-analysis.md +15 -8
  212. package/skills/skill-builder/workflows/improve-skill.md +86 -57
  213. package/skills/skill-builder/workflows/new-skill.md +80 -168
  214. package/skills/skill-builder/workflows/polish-skill.md +78 -54
  215. package/skills/structure-prompt/SKILL.md +50 -0
  216. package/skills/structure-prompt/reference/adversarial-tuning.md +62 -0
  217. package/skills/structure-prompt/reference/block-classification.md +27 -0
  218. package/skills/structure-prompt/reference/canonical-case.md +48 -0
  219. package/skills/structure-prompt/reference/citation-depth.md +70 -0
  220. package/skills/structure-prompt/reference/cleanup.md +33 -0
  221. package/skills/structure-prompt/reference/constraints.md +33 -0
  222. package/skills/structure-prompt/reference/directives.md +37 -0
  223. package/skills/structure-prompt/reference/examples.md +72 -0
  224. package/skills/structure-prompt/reference/instantiation.md +51 -0
  225. package/skills/structure-prompt/reference/output-contract.md +72 -0
  226. package/skills/structure-prompt/reference/per-category.md +23 -0
  227. package/skills/structure-prompt/reference/persona.md +38 -0
  228. package/skills/structure-prompt/reference/research.md +33 -0
  229. package/skills/structure-prompt/reference/structure.md +28 -0
  230. package/agents/code-standards-agent.md +0 -93
  231. package/agents/groq-coder.md +0 -113
  232. package/agents/plan-executor.md +0 -226
  233. package/agents/project-docs-analyzer.md +0 -53
  234. package/agents/project-structure-organizer-agent.md +0 -72
  235. package/agents/skill-to-agent-converter.md +0 -370
  236. package/agents/skill-writer-agent.md +0 -470
  237. package/agents/user-docs-writer.md +0 -67
  238. package/agents/workflow-visual-documenter.md +0 -82
  239. package/commands/readability-review.md +0 -20
  240. package/hooks/mypy.ini +0 -2
  241. package/hooks/notification/attention_needed_notify.py +0 -71
  242. package/hooks/notification/claude_notification_handler.py +0 -67
  243. package/hooks/notification/notification_utils.py +0 -267
  244. package/hooks/notification/subagent_complete_notify.py +0 -381
  245. package/hooks/notification/test_attention_needed_notify.py +0 -47
  246. package/hooks/notification/test_claude_notification_handler.py +0 -54
  247. package/hooks/notification/test_notification_utils.py +0 -91
  248. package/hooks/notification/test_subagent_complete_notify.py +0 -79
  249. package/scripts/config/groq_bugteam_config.py +0 -230
  250. package/scripts/config/test_groq_bugteam_config.py +0 -83
  251. package/scripts/config/test_spec_implementer_prompt.py +0 -32
  252. package/scripts/groq_bugteam.README.md +0 -131
  253. package/scripts/groq_bugteam.py +0 -647
  254. package/scripts/groq_bugteam_dotenv.py +0 -40
  255. package/scripts/groq_bugteam_spec.py +0 -226
  256. package/scripts/test_groq_bugteam.py +0 -529
  257. package/scripts/test_groq_bugteam_apply_fix_from_spec.py +0 -426
  258. package/scripts/test_groq_bugteam_dotenv.py +0 -66
  259. package/scripts/test_groq_bugteam_spec.py +0 -338
  260. package/skills/bugteam/SKILL_EVALS.md +0 -309
  261. package/skills/dream/SKILL.md +0 -118
  262. package/skills/ingest/SKILL.md +0 -40
  263. package/skills/npm-creator/SKILL.md +0 -187
  264. package/skills/readability-review/SKILL.md +0 -127
  265. package/skills/resume-review/SKILL.md +0 -261
  266. package/skills/rule-audit/SKILL.md +0 -307
  267. package/skills/rule-creator/SKILL.md +0 -150
  268. package/skills/searching-obsidian-vault/SKILL.md +0 -131
  269. package/skills/skill-writer/REFERENCE.md +0 -284
  270. package/skills/skill-writer/SKILL.md +0 -222
  271. package/skills/tdd-team/SKILL.md +0 -128
@@ -3,51 +3,34 @@ name: bugteam
3
3
  description: >-
4
4
  Open pull request audit–fix until convergence: CODE_RULES gate, clean-room
5
5
  audit (`code-quality-agent`, opus) and fix (`clean-coder`, opus), per-loop
6
- GitHub reviews, 10-audit cap; grant then revoke `.claude/**`. Spawns
6
+ GitHub reviews, 20-audit cap; grant then revoke `.claude/**`. Spawns
7
7
  background subagents (`Agent(..., run_in_background=true)`). Triggers: '/bugteam', 'run
8
8
  the bug team', 'auto-fix the PR until clean', 'loop audit and fix'.
9
9
  ---
10
10
 
11
11
  # Bugteam
12
12
 
13
- **Core principle:** Audit–fix until convergence. **Bugfind:**
14
- `code-quality-agent`, fresh context each loop. **Bugfix:** `clean-coder`. Hard
15
- cap: 10 audit loops. Grant `.claude/**` at start, revoke always at end.
13
+ Audit–fix until convergence. Bugfind: `code-quality-agent`, fresh context each
14
+ loop, auditing all A–K categories. Bugfix: `clean-coder`. Hard cap: 20 audit
15
+ loops. Grant `.claude/**` at start, revoke always at end.
16
16
 
17
- Both audit and fix roles run as background subagents
18
- (`Agent(..., run_in_background=true)`). Verbatim doc quotes and URLs:
19
- [`sources.md`](sources.md).
17
+ The audit agent loads the A–K category rubrics from
18
+ `$HOME/.claude/audit-rubrics/{category_rubrics,prompts}/` alongside
19
+ [`PROMPTS.md`](PROMPTS.md) and produces a single outcome XML per loop.
20
20
 
21
- ## Contents
21
+ ## Pre-flight
22
22
 
23
- Orchestration lives here; companion files hold prompts, invariants, examples,
24
- citations, and domain reference notes. Scan this list before a partial read.
25
-
26
- - When this skill applies — refusal cases and trigger conditions
27
- - Utility scripts — pre-flight (`scripts/`, executed not inlined)
28
- - Pre-audit gate — `validate_content` before each AUDIT
29
- - The Process — checklist + Steps 0–6
30
- - Step 0 — Grant project permissions
31
- - Step 1 — Resolve PR scope
32
- - Step 2 — Loop state
33
- - Step 2.5 — PR comment lifecycle (per-loop review + fix replies)
34
- - Step 3 — Cycle (AUDIT ↔ FIX, exits)
35
- - Step 4 — Teardown + clean tree
36
- - Step 4.5 — PR body via `pr-description-writer`
37
- - Step 5 — Revoke permissions
38
- - Step 6 — Final report
39
- - [`PROMPTS.md`](PROMPTS.md) — spawn XML, categories A–J, outcome schemas
40
- - [`EXAMPLES.md`](EXAMPLES.md) — exit scenarios
41
- - [`CONSTRAINTS.md`](CONSTRAINTS.md) — invariants and design rationale
42
- - [`sources.md`](sources.md) — doc URLs and verbatim quotes
43
- - [`reference/README.md`](reference/README.md) — expanded prose by topic
44
- (design, team setup, GitHub reviews, cycle, teardown)
23
+ ```bash
24
+ python "${CLAUDE_SKILL_DIR}/scripts/bugteam_preflight.py"
25
+ ```
45
26
 
46
- ## When this skill applies
27
+ Auto-remediation runs automatically when `core.hooksPath` is the failing check;
28
+ other failures require manual fix before Step 0. Full detail:
29
+ [reference/team-setup.md](reference/team-setup.md) § Pre-flight.
47
30
 
48
- `/bugteam` once authorizes the full cycle (up to 10 audits + fixes).
31
+ ## Refusals
49
32
 
50
- Refusals — first match wins; respond with the quoted line exactly and stop:
33
+ First match wins; respond with the quoted line exactly and stop:
51
34
 
52
35
  - **No PR or upstream diff.** `No PR or upstream diff. /bugteam needs a target.`
53
36
  - **Dirty tree.** `Uncommitted changes detected. Stash, commit, or revert before
@@ -56,44 +39,65 @@ Refusals — first match wins; respond with the quoted line exactly and stop:
56
39
  `clean-coder` exist. Else: `Required subagent type <name> not installed.
57
40
  /bugteam needs both code-quality-agent and clean-coder available.`
58
41
 
59
- ## Utility scripts
60
-
61
- Shell-heavy steps live under
62
- [`_shared/pr-loop/scripts/`](../../_shared/pr-loop/scripts/) (run, do not paste
63
- into context). Utility scripts are **executed**, not loaded as primary context
64
- ([`sources.md`](sources.md) § Progressive disclosure and utility scripts).
65
-
66
- ### Pre-flight (before Step 0)
67
-
68
- ```bash
69
- python "${CLAUDE_SKILL_DIR}/../../_shared/pr-loop/scripts/preflight.py"
70
- ```
71
-
72
- Non-zero fix before grant. `BUGTEAM_PREFLIGHT_SKIP=1` emergency only.
73
- `--pre-commit` if `.pre-commit-config.yaml` exists.
74
-
75
- **Auto-remediation for `core.hooksPath`:** when preflight fails with stderr
76
- containing `core.hooksPath` (the message starts with `bugteam_preflight:
77
- core.hooksPath is`, or `Git-side CODE_RULES enforcement is not active`), Claude
78
- must auto-invoke the fix script do not fall through to `AskUserQuestion`, do
79
- not punt to the user, do not ask for confirmation:
80
-
81
- ```bash
82
- python "${CLAUDE_SKILL_DIR}/../../_shared/pr-loop/scripts/fix_hookspath.py"
83
- ```
84
-
85
- The fix script removes any non-canonical local-scope override on the active
86
- repository, sets the global `core.hooksPath` to `~/.claude/hooks/git-hooks` if
87
- missing or wrong, and re-runs `preflight.py`. Its exit code becomes the
88
- preflight outcome. Exit 0 → continue to Step 0. Non-zero only when the
89
- canonical hooks directory is missing (run `npx claude-dev-env .` first) or
90
- `git config --global` writes are blocked. Other preflight failures (pytest,
91
- pre-commit) still require manual fixes —
92
- the auto-remediation only applies to the `core.hooksPath` failure mode.
93
-
94
- ## The Process
95
-
96
- ### Progress checklist
42
+ ## Audit posting
43
+
44
+ Every internal audit pass (CLEAN or DIRTY) ends with one call to
45
+ `post_audit_thread.py`. The script POSTs a single review to
46
+ `/repos/{owner}/{repo}/pulls/{N}/reviews` with `event=APPROVE` on CLEAN
47
+ (the request event; GitHub stores it as `state=APPROVED`; empty
48
+ `comments[]`, body documents "no findings") or
49
+ `event=REQUEST_CHANGES` on DIRTY (one inline anchored comment per
50
+ finding; each becomes its own resolvable thread). The mandate applies
51
+ whether bugteam runs inside `/pr-converge` or standalone.
52
+
53
+ **Self-PR precondition.** GitHub rejects both `APPROVE` and
54
+ `REQUEST_CHANGES` reviews when the authenticated identity (the `gh auth`
55
+ token in scope) matches the PR author with HTTP 422 ("Cannot
56
+ approve/request changes on your own pull request"). `post_audit_thread.py`
57
+ will retry on transient errors and then exit 2 (retry exhaustion); the
58
+ script does not detect the self-PR case and downgrade to `COMMENT`. To
59
+ run bugteam on a PR you authored, switch `gh auth` to an alternate
60
+ reviewer identity (a separate GitHub account) BEFORE invoking the skill.
61
+ Without this switch, exit 2 is a hard halt there is no automated
62
+ fallback path. The script does not auto-downgrade on the self-PR case.
63
+
64
+ ```
65
+ python "${CLAUDE_SKILL_DIR}/../../_shared/pr-loop/scripts/post_audit_thread.py" \
66
+ --skill bugteam \
67
+ --owner <owner> \
68
+ --repo <repo> \
69
+ --pr-number <N> \
70
+ --commit <head_sha> \
71
+ --state <CLEAN|DIRTY> \
72
+ --findings-json <path>
73
+ ```
74
+
75
+ `--findings-json` points to a JSON file whose root is a list of objects
76
+ shaped `{path, line, side, severity, description, fix_summary}`. The
77
+ audit agent's persisted finding output maps as follows: finding `file`
78
+ → `path`, and the agent's `failure_mode` field carries both the failure
79
+ narrative AND the `Fix:` / `Validation:` text per
80
+ [`agents/code-quality-agent.md`](../../agents/code-quality-agent.md)
81
+ ("The `failure_mode` field is the audit-to-fix handoff"). Split
82
+ `failure_mode` at the literal `Fix:` heading: the prefix (the failure
83
+ narrative) becomes `description`, and the suffix starting at `Fix:`
84
+ (including the trailing `Validation:` clause) becomes `fix_summary`.
85
+ When the agent omits the `Fix:` heading on a given finding, write the
86
+ full `failure_mode` text to BOTH `description` and `fix_summary` so the
87
+ script's body template (`INLINE_COMMENT_BODY_TEMPLATE` in
88
+ [`_shared/pr-loop/scripts/config/post_audit_thread_constants.py`](../../_shared/pr-loop/scripts/config/post_audit_thread_constants.py))
89
+ still renders coherently. Set `side="RIGHT"` for every entry. On CLEAN,
90
+ pass an empty array (`[]`) so the script posts an APPROVE review
91
+ (GitHub stores it as `state=APPROVED`) with a "no findings" summary and
92
+ zero inline comments.
93
+
94
+ Exit codes: `0` on success (emits the new review's `html_url` to
95
+ stdout); `1` on user input error; `2` on retry exhaustion (1s / 4s /
96
+ 16s backoff across four attempts total). Exit 2 is a hard blocker; the
97
+ lead halts the loop and exits `error: post_audit_thread retry
98
+ exhausted` without retrying.
99
+
100
+ ## Progress checklist
97
101
 
98
102
  ```
99
103
  [ ] Step 0: project permissions granted
@@ -106,387 +110,42 @@ the auto-remediation only applies to the `core.hooksPath` failure mode.
106
110
  [ ] Step 6: final report printed
107
111
  ```
108
112
 
109
- ### Step 0: Grant project permissions (once, first)
110
-
111
- ```bash
112
- python \
113
- "${CLAUDE_SKILL_DIR}/../../_shared/pr-loop/scripts/"\
114
- "grant_project_claude_permissions.py"
115
- ```
116
-
117
- `${CLAUDE_SKILL_DIR}` is host-substituted before the shell runs (unlike normal
118
- env expansion). Idempotent writes to `~/.claude/settings.json` from repo root.
119
- Non-zero → stop. Revoke in Step 5 on every exit path.
120
-
121
- ### Step 1: Resolve PR scope (once)
122
-
123
- Accept one or more PR numbers from the invocation. For each PR, call
124
- `pull_request_read(method="get", pullNumber=N, owner=O, repo=R)` (falling back
125
- to the merge-base diff path when no PR exists). Capture `all_prs = [{number, owner, repo, baseRef,
126
- headRef, url}, ...]`. A single-PR invocation produces a one-element list and
127
- follows the same downstream rules.
128
-
129
- Keep: owner/repo, branches, PR number, URL for all loops.
130
-
131
- **`<run_temp_dir>`:** `Path(tempfile.gettempdir()) / run_name` where
132
- `run_name = "bugteam-pr-<number>-<YYYYMMDDHHMMSS>"` for a single-PR invocation
133
- or `"bugteam-<YYYYMMDDHHMMSS>"` for multi-PR. Lead resolves once to an absolute
134
- path; every shell gets that literal string.
135
-
136
- #### Per-PR workspace
137
-
138
- For each PR in all_prs:
139
-
140
- 1. Create `<run_temp_dir>/pr-<N>/`.
141
- 2. Run `git worktree add "<run_temp_dir>/pr-<N>/worktree" origin/<headRef>`.
142
- 3. Record the absolute worktree path alongside the PR's other fields.
143
-
144
- Background subagents for a PR operate inside that PR's worktree. Step 4
145
- teardown runs `git worktree remove "<run_temp_dir>/pr-<N>/worktree"` for each
146
- PR before the shared `rmtree`.
147
-
148
- ### Step 2: Loop state
149
-
150
- **Loop state (lead; not a single script; per-PR):** The variables
151
- below are tracked independently for each PR in `all_prs`. Each PR has its
152
- own cycle, state, and exit reason.
153
-
154
- ```bash
155
- loop_count=0
156
- last_action="fresh"
157
- last_findings='{"total": 0}'
158
- audit_log=""
159
- run_temp_dir="<absolute-path>/<run_name>"
160
- starting_sha="$(git -C "<run_temp_dir>/pr-<N>/worktree" rev-parse HEAD)"
161
- loop_comment_index=""
162
- ```
163
-
164
- **Optional Groq-backed FIX (explicit opt-in only):** when the user explicitly
165
- sets `BUGTEAM_FIX_IMPLEMENTER=groq-coder` before invocation, spawn the FIX
166
- subagent with `subagent_type="groq-coder"`. Requires `GROQ_API_KEY` in the
167
- environment (load from `packages/claude-dev-env/.env` when that file exists;
168
- prompt the user to create it from `.env.example` if still unset). Any other
169
- `BUGTEAM_FIX_IMPLEMENTER` value (or unset) uses `clean-coder`.
170
-
171
- **`--bugbot-retrigger` flag:** when present, the FIX subagent posts a `bugbot
172
- run` issue comment via the Step 2.5 issue-comments fallback endpoint after
173
- every successful FIX push, to re-trigger Cursor's bugbot on the new commit.
174
-
175
- **`loop_comment_index`:** reset each AUDIT start; filled during AUDIT; FIX
176
- consumes for replies; cleared after FIX. Entries: `{loop, finding_id,
177
- finding_comment_id, finding_comment_url, used_fallback, fix_status}`.
178
-
179
- ### Step 2.5: PR comments (one review per loop)
180
-
181
- **Who posts:** the AUDIT subagent posts one `POST .../pulls/<n>/reviews` per
182
- loop. The FIX subagent posts `.../comments/<id>/replies` after push. The lead's
183
- only PR write before Step 4.5 is the final description rewrite.
184
-
185
- Order: audit → buffer → validate anchors vs diff → single review POST.
186
- Review body states counts; zero findings → still one review, `comments: []`,
187
- body `## /bugteam loop <L> audit: 0P0 / 0P1 / 0P2 → clean`.
188
-
189
- **Payloads:** Use MCP tool calls (see below). Body text with markdown (backticks,
190
- newlines, quotes) passes through safely as string parameters — no temp files, no
191
- jq, no shell pipes.
192
-
193
- **Review POST** (one `comments[]` object per anchored finding; single-line
194
- `{path, line, side: "RIGHT", body}`; multi-line add `start_line`, `start_side:
195
- "RIGHT"`):
196
-
197
- ```
198
- pull_request_review_write(
199
- method="create",
200
- event="COMMENT",
201
- body=<review_body_text>,
202
- commitID=<head_sha_at_post_time>,
203
- owner=<owner>, repo=<repo>, pullNumber=<number>,
204
- comments=[
205
- {path: <path_1>, line: <line_1>, side: "RIGHT", body: <finding_body_1>}
206
- [, ... ]
207
- ]
208
- )
209
- ```
210
-
211
- **Fix reply:** `add_reply_to_pull_request_comment(commentId=<finding_comment_id>,
212
- body=<reply_text>, owner=<owner>, repo=<repo>, pullNumber=<number>)`
213
-
214
- **Review POST fails:** issue comment fallback:
215
- `add_issue_comment(owner=<owner>, repo=<repo>, issueNumber=<number>,
216
- body=<fallback_text>)`
217
-
218
- `<head_sha_at_post_time>`: `git rev-parse HEAD` in subagent cwd immediately
219
- before POST.
220
-
221
- **Review body template (`<tmp_review_body.md>`):**
222
-
223
- ```
224
- ## /bugteam loop <L> audit: <P0>P0 / <P1>P1 / <P2>P2
225
-
226
- ### Findings without a diff anchor
227
- (only if needed)
228
- - **[severity] title** — <file>:<line> — <one-line description>
229
- ```
230
-
231
- **Anchor fallback:** lines not in diff → omit from `comments[]`, list under
232
- `### Findings without a diff anchor`; outcome `used_fallback="true"`, empty
233
- `finding_comment_id`, `finding_comment_url` = parent review URL.
234
-
235
- **POST failure fallback:** one issue comment with full text; all findings
236
- `used_fallback="true"`, URLs = issue comment.
237
-
238
- **Endpoints:** `POST .../pulls/{pull}/reviews`; `POST
239
- .../pulls/{pull}/comments/{id}/replies`; fallback `POST
240
- .../issues/{issue}/comments` (`issue` = PR number).
241
-
242
- ### Step 3: The cycle
243
-
244
- Run the AUDIT-FIX cycle for each PR in all_prs. The 10-loop cap applies per PR. Exit reasons (converged, cap reached,
245
- stuck, error) are tracked per PR; the final report lists one outcome line per
246
- PR.
247
-
248
- **Gate:** `validate_content` / `hooks/blocking/code_rules_enforcer.py` on
249
- PR-scoped files before every AUDIT
250
- (`_shared/pr-loop/scripts/code_rules_gate.py`). Lead runs gate; clean-coder
251
- clears failures; then bugfind audits.
252
-
253
- **Pre-cycle: walk prior bugteam reviews end-first** (once per PR, after Step 2
254
- and before iteration begins, when `last_action == "fresh"`). A re-invocation of
255
- `/bugteam` on a PR with prior loops detects whether the most recent loop already
256
- cleaned this HEAD (short-circuit) and otherwise records that prior loops were
257
- dirty so the AUDIT runs against the latest diff with that signal in mind:
258
-
259
- ```python
260
- dirty_review_count = 0
261
- all_reviews = pull_request_read(
262
- method="get_reviews", pullNumber=N, owner=O, repo=R
263
- )
264
- prior_reviews = [
265
- rev for rev in all_reviews
266
- if rev.get("body", "").startswith("## /bugteam loop ")
267
- ]
268
- prior_reviews.sort(key=lambda rev: rev["submitted_at"], reverse=True)
269
- ```
270
-
271
- Iterate from index 0 (most recent) toward older entries:
272
-
273
- - A bugteam review body that ends with `→ clean` is **clean**; any other `##
274
- /bugteam loop ...` body is **dirty**.
275
- - For a dirty review, increment `dirty_review_count` by one. The review's
276
- specific finding bodies are not carried forward —
277
- bugteam's AUDIT regenerates
278
- findings against the current HEAD's diff each loop, so prior bodies are stale
279
- by definition. The count alone is the carried signal.
280
- - Stop at the first clean review. Older reviews are presumed addressed at that
281
- clean checkpoint and are not re-read.
282
- - When index 0 is itself clean AND its `commit_id` matches `git rev-parse HEAD`,
283
- the PR is already converged on this HEAD — set `last_action="audited"`,
284
- `last_findings='{"total": 0}'`, fall through to step 1's `converged` exit,
285
- skip Step 3 iteration entirely.
286
- - When `dirty_review_count > 0`, log the count and proceed into the normal
287
- iteration; the next AUDIT regenerates anchored findings against the current
288
- HEAD so `loop_comment_index` stays correct. Unlike `pr-converge` — where
289
- Cursor Bugbot's prior dirty-review *bodies* are read back by the Fix protocol
290
- because each dirty body lists specific findings the loop must still address
291
-
292
- bugteam's per-loop bodies are anchored to the diff at *that loop's* HEAD, so
293
- re-applying them against a newer diff would be incorrect. The count is
294
- sufficient signal that "prior loops did not converge here."
295
-
296
- 1. From `last_action` / `last_findings`:
297
- - `last_action == "audited"` and `last_findings.total == 0` → exit
298
- `converged`
299
- - `last_action == "fixed"` and `git rev-parse HEAD` unchanged since
300
- pre-FIX → exit `stuck`
301
- - `last_action in {"fresh", "fixed"}` → **pre-audit** then **AUDIT**
302
- - `last_action == "audited"` and `last_findings.total > 0` → **FIX**
303
-
304
- 2. **Pre-audit** (only when the next step is AUDIT):
305
-
306
- ```bash
307
- python \
308
- "${CLAUDE_SKILL_DIR}/../../_shared/pr-loop/scripts/code_rules_gate.py" \
309
- --base origin/<baseRefName>
310
- ```
311
-
312
- Lead only; merge-base / diff semantics:
313
- [`../../_shared/pr-loop/code-rules-gate.md`][path-code-rules]; shared script
314
- inventory: [`../../_shared/pr-loop/scripts/README.md`][path-scripts-readme].
315
- Non-zero → spawn **clean-coder** standards-fix (`mode="bypassPermissions"`) (read stderr, edit, re-run
316
- **this same** command, one commit, `git push`, shutdown) until exit **0** or
317
- **5**
318
- failed gate rounds → `error: code rules gate failed pre-audit`. After **0**:
319
- `loop_count += 1`; if `loop_count > 10` → `cap reached`. Then **AUDIT**
320
- (bugfind); print `Loop <L> audit: ...`.
321
-
322
- 3. **FIX** (`last_action == "audited"` and `last_findings.total > 0`):
323
- `loop_count += 1`; if `loop_count > 10` → `cap reached`; **FIX** (bugfix);
324
- print `Loop <L> fix: ...`; `last_action = "fixed"`, update `audit_log`; loop
325
- to step 1.
326
-
327
- 4. After **AUDIT**: update `last_action`, `last_findings`, `audit_log`; print
328
- audit line if not already printed.
329
-
330
- 5. Loop.
331
-
332
- First pass: pre-audit → AUDIT. After a FIX, the next pass runs pre-audit again
333
- before the next AUDIT.
334
-
335
- ### AUDIT action
336
-
337
- 1. Create the directory: `mkdir -p "<run_temp_dir>/pr-<N>"`.
338
- 2. Call `pull_request_read(method="get_diff", pullNumber=N, owner=O, repo=R)`
339
- to capture the diff text, then write it to
340
- `"<run_temp_dir>/pr-<N>/loop-<L>.patch"` using the `Write` tool.
341
-
342
- ```
343
- Agent(
344
- subagent_type="code-quality-agent",
345
- name="bugfind-pr<N>-loop<L>",
346
- model="opus",
347
- run_in_background=true,
348
- description="Bugfind audit PR <N> loop <L>",
349
- prompt="<audit XML; see PROMPTS.md>"
350
- )
351
- ```
352
-
353
- Fresh spawn each loop for clean-room isolation. Lead awaits the
354
- background-completion notification, then reads
355
- `.bugteam-pr<N>-loop<L>.outcomes.xml` from the worktree directory, fills
356
- `loop_comment_index`. [`PROMPTS.md`](PROMPTS.md): XML + outcome schema.
357
-
358
- `last_action = "audited"`; append audit line to `audit_log`.
359
-
360
- **Parallel auditors (`loop_count >= 4`):** gate passes immediately before;
361
- after three full audit/fix rounds without convergence, issue eleven `Agent`
362
- calls in one assistant message (`run_in_background=true`):
363
-
364
- - **10 haiku auditors (`-b` through `-k`):** `subagent_type="code-quality-agent"`,
365
- `model="haiku"`, write sibling XML to
366
- `<run_temp_dir>/pr-<N>/loop-<L>-<letter>.outcomes.xml`, skip PR posting.
367
- Prompts must pass literal absolute sibling paths.
368
- - **1 opus validator (`-a`):** `subagent_type="code-quality-agent"`,
369
- `model="opus"`:
370
- - Polls for all 10 sibling XMLs before proceeding (60s timeout, 2s interval). On timeout: log diagnostics entry, proceed with validated findings from available XMLs, report count in validator output.
371
- - Validates each finding: file exists, line in bounds, excerpt contains the exact
372
- text of the cited line, category is A–J, severity is P0/P1/P2.
373
- - Hallucinated findings → quarantined to `<run_temp_dir>/pr-<N>/loop-<L>-diagnostics.json` under
374
- `validator_rejected` (added alongside the required diagnostics keys defined in the shared audit contract).
375
- - De-dups by `(file, line, category)`, max severity wins; on conflict, keep longest description text.
376
- - Re-ids as `loop<L>-<K>`.
377
- - Writes `<worktree_path>/.bugteam-pr<N>-loop<L>.outcomes.xml`, posts review.
378
-
379
- Lead awaits the opus validator (-a) background-completion notification (120s
380
- timeout). The validator independently polls all 10 sibling XMLs; the lead does
381
- not gate on haiku peer completion. On lead timeout: the validator did not post
382
- a merged review — treat as a hard blocker and abort the loop.
383
-
384
- The sibling-output paths in [`PROMPTS.md`](PROMPTS.md) must cover the full
385
- `-b` through `-k` range.
386
-
387
- ### FIX action
388
-
389
- **Spawn:**
390
-
391
- ```
392
- Agent(
393
- subagent_type="clean-coder",
394
- name="bugfix-pr<N>-loop<L>",
395
- model="opus",
396
- run_in_background=true,
397
- description="Bugfix PR <N> loop <L>",
398
- prompt="<fix XML; see PROMPTS.md>"
399
- )
400
- ```
401
-
402
- Pass finding comment URLs/ids from `loop_comment_index` in XML. Lead awaits the
403
- background-completion notification. Replies: `Fixed in <sha>` or `Could not
404
- address this loop: <reason>`.
405
-
406
- [`PROMPTS.md`](PROMPTS.md): fix XML + schema. Verify from worktree: `git -C "<run_temp_dir>/pr-<N>/worktree" rev-parse HEAD`
407
- advanced; `git -C "<run_temp_dir>/pr-<N>/worktree" fetch origin <branch> && git -C "<run_temp_dir>/pr-<N>/worktree" rev-parse origin/<branch>` matches
408
- `HEAD`. Unchanged HEAD →
409
- `stuck — bugfix subagent could not address findings`.
410
-
411
- **Scope verification.** Run `git diff HEAD~1 --name-only` and compare against the set of files referenced in bugs_to_fix. When the commit touches any file NOT in the bugs_to_fix list, downgrade the outcome to `unverified_fixed` with reason "commit touched unexpected files: <list>".
412
-
413
- ### Step 4: Teardown
414
-
415
- 1. For each PR in `all_prs`: `git worktree remove
416
- "<run_temp_dir>/pr-<N>/worktree"` (from Step 1) — tolerate already-removed
417
- worktrees.
418
-
419
- 2. **Windows-safe `rmtree`** — strips the Windows ReadOnly attribute and retries
420
- the failing syscall (see `~/.claude/rules/windows-filesystem-safe.md`).
421
- Remove the full `<run_temp_dir>`:
422
-
423
- ```bash
424
- python -c "import os, shutil, stat, sys; \
425
- h = lambda f, p, *_: (os.chmod(p, stat.S_IWRITE), f(p)); \
426
- shutil.rmtree(r'<run_temp_dir>', **({'onexc': h} if sys.version_info >= (3, 12)
427
- else {'onerror': h}))"
428
- ```
429
-
430
- ### Step 4.5: PR description
431
-
432
- Lead only; cumulative product narrative (not process). Delegate body to
433
- `pr-description-writer` via `Agent` (`mode="bypassPermissions"`) (else `general-purpose`) so the
434
- mandatory-pr-description hook accepts `update_pull_request`.
435
-
436
- 1. `pull_request_read(method="get_diff", pullNumber=N, owner=O, repo=R)` → write
437
- output to `.bugteam-final.diff` with `Write` tool.
438
- 2. `pull_request_read(method="get", pullNumber=N, owner=O, repo=R)` → extract
439
- `.body` from response, write to `.bugteam-original-body.md` with `Write` tool.
440
- 3. Agent brief: paths + branch names; describe merge-ready change from diff;
441
- keep curated original sections intact; return markdown body.
442
- 4. Write `.bugteam-final-body.md`; `update_pull_request(pullNumber=N, owner=O,
443
- repo=R, body=<body_text>)`.
444
- 5. Delete the three temp files.
445
-
446
- On failure: log in final report; continue to Step 5.
447
-
448
- ### Step 5: Revoke permissions (always)
449
-
450
- ```bash
451
- python \
452
- "${CLAUDE_SKILL_DIR}/../../_shared/pr-loop/scripts/"\
453
- "revoke_project_claude_permissions.py"
454
- ```
455
-
456
- Removes Step 0 grant — run even if Step 4 partially failed (log separately).
457
-
458
- ### Step 6: Final report
459
-
460
- ```
461
- /bugteam exit: <converged | cap reached | stuck | error>
462
- Loops: <loop_count>
463
- Starting commit: <starting_sha7>
464
- Final commit: <current_HEAD_sha7>
465
- Net change: <total_files> files, +<total_add>/-<total_del>
466
-
467
- Loop log:
468
- 1 audit: 3P0 2P1 0P2
469
- ...
470
- ```
471
-
472
- `cap reached` → suggest `/findbugs`. `stuck` → which findings. `error` →
473
- detail + loop.
474
-
475
- ## Constraints
476
-
477
- See [`CONSTRAINTS.md`](CONSTRAINTS.md).
478
-
479
- ## Examples
480
-
481
- See [`EXAMPLES.md`](EXAMPLES.md).
482
-
483
- ## Reference
484
-
485
- See [`reference/README.md`](reference/README.md).
486
-
487
- ## Sources
488
-
489
- See [`sources.md`](sources.md).
490
-
491
- [path-code-rules]: ../../_shared/pr-loop/code-rules-gate.md
492
- [path-scripts-readme]: ../../_shared/pr-loop/scripts/README.md
113
+ ## First invocation of a session
114
+
115
+ Read [reference/team-setup.md](reference/team-setup.md), then
116
+ [reference/audit-and-teammates.md](reference/audit-and-teammates.md), then
117
+ [reference/github-pr-reviews.md](reference/github-pr-reviews.md) for an
118
+ end-to-end mental model before starting Step 0.
119
+
120
+ ## Match situation, read spoke
121
+
122
+ | Situation | Read |
123
+ |---|---|
124
+ | Pre-flight, project permissions, PR scope, loop state, run-name / temp-dir | [reference/team-setup.md](reference/team-setup.md) |
125
+ | `--bugbot-retrigger` flag behavior | [reference/team-setup.md](reference/team-setup.md) |
126
+ | AUDIT action and code-rules pre-audit gate, pre-cycle walk, cycle decision tree | [reference/audit-and-teammates.md](reference/audit-and-teammates.md) |
127
+ | FIX action and verify-push semantics | [reference/audit-and-teammates.md](reference/audit-and-teammates.md) |
128
+ | Posting the end-of-pass audit review via `post_audit_thread.py` (APPROVE on CLEAN — the request event; GitHub stores it as `state=APPROVED` — REQUEST_CHANGES with inline anchored comments on DIRTY) | [§ Audit posting](#audit-posting) |
129
+ | Posting per-finding fix replies via GitHub MCP `add_reply_to_pull_request_comment` (rendered with the unified template at [`_shared/pr-loop/audit-reply-template.md`](../../_shared/pr-loop/audit-reply-template.md)) | [reference/github-pr-reviews.md](reference/github-pr-reviews.md) |
130
+ | Teardown, PR description rewrite via `pr-description-writer`, permission revoke, final report | [reference/teardown-publish-permissions.md](reference/teardown-publish-permissions.md) |
131
+ | Spawn-prompt XML, A–K category bindings, outcome XML schemas | [PROMPTS.md](PROMPTS.md) |
132
+ | Per-category audit content (sub-buckets, decision criteria, ready-to-send Variant C templates) | `$HOME/.claude/audit-rubrics/{category_rubrics,prompts}/` |
133
+ | Invariants and design rationale | [CONSTRAINTS.md](CONSTRAINTS.md), [reference/design-rationale.md](reference/design-rationale.md) |
134
+ | Audit-contract finding shape (Shape A / B), Haiku secondary, post-fix self-audit | [reference/audit-contract.md](reference/audit-contract.md) |
135
+ | Exit-scenario examples (converged, cap-reached, stuck, refusal, mixed-outcome) | [EXAMPLES.md](EXAMPLES.md) |
136
+ | Doc URLs and verbatim quotes | [sources.md](sources.md) |
137
+ | Historical Copilot gap analysis (superseded) | [reference/copilot-gap-analysis.md](reference/copilot-gap-analysis.md) |
138
+
139
+ ## Folder map
140
+
141
+ - `SKILL.md` — this hub.
142
+ - `reference/` workflow detail per situation.
143
+ - `scripts/` — utility scripts executed, not loaded as primary context.
144
+ - `PROMPTS.md` spawn XML, A–K category bindings, outcome schemas.
145
+ - `CONSTRAINTS.md` invariants.
146
+ - `EXAMPLES.md` exit scenarios.
147
+ - `sources.md` — doc URLs and verbatim quotes.
148
+ - `~/.claude/audit-rubrics/` installed by `npx claude-dev-env` from
149
+ `packages/claude-dev-env/audit-rubrics/`; the audit agent reads all A–K
150
+ rubrics under `category_rubrics/` and prompts under `prompts/`. Required
151
+ at audit time alongside `PROMPTS.md`.
@@ -7,7 +7,7 @@ Expanded material that used to live inline in `SKILL.md`. Load a file when the o
7
7
  | [`design-rationale.md`](design-rationale.md) | Why clean-room subagents, table-of-contents habit, when `/bugteam` applies, refusal reasons |
8
8
  | [`team-setup.md`](team-setup.md) | Permissions grant (`CLAUDE_SKILL_DIR`), PR scope, run name / temp dir / loop state |
9
9
  | [`github-pr-reviews.md`](github-pr-reviews.md) | Per-loop reviews, `jq` + `gh api` payloads, anchors, fallbacks, REST endpoints |
10
- | [`audit-and-teammates.md`](audit-and-teammates.md) | Pre-audit gate, full cycle numbering, AUDIT and FIX actions, parallel auditors |
10
+ | [`audit-and-teammates.md`](audit-and-teammates.md) | Pre-audit gate, full cycle numbering, AUDIT and FIX actions |
11
11
  | [`teardown-publish-permissions.md`](teardown-publish-permissions.md) | Utility scripts note, teardown, PR description rewrite, revoke, final report |
12
12
 
13
13
  Canonical documentation quotes: [`../sources.md`](../sources.md).