claude-dev-env 1.82.0 → 1.84.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 (217) hide show
  1. package/CLAUDE.md +16 -13
  2. package/_shared/pr-loop/audit-contract.md +24 -12
  3. package/_shared/pr-loop/scripts/CLAUDE.md +1 -0
  4. package/_shared/pr-loop/scripts/README.md +1 -0
  5. package/_shared/pr-loop/scripts/_claude_permissions_common.py +16 -5
  6. package/_shared/pr-loop/scripts/code_rules_gate.py +2 -3
  7. package/_shared/pr-loop/scripts/pr_loop_shared_constants/CLAUDE.md +1 -0
  8. package/_shared/pr-loop/scripts/pr_loop_shared_constants/reviewer_availability_constants.py +12 -0
  9. package/_shared/pr-loop/scripts/pr_loop_shared_constants/terminology_sweep_constants.py +0 -2
  10. package/_shared/pr-loop/scripts/reviewer_availability.py +182 -0
  11. package/_shared/pr-loop/scripts/reviews_disabled.py +2 -0
  12. package/_shared/pr-loop/scripts/terminology_sweep.py +9 -33
  13. package/_shared/pr-loop/scripts/tests/CLAUDE.md +2 -0
  14. package/_shared/pr-loop/scripts/tests/test__claude_permissions_common.py +212 -0
  15. package/_shared/pr-loop/scripts/tests/test_agent_config_carveout.py +18 -0
  16. package/_shared/pr-loop/scripts/tests/test_claude_permissions_common.py +18 -0
  17. package/_shared/pr-loop/scripts/tests/test_code_rules_gate.py +37 -0
  18. package/_shared/pr-loop/scripts/tests/test_reviewer_availability.py +159 -0
  19. package/_shared/pr-loop/scripts/tests/test_reviewer_availability_constants.py +36 -0
  20. package/_shared/pr-loop/scripts/tests/test_reviews_disabled.py +14 -0
  21. package/_shared/pr-loop/scripts/tests/test_terminology_sweep.py +14 -4
  22. package/agents/clean-coder.md +3 -0
  23. package/audit-rubrics/category_rubrics/category-o-docstring-vs-impl-drift.md +1 -1
  24. package/bin/install.mjs +16 -8
  25. package/bin/install.test.mjs +17 -6
  26. package/commands/CLAUDE.md +0 -1
  27. package/docs/CODE_RULES.md +1 -1
  28. package/hooks/blocking/CLAUDE.md +2 -4
  29. package/hooks/blocking/code_rules_constants_config.py +164 -1
  30. package/hooks/blocking/code_rules_docstrings.py +428 -15
  31. package/hooks/blocking/code_rules_enforcer.py +33 -0
  32. package/hooks/blocking/code_rules_imports_logging.py +867 -1
  33. package/hooks/blocking/code_rules_magic_values.py +5 -0
  34. package/hooks/blocking/code_rules_naming_collection.py +152 -6
  35. package/hooks/blocking/code_rules_shared.py +34 -0
  36. package/hooks/blocking/code_rules_string_magic.py +68 -0
  37. package/hooks/blocking/duplicate_rmtree_helper_blocker.py +4 -4
  38. package/hooks/blocking/pre_tool_use_dispatcher.py +3 -3
  39. package/hooks/blocking/reviewer_spawn_gate.py +182 -0
  40. package/hooks/blocking/stale_comment_reference_blocker.py +267 -0
  41. package/hooks/blocking/state_description_blocker.py +96 -5
  42. package/hooks/blocking/test_code_rules_config_duplicate_path_anchor.py +132 -0
  43. package/hooks/blocking/test_code_rules_enforcer_cap_meta.py +2 -0
  44. package/hooks/blocking/test_code_rules_enforcer_docstring_delegation_summary.py +385 -0
  45. package/hooks/blocking/test_code_rules_enforcer_docstring_prose_wall_illustration.py +197 -0
  46. package/hooks/blocking/test_code_rules_enforcer_docstring_runon_sentence.py +27 -0
  47. package/hooks/blocking/test_code_rules_enforcer_join_separator_magic.py +67 -0
  48. package/hooks/blocking/test_code_rules_enforcer_module_docstring_roster.py +40 -0
  49. package/hooks/blocking/test_code_rules_enforcer_naive_datetime.py +213 -0
  50. package/hooks/blocking/test_code_rules_enforcer_referenced_underscore_loop.py +169 -0
  51. package/hooks/blocking/test_code_rules_enforcer_split_constants_config.py +33 -0
  52. package/hooks/blocking/test_code_rules_enforcer_split_shared.py +23 -0
  53. package/hooks/blocking/test_code_rules_js_bare_flag_return_directive.py +266 -0
  54. package/hooks/blocking/test_code_rules_js_sibling_return_object_key_drift.py +490 -0
  55. package/hooks/blocking/test_code_rules_logging_adjacent_literals.py +171 -0
  56. package/hooks/blocking/test_code_rules_magic_values.py +54 -0
  57. package/hooks/blocking/test_duplicate_rmtree_helper_blocker.py +0 -6
  58. package/hooks/blocking/test_pr_converge_bugteam_enforcer_state_tolerance.py +184 -0
  59. package/hooks/blocking/test_pre_tool_use_dispatcher.py +9 -3
  60. package/hooks/blocking/test_reviewer_spawn_gate.py +230 -0
  61. package/hooks/blocking/test_shared_stdin_adoption.py +5 -30
  62. package/hooks/blocking/test_stale_comment_reference_blocker.py +236 -0
  63. package/hooks/blocking/test_state_description_blocker.py +135 -0
  64. package/hooks/hooks.json +5 -0
  65. package/hooks/hooks_constants/CLAUDE.md +3 -4
  66. package/hooks/hooks_constants/blocking_check_limits.py +46 -0
  67. package/hooks/hooks_constants/code_rules_enforcer_constants.py +41 -0
  68. package/hooks/hooks_constants/code_rules_path_utils_constants.py +1 -1
  69. package/hooks/hooks_constants/duplicate_rmtree_helper_blocker_constants.py +0 -1
  70. package/hooks/hooks_constants/post_tool_use_dispatcher_constants.py +0 -5
  71. package/hooks/hooks_constants/pre_tool_use_dispatcher_constants.py +4 -0
  72. package/hooks/hooks_constants/reviewer_spawn_gate_constants.py +41 -0
  73. package/hooks/hooks_constants/stale_comment_reference_blocker_constants.py +76 -0
  74. package/hooks/hooks_constants/state_description_blocker_constants.py +8 -0
  75. package/hooks/validation/post_tool_use_dispatcher.py +1 -1
  76. package/hooks/validation/test_post_tool_use_dispatcher.py +51 -35
  77. package/hooks/workflow/CLAUDE.md +2 -8
  78. package/package.json +1 -1
  79. package/rules/CLAUDE.md +5 -2
  80. package/rules/claude-md-orphan-file.md +5 -0
  81. package/rules/docstring-prose-matches-implementation.md +10 -1
  82. package/rules/env-var-table-code-drift.md +5 -0
  83. package/rules/es-exe-file-search.md +17 -0
  84. package/rules/no-historical-clutter.md +12 -1
  85. package/rules/orphan-css-class.md +5 -0
  86. package/rules/package-inventory-stale-entry.md +10 -0
  87. package/rules/paired-test-coverage.md +5 -0
  88. package/rules/plain-illustrative-docstrings.md +40 -1
  89. package/rules/verify-before-asking.md +7 -0
  90. package/rules/verify-runtime-state.md +40 -0
  91. package/rules/windows-filesystem-safe.md +8 -0
  92. package/rules/workers-done-before-complete.md +33 -0
  93. package/rules/workflow-substitution-slots.md +5 -0
  94. package/skills/CLAUDE.md +7 -2
  95. package/skills/autoconverge/SKILL.md +48 -61
  96. package/skills/autoconverge/reference/closing-report.md +6 -6
  97. package/skills/autoconverge/reference/convergence.md +17 -15
  98. package/skills/autoconverge/reference/gotchas.md +6 -3
  99. package/skills/autoconverge/workflow/autoconverge_report_constants/render_report_constants.py +2 -9
  100. package/skills/autoconverge/workflow/converge.contract.test.mjs +153 -10
  101. package/skills/autoconverge/workflow/converge.copilot-gate.test.mjs +55 -19
  102. package/skills/autoconverge/workflow/converge.merge-conflict.test.mjs +16 -9
  103. package/skills/autoconverge/workflow/converge.mjs +167 -106
  104. package/skills/autoconverge/workflow/render_report.py +7 -11
  105. package/skills/bugteam/CLAUDE.md +1 -1
  106. package/skills/bugteam/PROMPTS.md +7 -6
  107. package/skills/bugteam/SKILL.md +25 -72
  108. package/skills/bugteam/reference/CLAUDE.md +1 -3
  109. package/skills/bugteam/reference/README.md +1 -1
  110. package/skills/bugteam/reference/audit-and-teammates.md +1 -1
  111. package/skills/bugteam/reference/obstacles/fix-publish-summary.md +1 -1
  112. package/skills/bugteam/reference/team-setup.md +8 -7
  113. package/skills/bugteam/scripts/CLAUDE.md +0 -6
  114. package/skills/bugteam/scripts/README.md +0 -4
  115. package/skills/bugteam/scripts/bugteam_scripts_constants/CLAUDE.md +0 -1
  116. package/skills/code/SKILL.md +2 -0
  117. package/skills/copilot-review/CLAUDE.md +1 -1
  118. package/skills/copilot-review/SKILL.md +25 -23
  119. package/skills/everything-search/SKILL.md +5 -0
  120. package/skills/findbugs/CLAUDE.md +2 -2
  121. package/skills/findbugs/SKILL.md +22 -83
  122. package/skills/fixbugs/SKILL.md +2 -4
  123. package/skills/log-audit/CLAUDE.md +20 -0
  124. package/skills/log-audit/SKILL.md +68 -0
  125. package/skills/log-audit/reference/CLAUDE.md +9 -0
  126. package/skills/log-audit/reference/charter.md +52 -0
  127. package/skills/log-audit/scripts/CLAUDE.md +27 -0
  128. package/skills/log-audit/scripts/cluster_recurrences.py +261 -0
  129. package/skills/log-audit/scripts/collect_log_window.py +199 -0
  130. package/skills/log-audit/scripts/log_audit_constants/CLAUDE.md +12 -0
  131. package/skills/log-audit/scripts/log_audit_constants/cluster_recurrences_constants.py +23 -0
  132. package/skills/log-audit/scripts/log_audit_constants/collect_log_window_constants.py +24 -0
  133. package/skills/log-audit/scripts/log_audit_constants/mine_copilot_findings_constants.py +49 -0
  134. package/skills/log-audit/scripts/mine_copilot_findings.py +302 -0
  135. package/skills/log-audit/scripts/test_cluster_recurrences.py +160 -0
  136. package/skills/log-audit/scripts/test_collect_log_window.py +111 -0
  137. package/skills/log-audit/scripts/test_mine_copilot_findings.py +126 -0
  138. package/skills/monitor-open-prs/SKILL.md +2 -2
  139. package/skills/post-audit-findings/SKILL.md +84 -0
  140. package/skills/pr-converge/CLAUDE.md +2 -0
  141. package/skills/pr-converge/SKILL.md +72 -59
  142. package/skills/pr-converge/reference/CLAUDE.md +1 -1
  143. package/skills/pr-converge/reference/convergence-gates.md +16 -19
  144. package/skills/pr-converge/reference/examples.md +5 -5
  145. package/skills/pr-converge/reference/fix-protocol.md +16 -43
  146. package/skills/pr-converge/reference/obstacles/fix-publish-summary.md +1 -1
  147. package/skills/pr-converge/reference/per-tick.md +24 -45
  148. package/skills/pr-converge/reference/state-schema.md +15 -0
  149. package/skills/pr-converge/scripts/README.md +3 -5
  150. package/skills/pr-fix-protocol/SKILL.md +70 -0
  151. package/skills/pr-loop-lifecycle/SKILL.md +73 -0
  152. package/skills/{bugteam → pr-loop-lifecycle}/reference/teardown-publish-permissions.md +22 -24
  153. package/skills/pr-scope-resolve/SKILL.md +48 -0
  154. package/skills/qbug/CLAUDE.md +4 -4
  155. package/skills/qbug/SKILL.md +46 -144
  156. package/skills/qbug/test_qbug_skill_audit_schema.py +2 -2
  157. package/skills/qbug/test_qbug_skill_post_fix_audit.py +1 -1
  158. package/skills/reviewer-gates/SKILL.md +96 -0
  159. package/skills/session-log/CLAUDE.md +7 -7
  160. package/skills/session-log/SKILL.md +27 -44
  161. package/skills/test_markdown_link_integrity.py +103 -0
  162. package/commands/doc-gist.md +0 -16
  163. package/hooks/blocking/_md_to_html_blocker_test_support.py +0 -65
  164. package/hooks/blocking/conftest.py +0 -30
  165. package/hooks/blocking/md_path_exemptions.py +0 -224
  166. package/hooks/blocking/md_to_html_blocker.py +0 -155
  167. package/hooks/blocking/test_md_to_html_blocker_exemptions.py +0 -434
  168. package/hooks/blocking/test_md_to_html_blocker_extensions.py +0 -157
  169. package/hooks/blocking/test_md_to_html_blocker_path_resolution.py +0 -336
  170. package/hooks/hooks_constants/doc_gist_auto_publish_constants.py +0 -18
  171. package/hooks/hooks_constants/html_companion_constants.py +0 -20
  172. package/hooks/hooks_constants/md_to_html_blocker_constants.py +0 -76
  173. package/hooks/hooks_constants/test_md_to_html_blocker_constants.py +0 -125
  174. package/hooks/workflow/doc_gist_auto_publish.py +0 -144
  175. package/hooks/workflow/md_to_html_companion.py +0 -358
  176. package/hooks/workflow/test_doc_gist_auto_publish.py +0 -117
  177. package/hooks/workflow/test_md_to_html_companion.py +0 -613
  178. package/skills/bugteam/reference/audit-contract.md +0 -163
  179. package/skills/bugteam/scripts/_bugteam_permissions_common.py +0 -455
  180. package/skills/bugteam/scripts/bugteam_scripts_constants/claude_permissions_common_constants.py +0 -69
  181. package/skills/bugteam/scripts/grant_project_claude_permissions.py +0 -280
  182. package/skills/bugteam/scripts/revoke_project_claude_permissions.py +0 -266
  183. package/skills/bugteam/scripts/test__bugteam_permissions_common.py +0 -160
  184. package/skills/bugteam/scripts/test_agent_config_carveout.py +0 -356
  185. package/skills/bugteam/scripts/test_bugteam_permissions_common.py +0 -140
  186. package/skills/doc-gist/CLAUDE.md +0 -25
  187. package/skills/doc-gist/SKILL.md +0 -97
  188. package/skills/doc-gist/references/CLAUDE.md +0 -9
  189. package/skills/doc-gist/references/examples/01-exploration-code-approaches.html +0 -453
  190. package/skills/doc-gist/references/examples/02-exploration-visual-designs.html +0 -515
  191. package/skills/doc-gist/references/examples/03-code-review-pr.html +0 -638
  192. package/skills/doc-gist/references/examples/04-code-understanding.html +0 -491
  193. package/skills/doc-gist/references/examples/05-design-system.html +0 -629
  194. package/skills/doc-gist/references/examples/06-component-variants.html +0 -605
  195. package/skills/doc-gist/references/examples/07-prototype-animation.html +0 -455
  196. package/skills/doc-gist/references/examples/08-prototype-interaction.html +0 -396
  197. package/skills/doc-gist/references/examples/09-slide-deck.html +0 -592
  198. package/skills/doc-gist/references/examples/10-svg-illustrations.html +0 -492
  199. package/skills/doc-gist/references/examples/11-status-report.html +0 -528
  200. package/skills/doc-gist/references/examples/12-incident-report.html +0 -596
  201. package/skills/doc-gist/references/examples/13-flowchart-diagram.html +0 -395
  202. package/skills/doc-gist/references/examples/14-research-feature-explainer.html +0 -381
  203. package/skills/doc-gist/references/examples/15-research-concept-explainer.html +0 -368
  204. package/skills/doc-gist/references/examples/16-implementation-plan.html +0 -702
  205. package/skills/doc-gist/references/examples/17-pr-writeup.html +0 -595
  206. package/skills/doc-gist/references/examples/18-editor-triage-board.html +0 -573
  207. package/skills/doc-gist/references/examples/19-editor-feature-flags.html +0 -663
  208. package/skills/doc-gist/references/examples/20-editor-prompt-tuner.html +0 -722
  209. package/skills/doc-gist/references/examples/21-decision-signoff.html +0 -546
  210. package/skills/doc-gist/references/examples/CLAUDE.md +0 -25
  211. package/skills/doc-gist/references/examples/README.md +0 -5
  212. package/skills/doc-gist/scripts/CLAUDE.md +0 -27
  213. package/skills/doc-gist/scripts/doc_gist_scripts_constants/CLAUDE.md +0 -10
  214. package/skills/doc-gist/scripts/doc_gist_scripts_constants/gist_upload_constants.py +0 -16
  215. package/skills/doc-gist/scripts/gist_upload.py +0 -177
  216. package/skills/doc-gist/scripts/test_gist_upload.py +0 -51
  217. /package/skills/{doc-gist/scripts/doc_gist_scripts_constants → log-audit/scripts/log_audit_constants}/__init__.py +0 -0
@@ -36,7 +36,8 @@ First match wins; respond with the quoted line exactly and stop:
36
36
  token `bugteam` (comma-separated, case-insensitive, whitespace-tolerant):
37
37
  `/bugteam is disabled via CLAUDE_REVIEWS_DISABLED.` The pre-flight script
38
38
  also exits 7 in this case so any caller invoking it directly halts on the
39
- same signal.
39
+ same signal. Gate semantics live in the `reviewer-gates` skill
40
+ ([../reviewer-gates/SKILL.md](../reviewer-gates/SKILL.md)).
40
41
  - **No PR or upstream diff.** `No PR or upstream diff. /bugteam needs a target.`
41
42
  - **Dirty tree.** `Uncommitted changes detected. Stash, commit, or revert before
42
43
  /bugteam.`
@@ -46,74 +47,26 @@ First match wins; respond with the quoted line exactly and stop:
46
47
 
47
48
  ## Audit posting
48
49
 
49
- Every internal audit pass (CLEAN or DIRTY) ends with one call to
50
- `post_audit_thread.py`. The script POSTs a single review to
51
- `/repos/{owner}/{repo}/pulls/{N}/reviews` with `event=APPROVE` on CLEAN
52
- (the request event; GitHub stores it as `state=APPROVED`; empty
53
- `comments[]`, body documents "no findings") or
54
- `event=REQUEST_CHANGES` on DIRTY (one inline anchored comment per
55
- finding; each becomes its own resolvable thread). The mandate applies
56
- whether bugteam runs inside `/pr-converge` or standalone.
57
-
58
- **Self-PR auto-toggle.** GitHub rejects both `APPROVE` and
59
- `REQUEST_CHANGES` reviews with HTTP 422 when the authenticated identity
60
- matches the PR author ("Cannot approve/request changes on your own pull
61
- request"). `post_audit_thread.py` detects this case via `gh api user` +
62
- `gh api repos/<o>/<r>/pulls/<n>` and auto-resolves an alternate gh
63
- account's token for the reviews POST — the active `gh auth` account is
64
- not mutated; only the bearer token sent on the request changes. After
65
- the POST the active account is still whoever it was before, so no
66
- "swap back" step is needed.
67
-
68
- Configuration:
69
-
70
- - `GH_TOKEN` / `GITHUB_TOKEN` env vars take precedence over the toggle.
71
- Set them when you need to pin a specific reviewer identity by token
72
- rather than by account login.
73
- - `BUGTEAM_REVIEWER_ACCOUNT` env var names which authenticated alternate
74
- to prefer when a toggle is needed (for example,
75
- `BUGTEAM_REVIEWER_ACCOUNT=jl-cmd`). When unset, the script falls back
76
- to the first alternate account `gh auth status` reports.
77
- - The named alternate must be logged in (`gh auth login -h github.com -u
78
- <login>`) before the audit skill runs. The script exits 1 with a
79
- pointing-at-`gh auth login` message when self-PR is detected and no
80
- usable alternate is authenticated.
81
-
82
- ```
83
- python "${CLAUDE_SKILL_DIR}/../../_shared/pr-loop/scripts/post_audit_thread.py" \
84
- --skill bugteam \
85
- --owner <owner> \
86
- --repo <repo> \
87
- --pr-number <N> \
88
- --commit <head_sha> \
89
- --state <CLEAN|DIRTY> \
90
- --findings-json <path>
91
- ```
92
-
93
- `--findings-json` points to a JSON file whose root is a list of objects
94
- shaped `{path, line, side, severity, description, fix_summary}`. The
95
- audit agent's persisted finding output maps as follows: finding `file`
96
- → `path`, and the agent's `failure_mode` field carries both the failure
97
- narrative AND the `Fix:` / `Validation:` text per
98
- [`agents/code-quality-agent.md`](../../agents/code-quality-agent.md)
99
- ("The `failure_mode` field is the audit-to-fix handoff"). Split
100
- `failure_mode` at the literal `Fix:` heading: the prefix (the failure
101
- narrative) becomes `description`, and the suffix starting at `Fix:`
102
- (including the trailing `Validation:` clause) becomes `fix_summary`.
103
- When the agent omits the `Fix:` heading on a given finding, write the
104
- full `failure_mode` text to BOTH `description` and `fix_summary` so the
105
- script's body template (`INLINE_COMMENT_BODY_TEMPLATE` in
106
- [`_shared/pr-loop/scripts/pr_loop_shared_constants/post_audit_thread_constants.py`](../../_shared/pr-loop/scripts/pr_loop_shared_constants/post_audit_thread_constants.py))
107
- still renders coherently. Set `side="RIGHT"` for every entry. On CLEAN,
108
- pass an empty array (`[]`) so the script posts an APPROVE review
109
- (GitHub stores it as `state=APPROVED`) with a "no findings" summary and
110
- zero inline comments.
111
-
112
- Exit codes: `0` on success (emits the new review's `html_url` to
113
- stdout); `1` on user input error; `2` on retry exhaustion (1s / 4s /
114
- 16s backoff across four attempts total). Exit 2 is a hard blocker; the
115
- lead halts the loop and exits `error: post_audit_thread retry
116
- exhausted` without retrying.
50
+ Every internal audit pass (CLEAN or DIRTY) ends with one posted GitHub PR
51
+ review; the mandate applies whether bugteam runs inside `/pr-converge` or
52
+ standalone. Apply the `post-audit-findings` skill
53
+ ([../post-audit-findings/SKILL.md](../post-audit-findings/SKILL.md)) with
54
+ `--skill bugteam`: it covers the findings-JSON mapping (the `failure_mode`
55
+ split at the literal `Fix:` heading), the anchored-vs-unanchored partition,
56
+ the `post_audit_thread.py` invocation, the self-PR reviewer toggle
57
+ (`BUGTEAM_REVIEWER_ACCOUNT`), the exit codes, and the id harvest.
58
+
59
+ Bugteam-only obligations:
60
+
61
+ - The lead runs the posting step; the FIX teammate waits for the harvested
62
+ ids before replying or resolving.
63
+ - Record each harvested `{finding_comment_id, finding_comment_url,
64
+ thread_node_id}` triple into `loop_comment_index` (per-loop scope; see
65
+ [reference/team-setup.md](reference/team-setup.md) § Loop state block) so
66
+ the matching FIX action owns the reply-and-resolve unit.
67
+ - Exit 2 from `post_audit_thread.py` is a hard blocker: the lead halts the
68
+ loop and exits `error: post_audit_thread retry exhausted` without
69
+ retrying.
117
70
 
118
71
  ## Progress checklist
119
72
 
@@ -143,13 +96,13 @@ end-to-end mental model before starting Step 0.
143
96
  | `--bugbot-retrigger` flag behavior | [reference/team-setup.md](reference/team-setup.md) |
144
97
  | AUDIT action and code-rules pre-audit gate, pre-cycle walk, cycle decision tree | [reference/audit-and-teammates.md](reference/audit-and-teammates.md) |
145
98
  | FIX action and verify-push semantics | [reference/audit-and-teammates.md](reference/audit-and-teammates.md) |
146
- | 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) |
99
+ | Posting the end-of-pass audit review (APPROVE on CLEAN, REQUEST_CHANGES with inline anchored comments on DIRTY) | [§ Audit posting](#audit-posting), which applies [../post-audit-findings/SKILL.md](../post-audit-findings/SKILL.md) |
147
100
  | 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) |
148
- | Teardown, PR description rewrite via `pr-description-writer`, permission revoke, final report | [reference/teardown-publish-permissions.md](reference/teardown-publish-permissions.md) |
101
+ | Teardown, PR description rewrite via `pr-description-writer`, permission revoke, final report | [../pr-loop-lifecycle/reference/teardown-publish-permissions.md](../pr-loop-lifecycle/reference/teardown-publish-permissions.md) |
149
102
  | Spawn-prompt XML, A–P category bindings, outcome XML schemas | [PROMPTS.md](PROMPTS.md) |
150
103
  | Per-category audit content (sub-buckets, decision criteria, ready-to-send Variant C templates) | `$HOME/.claude/audit-rubrics/{category_rubrics,prompts}/` |
151
104
  | Invariants and design rationale | [CONSTRAINTS.md](CONSTRAINTS.md), [reference/design-rationale.md](reference/design-rationale.md) |
152
- | Audit-contract finding shape (Shape A / B), Haiku secondary, post-fix self-audit | [reference/audit-contract.md](reference/audit-contract.md) |
105
+ | Audit-contract finding shape (Shape A / B), Haiku secondary, post-fix self-audit | [../../_shared/pr-loop/audit-contract.md](../../_shared/pr-loop/audit-contract.md) |
153
106
  | Exit-scenario examples (converged, cap-reached, stuck, refusal, mixed-outcome) | [EXAMPLES.md](EXAMPLES.md) |
154
107
  | Doc URLs and verbatim quotes | [sources.md](sources.md) |
155
108
  | Historical Copilot gap analysis (superseded) | [reference/copilot-gap-analysis.md](reference/copilot-gap-analysis.md) |
@@ -7,11 +7,9 @@ Expanded workflow detail for the `bugteam` skill. Load a file from this director
7
7
  | File | Purpose |
8
8
  |---|---|
9
9
  | `README.md` | Index of all files in this directory with one-line domain summaries. |
10
- | `team-setup.md` | Permissions grant, PR scope resolution, run name, temp dir, and loop state. |
10
+ | `team-setup.md` | Permissions grant, PR scope resolution (applies the `pr-scope-resolve` skill), run name, temp dir, and loop state. |
11
11
  | `audit-and-teammates.md` | Pre-audit CODE_RULES gate, full cycle numbering, AUDIT and FIX action detail. |
12
- | `audit-contract.md` | Finding shape (Shape A / B), Haiku secondary merge rules, post-fix self-audit. |
13
12
  | `github-pr-reviews.md` | Per-loop review posting, `jq`+`gh api` payloads, inline anchors, fallbacks, REST endpoints. |
14
- | `teardown-publish-permissions.md` | Teardown steps, PR description rewrite via `pr-description-writer`, permission revoke, final report. |
15
13
  | `design-rationale.md` | Why clean-room subagents, when `/bugteam` applies, refusal reasons. |
16
14
  | `copilot-gap-analysis.md` | Historical gap analysis (reference only). |
17
15
 
@@ -8,7 +8,7 @@ Expanded material that used to live inline in `SKILL.md`. Load a file when the o
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
10
  | [`audit-and-teammates.md`](audit-and-teammates.md) | Pre-audit gate, full cycle numbering, AUDIT and FIX actions |
11
- | [`teardown-publish-permissions.md`](teardown-publish-permissions.md) | Utility scripts note, teardown, PR description rewrite, revoke, final report |
11
+ | [`../../pr-loop-lifecycle/reference/teardown-publish-permissions.md`](../../pr-loop-lifecycle/reference/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).
14
14
 
@@ -153,7 +153,7 @@ Agent(
153
153
 
154
154
  The teammate sees only the latest audit’s findings — each `Agent` call starts with a fresh context window; prior-loop findings, fix history, and chat stay in the lead.
155
155
 
156
- Pass finding comment URL, comment id, and thread node id for each finding (from `loop_comment_index`) in the XML prompt so the teammate owns both the reply and the thread resolution. After commit, the teammate posts one reply per finding using the unified template at [`../../../_shared/pr-loop/audit-reply-template.md`](../../../_shared/pr-loop/audit-reply-template.md) — the full header / horizontal rule / `<action_heading> ✅` / explanation / anchored-bullet / closing-paragraph skeleton, with `<status_line>` set per the path (`Fixed in <short_sha>` for `status=fixed`, `Could not address this loop` for `status=could_not_address`, `Hook blocked the fix commit` for `status=hook_blocked`). Per-thread reply and `resolve_thread` are atomic see [`../../../_shared/pr-loop/fix-protocol.md`](../../../_shared/pr-loop/fix-protocol.md) step 12 for the exact sequence. Same identity model as bugfind: teammate posts; lead waits.
156
+ Pass finding comment URL, comment id, and thread node id for each finding (from `loop_comment_index`) in the XML prompt so the teammate owns both the reply and the thread resolution. After commit, the teammate posts one reply per finding using the unified template at [`../../../_shared/pr-loop/audit-reply-template.md`](../../../_shared/pr-loop/audit-reply-template.md) — the full header / horizontal rule / `<action_heading> ✅` / explanation / anchored-bullet / closing-paragraph skeleton, with `<status_line>` set per the path (`Fixed in <short_sha>` for `status=fixed`, `Could not address this loop` for `status=could_not_address`, `Hook blocked the fix commit` for `status=hook_blocked`). Per-thread reply and `resolve_thread` are atomic; the mechanics follow the `pr-fix-protocol` skill ([`../../pr-fix-protocol/SKILL.md`](../../pr-fix-protocol/SKILL.md)), which frames the shared 13-step sequence in [`../../../_shared/pr-loop/fix-protocol.md`](../../../_shared/pr-loop/fix-protocol.md) (step 12 carries the exact reply-and-resolve sequence). Same identity model as bugfind: teammate posts; lead waits.
157
157
 
158
158
  After replies, the teammate writes outcome XML (schema in [`../PROMPTS.md`](../PROMPTS.md)).
159
159
 
@@ -1,6 +1,6 @@
1
1
  # Publish fix summary
2
2
 
3
- Publish fix summary HTML via /doc-gist with commit SHA, files, per-fix descriptions
3
+ Publish fix summary HTML via the Artifact tool with commit SHA, files, per-fix descriptions
4
4
 
5
5
  ## Self-population
6
6
 
@@ -8,7 +8,7 @@ Bugteam-specific utilities (preflight, fix_hookspath, grant, revoke) live in
8
8
  the skill-local [`scripts/`](../scripts/) directory. Shared utilities remain in
9
9
  [`_shared/pr-loop/scripts/`](../../_shared/pr-loop/scripts/) (run, do not paste
10
10
  into context). Utility scripts are **executed**, not loaded as primary context
11
- ([`sources.md`](sources.md) § Progressive disclosure and utility scripts).
11
+ ([`sources.md`](../sources.md) § Progressive disclosure and utility scripts).
12
12
 
13
13
  ```bash
14
14
  python "${CLAUDE_SKILL_DIR}/scripts/bugteam_preflight.py"
@@ -53,7 +53,7 @@ the auto-remediation only applies to the `core.hooksPath` failure mode.
53
53
  Before spawning any subagents, grant the session write access to the project's `.claude/**` tree:
54
54
 
55
55
  ```bash
56
- python "${CLAUDE_SKILL_DIR}/scripts/grant_project_claude_permissions.py"
56
+ python "${CLAUDE_SKILL_DIR}/../../_shared/pr-loop/scripts/grant_project_claude_permissions.py"
57
57
  ```
58
58
 
59
59
  `${CLAUDE_SKILL_DIR}` is a Claude Code host-managed token, pre-substituted by the runtime before any shell sees it. Unlike `${TMPDIR}` and similar shell parameter expansions, it does not depend on the shell’s expansion semantics, so it behaves the same on Unix and Windows shells.
@@ -64,11 +64,12 @@ This is the **first** action of every `/bugteam` invocation, before any subagent
64
64
 
65
65
  ## Step 1 — Resolve PR scope (detail)
66
66
 
67
- Same resolution path as `/findbugs`:
68
-
69
- 1. Call `pull_request_read(method="get", pullNumber=N, owner=O, repo=R)` to fetch PR metadata; capture `number`, `headRefName`, `baseRefName`, and `url` from the response. Falls back to the merge-base diff path when no PR exists.
70
- 2. Fall back to `git merge-base HEAD origin/<default>` then `git diff <merge-base>...HEAD`.
71
- 3. Neither refuse per refusal cases in `SKILL.md`.
67
+ Apply the `pr-scope-resolve` skill
68
+ ([../../pr-scope-resolve/SKILL.md](../../pr-scope-resolve/SKILL.md)) with
69
+ caller `bugteam`. Its resolution ladder hands back `owner`, `repo`, `number`,
70
+ `head_ref`, `base_ref`, `url`, and `head_sha`; when no PR and no upstream
71
+ diff exist, respond exactly `No PR or upstream diff. /bugteam needs a
72
+ target.` and stop.
72
73
 
73
74
  Capture `<owner>/<repo>`, head branch, base branch, PR number, PR URL. This scope persists across every loop — `/bugteam` runs to completion from the single up-front confirmation.
74
75
 
@@ -9,9 +9,6 @@ Python scripts executed by the bugteam lead or teammates at runtime. These are n
9
9
  | `bugteam_preflight.py` | Run pytest and optional `pre-commit` before the first loop. Skips pytest when `BUGTEAM_PREFLIGHT_SKIP=1` or no test files exist. |
10
10
  | `bugteam_fix_hookspath.py` | Auto-remediate a stale `core.hooksPath` override, set the canonical global value, re-run preflight. |
11
11
  | `bugteam_code_rules_gate.py` | Run `validate_content` from `code_rules_enforcer.py` on PR-scoped files. Exit 1 on mandatory rule failures. |
12
- | `grant_project_claude_permissions.py` | Grant Edit/Write/Read on `cwd/.claude/**` in `~/.claude/settings.json`. |
13
- | `revoke_project_claude_permissions.py` | Remove the matching grant entries from `~/.claude/settings.json`. |
14
- | `_bugteam_permissions_common.py` | Shared helpers for grant/revoke (atomic JSON writes, settings sections). |
15
12
  | `windows_safe_rmtree.py` | Remove a directory tree on Windows by stripping ReadOnly attributes and retrying on failure. |
16
13
  | `probe_code_rules_enforcer_check.py` | Load `code_rules_enforcer.py` and invoke a named check function against a fixture file. |
17
14
  | `reflow_skill_md.py` | Reflow the bugteam SKILL.md body to fit line-length limits. |
@@ -23,9 +20,6 @@ Python scripts executed by the bugteam lead or teammates at runtime. These are n
23
20
  | `test_bugteam_preflight.py` | `bugteam_preflight.py` |
24
21
  | `test_bugteam_code_rules_gate.py` | `bugteam_code_rules_gate.py` |
25
22
  | `test_bugteam_fix_hookspath.py` | `bugteam_fix_hookspath.py` |
26
- | `test_bugteam_permissions_common.py` | `_bugteam_permissions_common.py` |
27
- | `test__bugteam_permissions_common.py` | Internal helpers in `_bugteam_permissions_common.py` |
28
- | `test_agent_config_carveout.py` | `.claude/**` grant/revoke carveout logic |
29
23
  | `test_probe_code_rules_enforcer_check.py` | `probe_code_rules_enforcer_check.py` |
30
24
  | `test_windows_safe_rmtree.py` | `windows_safe_rmtree.py` |
31
25
 
@@ -7,10 +7,6 @@ Scripts in this directory are **executed** by the lead or teammates. They are no
7
7
  | `bugteam_preflight.py` | Run pytest (when configured) and optional `pre-commit` before `/bugteam`. |
8
8
  | `bugteam_fix_hookspath.py` | Auto-remediate a stale local `core.hooksPath` override, set canonical global value, re-run `bugteam_preflight.py`. Invoked by Claude when preflight reports a `core.hooksPath` failure. |
9
9
  | `bugteam_code_rules_gate.py` | Run `validate_content` from `code-rules-enforcer.py` on PR-scoped files (`git diff` vs merge-base). Exit `1` if any mandatory rule fails. Invoked **before each audit**; the fixer clears it before the auditor runs. |
10
- | `grant_project_claude_permissions.py` | Idempotent grant of Edit/Write/Read on `cwd/.claude/**` into `~/.claude/settings.json`. |
11
- | `revoke_project_claude_permissions.py` | Removes the matching grant entries from `~/.claude/settings.json`. |
12
- | `test_claude_permissions_common.py` | Pytest module for path normalization and glob-metacharacter guards in `_claude_permissions_common.py`. |
13
- | `_claude_permissions_common.py` | Shared helpers for the grant/revoke scripts (atomic JSON writes, settings sections). |
14
10
  | `windows_safe_rmtree.py` | Recursively remove a directory tree on Windows by stripping ReadOnly attributes and retrying the failing syscall. Invoked from SKILL.md Step 4 to delete `<run_temp_dir>` after teardown. |
15
11
  | `probe_code_rules_enforcer_check.py` | Dynamically load `~/.claude/hooks/blocking/code_rules_enforcer.py` and invoke a named check function against a fixture file. Used by the historical Copilot gap-analysis investigation as a verification shape (see `reference/copilot-gap-analysis.md`). |
16
12
 
@@ -9,7 +9,6 @@ Python package of named constants imported by the bugteam scripts. Each module h
9
9
  | `bugteam_preflight_constants.py` | `bugteam_preflight.py` — env var name, hooks path suffix, exit codes, ignore dirs, argument tuples, config filenames. |
10
10
  | `bugteam_code_rules_gate_constants.py` | `bugteam_code_rules_gate.py` — gate-related path and exit-code constants. |
11
11
  | `bugteam_fix_hookspath_constants.py` | `bugteam_fix_hookspath.py` — canonical hooks path, remediation message strings. |
12
- | `claude_permissions_common_constants.py` | `_bugteam_permissions_common.py` — settings JSON keys, glob patterns for the grant/revoke scripts. |
13
12
  | `probe_code_rules_enforcer_check_constants.py` | `probe_code_rules_enforcer_check.py` — enforcer module path and function name constants. |
14
13
  | `reflow_skill_md_constants.py` | `reflow_skill_md.py` — line-length and formatting constants. |
15
14
  | `windows_safe_rmtree_constants.py` | `windows_safe_rmtree.py` — retry count and wait constants. |
@@ -138,6 +138,8 @@ def load_config(config_path: str) -> AppConfig:
138
138
  """
139
139
  ```
140
140
 
141
+ For a public function whose behavior needs a picture, lead the narrative with a diagram: one summary line, then a `::` literal block or a doctest showing a concrete input and its marked outcome, then a couple of short prose lines, then the `Args:` / `Returns:` sections. See `../../rules/plain-illustrative-docstrings.md` for the shape and a worked example.
142
+
141
143
  ### 13. Build infrastructure
142
144
 
143
145
  The project under development must contain:
@@ -4,7 +4,7 @@ Spawns a background subagent that polls the GitHub Copilot reviewer on the curre
4
4
 
5
5
  ## Purpose
6
6
 
7
- The main session gathers PR context (number, HEAD SHA, owner/repo, branch), spawns a self-terminating background subagent with a fully filled-in prompt, and returns control at once. The subagent loops on a 5-minute `ScheduleWakeup` cadence: fetch Copilot's latest review, TDD-fix any inline findings, push a commit, reply inline, re-request review. It stops on convergence, a persistent blocker, `TaskStop`, or after 20 ticks.
7
+ The main session gathers PR context (number, HEAD SHA, owner/repo, branch), spawns a self-terminating background subagent with a fully filled-in prompt, and returns control at once. The subagent loops on a 6-minute `ScheduleWakeup` cadence: fetch Copilot's latest review, TDD-fix any inline findings, push a commit, reply inline, resolve each addressed thread, re-request review. It stops on convergence, a persistent blocker, `TaskStop`, three consecutive ticks with no Copilot review at the current HEAD, or after 20 ticks.
8
8
 
9
9
  ## Key file
10
10
 
@@ -2,10 +2,11 @@
2
2
  name: copilot-review
3
3
  description: >-
4
4
  Spawns a background subagent that babysits the GitHub Copilot reviewer on the current
5
- PR: each ~5-min tick it fetches the latest copilot-pull-request-reviewer[bot] review,
6
- fixes unaddressed findings against HEAD (commit, push, inline replies), re-requests
7
- review, and exits on convergence. Triggers: '/copilot-review', 'watch copilot',
8
- 'babysit copilot review', 'keep re-requesting copilot'.
5
+ PR: each ~6-min tick it fetches the latest copilot-pull-request-reviewer[bot] review,
6
+ fixes unaddressed findings against HEAD (commit, push, inline replies, thread
7
+ resolution), re-requests review, and exits on convergence. Triggers:
8
+ '/copilot-review', 'watch copilot', 'babysit copilot review', 'keep re-requesting
9
+ copilot'.
9
10
  ---
10
11
 
11
12
  # Copilot Review
@@ -20,20 +21,18 @@ The user is on a PR branch, wants Copilot (the GitHub Copilot reviewer bot) to k
20
21
 
21
22
  ### Step 0: Opt-out check
22
23
 
23
- Before any other work, inspect the `CLAUDE_REVIEWS_DISABLED` environment
24
- variable. Treat the value as a comma-separated list of skill tokens
25
- (case-insensitive, whitespace-tolerant). When the parsed list contains
26
- `copilot`, respond with the literal line `/copilot-review is disabled via
27
- CLAUDE_REVIEWS_DISABLED.` and stop — do not spawn the subagent, do not call
28
- the Copilot reviewer API, do not run any other step of this skill.
24
+ Before any other work, run:
29
25
 
30
- PowerShell probe (Windows):
31
-
32
- ```pwsh
33
- $disabled = ($env:CLAUDE_REVIEWS_DISABLED -split ',' | ForEach-Object { $_.Trim().ToLowerInvariant() })
34
- if ($disabled -contains 'copilot') { '/copilot-review is disabled via CLAUDE_REVIEWS_DISABLED.' }
26
+ ```bash
27
+ python "$HOME/.claude/_shared/pr-loop/scripts/reviews_disabled.py" --reviewer copilot
35
28
  ```
36
29
 
30
+ Exit 0 — Copilot reviews are disabled: respond with the literal line
31
+ `/copilot-review is disabled via CLAUDE_REVIEWS_DISABLED.` and stop — do not
32
+ spawn the subagent, do not call the Copilot reviewer API, do not run any
33
+ other step of this skill. Exit 1 — continue. Gate semantics live in the
34
+ `reviewer-gates` skill ([../reviewer-gates/SKILL.md](../reviewer-gates/SKILL.md)).
35
+
37
36
  ### Step 1: Gather PR context
38
37
 
39
38
  From the current repo:
@@ -74,25 +73,27 @@ Pass this verbatim to the subagent (substituting the bracketed values):
74
73
  > 2. Fetch latest Copilot review via `pull_request_read(method="get_reviews", pullNumber=[NUMBER], owner="[OWNER]", repo="[REPO]")`.
75
74
  > Capture `commit_id`, `state`, `submitted_at`, `id`.
76
75
  > 3. Decide the branch:
77
- > - **No review exists:** re-request (step 4), schedule next wakeup, return.
78
- > - **Latest review's `commit_id` != current HEAD:** re-request (step 4), schedule next wakeup, return.
79
- > - **Latest review's `commit_id` == current HEAD with unresolved inline findings:** TDD-fix them, push, reply inline on each thread, re-request (step 4), schedule next wakeup, return.
76
+ > - **No review exists:** increment `no_review_count` (see escalation rule below), re-request (step 4), schedule next wakeup, return.
77
+ > - **Latest review's `commit_id` != current HEAD:** increment `no_review_count`, re-request (step 4), schedule next wakeup, return.
78
+ > - **Latest review's `commit_id` == current HEAD with unresolved inline findings:** reset `no_review_count` to 0, TDD-fix them, push, reply inline on each thread, resolve each addressed thread, re-request (step 4), schedule next wakeup, return.
80
79
  > - **Latest review's `commit_id` == current HEAD and clean:** report convergence to the parent with a one-sentence summary and terminate. The loop is done; skip the ScheduleWakeup call.
80
+ >
81
+ > **Escalation rule:** `no_review_count` starts at 0, counts consecutive ticks where no Copilot review exists at the current HEAD, and resets to 0 on every push and every review sighted at HEAD. When it reaches 3, Copilot is not delivering reviews — report the stall to the parent with the count and the last request timestamp, then terminate without scheduling another wakeup.
81
82
  > 4. Re-request Copilot via `request_copilot_review(owner="[OWNER]", repo="[REPO]", pullNumber=[NUMBER])`.
82
83
  > The reviewer ID **must** be `copilot-pull-request-reviewer[bot]` with the `[bot]` suffix — empirically verified: `Copilot`, `copilot`, and `github-copilot` all return `requested_reviewers: []` with no error, silently no-op.
83
84
  > 5. Schedule the next wakeup with `ScheduleWakeup`:
84
- > - `delaySeconds: 300`
85
+ > - `delaySeconds: 360`
85
86
  > - `reason`: one short sentence on what you are waiting for.
86
87
  > - `prompt`: the literal sentinel `<<autonomous-loop-dynamic>>` so the next firing re-enters these instructions.
87
88
  >
88
89
  > **Fix protocol** (step 3, third branch):
89
90
  >
91
+ > - Read `$HOME/.claude/skills/pr-fix-protocol/SKILL.md` and apply it — it carries the shared fix sequence, the reply-and-resolve unit, and the unresolved-thread sweep.
90
92
  > - Read each referenced file:line.
91
93
  > - Write a failing test first when the finding has behavior to test. For pure doc or comment nits that have no behavior, go straight to the fix.
92
- > - Implement the fix.
93
94
  > - Stage the fix and create one new commit on the existing branch: `git add <files> && git commit -m "fix(review): ..."`.
94
95
  > - Push the new commit: `git push origin [BRANCH]`.
95
- > - Reply inline on each comment thread with `add_reply_to_pull_request_comment(owner="[OWNER]", repo="[REPO]", pullNumber=[NUMBER], body="...", commentId=<comment_id>)`, referencing the new commit SHA.
96
+ > - Reply inline via `add_reply_to_pull_request_comment(owner="[OWNER]", repo="[REPO]", pullNumber=[NUMBER], body="...", commentId=<comment_id>)`, referencing the new commit SHA; then resolve each addressed thread via `pull_request_review_write(method="resolve_thread", pullNumber=[NUMBER], owner="[OWNER]", repo="[REPO]", threadId="<PRRT id>")`, harvesting the `PRRT_…` id from `pull_request_read(method="get_review_comments", ...)`. Reply first, then resolve — atomic per thread, per the protocol.
96
97
  >
97
98
  > When a pre-push, pre-commit, or other hook rejects the change, solve it. Read the hook's error message, diagnose the root cause in the code or test, and fix that. Then rerun the commit or push. Hooks exist to catch real problems; treat each rejection as new evidence to act on.
98
99
  >
@@ -101,8 +102,9 @@ Pass this verbatim to the subagent (substituting the bracketed values):
101
102
  > - Convergence (clean review against HEAD): report one-sentence summary to parent and terminate.
102
103
  > - Blocker you have exhausted fix attempts on (API auth failure persists, CI regression whose root cause falls outside this PR, a hook you have investigated and cannot resolve in one commit): report the specific blocker and its diagnosis to the parent, then terminate without scheduling another wakeup.
103
104
  > - Parent sends `TaskStop`: terminate immediately.
105
+ > - `no_review_count` reaches 3 (escalation rule above): report the stall and terminate.
104
106
  >
105
- > **Safety cap:** after 20 ticks without convergence, stop and report. That many rounds means something structural is wrong with the loop.
107
+ > **Safety cap:** after 20 ticks without convergence, stop and report. This is the total-tick runaway guard, distinct from the 3-consecutive-no-review escalation; that many rounds means something structural is wrong with the loop.
106
108
 
107
109
  ### Step 4: Report back to the user
108
110
 
@@ -142,7 +144,7 @@ Subagent: [re-requests review, schedules next wakeup, returns]
142
144
 
143
145
  <example>
144
146
  Subagent tick fires, Copilot has 2 unaddressed inline findings on HEAD.
145
- Subagent: [TDD-fixes both, one commit, pushes, replies inline on both threads, re-requests review, schedules next wakeup]
147
+ Subagent: [TDD-fixes both, one commit, pushes, replies inline on both threads, resolves both threads, re-requests review, schedules next wakeup]
146
148
  </example>
147
149
 
148
150
  <example>
@@ -11,6 +11,11 @@ Search files instantly on Windows using the Everything command-line interface (e
11
11
 
12
12
  **Announce at start:** "I'm using the everything-search skill to find files."
13
13
 
14
+ ## Hard limits
15
+
16
+ - **Scope every search.** Pass a project path, an `ext:`/`dm:`/`size:` filter, or a name pattern. A bare whole-drive scan or a network-share sweep is out of bounds.
17
+ - **Fall back on failure.** When `es.exe` fails or returns nothing, try to start it. if that doesn't work, prompt the user to decide next steps: grep, debug further, etc.
18
+
14
19
  ## Instructions
15
20
 
16
21
  ### Command Syntax
@@ -4,13 +4,13 @@ Audits the current branch's pull request for bugs by spawning the `code-quality-
4
4
 
5
5
  ## Purpose
6
6
 
7
- Read-only. The skill resolves PR scope, writes the diff to a scoped temp file, and spawns two `code-quality-agent` instances (primary sonnet + secondary haiku) with a self-contained, context-free prompt covering all A–P audit categories. After both return it merges findings (de-dup, max-wins severity), posts one audit review to the PR via `post_audit_thread.py` (APPROVE on clean, REQUEST_CHANGES with inline anchored comments on dirty), and reports totals and cleared categories to the user.
7
+ Read-only. The skill resolves PR scope via the `pr-scope-resolve` skill, writes the diff to a scoped temp file, and spawns two `code-quality-agent` instances (primary sonnet + secondary haiku) with a self-contained, context-free prompt covering all A–P audit categories. After both return it merges findings (de-dup, max-wins severity), posts one audit review to the PR via the `post-audit-findings` skill (APPROVE on clean, REQUEST_CHANGES with inline anchored comments on dirty), and reports totals and cleared categories to the user.
8
8
 
9
9
  ## Key file
10
10
 
11
11
  | File | Purpose |
12
12
  |---|---|
13
- | `SKILL.md` | Five-step process: resolve scope, capture diff to a scoped temp path, spawn agents (clean-room prompt XML), post audit review via `post_audit_thread.py`, surface findings and offer `/fixbugs`. Includes refusals, output format, and the anchored-vs-unanchored finding split. |
13
+ | `SKILL.md` | Five-step process: resolve scope (`pr-scope-resolve` skill), capture diff to a scoped temp path, spawn agents (clean-room prompt XML), post audit review (`post-audit-findings` skill), surface findings and offer `/fixbugs`. Includes refusals and the output format. |
14
14
 
15
15
  ## Constraints
16
16
 
@@ -22,21 +22,21 @@ If the current branch has no associated PR and no diff against the default branc
22
22
 
23
23
  First match wins; respond with the quoted line exactly and stop:
24
24
 
25
- - **Disabled via environment.** When `CLAUDE_REVIEWS_DISABLED` contains the
26
- token `bugteam` (comma-separated, case-insensitive, whitespace-tolerant):
27
- `/findbugs is disabled via CLAUDE_REVIEWS_DISABLED.` `/findbugs` is a PR
28
- bug-audit skill in the same family as `/bugteam` and `/qbug`, so the
29
- shared `bugteam` token disables all three.
25
+ - **Disabled via environment.** When `CLAUDE_REVIEWS_DISABLED` carries the
26
+ token `bugteam`:
27
+ `/findbugs is disabled via CLAUDE_REVIEWS_DISABLED.` Run the check via
28
+ `python "$HOME/.claude/_shared/pr-loop/scripts/reviews_disabled.py" --reviewer bugteam`
29
+ (exit 0 = disabled). `/findbugs` is a PR bug-audit skill in the same family
30
+ as `/bugteam` and `/qbug`, so the shared `bugteam` token disables all three.
31
+ The gate semantics live in the `reviewer-gates` skill (`../reviewer-gates/SKILL.md`).
30
32
 
31
33
  ## The Process
32
34
 
33
35
  ### Step 1: Resolve PR scope
34
36
 
35
- Determine the audit target in this order:
37
+ Apply the `pr-scope-resolve` skill (`../pr-scope-resolve/SKILL.md`) with caller `findbugs`. Findbugs consumes the resolved `owner`, `repo`, `number`, `head_ref`, `base_ref`, and `url`; when no PR exists, the ladder's merge-base rung sets the audit scope. When no target exists, respond exactly with the sub-skill's canonical refusal line and stop:
36
38
 
37
- 1. **Open PR for current branch.** Call `pull_request_read(method="get", pullNumber=N, owner=O, repo=R)` for the current branch (`N` comes from the parent skill's context, or fall back to `search_issues` MCP with the current branch name to recover the PR number). If a PR exists, capture its number, base ref, head ref, and URL.
38
- 2. **No PR but a remote default branch exists.** Diff against the default branch's merge-base: `git merge-base HEAD origin/<default>` then `git diff <merge-base>...HEAD`. Treat this as the audit scope.
39
- 3. **Neither.** Respond exactly: `No PR or upstream diff found. Push the branch or open a PR first.` and stop.
39
+ `No PR or upstream diff. /findbugs needs a target.`
40
40
 
41
41
  ### Step 2: Capture the full PR diff
42
42
 
@@ -102,6 +102,8 @@ The XML prompt skeleton:
102
102
  L. Behavior-equivalence for refactors
103
103
  M. Producer/consumer cardinality vs collection-type contract
104
104
  N. Test-name scenario verifier
105
+ O. Docstring / fixture-prose vs implementation drift
106
+ P. Name / regex / word-list vs behavior-contract precision
105
107
 
106
108
  The category list above is a summary. The binding definition of each
107
109
  category is its rubric file under $HOME/.claude/audit-rubrics/category_rubrics/
@@ -117,7 +119,7 @@ The XML prompt skeleton:
117
119
  </constraints>
118
120
 
119
121
  <output_format>
120
- Follow the shared audit contract at ../bugteam/reference/audit-contract.md:
122
+ Follow the shared audit contract at $HOME/.claude/_shared/pr-loop/audit-contract.md:
121
123
 
122
124
  - Severity: P0 = will not run / data corruption; P1 = regression or silent
123
125
  failure; P2 = dead code, minor smell.
@@ -139,81 +141,18 @@ returns findings without posting them as inline comments is invisible
139
141
  to the gate. Findbugs remains read-only on code — the review post is
140
142
  the only side effect.
141
143
 
142
- **Self-PR auto-toggle.** GitHub rejects both `APPROVE` and
143
- `REQUEST_CHANGES` reviews with HTTP 422 when the authenticated identity
144
- matches the PR author ("Cannot approve/request changes on your own pull
145
- request"). `post_audit_thread.py` detects this case via `gh api user` +
146
- `gh api repos/<o>/<r>/pulls/<n>` and auto-resolves an alternate gh
147
- account's token for the reviews POST — the active `gh auth` account is
148
- not mutated; only the bearer token sent on the request changes. After
149
- the POST the active account is still whoever it was before, so no
150
- "swap back" step is needed.
151
-
152
- Configuration:
153
-
154
- - `GH_TOKEN` / `GITHUB_TOKEN` env vars take precedence over the toggle.
155
- Set them when you need to pin a specific reviewer identity by token
156
- rather than by account login.
157
- - `BUGTEAM_REVIEWER_ACCOUNT` env var names which authenticated alternate
158
- to prefer when a toggle is needed (for example,
159
- `BUGTEAM_REVIEWER_ACCOUNT=jl-cmd`). The env var name is shared across
160
- every skill that invokes `post_audit_thread.py`. When unset, the
161
- script falls back to the first alternate account `gh auth status`
162
- reports.
163
- - The named alternate must be logged in (`gh auth login -h github.com -u
164
- <login>`) before the audit skill runs. The script exits 1 with a
165
- pointing-at-`gh auth login` message when self-PR is detected and no
166
- usable alternate is authenticated.
167
-
168
- After the agent (and Haiku secondary) return and the merge is complete,
169
- serialize the merged findings to a JSON file and call
170
- `post_audit_thread.py`:
171
-
172
- ```
173
- python "${CLAUDE_SKILL_DIR}/../../_shared/pr-loop/scripts/post_audit_thread.py" \
174
- --skill findbugs \
175
- --owner <owner> \
176
- --repo <repo> \
177
- --pr-number <N> \
178
- --commit <head_sha> \
179
- --state <CLEAN|DIRTY> \
180
- --findings-json <path>
181
- ```
182
-
183
- The findings JSON root is a list of objects shaped
184
- `{path, line, side, severity, description, fix_summary}`. Before
185
- serializing, partition the merged findings into anchored (line appears
186
- in the captured diff) and unanchored (line is not in the diff) buckets.
187
- Only anchored findings are serialized to the JSON — the GitHub reviews
188
- API rejects the entire POST if any inline comment in `comments[]`
189
- targets a line not in the diff at `--commit`, so a single unanchored
190
- entry breaks the whole review. Unanchored findings are surfaced via
191
- Step 5's user-facing output rather than as inline anchored comments.
192
- For each anchored finding, map `file` → `path`; split the finding's
193
- `failure_mode` at the literal `Fix:` heading so the failure narrative
194
- becomes `description` and the suffix beginning at `Fix:` (including
195
- the trailing `Validation:` clause) becomes `fix_summary` (the
196
- `failure_mode` field carries the full audit-to-fix handoff per
197
- [`agents/code-quality-agent.md`](../../agents/code-quality-agent.md)).
198
- When a finding's `failure_mode` omits the `Fix:` heading, write the
199
- full text to BOTH `description` and `fix_summary`. Set `side="RIGHT"`
200
- for every entry. Zero anchored findings → `--state CLEAN` with the
201
- findings file holding an empty array (`[]`); one or more anchored
202
- findings → `--state DIRTY` with the full list. CLEAN posts an APPROVE review (the
203
- request event; GitHub stores it as `state=APPROVED`) with a "no
204
- findings" summary; DIRTY posts a REQUEST_CHANGES review with one inline
205
- anchored comment per finding (each becomes its own resolvable thread on
206
- the PR).
207
-
208
144
  Capture `<head_sha>` once at the start of Step 4 via `git rev-parse
209
145
  HEAD` in the worktree the diff was scoped against.
210
146
 
211
- Exit codes: `0` on success (emits the new review's `html_url` to
212
- stdout, surface alongside the totals in Step 5); `1` on user input
213
- error; `2` on retry exhaustion (1s / 4s / 16s backoff across four
214
- attempts). On exit 2, tell the user the review post failed and that
215
- the unresolved-thread gate will not see this audit pass; do not retry
216
- silently.
147
+ After the agent (and Haiku secondary) return and the merge is complete,
148
+ apply the `post-audit-findings` skill (`../post-audit-findings/SKILL.md`)
149
+ with `--skill findbugs`. That skill owns the findings-JSON mapping, the
150
+ anchored-only serialization (unanchored findings surface via Step 5's
151
+ user-facing output), the CLEAN/DIRTY decision, the self-PR reviewer
152
+ toggle, and the exit codes. On exit 0, surface the emitted review
153
+ `html_url` alongside the totals in Step 5. On exit 2, tell the user the
154
+ review post failed and that the unresolved-thread gate will not see this
155
+ audit pass; do not retry silently.
217
156
 
218
157
  ### Step 5: Surface findings, then clean up
219
158
 
@@ -285,7 +224,7 @@ Claude: [resolves PR #42 from current branch, fetches full diff, spawns code-qua
285
224
 
286
225
  <example>
287
226
  User: `/findbugs`
288
- Claude: `No PR or upstream diff found. Push the branch or open a PR first.`
227
+ Claude: `No PR or upstream diff. /findbugs needs a target.`
289
228
  </example>
290
229
 
291
230
  <example>
@@ -47,11 +47,9 @@ If the filtered set is empty, refuse per the refusal cases above.
47
47
 
48
48
  ### Step 2: Re-resolve PR scope
49
49
 
50
- Re-establish the same PR target `/findbugs` used:
50
+ Apply the `pr-scope-resolve` skill (`../pr-scope-resolve/SKILL.md`) with caller `fixbugs` to resolve the same PR target `/findbugs` used — the fixes stay scoped to the files the `/findbugs` findings from Step 1 name. When no target exists, respond with the sub-skill's canonical refusal line and stop:
51
51
 
52
- 1. `pull_request_read(method="get", pullNumber=N, owner=O, repo=R)` for the current branch (`N` comes from the parent skill's PR context, or fall back to `search_issues` MCP with the current branch name to recover the PR number).
53
- 2. Fall back to `git merge-base HEAD origin/<default>` then `git diff <merge-base>...HEAD`.
54
- 3. Neither → respond `No PR or upstream diff. Cannot scope fixes.` and stop.
52
+ `No PR or upstream diff. /fixbugs needs a target.`
55
53
 
56
54
  Capture: `<owner>/<repo>`, head branch, base branch, PR number, PR URL.
57
55
 
@@ -0,0 +1,20 @@
1
+ # log-audit
2
+
3
+ Reads this repository's own logs, finds recurring errors and timing regressions, and turns each real pattern into a tracked fix. Triggered by `/log-audit`, `audit the logs`, `what keeps failing`, or `what's getting slower`.
4
+
5
+ ## Purpose
6
+
7
+ The skill runs as a background agent on a recurring schedule. Each cycle it reads the hook block log and the diagnostic extractor pipeline, clusters recurring errors and timing regressions, opens a grouped draft fix pull request or a tracked optimization issue per finding, and mines the defects Copilot and Bugbot keep catching into skill-edit proposals. Cycle state lives under `~/.claude/runtime/log-audit/`, so a restart resumes the same run.
8
+
9
+ ## Key files
10
+
11
+ | File | Purpose |
12
+ |---|---|
13
+ | `SKILL.md` | Full instructions: the cycle steps, the three scripts and how to pipe them, the log sources in and out of scope, finding-filing rules, reviewer mining, cycle state, and cadence. |
14
+
15
+ ## Subdirectories
16
+
17
+ | Directory | Role |
18
+ |---|---|
19
+ | `reference/` | The agent charter — the fixed contract the skill answers to. |
20
+ | `scripts/` | The collect, cluster, and mine scripts and their constants package. |