5-phase-workflow 1.4.4 → 1.5.1

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/README.md CHANGED
@@ -126,10 +126,11 @@ All commands are available under the `/5:` namespace:
126
126
  | `/5:verify-implementation` | 4 | Verify completeness and correctness |
127
127
  | `/5:review-code` | 5 | AI-powered code review (CodeRabbit) |
128
128
  | `/5:quick-implement` | Fast | Streamlined workflow for small tasks |
129
+ | `/5:unlock` | Utility | Remove planning guard lock |
129
130
 
130
131
  ## Configuration
131
132
 
132
- The workflow is configured via `.claude/.5/config.json`. Here's an example:
133
+ The workflow is configured via `.5/config.json`. Here's an example:
133
134
 
134
135
  ```json
135
136
  {
@@ -181,7 +182,7 @@ Claude asks 5-10 clarifying questions to understand your requirements:
181
182
  - How will we verify it works?
182
183
  - Are there simpler alternatives?
183
184
 
184
- The output is a comprehensive feature spec at `.claude/.features/{ticket-id}.md`.
185
+ The output is a comprehensive feature spec at `.5/features/{ticket-id}/feature.md`.
185
186
 
186
187
  ### Phase 2: Implementation Planning
187
188
 
@@ -207,7 +208,7 @@ Claude executes the plan using specialized agents:
207
208
  - **step-verifier**: Compiles and checks for errors after each step
208
209
  - **integration-agent**: Wires components and registers routes
209
210
 
210
- State is tracked in `.claude/.implementations/state/{ticket-id}.json` for resumability.
211
+ State is tracked in `.5/features/{ticket-id}/state.json` for resumability.
211
212
 
212
213
  ### Phase 4: Verify Implementation
213
214
 
@@ -234,9 +235,12 @@ Automated review using CodeRabbit (if installed):
234
235
  After installation, your `.claude/` directory will contain:
235
236
 
236
237
  ```
238
+ .5/
239
+ ├── config.json # Project configuration
240
+ ├── version.json # Version tracking
241
+ └── features/ # Feature tracking
242
+
237
243
  .claude/
238
- ├── .5/
239
- │ └── config.json # Project configuration
240
244
  ├── commands/5/ # Workflow commands
241
245
  │ ├── plan-feature.md
242
246
  │ ├── plan-implementation.md
@@ -245,13 +249,17 @@ After installation, your `.claude/` directory will contain:
245
249
  │ ├── review-code.md
246
250
  │ ├── discuss-feature.md
247
251
  │ ├── quick-implement.md
248
- └── configure.md
252
+ ├── configure.md
253
+ │ └── unlock.md
249
254
  ├── skills/ # Atomic operations
250
255
  │ ├── build-project/
251
256
  │ ├── run-tests/
252
257
  │ └── generate-readme/
253
258
  ├── hooks/
254
- └── statusline.js # Status line integration
259
+ ├── statusline.js # Status line integration
260
+ │ ├── check-updates.js # Update notifications
261
+ │ ├── plan-guard.js # Planning phase edit guard
262
+ │ └── config-guard.js # Configuration guard
255
263
  └── settings.json # Claude Code settings
256
264
  ```
257
265
 
@@ -293,7 +301,7 @@ After installation, your `.claude/` directory will contain:
293
301
 
294
302
  1. Run `/5:configure` to verify configuration
295
303
  2. Test commands manually in terminal
296
- 3. Update `.claude/.5/config.json` with correct commands
304
+ 3. Update `.5/config.json` with correct commands
297
305
 
298
306
  ### "Cannot find project type"
299
307
 
@@ -303,7 +311,7 @@ The auto-detection failed. Run `/5:configure` and manually select your project t
303
311
 
304
312
  If implementation gets stuck:
305
313
 
306
- 1. Check `.claude/.implementations/state/{ticket-id}.json`
314
+ 1. Check `.5/features/{ticket-id}/state.json`
307
315
  2. Note the `currentStep` value
308
316
  3. Run `/5:implement-feature` again - it will resume from that step
309
317
 
@@ -338,7 +346,7 @@ npx 5-phase-workflow
338
346
  ```
339
347
 
340
348
  **Note:** During updates:
341
- - Config files in `.claude/.5/` are preserved
349
+ - Config files in `.5/` are preserved
342
350
  - User-created commands, agents, skills, hooks, and templates are preserved
343
351
  - Only workflow-managed files are updated
344
352
 
package/bin/install.js CHANGED
@@ -35,8 +35,8 @@ function compareVersions(v1, v2) {
35
35
  }
36
36
 
37
37
  // Get installed version from .5/version.json
38
- function getInstalledVersion(targetPath) {
39
- const versionFile = path.join(targetPath, '.5', 'version.json');
38
+ function getInstalledVersion(isGlobal) {
39
+ const versionFile = path.join(getDataPath(isGlobal), 'version.json');
40
40
  if (!fs.existsSync(versionFile)) return null;
41
41
 
42
42
  try {
@@ -55,13 +55,13 @@ function getPackageVersion() {
55
55
  }
56
56
 
57
57
  // Get full version info
58
- function getVersionInfo(targetPath) {
58
+ function getVersionInfo(targetPath, isGlobal) {
59
59
  const exists = checkExistingInstallation(targetPath);
60
60
  if (!exists) {
61
61
  return { exists: false };
62
62
  }
63
63
 
64
- const installed = getInstalledVersion(targetPath);
64
+ const installed = getInstalledVersion(isGlobal);
65
65
  const available = getPackageVersion();
66
66
 
67
67
  if (!installed) {
@@ -139,7 +139,7 @@ Examples:
139
139
  `);
140
140
  }
141
141
 
142
- // Get installation target path
142
+ // Get installation target path (.claude/ directory)
143
143
  function getTargetPath(isGlobal) {
144
144
  if (isGlobal) {
145
145
  const homeDir = process.env.HOME || process.env.USERPROFILE;
@@ -148,6 +148,60 @@ function getTargetPath(isGlobal) {
148
148
  return path.join(process.cwd(), '.claude');
149
149
  }
150
150
 
151
+ // Get data path (.5/ directory for config, version, features)
152
+ // Local installs: <project>/.5 (project root)
153
+ // Global installs: ~/.claude/.5 (alongside global install)
154
+ function getDataPath(isGlobal) {
155
+ if (isGlobal) {
156
+ return path.join(getTargetPath(true), '.5');
157
+ }
158
+ return path.join(process.cwd(), '.5');
159
+ }
160
+
161
+ // Migrate data from old .claude/.5/ to new .5/ location (local installs only)
162
+ // This runs during upgrades so existing users don't lose config/features/version data.
163
+ function migrateDataDir(isGlobal) {
164
+ // Global installs: old and new paths are both ~/.claude/.5 — no migration needed
165
+ if (isGlobal) return;
166
+
167
+ const oldDir = path.join(process.cwd(), '.claude', '.5');
168
+ const newDir = getDataPath(false); // <project>/.5
169
+
170
+ if (!fs.existsSync(oldDir)) return;
171
+
172
+ // If new dir doesn't exist, move everything over
173
+ if (!fs.existsSync(newDir)) {
174
+ fs.mkdirSync(newDir, { recursive: true });
175
+ }
176
+
177
+ // Copy all files/dirs from old to new (skip files that already exist in new)
178
+ copyDirMerge(oldDir, newDir);
179
+
180
+ // Remove old directory
181
+ removeDir(oldDir);
182
+ log.success('Migrated .claude/.5/ → .5/');
183
+ }
184
+
185
+ // Copy directory recursively, skipping files that already exist at destination
186
+ function copyDirMerge(src, dest) {
187
+ if (!fs.existsSync(dest)) {
188
+ fs.mkdirSync(dest, { recursive: true });
189
+ }
190
+
191
+ const entries = fs.readdirSync(src, { withFileTypes: true });
192
+
193
+ for (const entry of entries) {
194
+ const srcPath = path.join(src, entry.name);
195
+ const destPath = path.join(dest, entry.name);
196
+
197
+ if (entry.isDirectory()) {
198
+ copyDirMerge(srcPath, destPath);
199
+ } else if (!fs.existsSync(destPath)) {
200
+ fs.copyFileSync(srcPath, destPath);
201
+ }
202
+ }
203
+ }
204
+
151
205
  // Get source path (package installation directory)
152
206
  function getSourcePath() {
153
207
  // When installed via npm, __dirname is <install-location>/bin
@@ -200,8 +254,12 @@ function getWorkflowManagedFiles() {
200
254
  // Commands: only the 5/ namespace
201
255
  commands: ['5'],
202
256
 
203
- // Agents: none - instructions are now embedded inline in commands
204
- agents: [],
257
+ // Agents: separate agent files referenced by commands via agent: frontmatter
258
+ agents: [
259
+ 'feature-planner.md',
260
+ 'implementation-planner.md',
261
+ 'component-executor.md'
262
+ ],
205
263
 
206
264
  // Skills: specific skill directories
207
265
  skills: [
@@ -256,7 +314,7 @@ function selectiveUpdate(targetPath, sourcePath) {
256
314
  log.success('Updated commands/5/');
257
315
  }
258
316
 
259
- // Update specific agents (currently none instructions are embedded inline in commands)
317
+ // Update specific agents (referenced by commands via agent: frontmatter)
260
318
  if (managed.agents.length > 0) {
261
319
  const agentsSrc = path.join(sourcePath, 'agents');
262
320
  const agentsDest = path.join(targetPath, 'agents');
@@ -328,12 +386,12 @@ function selectiveUpdate(targetPath, sourcePath) {
328
386
  }
329
387
 
330
388
  // Initialize version.json after successful install
331
- function initializeVersionJson(targetPath, isGlobal) {
332
- const configDir = path.join(targetPath, '.5');
333
- const versionFile = path.join(configDir, 'version.json');
389
+ function initializeVersionJson(isGlobal) {
390
+ const dataDir = getDataPath(isGlobal);
391
+ const versionFile = path.join(dataDir, 'version.json');
334
392
 
335
- if (!fs.existsSync(configDir)) {
336
- fs.mkdirSync(configDir, { recursive: true });
393
+ if (!fs.existsSync(dataDir)) {
394
+ fs.mkdirSync(dataDir, { recursive: true });
337
395
  }
338
396
 
339
397
  const version = getPackageVersion();
@@ -427,7 +485,7 @@ function checkExistingInstallation(targetPath) {
427
485
  }
428
486
 
429
487
  // Helper to show commands
430
- function showCommandsHelp(targetPath) {
488
+ function showCommandsHelp(isGlobal) {
431
489
  log.info('Available commands:');
432
490
  log.info(' /5:plan-feature - Start feature planning (Phase 1)');
433
491
  log.info(' /5:plan-implementation - Create implementation plan (Phase 2)');
@@ -435,8 +493,9 @@ function showCommandsHelp(targetPath) {
435
493
  log.info(' /5:verify-implementation - Verify implementation (Phase 4)');
436
494
  log.info(' /5:review-code - Code review (Phase 5)');
437
495
  log.info(' /5:configure - Interactive project setup');
496
+ log.info(' /5:unlock - Remove planning guard lock');
438
497
  log.info('');
439
- log.info(`Config file: ${path.join(targetPath, '.5', 'config.json')}`);
498
+ log.info(`Config file: ${path.join(getDataPath(isGlobal), 'config.json')}`);
440
499
  }
441
500
 
442
501
  // Fresh installation
@@ -463,7 +522,7 @@ function performFreshInstall(targetPath, sourcePath, isGlobal) {
463
522
  mergeSettings(targetPath, sourcePath);
464
523
 
465
524
  // Initialize version tracking
466
- initializeVersionJson(targetPath, isGlobal);
525
+ initializeVersionJson(isGlobal);
467
526
 
468
527
  log.header('Installation Complete!');
469
528
  log.info('');
@@ -477,10 +536,10 @@ function performFreshInstall(targetPath, sourcePath, isGlobal) {
477
536
  log.info(' • Create project-specific skills');
478
537
  log.info('');
479
538
 
480
- showCommandsHelp(targetPath);
539
+ showCommandsHelp(isGlobal);
481
540
  }
482
541
 
483
- // Perform update (preserves .5/ directory and user-created files)
542
+ // Perform update (preserves user-created files, updates .5/ data directory)
484
543
  function performUpdate(targetPath, sourcePath, isGlobal, versionInfo) {
485
544
  log.header(`Updating from ${versionInfo.installed || 'legacy'} to ${versionInfo.available}`);
486
545
  log.info('Preserving user-created commands, agents, skills, and hooks');
@@ -492,8 +551,8 @@ function performUpdate(targetPath, sourcePath, isGlobal, versionInfo) {
492
551
  mergeSettings(targetPath, sourcePath);
493
552
 
494
553
  // Update version.json
495
- const configDir = path.join(targetPath, '.5');
496
- const versionFile = path.join(configDir, 'version.json');
554
+ const dataDir = getDataPath(isGlobal);
555
+ const versionFile = path.join(dataDir, 'version.json');
497
556
 
498
557
  let versionData;
499
558
  if (fs.existsSync(versionFile)) {
@@ -511,22 +570,22 @@ function performUpdate(targetPath, sourcePath, isGlobal, versionInfo) {
511
570
  versionData.installedVersion = versionInfo.available;
512
571
  versionData.lastUpdated = new Date().toISOString();
513
572
 
514
- if (!fs.existsSync(configDir)) {
515
- fs.mkdirSync(configDir, { recursive: true });
573
+ if (!fs.existsSync(dataDir)) {
574
+ fs.mkdirSync(dataDir, { recursive: true });
516
575
  }
517
576
  fs.writeFileSync(versionFile, JSON.stringify(versionData, null, 2));
518
577
 
519
578
  // Create features directory if it doesn't exist
520
- const featuresDir = path.join(configDir, 'features');
579
+ const featuresDir = path.join(dataDir, 'features');
521
580
  if (!fs.existsSync(featuresDir)) {
522
581
  fs.mkdirSync(featuresDir, { recursive: true });
523
- log.info('📁 Feature folders now nest under .5/features/');
524
- log.info('📋 See RELEASE_NOTES.md for migration if you have in-progress features');
582
+ log.info('Feature folders nest under .5/features/');
583
+ log.info('See RELEASE_NOTES.md for migration if you have in-progress features');
525
584
  }
526
585
 
527
586
  log.header('Update Complete!');
528
587
  log.success(`Now running version ${versionInfo.available}`);
529
- showCommandsHelp(targetPath);
588
+ showCommandsHelp(isGlobal);
530
589
  }
531
590
 
532
591
  // Perform installation
@@ -538,8 +597,11 @@ function install(isGlobal, forceUpgrade = false) {
538
597
  log.info(`Target: ${targetPath}`);
539
598
  log.info(`Source: ${sourcePath}`);
540
599
 
600
+ // Migrate data from old .claude/.5/ to new .5/ location
601
+ migrateDataDir(isGlobal);
602
+
541
603
  // Check for existing installation and version
542
- const versionInfo = getVersionInfo(targetPath);
604
+ const versionInfo = getVersionInfo(targetPath, isGlobal);
543
605
 
544
606
  if (versionInfo.exists) {
545
607
  if (versionInfo.legacy) {
@@ -603,6 +665,15 @@ function uninstall() {
603
665
  log.success('Removed commands/5/');
604
666
  }
605
667
 
668
+ // Remove only workflow-managed agents
669
+ for (const agent of managed.agents) {
670
+ const agentPath = path.join(targetPath, 'agents', agent);
671
+ if (fs.existsSync(agentPath)) {
672
+ fs.unlinkSync(agentPath);
673
+ }
674
+ }
675
+ log.success('Removed workflow agents (preserved user-created agents)');
676
+
606
677
  // Remove only workflow-managed skills
607
678
  for (const skill of managed.skills) {
608
679
  const skillPath = path.join(targetPath, 'skills', skill);
@@ -630,11 +701,18 @@ function uninstall() {
630
701
  }
631
702
  log.success('Removed workflow templates (preserved user-created templates)');
632
703
 
633
- // Remove config
634
- const configDir = path.join(targetPath, '.5');
635
- if (fs.existsSync(configDir)) {
636
- removeDir(configDir);
637
- log.success('Removed .5/ config directory');
704
+ // Remove data directory (.5/)
705
+ const dataDir = getDataPath(false);
706
+ if (fs.existsSync(dataDir)) {
707
+ removeDir(dataDir);
708
+ log.success('Removed .5/ data directory');
709
+ }
710
+
711
+ // Also clean up old .claude/.5/ if it still exists
712
+ const oldDataDir = path.join(targetPath, '.5');
713
+ if (fs.existsSync(oldDataDir)) {
714
+ removeDir(oldDataDir);
715
+ log.success('Removed legacy .claude/.5/ directory');
638
716
  }
639
717
 
640
718
  log.header('Uninstallation Complete!');
@@ -651,7 +729,8 @@ function main() {
651
729
 
652
730
  if (options.check) {
653
731
  const targetPath = getTargetPath(options.global);
654
- const versionInfo = getVersionInfo(targetPath);
732
+ migrateDataDir(options.global);
733
+ const versionInfo = getVersionInfo(targetPath, options.global);
655
734
 
656
735
  if (!versionInfo.exists) {
657
736
  log.info('Not installed');
@@ -72,7 +72,7 @@ The installer copies workflow files to `.claude/` directory. **It does NOT creat
72
72
  4. **Phase 4** (`/5:verify-implementation`): Verifies configuration
73
73
 
74
74
  After completing these steps, you have:
75
- - `.claude/.5/config.json` with your project settings
75
+ - `.5/config.json` with your project settings
76
76
  - `CLAUDE.md` with comprehensive project documentation
77
77
  - `.5/STRUCTURE.md`, `.5/STACK.md`, etc. with modular documentation
78
78
  - Project-specific skills in `.claude/skills/`
@@ -295,7 +295,7 @@ Map feature requirements to technical components, skills, and dependency steps.
295
295
  - **Step 2 (Logic)**: Business logic, services, handlers (sequential if needed)
296
296
  - **Step 3 (Integration)**: API routes, wiring, tests (sequential for integration)
297
297
 
298
- Note: Step count and organization is configurable in `.claude/.5/config.json`
298
+ Note: Step count and organization is configurable in `.5/config.json`
299
299
 
300
300
  6. **Implementation Plan Creation**: Claude writes an **atomic plan structure** to:
301
301
  ```
@@ -997,7 +997,7 @@ If working on multiple features:
997
997
 
998
998
  ## Configuring for Different Tech Stacks
999
999
 
1000
- The 5-phase workflow is designed to work with any technology stack. Configuration is stored in `.claude/.5/config.json` and can be customized using the `/5:configure` command.
1000
+ The 5-phase workflow is designed to work with any technology stack. Configuration is stored in `.5/config.json` and can be customized using the `/5:configure` command.
1001
1001
 
1002
1002
  ### Quick Setup
1003
1003
 
@@ -1096,7 +1096,7 @@ You can override auto-detected values in the config file.
1096
1096
 
1097
1097
  ### Further Customization
1098
1098
 
1099
- See the `/5:configure` command for interactive configuration, or manually edit `.claude/.5/config.json` to customize:
1099
+ See the `/5:configure` command for interactive configuration, or manually edit `.5/config.json` to customize:
1100
1100
  - Ticket ID patterns
1101
1101
  - Branch naming conventions
1102
1102
  - Build and test commands
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "5-phase-workflow",
3
- "version": "1.4.4",
3
+ "version": "1.5.1",
4
4
  "description": "A 5-phase feature development workflow for Claude Code",
5
5
  "bin": {
6
6
  "5-phase-workflow": "bin/install.js"
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: component-executor
3
+ description: Implements individual components by following existing codebase patterns. Spawned by /5:implement-feature orchestrator.
4
+ tools: Read, Write, Edit, Glob, Grep, Bash, context7
5
+ ---
6
+
7
+ <role>
8
+ You are a Component Executor. You implement individual components for a feature.
9
+ You follow existing codebase patterns. You do NOT deviate from the plan.
10
+ </role>
11
+
12
+ <process>
13
+ ## Implementation Process
14
+
15
+ 1. **Read the plan context** provided in your prompt (feature name, components, implementation notes)
16
+ 2. **For creating files:**
17
+ - Find a similar existing file via Glob
18
+ - Read that file to understand the pattern
19
+ - Create the new file following the same conventions
20
+ 3. **For modifying files:**
21
+ - Read the target file
22
+ - Apply the described change via Edit
23
+ - Verify the change is correct
24
+ 4. **Verify** each file exists after changes
25
+ </process>
26
+
27
+ <output-format>
28
+ When done, output your result in this exact format:
29
+
30
+ ---RESULT---
31
+ STATUS: success | failed
32
+ FILES_CREATED: [comma-separated paths]
33
+ FILES_MODIFIED: [comma-separated paths]
34
+ ERROR: none | {error description}
35
+ ---END---
36
+ </output-format>
37
+
38
+ <deviation-rules>
39
+ ## Deviation Rules
40
+
41
+ You WILL discover unplanned work. Handle as follows:
42
+
43
+ | Trigger | Action | Permission |
44
+ |---------|--------|------------|
45
+ | Bug/error in existing code | Fix → verify → note in result | Auto |
46
+ | Missing import/dependency | Add → verify → note in result | Auto |
47
+ | Architectural change needed | STOP → report in ERROR field | Ask user |
48
+ </deviation-rules>
@@ -0,0 +1,65 @@
1
+ ---
2
+ name: feature-planner
3
+ description: Creates feature specifications from requirements through structured Q&A. Planning-only agent — never implements.
4
+ tools: Read, Write, Task, AskUserQuestion
5
+ ---
6
+
7
+ <role>
8
+ You are a Feature Planner. You create feature specifications.
9
+ You do NOT implement. You write NO code.
10
+ You spawn ONLY Explore agents (subagent_type=Explore).
11
+ You write ONLY to .5/features/{name}/feature.md.
12
+ After creating the spec, you are DONE.
13
+ </role>
14
+
15
+ <constraints>
16
+ HARD CONSTRAINTS — violations waste tokens and get blocked by plan-guard:
17
+ - NEVER write code, pseudo-code, or implementation snippets in any output
18
+ - NEVER describe HOW something will be implemented (file contents, signatures, class structures)
19
+ - NEVER spawn Task agents with subagent_type other than Explore
20
+ - NEVER write to any file except .5/features/{name}/feature.md and .5/.planning-active
21
+ - The feature spec describes WHAT and WHY, never HOW
22
+ - If you feel the urge to implement, STOP and ask a clarifying question instead
23
+ - Your output is a SPECIFICATION, not a design document. No code. No file layouts. No API shapes.
24
+ </constraints>
25
+
26
+ <write-rules>
27
+ You have access to the Write tool for exactly these files:
28
+ 1. `.5/.planning-active` — Step 0 only
29
+ 2. `.5/features/{name}/feature.md` — Step 5 only
30
+ Any other Write target WILL be blocked by the plan-guard hook. Do not attempt it.
31
+ </write-rules>
32
+
33
+ <output-format>
34
+ Use the template structure from `.claude/templates/workflow/FEATURE-SPEC.md`.
35
+
36
+ **Content rules for feature.md:**
37
+ - Requirements use natural language ("The system shall..."), NOT code
38
+ - Affected Components lists module/domain names, NOT file paths
39
+ - NO code snippets, NO pseudo-code, NO type definitions
40
+ - Entity definitions describe data CONCEPTS, not DB schemas or TypeScript interfaces
41
+ - Acceptance criteria describe observable behavior, NOT test code
42
+ </output-format>
43
+
44
+ <question-strategy>
45
+ Ask 5-10 clarifying questions using AskUserQuestion.
46
+
47
+ **Rules:**
48
+ - ONE question at a time — wait for answer before next
49
+ - Use sub-agent findings to ask informed questions
50
+ - At least 5 questions before creating the spec
51
+ - Provide 2-4 options where meaningful
52
+
53
+ **Categories:** Requirements clarity, scope boundaries, edge cases, performance expectations,
54
+ testing strategy, integration points (from findings), alternative approaches, complexity trade-offs.
55
+
56
+ **Challenge assumptions:** "Is this the simplest solution?", "Could we reuse existing X?",
57
+ "What happens when Y fails?"
58
+ </question-strategy>
59
+
60
+ <constraints>
61
+ REMINDER: You are a Feature Planner. You wrote a specification. You did NOT implement.
62
+ If you wrote any code, file paths to create, class names, or function signatures in feature.md,
63
+ you have violated your role.
64
+ The feature spec contains WHAT and WHY. Phase 2 handles WHERE. Phase 3 handles HOW.
65
+ </constraints>
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: implementation-planner
3
+ description: Creates structured implementation plans (components tables) from feature specs. Planning-only agent — never implements.
4
+ tools: Read, Write, Task, AskUserQuestion
5
+ ---
6
+
7
+ <role>
8
+ You are an Implementation Planner. You create implementation plans.
9
+ You do NOT implement. You write NO code.
10
+ You spawn ONLY Explore agents (subagent_type=Explore).
11
+ You write ONLY to .5/features/{name}/plan.md.
12
+ After creating the plan, you are DONE.
13
+ </role>
14
+
15
+ <constraints>
16
+ HARD CONSTRAINTS — violations waste tokens and get blocked by plan-guard:
17
+ - NEVER write code, pseudo-code, or implementation snippets
18
+ - NEVER create source files — you create ONE file: plan.md
19
+ - NEVER spawn Task agents with subagent_type other than Explore
20
+ - The plan describes WHAT to build and WHERE. Agents figure out HOW by reading existing code.
21
+ - Each component in the table gets: name, action, file path, one-sentence description, complexity
22
+ - Implementation Notes reference EXISTING pattern files, not new code
23
+ - If a component needs more than one sentence to describe, split it into multiple components
24
+ </constraints>
25
+
26
+ <write-rules>
27
+ You have access to the Write tool for exactly these files:
28
+ 1. `.5/.planning-active` — Step 0 only
29
+ 2. `.5/features/{name}/plan.md` — Step 5 only
30
+ Any other Write target WILL be blocked by the plan-guard hook. Do not attempt it.
31
+ </write-rules>
32
+
33
+ <plans-are-prompts>
34
+ **Key principle: Plans are prompts, not documentation.**
35
+ The plan.md you write will be interpolated directly into agent prompts during Phase 3.
36
+ - The Description column becomes the agent's task instruction
37
+ - The File column tells the agent where to work
38
+ - Implementation Notes become the agent's context
39
+ - Keep descriptions action-oriented: "Create X with Y" not "X needs to support Y"
40
+ </plans-are-prompts>
41
+
42
+ <output-format>
43
+ Plan format — a single Markdown file with YAML frontmatter:
44
+
45
+ | Step | Component | Action | File | Description | Complexity |
46
+ |------|-----------|--------|------|-------------|------------|
47
+
48
+ **Complexity guide:**
49
+ - **simple** → haiku: Pattern-following, type defs, simple CRUD
50
+ - **moderate** → haiku/sonnet: Services with logic, multi-pattern files, modifications
51
+ - **complex** → sonnet: Integration points, complex rules, significant refactoring
52
+ </output-format>
53
+
54
+ <self-check>
55
+ After writing plan.md, read it back and verify:
56
+
57
+ 1. **Format:** Every row in the Components table has all 6 columns filled
58
+ 2. **No code:** Implementation Notes contain ONLY references to existing files and business rules
59
+ 3. **Scope:** Every component traces back to a requirement in feature.md — if not, remove it
60
+ 4. **Completeness:** Every functional requirement from feature.md has at least one component
61
+ 5. **Description length:** Each Description cell is one sentence. If longer, split the component.
62
+
63
+ Output the verification result before the completion message.
64
+ </self-check>
65
+
66
+ <constraints>
67
+ REMINDER: You are an Implementation Planner. You wrote a components table. You did NOT implement.
68
+ If you wrote any code, pseudo-code, or implementation snippets in plan.md, you have violated your role.
69
+ The plan describes WHAT and WHERE. Phase 3 agents handle HOW.
70
+ </constraints>
@@ -26,7 +26,7 @@ After running this command, proceed through the standard phases:
26
26
  Your job in this command:
27
27
  ✅ Analyze project (detect type, build commands, etc.)
28
28
  ✅ Gather user preferences via questions
29
- ✅ Write `.claude/.5/config.json` directly
29
+ ✅ Write `.5/config.json` directly
30
30
  ✅ Create feature spec at `.5/features/CONFIGURE/feature.md` for remaining work
31
31
  ✅ Tell user to run /5:plan-implementation CONFIGURE
32
32
 
@@ -49,7 +49,7 @@ Perform all detection silently, collecting results for Step 2.
49
49
 
50
50
  **1a. Check for existing config:**
51
51
  ```bash
52
- if [ -f ".claude/.5/config.json" ]; then
52
+ if [ -f ".5/config.json" ]; then
53
53
  # Config exists - will ask user in Step 2 what to do
54
54
  config_exists=true
55
55
  else
@@ -155,7 +155,7 @@ For each command found: record exact syntax, note variants (e.g., `test:unit`, `
155
155
 
156
156
  If "Start fresh" selected:
157
157
  - Confirm: "This will delete existing config. Are you sure?"
158
- - If confirmed: delete .claude/.5/config.json
158
+ - If confirmed: delete .5/config.json
159
159
  - Proceed to detection and questions
160
160
 
161
161
  If "Update existing configuration":
@@ -281,14 +281,14 @@ If no patterns/commands detected:
281
281
 
282
282
  ### Step 2.5: Write config.json
283
283
 
284
- Using the values gathered from Steps 1 and 2, write `.claude/.5/config.json` directly.
284
+ Using the values gathered from Steps 1 and 2, write `.5/config.json` directly.
285
285
 
286
286
  **If "Update existing" flow:** Read current config, merge updated values.
287
287
  **If "Start fresh" or new install:** Write new config.
288
288
 
289
289
  **Ensure directory exists:**
290
290
  ```bash
291
- mkdir -p .claude/.5
291
+ mkdir -p .5
292
292
  ```
293
293
 
294
294
  **Schema:**
@@ -413,7 +413,7 @@ Include only patterns/commands where user selected "Generate".
413
413
 
414
414
  Tell the user:
415
415
 
416
- 1. "Configuration saved to `.claude/.5/config.json`"
416
+ 1. "Configuration saved to `.5/config.json`"
417
417
  2. "Configuration feature planned at `.5/features/CONFIGURE/feature.md`"
418
418
  3. "Next steps:"
419
419
  - "Run `/clear` to reset context"
@@ -39,7 +39,7 @@ Parse:
39
39
 
40
40
  If the plan doesn't exist, tell the user to run `/5:plan-implementation` first.
41
41
 
42
- Also read `.claude/.5/config.json` and extract:
42
+ Also read `.5/config.json` and extract:
43
43
  - `git.autoCommit` (boolean, default `false`)
44
44
  - `git.commitMessage.pattern` (string, default `{ticket-id} {short-description}`)
45
45
 
@@ -59,6 +59,12 @@ Create `.5/features/{feature-name}/state.json`:
59
59
  }
60
60
  ```
61
61
 
62
+ Then remove the planning guard marker (planning is over, implementation is starting):
63
+
64
+ ```bash
65
+ rm -f .5/.planning-active
66
+ ```
67
+
62
68
  ### Step 3: Execute Steps
63
69
 
64
70
  Group components by step number from the plan. For each step:
@@ -89,7 +95,7 @@ Task tool call:
89
95
  model: {based on complexity}
90
96
  description: "{Action} {component-name} for {feature-name}"
91
97
  prompt: |
92
- Implement component(s) for a feature.
98
+ First, read ~/.claude/agents/component-executor.md for your role and instructions.
93
99
 
94
100
  ## Feature: {feature-name}
95
101
  ## Components
@@ -97,21 +103,10 @@ Task tool call:
97
103
 
98
104
  ## Implementation Notes
99
105
  {relevant notes from plan}
100
-
101
- ## Process
102
- - Creating: Find similar file via Glob, read pattern, create new file following it
103
- - Modifying: Read file, apply described change via Edit
104
- - Verify each file exists after changes
105
-
106
- ## Output
107
- ---RESULT---
108
- STATUS: success | failed
109
- FILES_CREATED: [comma-separated paths]
110
- FILES_MODIFIED: [comma-separated paths]
111
- ERROR: none | {error description}
112
- ---END---
113
106
  ```
114
107
 
108
+ 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.
109
+
115
110
  **3d. Process results**
116
111
 
117
112
  Collect results from all agents (parallel or sequential). Parse the `---RESULT---` block from each agent's response. For each:
@@ -1,19 +1,12 @@
1
1
  ---
2
2
  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
+ agent: feature-planner
4
5
  allowed-tools: Read, Write, Task, AskUserQuestion
5
6
  context: fork
6
7
  user-invocable: true
7
8
  ---
8
9
 
9
- <role>
10
- You are a Feature Planner. You create feature specifications.
11
- You do NOT implement. You write NO code.
12
- You spawn ONLY Explore agents (subagent_type=Explore).
13
- You write ONLY to .5/features/{name}/feature.md.
14
- After creating the spec, you are DONE.
15
- </role>
16
-
17
10
  # Plan Feature (Phase 1)
18
11
 
19
12
  ## Common Feature Types
@@ -37,6 +30,19 @@ After creating the spec, you are DONE.
37
30
 
38
31
  ## Process
39
32
 
33
+ ### Step 0: Activate Planning Guard
34
+
35
+ Write the planning guard marker to `.5/.planning-active` using the Write tool:
36
+
37
+ ```json
38
+ {
39
+ "phase": "plan-feature",
40
+ "startedAt": "{ISO-timestamp}"
41
+ }
42
+ ```
43
+
44
+ This activates the plan-guard hook which prevents accidental source file edits during planning. The marker is removed automatically when implementation starts (`/5:implement-feature`), expires after 4 hours, or can be cleared manually with `/5:unlock`.
45
+
40
46
  ### Step 1: Gather Feature Description
41
47
 
42
48
  Ask the developer for the feature description using AskUserQuestion:
@@ -90,17 +96,7 @@ Wait for the sub-agent to return before proceeding.
90
96
 
91
97
  ### Step 4: Intensive Q&A (5-10 Questions, One at a Time)
92
98
 
93
- After receiving the exploration report, ask 5-10 clarifying questions using AskUserQuestion.
94
-
95
- **Rules:**
96
- - ONE question at a time — wait for answer before next
97
- - Use sub-agent findings to ask informed questions
98
- - At least 5 questions before creating the spec
99
- - Provide 2-4 options where meaningful
100
-
101
- **Question categories:** Requirements clarity, scope boundaries, edge cases, performance expectations, testing strategy, integration points (from findings), alternative approaches (from findings), complexity trade-offs.
102
-
103
- **Challenge assumptions:** "Is this the simplest solution?", "Could we reuse existing X?" (reference findings), "What happens when Y fails?"
99
+ Follow the `<question-strategy>` defined in your agent file.
104
100
 
105
101
  **Optional re-exploration:** If the user mentions components not covered in the initial report, spawn a targeted Explore agent:
106
102
 
@@ -111,13 +107,25 @@ Targeted exploration for feature planning.
111
107
  **READ-ONLY.** Only use Read, Glob, and Grep tools.
112
108
  ```
113
109
 
110
+ ### Step 4b: Pre-Write Checkpoint
111
+
112
+ Before writing the feature spec, verify:
113
+ 1. You asked at least 5 questions and received answers
114
+ 2. You have NOT written any code or implementation details
115
+ 3. You can summarize the feature in 1-2 sentences WITHOUT mentioning files, classes, or functions
116
+ 4. The feature spec will contain ONLY: requirements, constraints, acceptance criteria, Q&A
117
+
118
+ If you have fewer than 5 Q&A pairs, go back to Step 4 and ask more questions.
119
+
114
120
  ### Step 5: Create Feature Specification
115
121
 
116
122
  Determine a feature name: short, kebab-case (e.g., "add-emergency-schedule").
117
123
 
118
124
  Write to `.5/features/{TICKET-ID}-{description}/feature.md` using Write tool.
119
125
 
120
- Use the template structure from `.claude/templates/workflow/FEATURE-SPEC.md`. Populate all sections:
126
+ Follow the `<output-format>` and `<write-rules>` defined in your agent file.
127
+
128
+ Populate all sections:
121
129
  - Ticket ID & Summary
122
130
  - Problem Statement
123
131
  - Requirements (functional and non-functional)
@@ -1,19 +1,12 @@
1
1
  ---
2
2
  name: 5:plan-implementation
3
3
  description: Creates an implementation plan from a feature spec. Phase 2 of the 5-phase workflow.
4
+ agent: implementation-planner
4
5
  allowed-tools: Read, Write, Task, AskUserQuestion
5
6
  context: fork
6
7
  user-invocable: true
7
8
  ---
8
9
 
9
- <role>
10
- You are an Implementation Planner. You create implementation plans.
11
- You do NOT implement. You write NO code.
12
- You spawn ONLY Explore agents (subagent_type=Explore).
13
- You write ONLY to .5/features/{name}/plan.md.
14
- After creating the plan, you are DONE.
15
- </role>
16
-
17
10
  # Plan Implementation (Phase 2)
18
11
 
19
12
  ## Example Workflow
@@ -66,6 +59,20 @@ Add emergency schedule tracking to products with date validation.
66
59
 
67
60
  ## Process
68
61
 
62
+ ### Step 0: Activate Planning Guard
63
+
64
+ Write (or refresh) the planning guard marker to `.5/.planning-active` using the Write tool:
65
+
66
+ ```json
67
+ {
68
+ "phase": "plan-implementation",
69
+ "feature": "{feature-name}",
70
+ "startedAt": "{ISO-timestamp}"
71
+ }
72
+ ```
73
+
74
+ This activates (or refreshes) the plan-guard hook which prevents accidental source file edits during planning. The marker is removed automatically when implementation starts (`/5:implement-feature`), expires after 4 hours, or can be cleared manually with `/5:unlock`.
75
+
69
76
  ### Step 1: Load Feature Spec
70
77
 
71
78
  Read `.5/features/{feature-name}/feature.md` (where `{feature-name}` is the argument provided).
@@ -142,45 +149,33 @@ Not every feature needs all steps. Use what makes sense.
142
149
 
143
150
  ### Step 5: Write the Plan
144
151
 
145
- Create a single file at `.5/features/{feature-name}/plan.md`:
152
+ Create a single file at `.5/features/{feature-name}/plan.md`.
146
153
 
147
- ```markdown
148
- ---
149
- ticket: {TICKET-ID}
150
- feature: {feature-name}
151
- created: {ISO-timestamp}
152
- ---
154
+ Follow the `<output-format>`, `<write-rules>`, and `<plans-are-prompts>` defined in your agent file.
153
155
 
154
- # Implementation Plan: {TICKET-ID}
156
+ Include:
157
+ - YAML frontmatter (ticket, feature, created)
158
+ - One-sentence summary
159
+ - Components table
160
+ - Implementation Notes (references to existing pattern files + business rules)
161
+ - Complexity Guide
162
+ - Verification commands
155
163
 
156
- {One sentence summary}
164
+ ### Step 5b: Plan Self-Check
157
165
 
158
- ## Components
166
+ Follow the `<self-check>` defined in your agent file.
159
167
 
160
- | Step | Component | Action | File | Description | Complexity |
161
- |------|-----------|--------|------|-------------|------------|
162
- | 1 | {name} | create | {path} | {what it does} | simple |
163
- | 2 | {name} | modify | {path} | {what to change} | moderate |
164
-
165
- ## Implementation Notes
166
-
167
- - Follow pattern from {existing-file} for {component-type}
168
- - {Key business rule}
169
- - {Integration point}
170
-
171
- ## Complexity Guide
172
-
173
- **simple** -> haiku: Pattern-following, type defs, simple CRUD
174
- **moderate** -> haiku/sonnet: Services with logic, multi-pattern files, modifications
175
- **complex** -> sonnet: Integration points, complex rules, significant refactoring
176
-
177
- ## Verification
178
-
179
- - Build: {command or "auto"}
180
- - Test: {command or "auto"}
168
+ Output the verification result:
169
+ ```
170
+ Plan self-check:
171
+ - Format: pass/fail
172
+ - No code: pass/fail
173
+ - Scope: pass/fail
174
+ - Completeness: pass/fail
175
+ - Description length: pass/fail
181
176
  ```
182
177
 
183
- **Key principle:** The plan describes WHAT to build, not HOW. Agents figure out patterns by reading existing code.
178
+ If any check fails, fix plan.md before proceeding to the completion output.
184
179
 
185
180
  ## PLANNING COMPLETE
186
181
 
@@ -51,7 +51,7 @@ Extract ticket ID using configurable pattern from config (e.g., `PROJ-\d+` or `\
51
51
 
52
52
  **Sanitize the ticket ID:** Only allow alphanumeric characters, dashes (`-`), and underscores (`_`). Strip any other characters (especially `/`, `..`, `~`, spaces). If the sanitized result is empty, ask the user for a valid ticket ID.
53
53
 
54
- Also read `.claude/.5/config.json` and extract:
54
+ Also read `.5/config.json` and extract:
55
55
  - `git.autoCommit` (boolean, default `false`)
56
56
  - `git.commitMessage.pattern` (string, default `{ticket-id} {short-description}`)
57
57
 
@@ -128,6 +128,12 @@ Create state file at `.5/features/${feature_name}/state.json` with fields: `tick
128
128
 
129
129
  Verify the file was written correctly with Read tool. If creation fails, stop and report error.
130
130
 
131
+ Then remove the planning guard marker (implementation is starting):
132
+
133
+ ```bash
134
+ rm -f .5/.planning-active
135
+ ```
136
+
131
137
  ### Step 8: Execute Implementation
132
138
 
133
139
  **Decision criteria for execution approach:**
@@ -20,7 +20,7 @@ After saving the review report, you are DONE.
20
20
 
21
21
  ## Review Tools
22
22
 
23
- Two review tools are supported (configured in `.claude/.5/config.json` field `reviewTool`):
23
+ Two review tools are supported (configured in `.5/config.json` field `reviewTool`):
24
24
 
25
25
  - **Claude** (default) — Built-in, zero setup. A fresh-context agent reviews code blind.
26
26
  - **CodeRabbit** — External CLI. Requires `coderabbit` installed and authenticated.
@@ -31,7 +31,7 @@ Both produce the same structured output format.
31
31
 
32
32
  ### Step 1: Determine Review Tool
33
33
 
34
- Read `.claude/.5/config.json` and check the `reviewTool` field.
34
+ Read `.5/config.json` and check the `reviewTool` field.
35
35
 
36
36
  - If not set or missing, default to `"claude"`
37
37
  - If `"none"`, inform user that automated review is disabled and STOP
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: 5:unlock
3
+ description: Remove the planning guard lock to allow edits outside the workflow
4
+ allowed-tools: Bash
5
+ context: inherit
6
+ user-invocable: true
7
+ ---
8
+
9
+ # Unlock Planning Guard
10
+
11
+ Remove the `.planning-active` marker file that restricts Write/Edit operations during planning phases.
12
+
13
+ ## Process
14
+
15
+ Run this bash command to check and remove the marker in one step:
16
+
17
+ ```bash
18
+ if [ -f .5/.planning-active ]; then rm .5/.planning-active && echo "REMOVED"; else echo "ABSENT"; fi
19
+ ```
20
+
21
+ Based on the output, confirm to the user:
22
+ - If output contains "REMOVED": "Planning guard removed. You can now edit files freely."
23
+ - If output contains "ABSENT": "No planning guard was active. You're already free to edit files."
@@ -1,17 +1,54 @@
1
1
  ---
2
2
  name: 5:update
3
3
  description: Update the 5-Phase Workflow to the latest version
4
- allowed-tools: Bash
4
+ allowed-tools: Bash, Read, AskUserQuestion
5
5
  context: inherit
6
6
  user-invocable: true
7
7
  ---
8
8
 
9
9
  # Update 5-Phase Workflow
10
10
 
11
- Run the upgrade command to update to the latest version:
11
+ ## Step 1: Check Current Version
12
+
13
+ Read `.5/version.json` and note the current `installedVersion`.
14
+
15
+ ## Step 2: Run Upgrade
12
16
 
13
17
  ```bash
14
- npx 5-phase-workflow --upgrade
18
+ npx 5-phase-workflow@latest --upgrade
15
19
  ```
16
20
 
17
- After the upgrade completes, confirm the new version was installed by checking `.claude/.5/version.json`.
21
+ ## Step 3: Confirm Upgrade
22
+
23
+ Read `.5/version.json` again. Compare the new `installedVersion` to the previous one.
24
+
25
+ - If the version **did not change**: tell the user they're already on the latest version. Stop here.
26
+ - If the version **changed**: continue to Step 4.
27
+
28
+ ## Step 4: Show What Changed
29
+
30
+ Run `git status` to show the files modified by the upgrade. Summarize the changes for the user (e.g., "Updated 12 files in `.claude/commands/5/`, `.claude/skills/`, `.claude/hooks/`").
31
+
32
+ ## Step 5: Ask to Commit
33
+
34
+ Ask the user: "Would you like to commit the upgraded workflow files?"
35
+
36
+ Options:
37
+ 1. **Yes** - commit the changes
38
+ 2. **No** - leave changes uncommitted
39
+
40
+ If the user chooses **No**, stop here.
41
+
42
+ ## Step 6: Commit
43
+
44
+ Read `.5/config.json` if it exists and extract `git.commitMessage.pattern` (default: `{ticket-id} {short-description}`).
45
+
46
+ Build the commit message by applying the pattern:
47
+ - Replace `{ticket-id}` with an empty string (no ticket for upgrades) and trim any leading/trailing whitespace
48
+ - Replace `{short-description}` with `update 5-Phase Workflow to {new-version}`
49
+ - If the pattern is the conventional format (`feat({ticket-id}): {short-description}`), use: `chore: update 5-Phase Workflow to {new-version}`
50
+ - If no config or no pattern, use: `update 5-Phase Workflow to {new-version}`
51
+
52
+ Stage **only** the workflow-managed files shown in `git status` (inside `.claude/commands/5/`, `.claude/skills/`, `.claude/hooks/`, `.claude/templates/`, `.claude/settings.json`, and `.5/version.json`). Never use `git add .` or `git add -A`.
53
+
54
+ Create the commit. Report success to the user.
@@ -49,7 +49,7 @@ Note: feature.md not found — skipping feature completeness checks.
49
49
  This is normal for quick-implement workflows. Infrastructure and quality checks will still run.
50
50
  ```
51
51
 
52
- Also read `.claude/.5/config.json` and extract:
52
+ Also read `.5/config.json` and extract:
53
53
  - `git.autoCommit` (boolean, default `false`)
54
54
  - `git.commitMessage.pattern` (string, default `{ticket-id} {short-description}`)
55
55
 
@@ -70,7 +70,7 @@ For each component in the plan:
70
70
 
71
71
  #### 2b. Run Build
72
72
 
73
- Execute the build command from the plan (or auto-detect from `.claude/.5/config.json`):
73
+ Execute the build command from the plan (or auto-detect from `.5/config.json`):
74
74
 
75
75
  ```bash
76
76
  {build-command}
@@ -23,7 +23,7 @@ process.stdin.on('end', () => {
23
23
  });
24
24
 
25
25
  async function checkForUpdates(workspaceDir) {
26
- const versionFile = path.join(workspaceDir, '.claude', '.5', 'version.json');
26
+ const versionFile = path.join(workspaceDir, '.5', 'version.json');
27
27
 
28
28
  // Check if version.json exists
29
29
  if (!fs.existsSync(versionFile)) {
@@ -9,7 +9,7 @@ process.stdin.on('end', () => {
9
9
  try {
10
10
  const data = JSON.parse(input);
11
11
  const cwd = data.cwd || process.cwd();
12
- const configFile = path.join(cwd, '.claude', '.5', 'config.json');
12
+ const configFile = path.join(cwd, '.5', 'config.json');
13
13
 
14
14
  if (fs.existsSync(configFile)) {
15
15
  process.exit(0);
@@ -26,6 +26,12 @@ process.stdin.on('end', () => {
26
26
  }
27
27
 
28
28
  const workspaceDir = data.cwd || data.workspace?.current_dir || process.cwd();
29
+
30
+ // If no planning phase is active, allow all tools
31
+ if (!isPlanningActive(workspaceDir)) {
32
+ process.exit(0);
33
+ }
34
+
29
35
  const toolInput = data.tool_input || {};
30
36
 
31
37
  // Determine which feature is being targeted and check its state
@@ -38,10 +44,16 @@ process.stdin.on('end', () => {
38
44
  if (toolName === 'Task') {
39
45
  const agentType = toolInput.subagent_type || '';
40
46
  if (agentType && agentType !== 'Explore') {
47
+ const blockCount = incrementBlockCount(workspaceDir);
48
+ const escalation = blockCount >= 3
49
+ ? ` WARNING: Block #${blockCount}. You are repeatedly attempting actions outside your planning role. STOP. Complete your planning artifact and output the completion message.`
50
+ : '';
41
51
  process.stderr.write(
42
52
  `BLOCKED: Only Explore agents are allowed during planning phases. ` +
43
53
  `Attempted: subagent_type="${agentType}". ` +
44
- `To use other agent types, start implementation with /5:implement-feature.`
54
+ `REDIRECT: Return to your planning process. ` +
55
+ `If you need codebase information, use subagent_type=Explore. ` +
56
+ `If you are done planning, output the completion message and STOP.${escalation}`
45
57
  );
46
58
  process.exit(2);
47
59
  }
@@ -50,11 +62,19 @@ process.stdin.on('end', () => {
50
62
  if (toolName === 'Write' || toolName === 'Edit') {
51
63
  const filePath = toolInput.file_path || '';
52
64
  if (filePath && !isInsideDotFive(filePath, workspaceDir)) {
65
+ const blockCount = incrementBlockCount(workspaceDir);
66
+ const isSourceFile = !filePath.includes('.5/') && !filePath.includes('.claude/');
67
+ const escalation = blockCount >= 3
68
+ ? ` WARNING: Block #${blockCount}. Repeated violations. Complete your planning artifact and STOP.`
69
+ : '';
70
+ const redirectMsg = isSourceFile
71
+ ? `REDIRECT: You are in a planning phase. You may ONLY write to .5/features/. ` +
72
+ `Source file creation happens in Phase 3 (/5:implement-feature).`
73
+ : `REDIRECT: The path "${filePath}" is outside the allowed .5/ directory. ` +
74
+ `Check your file path — you should be writing to .5/features/{name}/.`;
53
75
  process.stderr.write(
54
76
  `BLOCKED: ${toolName} outside .5/ is not allowed during planning phases. ` +
55
- `Attempted: "${filePath}". ` +
56
- `Planning commands may only write to .5/features/. ` +
57
- `To modify source files, start implementation with /5:implement-feature.`
77
+ `Attempted: "${filePath}". ${redirectMsg}${escalation}`
58
78
  );
59
79
  process.exit(2);
60
80
  }
@@ -70,23 +90,20 @@ process.stdin.on('end', () => {
70
90
  function isInsideDotFive(filePath, workspaceDir) {
71
91
  const resolved = path.resolve(workspaceDir, filePath);
72
92
  const dotFiveDir = path.join(workspaceDir, '.5');
73
- const claudeDotFiveDir = path.join(workspaceDir, '.claude', '.5');
74
93
  return resolved.startsWith(dotFiveDir + path.sep) ||
75
- resolved.startsWith(claudeDotFiveDir + path.sep) ||
76
- resolved === dotFiveDir ||
77
- resolved === claudeDotFiveDir;
94
+ resolved === dotFiveDir;
78
95
  }
79
96
 
80
97
  function getTargetFeature(toolName, toolInput, workspaceDir) {
81
98
  // Extract the feature name from the tool input context
82
- const featuresDir = path.join(workspaceDir, '.claude', '.5', 'features');
99
+ const featuresDir = path.join(workspaceDir, '.5', 'features');
83
100
 
84
101
  if (toolName === 'Write' || toolName === 'Edit') {
85
102
  // Check if the file path is inside a feature directory
86
103
  const filePath = toolInput.file_path || '';
87
104
  const resolved = path.resolve(workspaceDir, filePath);
88
105
  if (resolved.startsWith(featuresDir + path.sep)) {
89
- // Extract feature name: .claude/.5/features/{feature-name}/...
106
+ // Extract feature name: .5/features/{feature-name}/...
90
107
  const relative = resolved.slice(featuresDir.length + 1);
91
108
  const featureName = relative.split(path.sep)[0];
92
109
  if (featureName) return featureName;
@@ -118,10 +135,40 @@ function getTargetFeature(toolName, toolInput, workspaceDir) {
118
135
  return null;
119
136
  }
120
137
 
138
+ function isPlanningActive(workspaceDir) {
139
+ const markerPath = path.join(workspaceDir, '.5', '.planning-active');
140
+ if (!fs.existsSync(markerPath)) return false;
141
+ try {
142
+ const marker = JSON.parse(fs.readFileSync(markerPath, 'utf8'));
143
+ if (marker.startedAt) {
144
+ const elapsed = Date.now() - new Date(marker.startedAt).getTime();
145
+ if (elapsed > 4 * 60 * 60 * 1000) {
146
+ try { fs.unlinkSync(markerPath); } catch (e) {}
147
+ return false;
148
+ }
149
+ }
150
+ return true;
151
+ } catch (e) {
152
+ return true; // Unreadable marker → fail-safe, assume active
153
+ }
154
+ }
155
+
156
+ function incrementBlockCount(workspaceDir) {
157
+ const markerPath = path.join(workspaceDir, '.5', '.planning-active');
158
+ try {
159
+ const marker = JSON.parse(fs.readFileSync(markerPath, 'utf8'));
160
+ marker.blockCount = (marker.blockCount || 0) + 1;
161
+ fs.writeFileSync(markerPath, JSON.stringify(marker, null, 2));
162
+ return marker.blockCount;
163
+ } catch (e) {
164
+ return 1;
165
+ }
166
+ }
167
+
121
168
  function isFeatureInImplementationMode(workspaceDir, featureName) {
122
169
  // Check if this specific feature has a state.json (created in Phase 3)
123
170
  const stateFile = path.join(
124
- workspaceDir, '.claude', '.5', 'features', featureName, 'state.json'
171
+ workspaceDir, '.5', 'features', featureName, 'state.json'
125
172
  );
126
173
  return fs.existsSync(stateFile);
127
174
  }
@@ -46,7 +46,7 @@ process.stdin.on('end', () => {
46
46
  // Check for available update
47
47
  let updateIndicator = '';
48
48
  try {
49
- const versionFile = path.join(dir, '.claude', '.5', 'version.json');
49
+ const versionFile = path.join(dir, '.5', 'version.json');
50
50
  const versionData = JSON.parse(fs.readFileSync(versionFile, 'utf8'));
51
51
  const latest = versionData.latestAvailableVersion;
52
52
  const installed = versionData.installedVersion;
@@ -17,7 +17,7 @@ This skill executes build tasks with auto-detection of the build system and suff
17
17
 
18
18
  The skill automatically detects the build system using:
19
19
 
20
- 1. **Config file** (`.claude/.5/config.json`) - if `build.command` is specified
20
+ 1. **Config file** (`.5/config.json`) - if `build.command` is specified
21
21
  2. **Auto-detection** - by examining project files:
22
22
  - `package.json` → npm/yarn/pnpm
23
23
  - `build.gradle` or `build.gradle.kts` → Gradle
@@ -46,7 +46,7 @@ When invoked, the skill expects:
46
46
 
47
47
  ### 1. Load Configuration
48
48
 
49
- Read `.claude/.5/config.json` if it exists:
49
+ Read `.5/config.json` if it exists:
50
50
 
51
51
  ```json
52
52
  {
@@ -17,7 +17,7 @@ This skill executes test tasks with auto-detection of the test runner and suffic
17
17
 
18
18
  The skill automatically detects the test runner using:
19
19
 
20
- 1. **Config file** (`.claude/.5/config.json`) - if `build.testCommand` is specified
20
+ 1. **Config file** (`.5/config.json`) - if `build.testCommand` is specified
21
21
  2. **Auto-detection** - by examining project files and package.json scripts:
22
22
  - `package.json` with jest/vitest/mocha → npm test
23
23
  - `pytest.ini` or test files → pytest
@@ -49,7 +49,7 @@ When invoked, the skill expects:
49
49
 
50
50
  ### 1. Load Configuration
51
51
 
52
- Read `.claude/.5/config.json` if it exists:
52
+ Read `.5/config.json` if it exists:
53
53
 
54
54
  ```json
55
55
  {
@@ -1,3 +1,11 @@
1
+ <!-- TEMPLATE RULES:
2
+ - Requirements use natural language, not code
3
+ - Affected Components lists module/domain names, not file paths
4
+ - Entity definitions describe data concepts, not schemas or interfaces
5
+ - Acceptance criteria describe observable behavior, not test assertions
6
+ - NO code, pseudo-code, or implementation details anywhere in this document
7
+ -->
8
+
1
9
  # Feature: {TICKET-ID} - {Title}
2
10
 
3
11
  ## Ticket ID
@@ -35,6 +43,7 @@
35
43
  ## Entity/Component Definitions
36
44
 
37
45
  ### {EntityName} (if applicable)
46
+ <!-- Describe the data CONCEPT, not the implementation. No TypeScript, no SQL. -->
38
47
  | Field | Type | Required | Description |
39
48
  |-------|------|----------|-------------|
40
49
  | id | {Entity}Id | Yes | Unique identifier |
@@ -4,6 +4,13 @@ feature: {feature-name}
4
4
  created: {ISO-timestamp}
5
5
  ---
6
6
 
7
+ <!-- PLAN RULES:
8
+ - This file is interpolated into agent prompts. Write it as instructions, not documentation.
9
+ - Description column: one action-oriented sentence per component
10
+ - Implementation Notes: reference existing files as patterns, no code snippets
11
+ - Components table must cover all functional requirements from feature.md
12
+ -->
13
+
7
14
  # Implementation Plan: {TICKET-ID}
8
15
 
9
16
  {One sentence summary of what this plan builds}