claude-dev-env 2.0.0 → 2.0.2

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 (44) hide show
  1. package/agents/clean-coder.md +31 -1
  2. package/audit-rubrics/prompts/category-e-dead-code.md +2 -2
  3. package/bin/install.test.mjs +2 -2
  4. package/docs/CLAUDE.md +6 -3
  5. package/docs/CODE_RULES.md +5 -1
  6. package/docs/agent-spawn-protocol.md +39 -0
  7. package/docs/nas-ssh-invocation.md +23 -0
  8. package/docs/worker-completion-gate.md +33 -0
  9. package/hooks/blocking/code_rules_dead_module_constant.py +11 -5
  10. package/hooks/blocking/config/verified_commit_constants.py +8 -1
  11. package/hooks/blocking/test_code_rules_enforcer_dead_module_constant.py +58 -0
  12. package/hooks/blocking/test_code_rules_enforcer_dead_module_constant_alias.py +133 -0
  13. package/hooks/blocking/test_verification_verdict_store.py +12 -0
  14. package/hooks/blocking/test_verified_commit_docs_delta.py +176 -0
  15. package/hooks/blocking/test_verifier_verdict_minter.py +55 -158
  16. package/hooks/blocking/tests/test_pii_prevention_blocker.py +0 -1
  17. package/hooks/hooks_constants/dead_module_constant_constants.py +8 -0
  18. package/hooks/hooks_constants/pii_prevention_constants.py +1 -0
  19. package/package.json +1 -1
  20. package/rules/CLAUDE.md +2 -3
  21. package/rules/agent-spawn-protocol.md +5 -43
  22. package/rules/code-standards.md +1 -36
  23. package/rules/env-var-table-code-drift.md +2 -21
  24. package/rules/hook-prose-matches-detector.md +5 -16
  25. package/rules/nas-ssh-invocation.md +3 -15
  26. package/rules/no-historical-clutter.md +7 -49
  27. package/rules/no-inline-destructive-literals.md +3 -5
  28. package/rules/package-inventory-stale-entry.md +7 -32
  29. package/rules/re-stage-before-commit.md +6 -23
  30. package/rules/shell-invocation-policy.md +1 -1
  31. package/rules/vault-context.md +3 -3
  32. package/rules/workers-done-before-complete.md +2 -30
  33. package/scripts/claude_chain_runner.py +39 -3
  34. package/scripts/dev_env_scripts_constants/claude_chain_constants.py +3 -0
  35. package/scripts/test_claude_chain_runner.py +112 -0
  36. package/scripts/test_grok_headless_runner.py +0 -1
  37. package/skills/auditing-claude-config/SKILL.md +1 -1
  38. package/skills/everything-search/SKILL.md +7 -1
  39. package/skills/orchestrator/SKILL.md +166 -143
  40. package/skills/orchestrator-refresh/SKILL.md +12 -4
  41. package/system-prompts/CLAUDE.md +3 -3
  42. package/docs/agents-md-alignment-plan.md +0 -123
  43. package/docs/emotion-informed-prompt-design.md +0 -362
  44. package/rules/es-exe-file-search.md +0 -17
@@ -13,7 +13,13 @@ Search files instantly on Windows using the Everything command-line interface (e
13
13
 
14
14
  ## Hard limits
15
15
 
16
- Scope and fallback policy: `packages/claude-dev-env/rules/es-exe-file-search.md`.
16
+ Every search carries a scope: a project path or registry token, an `ext:` filter, a `dm:` date filter, a `size:` filter, or a name pattern. A bare whole-drive scan or a network-share sweep is out of bounds — narrow the search to what you need.
17
+
18
+ When `es.exe` fails or returns nothing, self-heal first: fall back to the `Glob` tool (name and path patterns) or `Grep` (file contents), and report the outage so the reader knows the index was unavailable. When self-healing also fails, ask the user through `AskUserQuestion` with a short analysis and next-step options.
19
+
20
+ ## Registry tokens
21
+
22
+ The `es_exe_path_rewriter` hook resolves scope tokens before the command runs. A `{project-name}` placeholder or a bare registry key from `~/.claude/project-paths.json` becomes its quoted absolute path in the command. The hook allows and rewrites — it never blocks — so a search scoped to a registered project names the project token and lets the hook fill in the path.
17
23
 
18
24
  ## Instructions
19
25
 
@@ -21,115 +21,118 @@ delegating to Sonnet-5 workers came out cheaper and faster
21
21
  than a solo frontier agent held to the same verification rigor, with
22
22
  84-98% of the team's input tokens billed at the worker rate.
23
23
 
24
- Claude Code has no `multiagent` coordinator field or Managed-Agents-style
25
- `create_agent`/`send_to_agent` primitives; this skill reaches the same
26
- shape with the tools Claude Code already has. Under this skill the session
27
- is the orchestrator. In Claude Code the user always talks to the session and never to a
28
- subagent, so the session is the user's sole interface: all user-facing
29
- communication flows through it. It spawns and resumes executor subagents
30
- `clean-coder` and the like and those executors do every bit of the
31
- execution: the code edits, the build runs, the test runs. The orchestrating
32
- session drives the plan and routes hard decisions to the shared advisor
33
- (Claude: warm `session-advisor`; a third-party host: Claude CLI advisor via the chain runner).
34
-
35
- ## Gotchas
36
-
37
- - **Double invocation duplicates the reminder loop.** A second `/orchestrator`
38
- in the same session schedules a second refresh loop. Check whether the loop
39
- is already running before you schedule one (see the invocation guard in
40
- Process step 1).
41
- - **The orchestrating session never executes.** The moment it edits a file or
42
- runs the tests itself, the pairing breaks and the executor's warm context is
43
- wasted. Hand every code edit and every build or test run to an executor; keep
44
- the orchestrating session's own tool use to orchestration and light
45
- verification reads. Hard decisions go to the shared advisor (Claude:
46
- `session-advisor` via SendMessage; a third-party host: Claude CLI advisor via the chain).
47
- - **Flat ad hoc spawns bypass routing.** Every execution task goes through a
48
- workflow-backed spawn or workflow resume so the required agent type, model,
49
- prompt packet, and sidecar metadata stay attached to the work.
50
- - **Wrong agent or model is an enforcement failure.** If a task category maps
51
- to `clean-coder` on `opus`, a `general-purpose` Sonnet spawn is not a cost
52
- optimization; it is the wrong executor for the contract.
53
- - **Resuming an unnamed background agent needs its agentId.** A background
54
- spawn returns an `agentId` (format `a...-...`); keep it so `SendMessage` can
55
- reach that agent later. A named agent is reachable by name.
56
- - **Only the orchestrating session owns the shared advisor's lifecycle.** An
57
- executor that finds the advisor unreachable (Claude warm agent, or Claude
58
- CLI bind on a third-party host) reports that upward; it never spawns a replacement itself.
24
+ Under this skill the session is the orchestrator. It spawns and resumes
25
+ executor subagents — `clean-coder` and the like and those executors do
26
+ every bit of the execution: the code edits, the build runs, the test
27
+ runs. The orchestrating session drives the plan, keeps the run artifacts
28
+ and the ledger current, and routes hard decisions to the shared advisor.
29
+ The moment it edits a file or runs a test itself, the pairing breaks —
30
+ its own tool use stays orchestration, run-artifact writes, and light
31
+ verification reads.
32
+
33
+ ## Design rule thin prompts, thick artifacts, thin skill
34
+
35
+ Three faces of one rule (reading pinned by the audit spec on
36
+ jl-cmd/claude-dev-env#174: thin means high-signal, not short; thick
37
+ context lives outside the window, reachable by pointers):
38
+
39
+ - **Thin prompts.** A spawn prompt is a dispatch ticket: one task,
40
+ pointers to the artifacts that hold the context, one done-check, a thin
41
+ return contract. The prompt can be thin because the context is thick
42
+ elsewhere.
43
+ - **Thick artifacts.** Durable run state lives in files the run
44
+ charter, one assignment file per task, result records written once,
45
+ read by every agent that needs them, and still there when any one
46
+ agent's context is gone.
47
+ - **Thin skill.** This file holds only what changes decisions at
48
+ orchestration time. Standing policy lives where it loads once:
49
+ [`_shared/advisor/advisor-protocol.md`](../../_shared/advisor/advisor-protocol.md)
50
+ for everything advisor, the agent definitions for executor discipline.
59
51
 
60
52
  ## Process
61
53
 
62
- 1. **Check whether the refresh loop is already running this
63
- session.** If it is, do not schedule a second loop. Reuse any live
64
- shared advisor bind (Claude warm `session-advisor`, or a third-party host's
65
- Claude CLI bind run step 3 only when none exists yet), then skip straight to step 4.
66
-
67
- 2. **Register the discipline reminder.** By default, schedule it with
68
- `ScheduleWakeup` at `delaySeconds: 1200`, prompt `/orchestrator-refresh`,
69
- where each refresh re-schedules the next one — a 1200-second wakeup costs
70
- one prompt-cache miss per firing and nothing more (see Gotchas). The loop
71
- mechanism (`/loop 20m /orchestrator-refresh`) is the escape hatch when
72
- `ScheduleWakeup` is not available. Either way the reminder is the
73
- enforcement surface: each firing re-asserts the discipline while the run is
74
- in flight.
75
-
76
- 3. **Bind the shared advisor before any executor.** Detect the host profile
77
- first (see Host profiles in
78
- [`_shared/advisor/advisor-protocol.md`](../../_shared/advisor/advisor-protocol.md)).
79
- On a **Claude host**, follow the Warm-up procedure in that doc (Agent spawn
80
- of `session-advisor`). Compute the model floor as the max of the
81
- orchestrating session's own tier and the highest model in the Workflow Agent
82
- Routing table below (for example, max(Sonnet, Opus) = Opus when those are
83
- the tiers in play). That floor is a lower bound only — the Claude spawn walk
84
- tries top-down from Fable down to that floor per
85
- [`_shared/advisor/advisor-protocol.md`](../../_shared/advisor/advisor-protocol.md);
86
- it is not a "spawn only at the floor" rule. Paste the **Claude host**
87
- Advisor block from that doc, with the resolved agent name filled in, into
88
- every executor's spawn prompt. On a **third-party host**, skip the Agent spawn —
89
- bind a max-tier Claude advisor through the protocol's CLI Claude-chain path
90
- (Fable high, then Opus max; `claude_chain_runner.py` for account usage
91
- failover). Paste the **Third-party host** Advisor block from that doc into every
92
- executor's spawn prompt — never the Claude SendMessage block. Every row in
93
- the routing table is a consumer of the shared advisor, not just this
94
- session. The orchestrating session owns the shared advisor's lifecycle end
95
- to end (Agent spawn or CLI bind, drift handling per the shared doc,
96
- shutdown at task end); executors only ever SendMessage the warm agent
97
- (Claude) or report to this session so it can consult the CLI advisor
98
- (a third-party host). When the CLI chain cannot bind, fail closed and report
99
- to the user — do not answer the four signals as this third-party session.
100
-
101
- 4. **Orchestrate the task.** Hold the plan and the user conversation. Execute
102
- workflow-backed spawns or resumes using the routing table below, and keep
103
- driving while they work. Every executor spawn includes the host-matched
104
- Advisor block from step 3. Your own tool use stays orchestration and light
105
- verification reads. Keep your task list updated religiously.
106
-
107
- 5. **Consult the shared advisor at hard decisions.** Every consumer — each
108
- executor and this session — consults when one of these holds (same list as
109
- the protocol and Advisor block):
110
- - A nontrivial plan is about to be locked in and acted on.
111
- - The consumer believes its assigned work is finished.
112
- - A commit, push, or other hard-to-reverse action is about to run.
113
- - The same failure has come back more than once, or progress has stalled.
114
- - The chosen approach is being reconsidered.
115
-
116
- **Claude host:** consult the shared `session-advisor` via `SendMessage`.
117
- **Third-party host:** executors report to this orchestrating session; this session
118
- consults the bound Claude CLI advisor (`claude_chain_runner.py` +
119
- `--resume`) and relays the four-signal reply (no Agent-tool
120
- `session-advisor`, no SendMessage to one). Every consult gets back one of
121
- four signals (ENDORSE, CORRECTION, PLAN, or STOP). When the CLI advisor is
122
- unreachable, fail closed and surface that to the user — do not invent a
123
- signal as this session. See `agents/session-advisor.md` for what each
124
- signal means and
54
+ 1. **Invocation guard.** One `/orchestrator` per session. When the
55
+ refresh loop is already running, do not schedule a second one; reuse
56
+ the live advisor bind and go to step 4.
57
+ 2. **Register the discipline reminder.** Schedule it with
58
+ `ScheduleWakeup` at `delaySeconds: 1800`, prompt
59
+ `/orchestrator-refresh`, where each refresh re-schedules the next one.
60
+ 3. **Bind the shared advisor before any executor.** Follow
125
61
  [`_shared/advisor/advisor-protocol.md`](../../_shared/advisor/advisor-protocol.md)
126
- for the consult format.
62
+ end to end: detect the host profile, compute the floor from the
63
+ orchestrator consumer set — this session plus every tier in the
64
+ routing table (its Model floor section) — walk the ladder top-down,
65
+ and fail closed when nothing binds. This session owns the advisor's
66
+ whole lifecycle (its Lifecycle ownership section); executors only ever
67
+ message the warm agent or report here, and an executor that finds the
68
+ advisor unreachable reports that upward — it never spawns a
69
+ replacement itself.
70
+ 4. **Write the run artifacts** (next section) before the first spawn.
71
+ 5. **Orchestrate.** Hold the plan and the user conversation. Spawn each
72
+ task with a ticket (Spawn ticket section), keep driving while
73
+ executors work, and keep the ledger reconciled (Task ledger
74
+ discipline).
75
+ 6. **Consult the advisor at hard decisions.** The trigger list, consult
76
+ format, and reply handling live in the protocol's "Consulting the
77
+ warm agent" section; both this session and every executor are
78
+ consumers. Replies open with one of ENDORSE, CORRECTION, PLAN, or
79
+ STOP — `agents/session-advisor.md` defines each signal.
80
+
81
+ ## Run state lives in artifacts
82
+
83
+ Write these before the first spawn, default home `docs/plans/<run-slug>/`
84
+ in the repo the run works on (working files, not committed):
85
+
86
+ - **Run charter** — the goal, the repo root, the advisor name and host
87
+ profile. One file every ticket points at.
88
+ - **One assignment file per task** — scope, file list, constraints, the
89
+ acceptance check, baseline command output. The thick context goes
90
+ here. `/prompt-generator` authors the assignment once at plan time,
91
+ and every ticket for that task reuses it — that reuse is what
92
+ satisfies the agent-spawn-protocol context check at each spawn.
93
+ - **Results merge into run state.** An executor's product is its
94
+ artifact — the branch diff, the test output, the report its agent type
95
+ may write — and its reply is thin: status, artifact paths, blockers.
96
+ The orchestrating session records each result into the run's result
97
+ files as it reconciles the ledger.
98
+
99
+ Correctness never rides on any agent's private context: when an executor
100
+ dies or hangs, point a fresh spawn at the same assignment file plus its
101
+ partial results and the run continues.
102
+
103
+ ## Spawn ticket — the whole prompt
104
+
105
+ Every executor spawn prompt is this shape:
106
+
107
+ ```
108
+ Task: <one sentence, one deliverable>
109
+ Read first: <assignment file path>; <run charter path>
110
+ Touch only: <files or globs>
111
+ Done when: <one mechanical check — a command, a test, a diff scope>
112
+ Return: status, artifact paths, blockers — nothing else.
113
+
114
+ <host-matched Advisor block from advisor-protocol.md, advisor name filled in>
115
+ ```
116
+
117
+ - **Size the task by its done-check.** The right task is the largest
118
+ unit that fits one sentence plus pointers, has one mechanical
119
+ done-check, and needs no mid-run clarification. A task that does not
120
+ fit gets split in the plan — never padded into a longer prompt.
121
+ Explore fan-outs run tiny; a `clean-coder` assignment can carry a
122
+ whole scoped feature.
123
+ - **Do not restate what the agent definition carries.** The routing
124
+ table picks the definition, and `clean-coder` already holds the code
125
+ discipline. The ticket adds the task, the pointers, and the Advisor
126
+ block only.
127
+ - **The Advisor block is the one pasted paragraph.** It is host-matched
128
+ at bind time and written to be self-contained (the protocol's Advisor
129
+ block section) — paste it; do not point at it.
127
130
 
128
131
  ## Workflow Agent Routing
129
132
 
130
- Every delegated task runs through a workflow-backed agent invocation. Do not
131
- spawn a flat subagent directly when a workflow invocation or workflow resume is
132
- available.
133
+ Every delegated task runs through a workflow-backed agent invocation. Do
134
+ not spawn a flat subagent directly when a workflow invocation or
135
+ workflow resume is available.
133
136
 
134
137
  | Work | Agent type | Model |
135
138
  |---|---|---|
@@ -141,58 +144,78 @@ available.
141
144
 
142
145
  Routing rules:
143
146
 
144
- - Use a workflow invocation or resume for each row above. The workflow prompt
145
- must name the selected agent type, model, work category, task scope, and
146
- expected output.
147
- - Resume a warm workflow agent before creating a new workflow run when the warm
148
- agent holds the relevant context.
149
- - `clean-coder` owns code edits. `code-verifier` owns verification. The same
150
- workflow agent never grades work it wrote.
151
- - PR-description workflows include the actual changed-file list in the prompt
152
- and verify the final body against that file list before posting or returning
153
- it.
154
- - Exploration workflows return file paths, line numbers, and direct evidence;
155
- they do not write code or mutate repo state.
147
+ - Each row spawns workflow-backed with a ticket; the routing row and the
148
+ ticket together carry the agent type, model, task, and return
149
+ contract. A task category that maps to `clean-coder` on `opus` is not
150
+ served by a `general-purpose` Sonnet spawn the table is the
151
+ contract, not a cost suggestion.
152
+ - Resume a warm workflow agent before creating a new workflow run when
153
+ the warm agent holds the relevant context.
154
+ - `clean-coder` owns code edits. `code-verifier` owns verification. The
155
+ same workflow agent never grades work it wrote.
156
+ - PR-description workflows include the actual changed-file list in the
157
+ prompt and verify the final body against that file list before posting
158
+ or returning it.
159
+ - Exploration workflows return file paths, line numbers, and direct
160
+ evidence; they do not write code or mutate repo state.
156
161
  - Fan-out worker fleets use the **grok-spawn** skill when that skill is
157
- installed and grok is usable (`grok_worker_preflight.py` soft gate). The
158
- Claude Code Agent tool remains the Claude-host alternative for in-process
159
- workers.
160
-
161
- ## Agent reuse (non-negotiable)
162
-
163
- - **Resume before you spawn, always.** A warm agent carries its context and
164
- cached tokens; a fresh spawn starts cold and pays to rebuild both.
165
- Resume the existing workflow agent by name or `agentId` when it holds
166
- relevant context. Prefer that path every time an existing workflow agent
167
- matches the routing table.
168
- - **Spawn a fresh agent only when** no existing agent holds relevant context,
169
- or a genuine task switch needs a clean context.
170
- - **Name the agent to resume.** When a PLAN from the shared advisor fits a warm
171
- agent, name which agent to resume and where.
162
+ installed and grok is usable (`grok_worker_preflight.py` soft gate).
163
+ The Claude Code Agent tool remains the Claude-host alternative for
164
+ in-process workers.
165
+
166
+ ## Agent reuse
167
+
168
+ - **Resume before you spawn.** A warm agent (active within the past 59
169
+ minutes) carries its context and cached tokens; a fresh spawn pays to
170
+ rebuild both. Resume by name, or by `agentId` for an unnamed
171
+ background spawn keep the `agentId` (format `a...-...`) from the
172
+ spawn result so `SendMessage` can reach that agent later.
173
+ - **Spawn a fresh agent only when** no existing agent holds relevant
174
+ context, or a genuine task switch needs a clean context.
175
+ - **Reuse is a cost rule, not a correctness dependency.** The run
176
+ artifacts keep every executor replaceable (Run state section).
177
+ - **Name the agent to resume.** When a PLAN from the shared advisor fits
178
+ a warm agent, name which agent to resume and where.
179
+
180
+ ## Task ledger discipline
181
+
182
+ The task list is the run's ledger, and it must be reconcilable against
183
+ the live agents at any moment. Four invariants hold at all times:
184
+
185
+ 1. **No untracked work.** Every unit of delegated work has a task BEFORE
186
+ its executor spawns — TaskCreate first, then Agent.
187
+ 2. **Ownership is live.** At spawn, set the task `in_progress` with
188
+ `owner` = the executor's agent name. One task, one owner.
189
+ 3. **Completion follows evidence.** A task turns `completed` only when
190
+ the executor's result is back AND merged into run state — the run's
191
+ result files and the task record — never on dispatch, never on a
192
+ self-report alone (see `workers-done-before-complete`).
193
+ 4. **Dependencies mirror the plan.** Phase order is encoded as
194
+ `blockedBy` links, updated the moment the plan changes.
195
+
196
+ Reconcile on every state change (spawn, completion notification, plan
197
+ change) and on every `/orchestrator-refresh` firing.
172
198
 
173
199
  ## Constraints
174
200
 
175
201
  - One `/orchestrator` per session; the invocation guard blocks a second
176
202
  reminder loop.
177
- - The orchestrating session orchestrates and routes hard decisions to the
178
- shared advisor (host-matched path in step 5), but never edits code or runs a
179
- build or test itself executors do that.
180
- - Delegated execution uses workflow-backed agent invocations and follows the
181
- Workflow Agent Routing table exactly.
182
- - One shared advisor per orchestrated session, owned by the orchestrating
183
- session (see
184
- [`_shared/advisor/advisor-protocol.md`](../../_shared/advisor/advisor-protocol.md))
185
- — on Claude, executors consult a warm `session-advisor` via SendMessage; on
186
- a third-party host, executors report here and this session relays the Claude CLI advisor.
187
- Executors never spawn or respawn the advisor.
188
- - Reuse a warm agent over a cold spawn whenever one holds relevant context.
203
+ - The orchestrating session never edits code or runs a build or test
204
+ itself executors do that. Its own tool use stays orchestration,
205
+ run-artifact writes, and light verification reads.
206
+ - Every delegated task carries a ledger entry, an assignment artifact,
207
+ and a workflow-backed spawn with a ticket, routed by the table.
208
+ - One shared advisor per orchestrated session, owned by this session per
209
+ the protocol; executors never spawn, respawn, or shut it down.
189
210
 
190
211
  ## File Index
191
212
 
192
213
  | File | Purpose |
193
214
  |---|---|
194
- | `SKILL.md` | Orchestrator strategy, workflow routing contract, shared-advisor consult protocol, reuse rules, and constraints. |
215
+ | `SKILL.md` | Orchestrator strategy: design rule, process, run artifacts, spawn ticket, routing table, reuse rules, ledger invariants, constraints. |
195
216
 
196
217
  ## Folder Map
197
218
 
198
- - `SKILL.md` — complete orchestrator workflow instructions.
219
+ - `SKILL.md` — complete orchestrator workflow instructions. Advisor
220
+ policy lives in
221
+ [`_shared/advisor/advisor-protocol.md`](../../_shared/advisor/advisor-protocol.md).
@@ -15,10 +15,18 @@ Detect the host profile first (see Host profiles in
15
15
  Re-assert the discipline for that host only — do not invent an Agent-tool
16
16
  Claude `session-advisor` spawn on a third-party host.
17
17
 
18
- 1. **You are the orchestrator.** Orchestrate and hold the user conversation;
18
+ 1. **Reconcile the task ledger first.** Call `TaskList` before anything else
19
+ this firing. The ledger is stale when any of these holds: a running or
20
+ finished executor has no `in_progress` task naming it as owner; a finished
21
+ executor's task is still open (or was closed without its result merged);
22
+ the next phase you will dispatch has no pending task; a `blockedBy` link
23
+ contradicts the actual run order. Fix every mismatch with TaskCreate /
24
+ TaskUpdate in this same firing — never defer reconciliation to "when the
25
+ agent reports".
26
+ 2. **You are the orchestrator.** Orchestrate and hold the user conversation;
19
27
  spawn executor subagents to do all the work — every code edit and build or
20
28
  test run.
21
- 2. **Hard decisions go to the shared advisor.**
29
+ 3. **Hard decisions go to the shared advisor.**
22
30
  - **Claude host:** executors consult the warm `session-advisor` via
23
31
  `SendMessage` and receive one of four signals — ENDORSE, CORRECTION, PLAN,
24
32
  or STOP. The orchestrating session routes its own hard decisions the same
@@ -30,11 +38,11 @@ Claude `session-advisor` spawn on a third-party host.
30
38
  session; consult the Claude CLI advisor and relay ENDORSE / CORRECTION /
31
39
  PLAN / STOP. When the CLI bind is unreachable, fail closed and report to
32
40
  the user — do not answer the four signals as this third-party session.
33
- 3. **Resume before you spawn.** `SendMessage` an existing *executor* agent by
41
+ 4. **Resume before you spawn.** `SendMessage` an existing *executor* agent by
34
42
  name or `agentId` to reuse its warm context; prefer that over a cold spawn.
35
43
  (On a third-party host this is executor reuse only — advisor re-bind stays on the CLI
36
44
  chain path in the shared protocol.)
37
- 4. **Fresh spawn only for a genuine task switch.** No tool compacts or clears a
45
+ 5. **Fresh spawn only for a genuine task switch.** No tool compacts or clears a
38
46
  subagent's context, so a clean context comes from a fresh spawn — never tell
39
47
  an agent to compact.
40
48
  5. **Re-schedule the next refresh** (about 1200 seconds out) when the loop
@@ -1,16 +1,16 @@
1
1
  # system-prompts
2
2
 
3
- System prompt files installed into `~/.claude/system-prompts/` by `bin/install.mjs`. Claude Code loads these as the base persona and behavioral protocol for a session.
3
+ System-prompt reference files installed into `~/.claude/system-prompts/` by `bin/install.mjs`. Rules and skills pull a file (or one of its sections) into context on demand by citing its installed path.
4
4
 
5
5
  ## Files
6
6
 
7
7
  | File | Purpose |
8
8
  |---|---|
9
- | `software-engineer.xml` | Primary system prompt: defines the software engineering role, task-scope rules, output style, and the BDD `<behavior_protocol>` that rules in `rules/bdd.md` reference |
9
+ | `software-engineer.xml` | Software-engineering reference: defines the engineering role, task-scope rules, output style, and the BDD `<behavior_protocol>` that `rules/bdd.md` cites on demand |
10
10
 
11
11
  ## Format
12
12
 
13
- Files use XML with named sections (`<role>`, `<task_scope>`, `<output_style>`, `<behavior_protocol>`, etc.). Claude Code injects the full file into the system prompt slot at session start.
13
+ Files use XML with named sections (`<role>`, `<task_scope>`, `<output_style>`, `<behavior_protocol>`, etc.). A rule or skill cites a file, or one of its sections, to pull it into context when the task needs it.
14
14
 
15
15
  ## Adding a prompt
16
16
 
@@ -1,123 +0,0 @@
1
- # AGENTS.md Alignment Plan
2
-
3
- This document captures the alignment between `AGENTS.md` (the canonical code-rules instruction set consumed by Cursor BugBot, Copilot, Claude, and other code-review/authoring agents) and the local enforcement layer (`code_rules_enforcer.py` and companion blocking hooks).
4
-
5
- ## Goal
6
-
7
- Two-way alignment:
8
-
9
- 1. Every rule the hooks enforce at write time is documented in `AGENTS.md` so review tools without hook access (Cursor BugBot, Copilot, external reviewers) flag the same violations from the diff alone.
10
- 2. Every rule `AGENTS.md` requires is either (a) enforced by a hook at write time, (b) explicitly listed as bugbot-only judgment because it requires diff-semantic reasoning, or (c) a candidate for a future hook.
11
-
12
- This file is the single source of truth for the alignment status.
13
-
14
- ## Methodology
15
-
16
- - Read every `check_*` function in `packages/claude-dev-env/hooks/blocking/code_rules_enforcer.py` (28 functions, lines 108–2236) plus the `validate_content` dispatch (line 2239).
17
- - Read every Write/Edit hook registered in `packages/claude-dev-env/hooks/hooks.json`.
18
- - Read `packages/claude-dev-env/hooks/blocking/sensitive_file_protector.py` for file-level blocks.
19
- - Read every rule file in `~/.claude/rules/*.md` and the canonical CODE_RULES.md files in this repo.
20
- - Walked `AGENTS.md` bullet by bullet against the above.
21
-
22
- ## What this PR changes
23
-
24
- ### Added to `AGENTS.md`
25
-
26
- - Intro pointer to the new **Hook enforcement** appendix.
27
- - **Magic values & configuration**: explicit config-domain table (`config/timing.py` for timing values, `config/constants.py` for ports/URLs/thresholds, `config/selectors.py` for DOM locators) and a flag rule for new constants whose value or semantic name already exists in `config/`.
28
- - **Design**: tightened the YAGNI bullet to specify "every existing call site passes the same value → required (or inline)".
29
- - **Tests**: five new bullets — delete-no-value tests, fail-not-skip rule, pragmatic-infra five-point checklist, public-API-only assertions, React query priority and `userEvent`/API-boundary mocking.
30
- - **Platform and tooling**: the unsafe-`rmtree`-on-Windows pattern is blocked (with the canonical `force_rmtree` helper inlined), Node `mkdirSync` requires `{ recursive: true }` on possibly-existing paths, and all `gh` commands with markdown body content must use `--body-file`.
31
- - **Repo hygiene**: never-commit list (`docs/plans/*.md`, `*.plan.md`, `SESSION_STATE.md`, `*.audit.json`, `*.audit.md`, image extensions) and a scratch-file pattern enumeration.
32
- - **Hook enforcement** appendix mapping each hook-enforced rule to its enforcing hook file.
33
-
34
- ### Deliberately excluded
35
-
36
- PR draft lifecycle bullets and one-commit-per-review-stage rules were proposed and then removed. Cursor BugBot reviews diffs and PR descriptions; it cannot toggle PR ready/draft state or enforce commit-stage discipline. Those rules belong in human-facing workflow documentation, not in `AGENTS.md`.
37
-
38
- ## Open items
39
-
40
- The following are documented gaps. None are addressed in this PR.
41
-
42
- ### Category A — enforced locally, not yet in AGENTS.md
43
-
44
- Each closure is concrete and additive — recommended for a follow-up PR titled `docs(agents): close remaining hook-vs-rule gaps`.
45
-
46
- | ID | Hook check (file:line) | Gap |
47
- |---|---|---|
48
- | A1 | `code_rules_enforcer.py:404` `check_windows_api_none` | `win32gui.X(.., None)` — use `0` for unused int params |
49
- | A2 | `code_rules_enforcer.py:603` `check_e2e_test_naming` | `online`/`offline` in `test()`/`it()`/`describe()` titles in `*.spec.*` files |
50
- | A3 | `code_rules_enforcer.py:713` `check_type_escape_hatches` | `# type: ignore` requires trailing `# <reason>` of ≥5 chars |
51
- | A4 | `code_rules_enforcer.py:2126` `check_inline_literal_collections` | inline `[...]` / `{...}` of constants in production function bodies |
52
- | A5 | `code_rules_enforcer.py:2085` `check_string_literal_magic` | bare string literals (not just f-string fragments) matching path / URL / regex shape |
53
- | A6 | `code_rules_enforcer.py:843` `check_constants_outside_config_advisory` | function-local `UPPER_SNAKE = ...` advisory |
54
- | A7 | `code_rules_enforcer.py:2003` `check_library_print` | `print()` outside CLI markers (`/scripts/`, `_cli.py`, `/cli.py`) |
55
- | A8 | `sensitive_file_protector.py` | edits to `package-lock.json`, `yarn.lock`, `Pipfile.lock`, `poetry.lock`, `pnpm-lock.yaml`, `composer.lock` |
56
- | A9 | `sensitive_file_protector.py` | edits to `.env*`, `*.pem`, `*.key`, `*.p12`, `*.pfx`, `credentials.json`, `secrets.json`, `id_rsa`, `id_ed25519` |
57
- | A10 | `code_rules_enforcer.py:1175` `check_existence_check_tests` | `x is not None` as sole-assertion form (currently `AGENTS.md` lists only `callable` and `hasattr`) |
58
- | A11 | `code_rules_enforcer.py:1839` `check_unused_optional_parameters` | the exact trigger: optional param where every call site passes the same value |
59
- | A12 | `mypy_validator.py` | mypy-clean is required at write time |
60
- | A13 | `auto_formatter.py` | auto-formatter runs on Write/Edit |
61
- | A14 | `code_rules_enforcer.py:1072` `check_skip_decorators_in_tests` | the broader rule is "any decorator named `skip*`", not just `@skip_if_missing_dependency` |
62
- | A15 | `code_rules_enforcer.py:1786` `check_duplicated_format_patterns` | identical format-string patterns at multiple call sites |
63
-
64
- ### Category B — required by AGENTS.md, no local hook (bugbot-only judgment)
65
-
66
- These are reviewable from a diff but not amenable to AST/regex enforcement; they remain bugbot's judgment.
67
-
68
- - **Naming**: `ctx`/`cfg`/`msg`/`btn`/`idx`/`cnt`/`elem`/`val`/`tmp` abbreviation expansion (B1); `X_by_Y` map naming (B2); preposition parameter prefixes (B3); banned function-name prefixes `handle_`/`process_`/`manage_`/`do_` (B4); component naming for what they ARE (B5).
69
- - **Structure**: function length ≤ 30 lines (B6); two blank lines between Python top-level functions (B7).
70
- - **Types**: concrete type captures actual shape, even when bare `object` would compile (B8).
71
- - **Architecture**: functions vs classes vs ABCs (B9); SOLID S/O/L/I/D (B10); construction logic in models/services (B11); self-contained components (B12); `TODO:` on scaffolding (B14).
72
- - **Data flow**: reuse data already in scope (B13); reuse-before-create semantic duplication (B23).
73
- - **Tests**: pragmatic-infra five-point checklist (B15); test through public API (B16); React query priority and mocking strategy (B17).
74
- - **Platform**: Node `mkdirSync({recursive: true})` (B18) — Python `shutil.rmtree` is hooked, Node equivalent is not.
75
- - **Hygiene**: planning/image file globs (B19); scratch-file patterns (B20); PR-description references for kept files (B21).
76
- - **Config**: domain placement within `config/` (B22); 0-reference dead-code constants (B24).
77
-
78
- ### Category C — JS/TS asymmetry
79
-
80
- `code_rules_enforcer.py` `validate_content` (line 2239) dispatches on file extension. For `.js`/`.ts`/`.tsx`/`.jsx`, only three checks run:
81
-
82
- - `check_comment_changes` — added inline / removed existing comments.
83
- - `check_e2e_test_naming` — online/offline in spec test titles.
84
- - `advise_file_line_count` — advisory.
85
-
86
- Every other rule (magic values, constants location, banned identifiers, type annotations, boolean naming, loop variable naming, parameter annotations, return annotations, library print, optional-param-unused, `Any` detection) runs on Python files only. For JS/TS code, `AGENTS.md` is the only enforcement layer — bugbot review is the gate.
87
-
88
- Whether each Python check has a JS/TS equivalent that ports cleanly: not investigated. Out of scope for this PR.
89
-
90
- ## Recommended hook additions
91
-
92
- Not part of this PR — proposed as separate small PRs (one new check + tests per PR, following the existing `test_code_rules_enforcer_*.py` pattern). Each is AST/regex-tractable.
93
-
94
- | Item | Suggested check | Note |
95
- |---|---|---|
96
- | B1 | extend `BANNED_IDENTIFIERS` | add `ctx`, `cfg`, `msg`, `btn`, `idx`, `cnt`, `elem`, `val`, `tmp` |
97
- | B2 | dict-target naming rule | flag dict assignments whose target name lacks `_by_` |
98
- | B3 | parameter-name prefix rule | flag direction parameters lacking `from_`/`to_`/`into_` |
99
- | B4 | banned function-name prefixes | flag `def handle_*`, `def process_*`, `def manage_*`, `def do_*` |
100
- | B6 | function-length advisory | per-function line count, advisory above 30 |
101
- | B19 | extend `sensitive_file_protector.py` | block edits to `*.plan.md`, `SESSION_STATE.md`, `docs/plans/*.md`, `*.audit.{json,md}`, image extensions |
102
- | B20 | scratch-file name patterns | block edits to `scratch_*.py`, `debug_*.py`, `try_*.py`, `repro_*.py` |
103
- | B22 | config-domain placement | flag a constant added to `config/constants.py` whose name suggests `timing.py` or `selectors.py` |
104
- | B24 | 0-reference dead-code constants | extend `check_file_global_constants_use_count` to also flag 0 callers |
105
-
106
- ## Files in this PR
107
-
108
- - `AGENTS.md` (modified) — adds the rules and sections listed above.
109
- - `packages/claude-dev-env/docs/agents-md-alignment-plan.md` (new) — this document.
110
-
111
- ## Verification
112
-
113
- - Read updated `AGENTS.md` end-to-end and confirm each new bullet lives under the correct section heading.
114
- - Confirm no rule mentioned in the **Hook enforcement** appendix is missing its source check in `code_rules_enforcer.py` or sibling hook file.
115
- - Confirm the canonical `force_rmtree` helper code block in **Platform and tooling** describes the rule without containing the exact match-string the `windows_rmtree_blocker.py` hook scans for. Otherwise the hook will block any future edit to the file.
116
- - No code changes — the `AGENTS.md` and plan doc are documentation only.
117
-
118
- ## Out of scope
119
-
120
- - Closing the Category A gaps in `AGENTS.md` (tracked above; recommended follow-up PR).
121
- - Implementing any of the Category B hook additions (each is its own small PR).
122
- - Investigating JS/TS hook coverage parity (Category C).
123
- - Changes to `code_rules_enforcer.py` or any other hook source file.