Skip to content

Commit 5e464d9

Browse files
1 parent acf4541 commit 5e464d9

16 files changed

Lines changed: 809 additions & 162 deletions

.claude/commands/implement-extensions-batch.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,38 @@ stub-blocker test pattern (see template) when an in-scope test would otherwise
5151
need to traverse a still-stubbed upstream method that is NOT part of the current
5252
batch.
5353

54+
## Pre-flight: detect orchestrator plan mode
55+
56+
If the orchestrator session is itself in **plan mode** at the moment
57+
`/implement-extensions-batch` runs, spawned sub-agents (researchers, implementers,
58+
testers, reviewers) inherit that state. The Agent tool's `mode: "acceptEdits"`
59+
parameter does NOT override the inherited plan-mode state on the current Claude
60+
Code build — sub-agents will respect the `<system-reminder>` that declares plan
61+
mode and refuse to apply any edits, even though their prompts tell them to.
62+
63+
Symptom: every sub-agent reports "ready to execute on exit from plan mode" and
64+
writes its work to its own per-agent plan file at
65+
`C:\Users\<user>\.claude\plans\<plan-name>-agent-<id>.md` instead of to the
66+
target file.
67+
68+
Before spawning any sub-agent, check whether plan mode is active in the
69+
orchestrator session. If it is:
70+
71+
1. **Stop** and surface the situation to the user with `AskUserQuestion`. Two
72+
options:
73+
- **Exit plan mode first** (user toggles their harness off plan mode, then
74+
re-invokes the command). Cleanest.
75+
- **Proceed in degraded mode**: spawn researchers as normal (they only need
76+
to write to `.team-notes/`, which the orchestrator can copy into place
77+
from their per-agent plan files if blocked). For Phase IT (implementers +
78+
testers) and Phase RV (reviewers), the orchestrator applies the
79+
production / test edits itself, reading each implementer's plan file to
80+
extract the verbatim code. Reviewers can still run read-only.
81+
82+
2. If the user picks degraded mode, set an internal `PLAN_MODE_DEGRADED=true`
83+
flag for the run and follow the per-phase divergences in the **Notes for
84+
the orchestrator** block below.
85+
5486
## Workflow
5587

5688
### 1. Parse `$ARGUMENTS` and validate the batch
@@ -310,6 +342,8 @@ Print to the user:
310342
| Sibling test failure in regression sweep | Step 11 | Dispatch a regression-sweep tester per touched fixture; in scope. |
311343
| Reviewer NEEDS FIX | Step 12 | Re-dispatch implementer or tester for that file only; other files' results still reported. |
312344
| One file's implementation fails after branch + assignment | Any step ≥ 6 | Keep the branch; surface in final summary; user decides whether to retry via `/implement-extensions` for that single file or revert. |
345+
| Sub-agent inherits orchestrator plan mode and refuses to edit | Phases R / IT / RV | Surface to user via `AskUserQuestion`. Either exit plan mode and retry, or proceed in degraded mode (orchestrator copies researcher specs from agent plan files into `.team-notes/`, applies implementer + tester code from agent plan files, runs reviewers as read-only). |
346+
| Agent's `mode: "acceptEdits"` parameter does not override inherited plan mode | Phases IT / RV | Known limitation of this Claude Code build. The orchestrator must apply the edits itself in degraded mode (see "Pre-flight: detect orchestrator plan mode"). |
313347

314348
## Parallelism caps (orchestrator self-enforced)
315349

@@ -339,3 +373,25 @@ Print to the user:
339373
- If the user supplies a single file, route them to `/implement-extensions`
340374
with the same filename rather than creating a degenerate 1-file "batch"
341375
branch.
376+
- **Plan-mode degraded mode** (`PLAN_MODE_DEGRADED=true`):
377+
- **Phase R**: researchers will write to per-agent plan files instead of
378+
`.team-notes/`. After each returns, copy its plan file from
379+
`C:\Users\<user>\.claude\plans\<plan-name>-agent-<id>.md` into
380+
`.team-notes/<foo>-extensions-spec.md` and verify content matches the
381+
schema the template expects.
382+
- **Phase IT**: implementers + testers will write to per-agent plan files,
383+
NOT to the production / test fixtures. The orchestrator reads each
384+
agent's plan file, extracts the verbatim code, and applies the edits
385+
itself via `Edit` / `Write`. Build + targeted tests still run in
386+
Phase V. Do NOT mark Phase IT complete on the sub-agent's "ready to
387+
execute" message alone — only after the orchestrator has applied each
388+
file's diffs and the build is green.
389+
- **Phase RV**: reviewers operate read-only, so plan mode does not block
390+
them. No degradation needed.
391+
- **Sanity check**: in degraded mode, the orchestrator does roughly 2× the
392+
work it would in normal mode. Budget for it — do not silently fall
393+
behind on Phase V verification just because Phase IT cost more turns.
394+
- The Agent tool's `mode` parameter cannot reliably escape inherited plan mode
395+
on this Claude Code build. The orchestrator MUST detect plan mode at
396+
pre-flight and pick the degraded-mode branch deliberately rather than
397+
assuming `mode: "acceptEdits"` will work.

.claude/commands/implement-extensions.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,39 @@ This is the user-memory `feedback_scope_discipline.md` rule. Even when an adjace
4545
stub blocks dependent test coverage, surface the blocker; do not silently expand
4646
scope. Use the stub-blocker test pattern (see template).
4747

48+
## Pre-flight: detect orchestrator plan mode
49+
50+
If the orchestrator session is itself in **plan mode** at the moment
51+
`/implement-extensions` runs, spawned sub-agents (researcher, implementer, tester,
52+
reviewer) inherit that state. The Agent tool's `mode: "acceptEdits"` parameter
53+
does NOT override the inherited plan-mode state on the current Claude Code build
54+
— sub-agents will respect the `<system-reminder>` that declares plan mode and
55+
refuse to apply any edits, even though their prompts tell them to.
56+
57+
Symptom: every sub-agent reports "ready to execute on exit from plan mode" and
58+
writes its work to its own per-agent plan file at
59+
`C:\Users\<user>\.claude\plans\<plan-name>-agent-<id>.md` instead of to the
60+
target file.
61+
62+
Before spawning any sub-agent, check whether plan mode is active in the
63+
orchestrator session. If it is:
64+
65+
1. **Stop** and surface the situation to the user with `AskUserQuestion`. Two
66+
options:
67+
- **Exit plan mode first** (user toggles their harness off plan mode, then
68+
re-invokes the command). Cleanest.
69+
- **Proceed in degraded mode**: spawn the researcher as normal (it only
70+
needs to write to `.team-notes/`, which the orchestrator can copy into
71+
place from the agent's plan file if blocked). For the step-6 implementer
72+
+ tester pair and the step-9 reviewer, the orchestrator applies the
73+
production / test edits itself, reading each sub-agent's plan file to
74+
extract the verbatim code. The reviewer is already read-only and runs
75+
unaffected.
76+
77+
2. If the user picks degraded mode, set an internal `PLAN_MODE_DEGRADED=true`
78+
flag for the run and follow the per-step divergences in the **Notes for
79+
the orchestrator** block at the bottom of this file.
80+
4881
## Workflow
4982

5083
### 1. Validate input
@@ -421,3 +454,31 @@ unresolved findings are separately surfaced in the final-summary report. The
421454
implementation state of the file; unresolved findings are separately surfaced
422455
in the final-summary report. The `gh issue edit` push must touch ONLY the
423456
`### Checklist` section — verify with a re-fetch + diff before reporting "done".
457+
- **Plan-mode degraded mode** (`PLAN_MODE_DEGRADED=true` — set in the pre-flight
458+
step at the top of this file):
459+
- **Step 5 (researcher)**: the researcher will write its spec to a per-agent
460+
plan file under `C:\Users\<user>\.claude\plans\<plan-name>-agent-<id>.md`
461+
instead of `.team-notes/<foo>-extensions-spec.md`. After it returns, copy
462+
the agent plan file into `.team-notes/<foo>-extensions-spec.md` and verify
463+
the content matches the schema in `.claude/team-templates/extension-impl.md`.
464+
- **Step 6 (implementer + tester)**: both will write their final production
465+
/ test code to per-agent plan files, NOT to `{{PRODUCTION_FILE}}` /
466+
`{{TEST_FILE}}`. The orchestrator reads each agent's plan file, extracts
467+
the verbatim code, and applies the edits itself via `Edit` / `Write`.
468+
Step 7's `dotnet build` + targeted `dotnet test` then runs against the
469+
orchestrator-applied diffs as normal. Do NOT mark step 6 complete on the
470+
sub-agent's "ready to execute" message alone — only after the orchestrator
471+
has applied each file's diffs and the build is green.
472+
- **Step 8 (regression sweep)**: same as step 6 — the regression-sweep
473+
tester writes to a per-agent plan file; orchestrator applies the diffs to
474+
each touched sibling fixture itself.
475+
- **Step 9 (reviewer)**: read-only, so plan mode does not block it. No
476+
degradation needed.
477+
- **Sanity check**: in degraded mode, the orchestrator does roughly 2× the
478+
work it would in normal mode (it now applies the edits the sub-agents
479+
would otherwise apply themselves). Budget for it — do not silently fall
480+
behind on step-7 verification just because step 6 cost more turns.
481+
- The Agent tool's `mode` parameter cannot reliably escape inherited plan mode
482+
on this Claude Code build. The orchestrator MUST detect plan mode at
483+
pre-flight and pick the degraded-mode branch deliberately rather than
484+
assuming `mode: "acceptEdits"` will work.

.claude/team-templates/extension-impl.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,31 @@ Don't use this template when:
8080
fixtures that now fail get updated as part of the same PR.
8181
```
8282

83+
## Plan-mode-aware prompting (added 2026-05-28)
84+
85+
If the orchestrator session is in plan mode when this template is used, sub-agents
86+
will inherit it and cannot apply edits. The Agent-tool `mode: "acceptEdits"`
87+
parameter does NOT override the inherited state on the current Claude Code build.
88+
89+
Role prompts in this template are written so that the orchestrator can fall back
90+
to applying edits itself when this happens:
91+
92+
- **Researcher** prompts always direct the agent to write the spec to its
93+
declared `{{NOTES_FILE}}` location. In plan-mode-degraded runs the agent will
94+
write to a per-agent plan file under
95+
`C:\Users\<user>\.claude\plans\<plan-name>-agent-<id>.md` instead; the
96+
orchestrator then copies it to `.team-notes/`.
97+
- **Implementer / tester** prompts must emit the verbatim production / test code
98+
in their text response (or, equivalently, in their per-agent plan file) so it
99+
survives a plan-mode block. The orchestrator extracts and applies it via
100+
`Edit` / `Write`.
101+
- **Reviewer** prompts are already read-only and unaffected by plan mode.
102+
103+
The `/implement-extensions-batch` command body documents the degraded-mode flow
104+
end-to-end in its "Pre-flight: detect orchestrator plan mode" section. The
105+
single-file `/implement-extensions` command should also adopt the same flow —
106+
see that file's notes section.
107+
83108
## Hard scope-discipline rule (v2)
84109

85110
**Honor user-memory `feedback_scope_discipline.md`**: when the task names a single

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Auto-generated DTOs use structured namespaces reflecting the KerML/SysML package
154154
- Use 'StringBuilder.Append(char)' instead of 'StringBuilder.Append(string)' when the input is a constant unit string
155155
- Prefer 'string.IsNullOrWhiteSpace' over 'string.IsNullOrEmpty' when checking the non-nullable value of a string
156156
- Prefer switch expressions/statements over if-else chains when applicable
157-
- Prefer indexer syntax (e.g., 'list[^1]') and range syntax (e.g., 'array[1..^1]') over LINQ methods (e.g., 'list.Last()', 'list.Skip(1).Take(n)') when applicable
157+
- Prefer LINQ as much as possible — including for projection / filter / aggregation over collections (`items.Where(...).Select(...).ToList()`, `result.AddRange(items.Select(...))`, `items.Any(predicate)`, etc.) instead of hand-rolled `foreach` + `if` + `.Add()` loops. The ONE exception is straightforward positional or range access on a concrete `List`/array: `list[^1]` beats `list.Last()`, `array[1..^1]` beats `array.Skip(1).SkipLast(1)` — indexer/range syntax is more performant there. Outside that narrow exception, LINQ wins for clarity AND maintainability.
158158
- Prefer C# collection expressions (`[a, b, c]`, `[..xs]`, `[]`) over `new[] { ... }`, `new List<T> { ... }`, `new T[] { ... }` when constructing a collection. Applies to both production code AND tests (e.g. `Is.EqualTo([classifier1, classifier2])` not `Is.EqualTo(new[] { classifier1, classifier2 })`, `return [];` not `return new List<T>();`). Fall back to explicit construction only when type inference cannot pick the right collection type.
159159
- Use meaningful variable names instead of single-letter names in any context (e.g., 'charIndex' instead of 'i', 'currentChar' instead of 'c', 'element' instead of 'e')
160160
- Use 'NotSupportedException' (not 'NotImplementedException') for placeholder/stub methods that require manual implementation

0 commit comments

Comments
 (0)