5-phase-workflow 1.8.1 → 1.8.4
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.
- package/bin/install.js +114 -3
- package/package.json +1 -1
- package/src/agents/component-executor.md +15 -6
- package/src/commands/5/address-review-findings.md +0 -1
- package/src/commands/5/configure.md +0 -1
- package/src/commands/5/discuss-feature.md +0 -1
- package/src/commands/5/implement-feature.md +68 -5
- package/src/commands/5/plan-feature.md +36 -6
- package/src/commands/5/plan-implementation.md +52 -9
- package/src/commands/5/quick-implement.md +13 -2
- package/src/commands/5/reconfigure.md +0 -1
- package/src/commands/5/review-code.md +0 -1
- package/src/commands/5/unlock.md +0 -1
- package/src/commands/5/update.md +0 -1
- package/src/commands/5/verify-implementation.md +0 -1
- package/src/hooks/plan-guard.js +45 -9
- package/src/settings.json +1 -1
- package/src/templates/workflow/FEATURE-SPEC.md +12 -3
- package/src/templates/workflow/PLAN.md +12 -10
package/bin/install.js
CHANGED
|
@@ -248,6 +248,19 @@ function removeDir(dir) {
|
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
// Files removed from the package before manifest tracking existed.
|
|
252
|
+
// This list is frozen — future removals are handled by manifest diffing.
|
|
253
|
+
const LEGACY_REMOVED_FILES = [
|
|
254
|
+
'agents/feature-planner.md',
|
|
255
|
+
'agents/implementation-planner.md',
|
|
256
|
+
'agents/review-processor.md',
|
|
257
|
+
'agents/step-executor.md',
|
|
258
|
+
'agents/integration-agent.md',
|
|
259
|
+
'agents/step-fixer.md',
|
|
260
|
+
'agents/step-verifier.md',
|
|
261
|
+
'agents/verification-agent.md'
|
|
262
|
+
];
|
|
263
|
+
|
|
251
264
|
// Get list of workflow-owned files/directories (not user-created)
|
|
252
265
|
function getWorkflowManagedFiles() {
|
|
253
266
|
return {
|
|
@@ -303,6 +316,46 @@ function getWorkflowManagedFiles() {
|
|
|
303
316
|
};
|
|
304
317
|
}
|
|
305
318
|
|
|
319
|
+
// Flatten getWorkflowManagedFiles() into a list of relative paths (relative to .claude/)
|
|
320
|
+
function getFileManifest() {
|
|
321
|
+
const managed = getWorkflowManagedFiles();
|
|
322
|
+
const manifest = [];
|
|
323
|
+
|
|
324
|
+
// Commands are directories
|
|
325
|
+
for (const cmd of managed.commands) {
|
|
326
|
+
manifest.push(`commands/${cmd}`);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Agents are files
|
|
330
|
+
for (const agent of managed.agents) {
|
|
331
|
+
manifest.push(`agents/${agent}`);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Skills are directories
|
|
335
|
+
for (const skill of managed.skills) {
|
|
336
|
+
manifest.push(`skills/${skill}`);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Hooks are files
|
|
340
|
+
for (const hook of managed.hooks) {
|
|
341
|
+
manifest.push(`hooks/${hook}`);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Templates are files (may include nested paths like workflow/FEATURE-SPEC.md)
|
|
345
|
+
for (const template of managed.templates) {
|
|
346
|
+
manifest.push(`templates/${template}`);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// References are files
|
|
350
|
+
if (managed.references) {
|
|
351
|
+
for (const ref of managed.references) {
|
|
352
|
+
manifest.push(`references/${ref}`);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return manifest;
|
|
357
|
+
}
|
|
358
|
+
|
|
306
359
|
// Selectively update only workflow-managed files, preserve user content
|
|
307
360
|
function selectiveUpdate(targetPath, sourcePath) {
|
|
308
361
|
const managed = getWorkflowManagedFiles();
|
|
@@ -406,6 +459,50 @@ function selectiveUpdate(targetPath, sourcePath) {
|
|
|
406
459
|
}
|
|
407
460
|
}
|
|
408
461
|
|
|
462
|
+
// Clean up files that were previously installed but are no longer managed
|
|
463
|
+
function cleanupOrphanedFiles(targetPath, dataDir) {
|
|
464
|
+
const versionFile = path.join(dataDir, 'version.json');
|
|
465
|
+
const currentManifest = getFileManifest();
|
|
466
|
+
const currentSet = new Set(currentManifest);
|
|
467
|
+
|
|
468
|
+
let oldManifest = null;
|
|
469
|
+
if (fs.existsSync(versionFile)) {
|
|
470
|
+
try {
|
|
471
|
+
const data = JSON.parse(fs.readFileSync(versionFile, 'utf8'));
|
|
472
|
+
oldManifest = data.manifest || null;
|
|
473
|
+
} catch (e) {
|
|
474
|
+
// Corrupted file, treat as no manifest
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
if (oldManifest) {
|
|
479
|
+
// Manifest exists: diff old vs current, delete orphans
|
|
480
|
+
for (const entry of oldManifest) {
|
|
481
|
+
if (!currentSet.has(entry)) {
|
|
482
|
+
const fullPath = path.join(targetPath, entry);
|
|
483
|
+
if (fs.existsSync(fullPath)) {
|
|
484
|
+
const stat = fs.statSync(fullPath);
|
|
485
|
+
if (stat.isDirectory()) {
|
|
486
|
+
removeDir(fullPath);
|
|
487
|
+
} else {
|
|
488
|
+
fs.unlinkSync(fullPath);
|
|
489
|
+
}
|
|
490
|
+
log.info(`Removed orphaned: ${entry}`);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
} else {
|
|
495
|
+
// No manifest (legacy upgrade): use static legacy removals list
|
|
496
|
+
for (const entry of LEGACY_REMOVED_FILES) {
|
|
497
|
+
const fullPath = path.join(targetPath, entry);
|
|
498
|
+
if (fs.existsSync(fullPath)) {
|
|
499
|
+
fs.unlinkSync(fullPath);
|
|
500
|
+
log.info(`Removed legacy orphan: ${entry}`);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
409
506
|
// Ensure .5/.gitignore exists and contains .update-cache.json
|
|
410
507
|
function ensureDotFiveGitignore(dataDir) {
|
|
411
508
|
const gitignorePath = path.join(dataDir, '.gitignore');
|
|
@@ -436,7 +533,8 @@ function initializeVersionJson(isGlobal) {
|
|
|
436
533
|
packageVersion: version,
|
|
437
534
|
installedAt: now,
|
|
438
535
|
lastUpdated: now,
|
|
439
|
-
installationType: isGlobal ? 'global' : 'local'
|
|
536
|
+
installationType: isGlobal ? 'global' : 'local',
|
|
537
|
+
manifest: getFileManifest()
|
|
440
538
|
};
|
|
441
539
|
|
|
442
540
|
fs.writeFileSync(versionFile, JSON.stringify(versionData, null, 2));
|
|
@@ -583,11 +681,14 @@ function performUpdate(targetPath, sourcePath, isGlobal, versionInfo) {
|
|
|
583
681
|
// Selectively update only workflow-managed files (preserves user content)
|
|
584
682
|
selectiveUpdate(targetPath, sourcePath);
|
|
585
683
|
|
|
684
|
+
// Clean up orphaned files from previous versions
|
|
685
|
+
const dataDir = getDataPath(isGlobal);
|
|
686
|
+
cleanupOrphanedFiles(targetPath, dataDir);
|
|
687
|
+
|
|
586
688
|
// Merge settings (deep merge preserves user customizations)
|
|
587
689
|
mergeSettings(targetPath, sourcePath);
|
|
588
690
|
|
|
589
691
|
// Update version.json
|
|
590
|
-
const dataDir = getDataPath(isGlobal);
|
|
591
692
|
const versionFile = path.join(dataDir, 'version.json');
|
|
592
693
|
const now = new Date().toISOString();
|
|
593
694
|
|
|
@@ -598,7 +699,8 @@ function performUpdate(targetPath, sourcePath, isGlobal, versionInfo) {
|
|
|
598
699
|
packageVersion: versionInfo.available,
|
|
599
700
|
installedAt: existing.installedAt || now,
|
|
600
701
|
lastUpdated: now,
|
|
601
|
-
installationType: existing.installationType || (isGlobal ? 'global' : 'local')
|
|
702
|
+
installationType: existing.installationType || (isGlobal ? 'global' : 'local'),
|
|
703
|
+
manifest: getFileManifest()
|
|
602
704
|
};
|
|
603
705
|
|
|
604
706
|
if (!fs.existsSync(dataDir)) {
|
|
@@ -690,6 +792,15 @@ function uninstall() {
|
|
|
690
792
|
|
|
691
793
|
const managed = getWorkflowManagedFiles();
|
|
692
794
|
|
|
795
|
+
// Remove legacy orphaned files that may still exist from older versions
|
|
796
|
+
for (const entry of LEGACY_REMOVED_FILES) {
|
|
797
|
+
const fullPath = path.join(targetPath, entry);
|
|
798
|
+
if (fs.existsSync(fullPath)) {
|
|
799
|
+
fs.unlinkSync(fullPath);
|
|
800
|
+
log.info(`Removed legacy orphan: ${entry}`);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
|
|
693
804
|
// Remove commands/5/ (workflow namespace only)
|
|
694
805
|
const commands5 = path.join(targetPath, 'commands', '5');
|
|
695
806
|
if (fs.existsSync(commands5)) {
|
package/package.json
CHANGED
|
@@ -12,16 +12,16 @@ You follow existing codebase patterns. You do NOT deviate from the plan.
|
|
|
12
12
|
<process>
|
|
13
13
|
## Implementation Process
|
|
14
14
|
|
|
15
|
-
1. **Read
|
|
15
|
+
1. **Read required files FIRST** — If your prompt includes a `Pattern File` or `Read First` field, you MUST read every listed file before writing any code. This establishes ground truth and prevents assumptions about conventions, naming, or structure.
|
|
16
16
|
2. **For creating files:**
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
17
|
+
- Read the pattern file (from step 1) to understand conventions
|
|
18
|
+
- Create the new file following the same patterns exactly
|
|
19
|
+
- If no pattern file was provided, find a similar existing file via Glob and read it
|
|
20
20
|
3. **For modifying files:**
|
|
21
21
|
- Read the target file
|
|
22
22
|
- Apply the described change via Edit
|
|
23
23
|
- Verify the change is correct
|
|
24
|
-
4. **
|
|
24
|
+
4. **Run verify command** — If your prompt includes a `Verify` field, run that command and confirm it passes. If it fails, fix the issue (subject to the 3-attempt limit). If no verify command was provided, verify each file exists after changes.
|
|
25
25
|
</process>
|
|
26
26
|
|
|
27
27
|
<output-format>
|
|
@@ -31,6 +31,8 @@ When done, output your result in this exact format:
|
|
|
31
31
|
STATUS: success | failed
|
|
32
32
|
FILES_CREATED: [comma-separated paths]
|
|
33
33
|
FILES_MODIFIED: [comma-separated paths]
|
|
34
|
+
VERIFY: passed | failed | skipped
|
|
35
|
+
DEVIATIONS: none | {brief list of auto-fixes applied}
|
|
34
36
|
ERROR: none | {error description}
|
|
35
37
|
---END---
|
|
36
38
|
</output-format>
|
|
@@ -44,5 +46,12 @@ You WILL discover unplanned work. Handle as follows:
|
|
|
44
46
|
|---------|--------|------------|
|
|
45
47
|
| Bug/error in existing code | Fix → verify → note in result | Auto |
|
|
46
48
|
| Missing import/dependency | Add → verify → note in result | Auto |
|
|
47
|
-
|
|
|
49
|
+
| Missing validation/auth/logging | Add → verify → note in result | Auto |
|
|
50
|
+
| Blocking issue (prevents task completion) | Fix → verify → note in result | Auto |
|
|
51
|
+
| Architectural change needed (new DB table, schema change, service switch) | STOP → report in ERROR field | Ask user |
|
|
52
|
+
| Auth error ("401", "Not authenticated", "Set ENV_VAR") | STOP → report as AUTH_GATE in ERROR | Ask user |
|
|
53
|
+
|
|
54
|
+
**Priority:** Architectural/Auth (ask) > Auto-fix rules > Unsure (treat as architectural, ask)
|
|
55
|
+
|
|
56
|
+
**3-attempt limit:** If you have attempted 3 auto-fixes on a SINGLE issue and it still fails, STOP. Report the issue in the ERROR field with `ATTEMPTS_EXHAUSTED: {description}`. Do not keep trying — the orchestrator will handle it.
|
|
48
57
|
</deviation-rules>
|
|
@@ -3,7 +3,6 @@ name: 5:address-review-findings
|
|
|
3
3
|
description: Applies annotated review findings and/or addresses GitHub PR review comments. Use --github to process PR comments only.
|
|
4
4
|
allowed-tools: Bash, Read, Edit, Write, Glob, Grep, AskUserQuestion, Task, Skill, mcp__jetbrains__*
|
|
5
5
|
user-invocable: true
|
|
6
|
-
disable-model-invocation: true
|
|
7
6
|
model: sonnet
|
|
8
7
|
context: fork
|
|
9
8
|
---
|
|
@@ -3,7 +3,6 @@ name: 5:configure
|
|
|
3
3
|
description: Configures the project. Analyzes project, gathers preferences, writes config.json, and creates feature spec for remaining setup. Follow up with /5:plan-implementation CONFIGURE.
|
|
4
4
|
allowed-tools: Read, Write, Bash, Glob, Grep, AskUserQuestion
|
|
5
5
|
user-invocable: true
|
|
6
|
-
disable-model-invocation: true
|
|
7
6
|
model: opus
|
|
8
7
|
context: fork
|
|
9
8
|
---
|
|
@@ -3,7 +3,6 @@ name: 5:discuss-feature
|
|
|
3
3
|
description: Discusses and refines an existing feature specification through iterative Q&A. Use after /plan-feature when requirements need clarification or changes. Updates the feature spec based on discussion.
|
|
4
4
|
allowed-tools: Read, Write, Glob, Grep, Task, AskUserQuestion
|
|
5
5
|
user-invocable: true
|
|
6
|
-
disable-model-invocation: true
|
|
7
6
|
model: opus
|
|
8
7
|
context: inherit
|
|
9
8
|
---
|
|
@@ -3,7 +3,6 @@ name: 5:implement-feature
|
|
|
3
3
|
description: Executes an implementation plan by delegating to agents. Phase 3 of the 5-phase workflow.
|
|
4
4
|
allowed-tools: Task, Read, Write, Glob, Grep, Bash, TaskCreate, TaskUpdate, TaskList
|
|
5
5
|
user-invocable: true
|
|
6
|
-
disable-model-invocation: true
|
|
7
6
|
model: opus
|
|
8
7
|
context: fork
|
|
9
8
|
---
|
|
@@ -35,6 +34,15 @@ You are a thin orchestrator:
|
|
|
35
34
|
- State is the source of truth: write it before moving on
|
|
36
35
|
- Forward progress: failed components are logged, not blocking
|
|
37
36
|
- Resumable: state enables restart from any interrupted step
|
|
37
|
+
- Context budget: keep orchestrator lean — delegate ALL implementation to agents
|
|
38
|
+
|
|
39
|
+
**Context Budget Rules:**
|
|
40
|
+
Your context window is shared across all steps. To avoid running out of context on large features:
|
|
41
|
+
- NEVER read source files yourself — that's the executor agent's job
|
|
42
|
+
- NEVER paste full agent outputs into your reasoning — extract only the `---RESULT---` block
|
|
43
|
+
- Keep state.json updates minimal — write only changed fields
|
|
44
|
+
- If an agent returns a very long response, parse the RESULT block and discard the rest
|
|
45
|
+
- For features with 10+ components: after processing each step's results, summarize the step outcome in one line and move on. Do NOT accumulate detailed logs across steps.
|
|
38
46
|
|
|
39
47
|
**State verification rule:** After every state.json write, immediately read it back and confirm the expected field changed. If verification fails, stop with an error message. This applies to every state write below — marked as **(verify write)**.
|
|
40
48
|
|
|
@@ -99,6 +107,37 @@ Then remove the planning guard marker (planning is over, implementation is start
|
|
|
99
107
|
rm -f .5/.planning-active
|
|
100
108
|
```
|
|
101
109
|
|
|
110
|
+
### Step 2c: Regression Baseline
|
|
111
|
+
|
|
112
|
+
Before spawning any agents, establish a baseline by running the project's build and test commands:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Build command from plan (or auto-detect)
|
|
116
|
+
{build-command}
|
|
117
|
+
|
|
118
|
+
# Test command from plan (or auto-detect)
|
|
119
|
+
{test-command}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Record the results in state.json as `baseline`:
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"baseline": {
|
|
126
|
+
"buildStatus": "success|failed",
|
|
127
|
+
"testStatus": "success|failed|skipped",
|
|
128
|
+
"checkedAt": "{ISO-timestamp}"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**(verify write)** — confirm `baseline.checkedAt` is set.
|
|
134
|
+
|
|
135
|
+
**If the baseline build fails:** Warn the user: `"⚠ Build fails BEFORE implementation. Any post-implementation build failures may be pre-existing."` Continue — don't block on pre-existing failures.
|
|
136
|
+
|
|
137
|
+
**If baseline tests fail:** Warn the user: `"⚠ {N} tests fail BEFORE implementation. These will be excluded from regression comparison."` Record the failing test names/patterns if available, so Step 4 can distinguish pre-existing failures from new ones.
|
|
138
|
+
|
|
139
|
+
This baseline enables Step 4 to detect regressions: tests that passed before but fail after implementation.
|
|
140
|
+
|
|
102
141
|
### Step 2b: Create Progress Checklist
|
|
103
142
|
|
|
104
143
|
Before executing any steps, create one TaskCreate entry per step:
|
|
@@ -115,6 +154,19 @@ Then mark the task for Step 1 as `in_progress`.
|
|
|
115
154
|
|
|
116
155
|
Group components by step number from the plan. For each step (starting from `currentStep` in state.json):
|
|
117
156
|
|
|
157
|
+
**3pre. Pre-step dependency check (steps 2+)**
|
|
158
|
+
|
|
159
|
+
Before executing step N (where N > 1), verify that prior steps' outputs exist on disk:
|
|
160
|
+
|
|
161
|
+
1. For each component in `completedComponents` from prior steps: use Glob to confirm every file in `filesCreated` and `filesModified` still exists
|
|
162
|
+
2. If ANY file is missing:
|
|
163
|
+
- Log: `"⚠ Pre-step check: {file} from step {M} component {name} not found on disk"`
|
|
164
|
+
- Move the component back from `completedComponents` to `pendingComponents`
|
|
165
|
+
- STOP execution for this step. Report to user: `"Step {N} blocked: prior step output missing. Re-run step {M} or fix manually."`
|
|
166
|
+
3. If all files verified, proceed to 3a
|
|
167
|
+
|
|
168
|
+
This prevents cascading failures where step N assumes step N-1's outputs exist but they don't.
|
|
169
|
+
|
|
118
170
|
**3a. Analyze step for parallel execution**
|
|
119
171
|
|
|
120
172
|
Components within the same step are independent by design. For steps with multiple components:
|
|
@@ -145,7 +197,13 @@ Task tool call:
|
|
|
145
197
|
|
|
146
198
|
## Feature: {feature-name}
|
|
147
199
|
## Components
|
|
148
|
-
{component(s) from plan table: name, action, file, description}
|
|
200
|
+
{component(s) from plan table: name, action, file, description, complexity}
|
|
201
|
+
|
|
202
|
+
## Read First
|
|
203
|
+
{Pattern File value(s) from plan table — executor MUST read these before writing any code}
|
|
204
|
+
|
|
205
|
+
## Verify
|
|
206
|
+
{Verify command(s) from plan table — executor runs these after implementation}
|
|
149
207
|
|
|
150
208
|
## Implementation Notes
|
|
151
209
|
{relevant notes from plan}
|
|
@@ -153,9 +211,9 @@ Task tool call:
|
|
|
153
211
|
|
|
154
212
|
The agent file defines the implementation process, output format, and deviation rules. If the agent file is not found (local install), fall back to `.claude/agents/component-executor.md` relative to the project root.
|
|
155
213
|
|
|
156
|
-
**3d. Process results**
|
|
214
|
+
**3d. Process results (context-lean)**
|
|
157
215
|
|
|
158
|
-
Collect results from all agents (parallel or sequential). Parse the `---RESULT---` block from each agent's response. For each:
|
|
216
|
+
Collect results from all agents (parallel or sequential). Parse ONLY the `---RESULT---` block from each agent's response — do NOT retain the full agent output in your context. For each:
|
|
159
217
|
- If `STATUS: success` → component succeeded; note files from `FILES_CREATED`/`FILES_MODIFIED`
|
|
160
218
|
- If `STATUS: failed` → component failed; log the `ERROR` message
|
|
161
219
|
- If no `---RESULT---` block found → treat as success if the agent reported creating/modifying files, otherwise treat as failed
|
|
@@ -251,8 +309,13 @@ For each non-test component with action "create" that contains logic:
|
|
|
251
309
|
**(verify write)** — confirm `verificationResults.builtAt` is set.
|
|
252
310
|
|
|
253
311
|
If build or tests fail:
|
|
312
|
+
- Compare against `baseline` in state.json:
|
|
313
|
+
- If build failed in baseline AND still fails → report as `"Pre-existing build failure (not a regression)"`
|
|
314
|
+
- If build passed in baseline BUT fails now → report as `"⚠ REGRESSION: Build broke during implementation"`
|
|
315
|
+
- If tests that passed in baseline now fail → report as `"⚠ REGRESSION: {N} tests broke during implementation: {test names}"`
|
|
316
|
+
- If tests that failed in baseline still fail → report as `"Pre-existing test failure (not a regression)"`
|
|
254
317
|
- Record in state.json
|
|
255
|
-
- Report to user with error details
|
|
318
|
+
- Report to user with error details and regression classification
|
|
256
319
|
|
|
257
320
|
Mark the "Run verification" TaskCreate task as `completed`.
|
|
258
321
|
|
|
@@ -3,7 +3,6 @@ name: 5:plan-feature
|
|
|
3
3
|
description: Plans feature implementation by analyzing requirements, identifying affected modules, and creating a structured feature specification. Use at the start of any new feature to ensure systematic implementation. This is Phase 1 of the 5-phase workflow.
|
|
4
4
|
allowed-tools: Read, Write, Task, AskUserQuestion
|
|
5
5
|
user-invocable: true
|
|
6
|
-
disable-model-invocation: true
|
|
7
6
|
model: opus
|
|
8
7
|
context: fork
|
|
9
8
|
---
|
|
@@ -22,6 +21,8 @@ HARD CONSTRAINTS — violations waste tokens and get blocked by plan-guard:
|
|
|
22
21
|
- NEVER spawn Task agents with subagent_type other than Explore
|
|
23
22
|
- NEVER write to any file except .5/features/{name}/feature.md (where {name} may include a ticket prefix) and .5/.planning-active
|
|
24
23
|
- NEVER call EnterPlanMode — the workflow has its own planning process
|
|
24
|
+
- NEVER use Bash to create, write, or modify files — this bypasses the plan-guard and is a constraint violation
|
|
25
|
+
- NEVER continue past the completion message — when you output "Feature spec created at...", you are DONE
|
|
25
26
|
- The feature spec describes WHAT and WHY, never HOW
|
|
26
27
|
- If you feel the urge to implement, STOP and ask a clarifying question instead
|
|
27
28
|
- Your output is a SPECIFICATION, not a design document. No code. No file layouts. No API shapes.
|
|
@@ -30,7 +31,8 @@ HARD CONSTRAINTS — violations waste tokens and get blocked by plan-guard:
|
|
|
30
31
|
<write-rules>
|
|
31
32
|
You have access to the Write tool for exactly these files:
|
|
32
33
|
1. `.5/.planning-active` — Step 0 only
|
|
33
|
-
2. `.5/features/{name}/
|
|
34
|
+
2. `.5/features/{name}/codebase-scan.md` — Step 2 only (Explore agent results cache)
|
|
35
|
+
3. `.5/features/{name}/feature.md` — Step 4 only
|
|
34
36
|
Any other Write target WILL be blocked by the plan-guard hook. Do not attempt it.
|
|
35
37
|
</write-rules>
|
|
36
38
|
|
|
@@ -63,6 +65,20 @@ testing strategy, integration points (from findings), alternative approaches, co
|
|
|
63
65
|
|
|
64
66
|
# Plan Feature (Phase 1)
|
|
65
67
|
|
|
68
|
+
## Progress Checklist
|
|
69
|
+
|
|
70
|
+
Follow these steps IN ORDER. Do NOT skip steps. Do NOT proceed to a later step until the current one is complete. After completing each step, output a status line: `✓ Step N complete`.
|
|
71
|
+
|
|
72
|
+
- [ ] Step 0: Activate planning guard — write `.5/.planning-active`
|
|
73
|
+
- [ ] Step 1: Gather feature description — ask developer via AskUserQuestion
|
|
74
|
+
- [ ] Step 2: Explore codebase — spawn Explore sub-agent, wait for results, cache to codebase-scan.md
|
|
75
|
+
- [ ] Step 3: Ask 5+ clarifying questions — one at a time, minimum 5 before proceeding
|
|
76
|
+
- [ ] Step 3b: Pre-write checkpoint — verify ≥5 Q&A pairs exist, no code in spec
|
|
77
|
+
- [ ] Step 4: Write feature specification — create `.5/features/{name}/feature.md`
|
|
78
|
+
- [ ] Output completion message and STOP
|
|
79
|
+
|
|
80
|
+
> **MANDATORY:** After each step, output `✓ Step N complete` before moving on. This is your progress anchor — if you cannot say which step you just completed, you are skipping ahead. If Step 3b fails (< 5 Q&A), return to Step 3.
|
|
81
|
+
|
|
66
82
|
## Process
|
|
67
83
|
|
|
68
84
|
### Step 0: Activate Planning Guard
|
|
@@ -82,17 +98,19 @@ This activates the plan-guard hook which prevents accidental source file edits d
|
|
|
82
98
|
|
|
83
99
|
Ask the developer for the feature description using AskUserQuestion:
|
|
84
100
|
|
|
85
|
-
"Please describe the feature you want to
|
|
101
|
+
"Please describe the feature you want to specify. Paste the full ticket description or explain it in your own words."
|
|
86
102
|
|
|
87
103
|
- Expect free-text answer, do NOT provide options
|
|
88
104
|
- Do NOT ask follow-up questions yet
|
|
89
105
|
|
|
90
106
|
### Step 2: Spawn Explore Agent for Codebase Analysis
|
|
91
107
|
|
|
108
|
+
> **ROLE CHECK:** You are a Feature Planner. Your ONLY output is feature.md. If you are tempted to write code or create files, STOP and return to the next question in Step 3.
|
|
109
|
+
|
|
92
110
|
Spawn a Task with `subagent_type=Explore`:
|
|
93
111
|
|
|
94
112
|
```
|
|
95
|
-
Analyze the codebase for a feature
|
|
113
|
+
Analyze the codebase for a feature specification session.
|
|
96
114
|
|
|
97
115
|
**Feature Description:** {paste the user's feature description}
|
|
98
116
|
|
|
@@ -118,7 +136,11 @@ Analyze the codebase for a feature planning session.
|
|
|
118
136
|
|
|
119
137
|
Wait for the sub-agent to return before proceeding.
|
|
120
138
|
|
|
121
|
-
|
|
139
|
+
**Cache the results:** Write the Explore agent's full output to `.5/features/{name}/codebase-scan.md` using the Write tool. This saves Phase 2 from re-scanning the same codebase and saves significant tokens.
|
|
140
|
+
|
|
141
|
+
### Step 3: Intensive Q&A
|
|
142
|
+
|
|
143
|
+
> **ROLE CHECK:** You are gathering requirements, NOT designing solutions. Questions ask WHAT and WHY, never HOW.
|
|
122
144
|
|
|
123
145
|
Ask 5-10 clarifying questions using AskUserQuestion. ONE question at a time — wait for the answer before asking the next. Use the sub-agent findings to inform questions. Cover: requirements clarity, scope boundaries, edge cases, performance expectations, testing strategy, integration points, alternative approaches, and complexity trade-offs. Challenge assumptions: "Is this the simplest solution?", "Could we reuse existing X?", "What happens when Y fails?"
|
|
124
146
|
|
|
@@ -141,6 +163,8 @@ If you have fewer than 5 Q&A pairs, go back to Step 3 and ask more questions.
|
|
|
141
163
|
|
|
142
164
|
### Step 4: Create Feature Specification
|
|
143
165
|
|
|
166
|
+
> **ROLE CHECK:** You are writing a SPECIFICATION (WHAT/WHY), not a design document (HOW). Zero code, zero file paths to create, zero signatures. After writing feature.md you are DONE — do NOT proceed to implementation planning or coding.
|
|
167
|
+
|
|
144
168
|
**Extract ticket ID from git branch:**
|
|
145
169
|
- The Explore agent from Step 2 already ran `git branch --show-current` — find the branch name in its results
|
|
146
170
|
- Use the configurable ticket pattern from `.5/config.json` (e.g., `PROJ-\d+`) to extract the ticket ID from the branch name
|
|
@@ -163,7 +187,13 @@ Populate all sections:
|
|
|
163
187
|
- Affected Components (from exploration)
|
|
164
188
|
- Acceptance Criteria
|
|
165
189
|
- Alternatives Considered
|
|
166
|
-
-
|
|
190
|
+
- Decisions (from Q&A session) — label each with **[DECIDED]**, **[FLEXIBLE]**, or **[DEFERRED]**
|
|
191
|
+
|
|
192
|
+
**Decision labeling rules:**
|
|
193
|
+
- **[DECIDED]**: The user gave a clear, specific answer → Phase 2 planner and Phase 3 agents MUST honor exactly
|
|
194
|
+
- **[FLEXIBLE]**: The user said "up to you", "whatever works", or didn't express a strong preference → planner chooses
|
|
195
|
+
- **[DEFERRED]**: The user explicitly said "not now", "later", "skip this" → planner MUST NOT include in the plan
|
|
196
|
+
- When in doubt, label as **[DECIDED]** — it's safer to honor a decision than to override it
|
|
167
197
|
|
|
168
198
|
## PLANNING COMPLETE
|
|
169
199
|
|
|
@@ -3,7 +3,6 @@ name: 5:plan-implementation
|
|
|
3
3
|
description: Creates an implementation plan from a feature spec. Phase 2 of the 5-phase workflow.
|
|
4
4
|
allowed-tools: Read, Write, Task, AskUserQuestion
|
|
5
5
|
user-invocable: true
|
|
6
|
-
disable-model-invocation: true
|
|
7
6
|
model: opus
|
|
8
7
|
context: fork
|
|
9
8
|
---
|
|
@@ -21,8 +20,12 @@ HARD CONSTRAINTS — violations get blocked by plan-guard:
|
|
|
21
20
|
- NEVER create source files — you create ONE file: plan.md
|
|
22
21
|
- NEVER call EnterPlanMode — the workflow has its own planning process
|
|
23
22
|
- NEVER spawn Task agents with subagent_type other than Explore
|
|
23
|
+
- NEVER use Bash to create, write, or modify files — this bypasses the plan-guard and is a constraint violation
|
|
24
|
+
- NEVER continue past the completion message — when you output "Plan created at...", you are DONE
|
|
24
25
|
- The plan describes WHAT to build and WHERE. Agents figure out HOW by reading existing code.
|
|
25
|
-
- Each component in the table gets: name, action, file path, one-sentence description, complexity
|
|
26
|
+
- Each component in the table gets: name, action, file path, one-sentence description, pattern file, verify command, complexity
|
|
27
|
+
- **Pattern File** (required for "create" actions): Path to an existing file the executor reads before implementing. For "modify" actions, this is the target file itself. Helps executor match conventions exactly.
|
|
28
|
+
- **Verify** (required): A concrete command or grep check the executor runs after implementing. Examples: `grep -q 'export class UserService' src/services/user.service.ts`, `npm test -- --testPathPattern=user`, `npx tsc --noEmit`. Never use vague checks like "works correctly".
|
|
26
29
|
- If a component needs more than one sentence to describe, split it into multiple components
|
|
27
30
|
- Implementation Notes reference EXISTING pattern files, not new code
|
|
28
31
|
- Every component with action "create" that contains logic (services, controllers, repositories, hooks, utilities, helpers) MUST have a corresponding test component. Declarative components (types, interfaces, models without logic, route registrations, config files) are exempt. When uncertain, include the test.
|
|
@@ -31,7 +34,8 @@ HARD CONSTRAINTS — violations get blocked by plan-guard:
|
|
|
31
34
|
<write-rules>
|
|
32
35
|
You have access to the Write tool for exactly these files:
|
|
33
36
|
1. `.5/.planning-active` — Step 0 only
|
|
34
|
-
2. `.5/features/{name}/
|
|
37
|
+
2. `.5/features/{name}/codebase-scan.md` — Step 2 only (if fresh scan was needed)
|
|
38
|
+
3. `.5/features/{name}/plan.md` — Step 5 only
|
|
35
39
|
Any other Write target WILL be blocked by the plan-guard hook. Do not attempt it.
|
|
36
40
|
</write-rules>
|
|
37
41
|
|
|
@@ -58,6 +62,22 @@ Assign complexity per component using this rubric:
|
|
|
58
62
|
|
|
59
63
|
# Plan Implementation (Phase 2)
|
|
60
64
|
|
|
65
|
+
## Progress Checklist
|
|
66
|
+
|
|
67
|
+
Follow these steps IN ORDER. Do NOT skip steps. Do NOT proceed to a later step until the current one is complete. After completing each step, output a status line: `✓ Step N complete`.
|
|
68
|
+
|
|
69
|
+
- [ ] Step 0: Activate planning guard — write `.5/.planning-active`
|
|
70
|
+
- [ ] Step 1: Load feature spec — read `.5/features/{name}/feature.md`
|
|
71
|
+
- [ ] Step 1b: Load project configuration — read `.5/config.json` if it exists
|
|
72
|
+
- [ ] Step 2: Load or generate codebase scan — reuse cached scan from Phase 1, or spawn Explore if missing
|
|
73
|
+
- [ ] Step 3: Ask 2-3 technical questions — one at a time via AskUserQuestion
|
|
74
|
+
- [ ] Step 4: Design components — identify files, order, step grouping
|
|
75
|
+
- [ ] Step 5: Write the plan — create `.5/features/{name}/plan.md`
|
|
76
|
+
- [ ] Step 5b: Plan self-check — verify format, no code, scope, completeness, tests
|
|
77
|
+
- [ ] Output completion message and STOP
|
|
78
|
+
|
|
79
|
+
> **MANDATORY:** After each step, output `✓ Step N complete` before moving on. This is your progress anchor — if you cannot say which step you just completed, you are skipping ahead. If Step 5b fails, fix plan.md before outputting completion.
|
|
80
|
+
|
|
61
81
|
## Output Format
|
|
62
82
|
|
|
63
83
|
Read the plan template at `.claude/templates/workflow/PLAN.md` for the exact structure and rules. Your output must follow that template precisely — fill in the placeholders with real values from the feature spec and codebase scan.
|
|
@@ -82,7 +102,12 @@ This activates (or refreshes) the plan-guard hook which prevents accidental sour
|
|
|
82
102
|
|
|
83
103
|
Read `.5/features/{feature-name}/feature.md` (where `{feature-name}` is the argument provided).
|
|
84
104
|
|
|
85
|
-
Extract: Ticket ID, requirements (functional and non-functional), acceptance criteria, affected components
|
|
105
|
+
Extract: Ticket ID, requirements (functional and non-functional), acceptance criteria, affected components, and **decisions**.
|
|
106
|
+
|
|
107
|
+
**Decision labels from feature spec:**
|
|
108
|
+
- **[DECIDED]** items are locked — your plan MUST honor them exactly. Do not override or reinterpret.
|
|
109
|
+
- **[FLEXIBLE]** items are your discretion — choose the best approach based on codebase patterns.
|
|
110
|
+
- **[DEFERRED]** items are out of scope — do NOT plan components for them. If a deferred item is needed as a dependency, flag it in Implementation Notes.
|
|
86
111
|
|
|
87
112
|
If the file doesn't exist, tell the user to run `/5:plan-feature` first.
|
|
88
113
|
|
|
@@ -95,7 +120,15 @@ Read `.5/config.json` if it exists. Extract:
|
|
|
95
120
|
|
|
96
121
|
If config.json doesn't exist, proceed without it.
|
|
97
122
|
|
|
98
|
-
### Step 2:
|
|
123
|
+
### Step 2: Load or Generate Codebase Scan
|
|
124
|
+
|
|
125
|
+
> **ROLE CHECK:** You are an Implementation Planner. Your ONLY output is plan.md. You do NOT write code, create source files, or start implementation. If you feel the urge to implement, STOP — that is Phase 3's job.
|
|
126
|
+
|
|
127
|
+
**First, check for a cached scan from Phase 1:**
|
|
128
|
+
|
|
129
|
+
Read `.5/features/{feature-name}/codebase-scan.md`. If it exists and is non-empty, use it as the codebase scan results. This was generated during Phase 1 (`/5:plan-feature`) and contains project structure, naming conventions, pattern files, and test framework detection.
|
|
130
|
+
|
|
131
|
+
**If `codebase-scan.md` does NOT exist** (e.g., user skipped Phase 1 or ran an older version), spawn a fresh Explore agent:
|
|
99
132
|
|
|
100
133
|
Spawn a Task with `subagent_type=Explore`:
|
|
101
134
|
|
|
@@ -136,6 +169,8 @@ Focus scan on {projectType}-relevant directories and patterns.
|
|
|
136
169
|
|
|
137
170
|
Wait for the sub-agent to return before proceeding.
|
|
138
171
|
|
|
172
|
+
**If a fresh scan was spawned**, write the results to `.5/features/{feature-name}/codebase-scan.md` for future reference.
|
|
173
|
+
|
|
139
174
|
### Step 3: Ask 2-3 Technical Questions (One at a Time)
|
|
140
175
|
|
|
141
176
|
Use AskUserQuestion to clarify:
|
|
@@ -159,6 +194,8 @@ Targeted scan for implementation planning.
|
|
|
159
194
|
|
|
160
195
|
### Step 4: Design Components
|
|
161
196
|
|
|
197
|
+
> **ROLE CHECK:** You are identifying WHAT and WHERE — component names, actions, file paths, one-sentence descriptions. You are NOT writing code, pseudo-code, or implementation details. The HOW is figured out by Phase 3 agents reading existing code.
|
|
198
|
+
|
|
162
199
|
Based on feature spec and codebase scan, identify:
|
|
163
200
|
- Files to create
|
|
164
201
|
- Files to modify
|
|
@@ -195,6 +232,8 @@ Not every feature needs all non-test steps. Use what makes sense. But testable c
|
|
|
195
232
|
|
|
196
233
|
### Step 5: Write the Plan
|
|
197
234
|
|
|
235
|
+
> **ROLE CHECK:** You are writing plan.md — a components table with descriptions, NOT code. After writing and verifying, output the completion message and STOP. Do NOT continue to implementation.
|
|
236
|
+
|
|
198
237
|
Create a single file at `.5/features/{feature-name}/plan.md`.
|
|
199
238
|
|
|
200
239
|
Include:
|
|
@@ -212,22 +251,26 @@ Include:
|
|
|
212
251
|
|
|
213
252
|
Read plan.md back and verify:
|
|
214
253
|
|
|
215
|
-
1. **Format:** Every row in the Components table has all
|
|
254
|
+
1. **Format:** Every row in the Components table has all 8 columns filled (Step, Component, Action, File, Description, Pattern File, Verify, Complexity)
|
|
216
255
|
2. **No code:** Implementation Notes contain ONLY references to existing files and business rules
|
|
217
256
|
3. **Scope:** Every component traces back to a requirement in feature.md — if not, remove it
|
|
218
257
|
4. **Completeness:** Every functional requirement from feature.md has at least one component
|
|
219
258
|
5. **Description length:** Each Description cell is one sentence. If longer, split the component.
|
|
220
|
-
6. **
|
|
221
|
-
7. **
|
|
259
|
+
6. **Pattern files:** Every "create" component has a Pattern File pointing to an existing file. Verify these files exist via Glob.
|
|
260
|
+
7. **Verify commands:** Every component has a concrete Verify command (grep, test, build). No vague checks.
|
|
261
|
+
8. **Unit test coverage:** Every "create" component with logic has a corresponding unit test component. Declarative-only components (types, interfaces, route wiring) are exempt.
|
|
262
|
+
9. **Integration/e2e coverage:** If the explore agent detected integration or e2e frameworks AND the feature touches endpoints or cross-module flows, verify at least one integration or e2e test component is planned.
|
|
222
263
|
|
|
223
264
|
Output the verification result:
|
|
224
265
|
```
|
|
225
266
|
Plan self-check:
|
|
226
|
-
- Format: pass/fail
|
|
267
|
+
- Format (8 columns): pass/fail
|
|
227
268
|
- No code: pass/fail
|
|
228
269
|
- Scope: pass/fail
|
|
229
270
|
- Completeness: pass/fail
|
|
230
271
|
- Description length: pass/fail
|
|
272
|
+
- Pattern files exist: pass/fail
|
|
273
|
+
- Verify commands concrete: pass/fail
|
|
231
274
|
- Unit test coverage: pass/fail
|
|
232
275
|
- Integration/e2e coverage: pass/fail/n-a
|
|
233
276
|
```
|
|
@@ -3,7 +3,6 @@ name: 5:quick-implement
|
|
|
3
3
|
description: Execute small, focused implementations quickly with state tracking and atomic commits. Skips extensive planning phases and verification agents - use for tasks where you know exactly what to do.
|
|
4
4
|
allowed-tools: Read, Write, Edit, Glob, Grep, Bash, Task, AskUserQuestion, Skill, TaskCreate, TaskUpdate, TaskList, mcp__jetbrains__*
|
|
5
5
|
user-invocable: true
|
|
6
|
-
disable-model-invocation: true
|
|
7
6
|
context: fork
|
|
8
7
|
---
|
|
9
8
|
|
|
@@ -25,6 +24,7 @@ Fast path for small, well-understood tasks (1-5 files). Skips extensive planning
|
|
|
25
24
|
Your job in this command:
|
|
26
25
|
✅ Get task description
|
|
27
26
|
✅ Extract ticket ID
|
|
27
|
+
✅ Scope check (>5 files or >3 modules → redirect to full workflow)
|
|
28
28
|
✅ Create quick plan (max 5 components)
|
|
29
29
|
✅ Get user approval on plan
|
|
30
30
|
✅ Initialize state tracking
|
|
@@ -90,12 +90,23 @@ Check if `.5/features/${feature_name}/state.json` already exists:
|
|
|
90
90
|
- If Resume: skip Steps 4–7 initialization; go directly to Step 7b (recreate TaskCreate tasks) and Step 8 (resume remaining `pendingComponents`)
|
|
91
91
|
- If Restart: delete state.json, proceed normally from Step 4
|
|
92
92
|
|
|
93
|
-
### Step 4: Analyze and
|
|
93
|
+
### Step 4: Analyze and Scope Check
|
|
94
94
|
|
|
95
95
|
1. **Identify affected files** using Glob and Grep
|
|
96
96
|
2. **Determine skills needed** based on task type
|
|
97
97
|
3. **List components** (max 5 for quick mode)
|
|
98
98
|
|
|
99
|
+
**Scope gate — check BEFORE planning:**
|
|
100
|
+
|
|
101
|
+
Count the number of files that will be created or modified and the number of distinct modules/directories involved. Apply these rules:
|
|
102
|
+
|
|
103
|
+
- **>5 files** → STOP. Tell the user: `"This task affects {N} files, which exceeds quick-implement's scope (max 5). Use the full workflow instead: /5:plan-feature"`. Do NOT continue.
|
|
104
|
+
- **>3 distinct modules/directories** → STOP. Tell the user: `"This task spans {N} modules ({list}), which is too broad for quick-implement. Use the full workflow: /5:plan-feature"`. Do NOT continue.
|
|
105
|
+
- **Involves database schema changes, new API endpoints with auth, or architectural decisions** → STOP. Tell the user: `"This task involves {reason}, which needs proper planning. Use: /5:plan-feature"`. Do NOT continue.
|
|
106
|
+
- **≤5 files AND ≤3 modules AND no architectural changes** → Proceed to Step 5.
|
|
107
|
+
|
|
108
|
+
This gate prevents quick-implement from being used for tasks that should go through full planning, where the absence of a feature spec and structured plan leads to poor results.
|
|
109
|
+
|
|
99
110
|
**If unclear about implementation details**, ask 2-3 focused questions using AskUserQuestion:
|
|
100
111
|
- What validation rules apply?
|
|
101
112
|
- Which existing patterns to follow?
|
|
@@ -3,7 +3,6 @@ name: 5:reconfigure
|
|
|
3
3
|
description: Lightweight refresh of project documentation and skills without full Q&A. Re-detects codebase changes, regenerates .5/*.md docs, updates CLAUDE.md, and refreshes all skills.
|
|
4
4
|
allowed-tools: Read, Write, Bash, Glob, Grep, Task, AskUserQuestion
|
|
5
5
|
user-invocable: true
|
|
6
|
-
disable-model-invocation: true
|
|
7
6
|
context: fork
|
|
8
7
|
---
|
|
9
8
|
|
|
@@ -3,7 +3,6 @@ name: 5:review-code
|
|
|
3
3
|
description: Reviews code changes using Claude (built-in) or CodeRabbit CLI. Categorizes findings and saves them for /5:address-review-findings.
|
|
4
4
|
allowed-tools: Bash, Read, Glob, Grep, AskUserQuestion, Task, mcp__jetbrains__*
|
|
5
5
|
user-invocable: true
|
|
6
|
-
disable-model-invocation: true
|
|
7
6
|
model: sonnet
|
|
8
7
|
context: fork
|
|
9
8
|
---
|
package/src/commands/5/unlock.md
CHANGED
package/src/commands/5/update.md
CHANGED
|
@@ -3,7 +3,6 @@ name: 5:verify-implementation
|
|
|
3
3
|
description: Verifies a feature implementation is complete and working with multi-layer checks. Phase 4 of the 5-phase workflow.
|
|
4
4
|
allowed-tools: Read, Glob, Grep, Bash, Write, Task, AskUserQuestion
|
|
5
5
|
user-invocable: true
|
|
6
|
-
disable-model-invocation: true
|
|
7
6
|
model: sonnet
|
|
8
7
|
context: fork
|
|
9
8
|
---
|
package/src/hooks/plan-guard.js
CHANGED
|
@@ -20,8 +20,8 @@ process.stdin.on('end', () => {
|
|
|
20
20
|
const data = JSON.parse(input);
|
|
21
21
|
const toolName = data.tool_name || '';
|
|
22
22
|
|
|
23
|
-
// Short-circuit: only check Task, Write, Edit, and
|
|
24
|
-
if (toolName !== 'Task' && toolName !== 'Write' && toolName !== 'Edit' && toolName !== 'EnterPlanMode') {
|
|
23
|
+
// Short-circuit: only check Task, Write, Edit, EnterPlanMode, and Bash tools
|
|
24
|
+
if (toolName !== 'Task' && toolName !== 'Write' && toolName !== 'Edit' && toolName !== 'EnterPlanMode' && toolName !== 'Bash') {
|
|
25
25
|
process.exit(0);
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -43,13 +43,15 @@ process.stdin.on('end', () => {
|
|
|
43
43
|
// Planning mode enforcement
|
|
44
44
|
if (toolName === 'EnterPlanMode') {
|
|
45
45
|
const blockCount = incrementBlockCount(workspaceDir);
|
|
46
|
+
const phase = getPlanningPhase(workspaceDir);
|
|
46
47
|
const escalation = blockCount >= 3
|
|
47
|
-
? `
|
|
48
|
+
? ` CRITICAL: Block #${blockCount}. You have attempted to break out of planning ${blockCount} times. You MUST return to your current step in the Progress Checklist, complete your planning artifact, output the completion message, and STOP. Do NOT attempt any other action.`
|
|
48
49
|
: '';
|
|
49
50
|
process.stderr.write(
|
|
50
51
|
`BLOCKED: EnterPlanMode is not allowed during workflow planning phases. ` +
|
|
51
52
|
`The 5-phase workflow has its own planning process. ` +
|
|
52
|
-
`REDIRECT:
|
|
53
|
+
`REDIRECT: You are in ${phase || 'a planning phase'}. Return to your Progress Checklist. ` +
|
|
54
|
+
`Find the last "✓ Step N complete" you output, then continue with Step N+1. ` +
|
|
53
55
|
`Write your output to .5/features/{name}/ and output the completion message when done.${escalation}`
|
|
54
56
|
);
|
|
55
57
|
process.exit(2);
|
|
@@ -59,13 +61,15 @@ process.stdin.on('end', () => {
|
|
|
59
61
|
const agentType = toolInput.subagent_type || '';
|
|
60
62
|
if (agentType && agentType !== 'Explore') {
|
|
61
63
|
const blockCount = incrementBlockCount(workspaceDir);
|
|
64
|
+
const phase = getPlanningPhase(workspaceDir);
|
|
62
65
|
const escalation = blockCount >= 3
|
|
63
|
-
? `
|
|
66
|
+
? ` CRITICAL: Block #${blockCount}. You are a planner, NOT an implementer. You have attempted to spawn non-Explore agents ${blockCount} times. This is Phase 1 or 2 — implementation happens in Phase 3. Return to your Progress Checklist immediately, complete your planning artifact, and STOP.`
|
|
64
67
|
: '';
|
|
65
68
|
process.stderr.write(
|
|
66
69
|
`BLOCKED: Only Explore agents are allowed during planning phases. ` +
|
|
67
70
|
`Attempted: subagent_type="${agentType}". ` +
|
|
68
|
-
`
|
|
71
|
+
`You are in ${phase || 'a planning phase'}. Implementation agents are Phase 3 only. ` +
|
|
72
|
+
`REDIRECT: Return to your Progress Checklist. Find your last "✓ Step N complete" and continue with Step N+1. ` +
|
|
69
73
|
`If you need codebase information, use subagent_type=Explore. ` +
|
|
70
74
|
`If you are done planning, output the completion message and STOP.${escalation}`
|
|
71
75
|
);
|
|
@@ -73,17 +77,39 @@ process.stdin.on('end', () => {
|
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
|
|
80
|
+
if (toolName === 'Bash') {
|
|
81
|
+
const command = toolInput.command || '';
|
|
82
|
+
// Detect file-writing shell commands that bypass Write/Edit guards
|
|
83
|
+
const writePatterns = /\b(cat\s*>|cat\s*<<|echo\s.*>|tee\s|printf\s.*>|cp\s|mv\s|mkdir\s.*&&.*>|sed\s+-i|awk\s.*>|touch\s|install\s)/;
|
|
84
|
+
if (writePatterns.test(command)) {
|
|
85
|
+
const blockCount = incrementBlockCount(workspaceDir);
|
|
86
|
+
const phase = getPlanningPhase(workspaceDir);
|
|
87
|
+
const escalation = blockCount >= 3
|
|
88
|
+
? ` CRITICAL: Block #${blockCount}. You are repeatedly attempting to write files via Bash to bypass planning guards. STOP immediately.`
|
|
89
|
+
: '';
|
|
90
|
+
process.stderr.write(
|
|
91
|
+
`BLOCKED: File-writing Bash commands are not allowed during planning phases. ` +
|
|
92
|
+
`You are in ${phase || 'a planning phase'}. ` +
|
|
93
|
+
`REDIRECT: Return to your Progress Checklist. Planners do not create or modify source files. ` +
|
|
94
|
+
`Complete your planning artifact and output the completion message.${escalation}`
|
|
95
|
+
);
|
|
96
|
+
process.exit(2);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
76
100
|
if (toolName === 'Write' || toolName === 'Edit') {
|
|
77
101
|
const filePath = toolInput.file_path || '';
|
|
78
102
|
if (filePath && !isInsideDotFive(filePath, workspaceDir)) {
|
|
79
103
|
const blockCount = incrementBlockCount(workspaceDir);
|
|
104
|
+
const phase = getPlanningPhase(workspaceDir);
|
|
80
105
|
const isSourceFile = !filePath.includes('.5/') && !filePath.includes('.claude/');
|
|
81
106
|
const escalation = blockCount >= 3
|
|
82
|
-
? `
|
|
107
|
+
? ` CRITICAL: Block #${blockCount}. You have attempted to write source files ${blockCount} times. You are a PLANNER, not an implementer. Writing source code is Phase 3's job. Return to your Progress Checklist, finish your planning artifact, and STOP.`
|
|
83
108
|
: '';
|
|
84
109
|
const redirectMsg = isSourceFile
|
|
85
|
-
? `REDIRECT: You are in a planning phase. You may ONLY write to .5/features/. ` +
|
|
86
|
-
`Source file creation happens in Phase 3 (/5:implement-feature)
|
|
110
|
+
? `REDIRECT: You are in ${phase || 'a planning phase'}. You may ONLY write to .5/features/. ` +
|
|
111
|
+
`Source file creation happens in Phase 3 (/5:implement-feature). ` +
|
|
112
|
+
`Return to your Progress Checklist — find your last "✓ Step N complete" and continue with Step N+1.`
|
|
87
113
|
: `REDIRECT: The path "${filePath}" is outside the allowed .5/ directory. ` +
|
|
88
114
|
`Check your file path — you should be writing to .5/features/{name}/.`;
|
|
89
115
|
process.stderr.write(
|
|
@@ -179,6 +205,16 @@ function incrementBlockCount(workspaceDir) {
|
|
|
179
205
|
}
|
|
180
206
|
}
|
|
181
207
|
|
|
208
|
+
function getPlanningPhase(workspaceDir) {
|
|
209
|
+
const markerPath = path.join(workspaceDir, '.5', '.planning-active');
|
|
210
|
+
try {
|
|
211
|
+
const marker = JSON.parse(fs.readFileSync(markerPath, 'utf8'));
|
|
212
|
+
return marker.phase || null;
|
|
213
|
+
} catch (e) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
182
218
|
function isFeatureInImplementationMode(workspaceDir, featureName) {
|
|
183
219
|
// Check if this specific feature has a state.json (created in Phase 3)
|
|
184
220
|
const stateFile = path.join(
|
package/src/settings.json
CHANGED
|
@@ -76,13 +76,22 @@
|
|
|
76
76
|
### Chosen Approach: {Selected approach}
|
|
77
77
|
**Rationale:** {Why this approach was chosen}
|
|
78
78
|
|
|
79
|
-
##
|
|
79
|
+
## Decisions
|
|
80
|
+
|
|
81
|
+
<!-- Tag every Q&A with exactly one of: [DECIDED], [FLEXIBLE], [DEFERRED]
|
|
82
|
+
- [DECIDED]: Locked decision — Phase 2 planner and Phase 3 agents MUST honor exactly
|
|
83
|
+
- [FLEXIBLE]: Claude's discretion — planner chooses the best approach
|
|
84
|
+
- [DEFERRED]: Explicitly out of scope — planner MUST NOT include in the plan
|
|
85
|
+
-->
|
|
80
86
|
|
|
81
87
|
### Q1: {Question from collaboration phase}
|
|
82
|
-
**A:** {Answer from developer}
|
|
88
|
+
**A:** {Answer from developer} **[DECIDED]**
|
|
83
89
|
|
|
84
90
|
### Q2: {Question}
|
|
85
|
-
**A:** {Answer}
|
|
91
|
+
**A:** {Answer} **[FLEXIBLE]**
|
|
92
|
+
|
|
93
|
+
### Q3: {Question about a nice-to-have}
|
|
94
|
+
**A:** {Answer — let's skip this for now} **[DEFERRED]**
|
|
86
95
|
|
|
87
96
|
...
|
|
88
97
|
|
|
@@ -8,6 +8,8 @@ created: {ISO-timestamp}
|
|
|
8
8
|
<!-- PLAN RULES:
|
|
9
9
|
- This file is interpolated into agent prompts. Write it as instructions, not documentation.
|
|
10
10
|
- Description column: one action-oriented sentence per component
|
|
11
|
+
- Pattern File column: path to an existing file the executor MUST read before implementing (establishes conventions)
|
|
12
|
+
- Verify column: a concrete command or check the executor runs after implementing (grep pattern, test command, build check)
|
|
11
13
|
- Implementation Notes: reference existing files as patterns, no code snippets
|
|
12
14
|
- Components table must cover all functional requirements from feature.md
|
|
13
15
|
- Three test tiers: unit (always required for logic), integration (when framework detected + cross-module/DB/API), e2e (when framework detected + endpoints/UI flows)
|
|
@@ -22,16 +24,16 @@ created: {ISO-timestamp}
|
|
|
22
24
|
|
|
23
25
|
## Components
|
|
24
26
|
|
|
25
|
-
| Step | Component | Action | File | Description | Complexity |
|
|
26
|
-
|
|
27
|
-
| 1 | {name} | create | {path} | {what it does} | simple |
|
|
28
|
-
| 1 | {name} | create | {path} | {what it does} | simple |
|
|
29
|
-
| 2 | {name} | create | {path} | {what it does} | moderate |
|
|
30
|
-
| 2 | {name} | modify | {path} | {what to change} | moderate |
|
|
31
|
-
| 3 | {name} | create | {path} | {what it does} | complex |
|
|
32
|
-
| 4 | {name} unit tests | create | {test-path} | Test {what it tests} | moderate |
|
|
33
|
-
| 4 | {name} integration tests | create | {test-path} | Test {cross-module interaction} | moderate |
|
|
34
|
-
| 4 | {name} e2e tests | create | {test-path} | Test {user-facing flow end-to-end} | moderate |
|
|
27
|
+
| Step | Component | Action | File | Description | Pattern File | Verify | Complexity |
|
|
28
|
+
|------|-----------|--------|------|-------------|-------------|--------|------------|
|
|
29
|
+
| 1 | {name} | create | {path} | {what it does} | {existing file to read first} | {grep/test command} | simple |
|
|
30
|
+
| 1 | {name} | create | {path} | {what it does} | {pattern} | {verify} | simple |
|
|
31
|
+
| 2 | {name} | create | {path} | {what it does} | {pattern} | {verify} | moderate |
|
|
32
|
+
| 2 | {name} | modify | {path} | {what to change} | {target file} | {verify} | moderate |
|
|
33
|
+
| 3 | {name} | create | {path} | {what it does} | {pattern} | {verify} | complex |
|
|
34
|
+
| 4 | {name} unit tests | create | {test-path} | Test {what it tests} | {existing test} | {test command} | moderate |
|
|
35
|
+
| 4 | {name} integration tests | create | {test-path} | Test {cross-module interaction} | {existing test} | {test command} | moderate |
|
|
36
|
+
| 4 | {name} e2e tests | create | {test-path} | Test {user-facing flow end-to-end} | {existing test} | {test command} | moderate |
|
|
35
37
|
|
|
36
38
|
## Testing Strategy
|
|
37
39
|
|