5-phase-workflow 1.8.7 → 1.8.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "5-phase-workflow",
3
- "version": "1.8.7",
3
+ "version": "1.8.9",
4
4
  "description": "A 5-phase feature development workflow for Claude Code",
5
5
  "bin": {
6
6
  "5-phase-workflow": "bin/install.js"
@@ -23,7 +23,7 @@ This command is **Phase 1** of the 5-phase workflow applied to project configura
23
23
  After running this command, proceed through the standard phases:
24
24
  1. **`/5:configure`** (this command) - Plan the configuration feature
25
25
  2. `/5:plan-implementation CONFIGURE` - Create implementation plan
26
- 3. `/5:implement-feature CONFIGURE` - Execute configuration (uses `configure-project` skill)
26
+ 3. `/5:implement-feature CONFIGURE` - Execute configuration (uses `configure-docs-index` and `configure-skills`)
27
27
  4. `/5:verify-implementation` - Verify configuration
28
28
  5. `/5:review-code` - Review generated files
29
29
 
@@ -307,11 +307,13 @@ Write `.5/features/CONFIGURE/feature.md` containing all gathered data:
307
307
  # Feature: Project Configuration
308
308
 
309
309
  ## Summary
310
- Generates CLAUDE.md with codebase analysis and creates project-specific skills. (config.json already written.)
310
+ Generates CLAUDE.md, a rebuildable codebase index, and project-specific skills. (config.json already written.)
311
311
 
312
312
  ## Requirements
313
313
 
314
314
  ### Requirement 1: Generate Documentation Files
315
+ Handled by: `configure-docs-index`
316
+
315
317
  Analyze the codebase and generate focused documentation capturing only non-derivable knowledge (skip version numbers, dependency lists, directory layouts, linter configs — Claude Code can look these up directly):
316
318
 
317
319
  **Create documentation files in `.5/` folder:**
@@ -319,9 +321,18 @@ Analyze the codebase and generate focused documentation capturing only non-deriv
319
321
  - `.5/TESTING.md` - Test organization, patterns, mocking approach, gotchas
320
322
  - `.5/CONCERNS.md` - Tech debt, known issues, security/integration/performance notes (**only if concerns found — skip file entirely if nothing detected**)
321
323
 
324
+ **Create a rebuildable codebase index in `.5/index/`:**
325
+ - Generate a repository-local script at `.5/index/rebuild-index.sh`
326
+ - Generate multiple focused Markdown index files in `.5/index/` plus `.5/index/README.md`
327
+ - Keep the index generic and adapted to the actual project
328
+ - Skip empty categories; do not create placeholder index files
329
+ - Re-running the script should fully refresh the index in place
330
+
322
331
  **Create CLAUDE.md:**
323
332
  - Project overview and build commands
324
333
  - Links to whichever `.5/` documentation files were created
334
+ - Links to `.5/index/README.md`, the generated index files, and `.5/index/rebuild-index.sh`
335
+ - An explicit instruction that if the codebase index is older than one day, it should be regenerated by running `.5/index/rebuild-index.sh`
325
336
  - Workflow rules section (verbatim):
326
337
  ```
327
338
  ## Workflow Rules
@@ -341,6 +352,7 @@ Analyze the codebase and generate focused documentation capturing only non-deriv
341
352
  - If CLAUDE.md already exists, preserve user-written custom sections
342
353
 
343
354
  ### Requirement 2: Generate Project-Specific Skills
355
+ Handled by: `configure-skills`
344
356
 
345
357
  **Create-* skills** for each user-selected architectural pattern:
346
358
  - Skill name: `create-{pattern}` (e.g., `create-controller`, `create-service`)
@@ -355,6 +367,8 @@ Analyze the codebase and generate focused documentation capturing only non-deriv
355
367
  Include only patterns/commands where user selected "Generate".
356
368
 
357
369
  ### Requirement 3: Generate Scoped Rules (if selected)
370
+ Handled by: `configure-skills`
371
+
358
372
  Generate `.claude/rules/` files with project-specific conventions scoped to relevant file types.
359
373
  Rules are concise directives (15-40 lines, NOT documentation) derived from codebase analysis.
360
374
  Only generate rules for patterns that were actually detected:
@@ -369,8 +383,14 @@ Only generate rules for patterns that were actually detected:
369
383
  - [ ] `.5/ARCHITECTURE.md` — architecture, conventions, where to add code
370
384
  - [ ] `.5/TESTING.md` — test patterns and gotchas
371
385
  - [ ] `.5/CONCERNS.md` — only if concerns were found (omit if empty)
386
+ - [ ] `.5/index/` directory exists
387
+ - [ ] `.5/index/rebuild-index.sh` exists and rebuilds the index
388
+ - [ ] `.5/index/README.md` exists and documents the generated index files
389
+ - [ ] Multiple focused `.5/index/*.md` files are generated for applicable codebase concerns
372
390
  - [ ] Empty sections omitted (no "Not detected" / "None found" placeholders)
373
391
  - [ ] `CLAUDE.md` exists with references to created `.5/` files
392
+ - [ ] `CLAUDE.md` links to the codebase index and rebuild script
393
+ - [ ] `CLAUDE.md` says to regenerate the index if it is older than one day
374
394
  - [ ] CLAUDE.md contains 6 coding guidelines
375
395
  - [ ] All specified project-specific skills are generated in `.claude/skills/`
376
396
  - [ ] Generated skills reference actual project conventions
@@ -395,4 +415,5 @@ Tell the user:
395
415
  4. "After that: Continue with `/5:implement-feature CONFIGURE` -> `/5:verify-implementation` -> `/5:review-code` (clearing context between each phase)"
396
416
 
397
417
  ## Related Documentation
398
- - [configure-project skill](../../skills/configure-project/SKILL.md)
418
+ - [configure-docs-index skill](../../skills/configure-docs-index/SKILL.md)
419
+ - [configure-skills skill](../../skills/configure-skills/SKILL.md)
@@ -3,8 +3,6 @@ name: 5:eject
3
3
  description: Eject from the update mechanism — permanently removes update infrastructure
4
4
  allowed-tools: Bash, Read, Edit, AskUserQuestion
5
5
  user-invocable: true
6
- model: haiku
7
- context: fork
8
6
  ---
9
7
 
10
8
  <role>
@@ -14,13 +12,17 @@ After ejecting, you are DONE.
14
12
 
15
13
  # Eject from Update Mechanism
16
14
 
15
+ Determine which runtime is installed before making any changes:
16
+ - Claude Code install: workflow files live in `.claude/`
17
+ - Codex install: workflow files live in `.codex/`
18
+
19
+ Use runtime-appropriate paths in every step below.
20
+
17
21
  Ejecting permanently removes the update system from this installation. After ejecting:
18
- - The update check hook (`check-updates.js`) is deleted
19
- - The update command (`/5:update`) is deleted
20
- - The eject command (`/5:eject`) is deleted
22
+ - The update infrastructure files are deleted
21
23
  - Version tracking (`.5/version.json`) is deleted
22
24
  - The update cache (`.5/.update-cache.json`) is deleted
23
- - The `check-updates.js` hook entry is removed from `.claude/settings.json`
25
+ - Claude Code installs also remove the `check-updates.js` hook entry from `.claude/settings.json`
24
26
 
25
27
  All other workflow files (commands, skills, hooks, templates) remain untouched.
26
28
 
@@ -39,13 +41,19 @@ Tell the user what ejecting means:
39
41
  > **Eject from 5-Phase Workflow updates?**
40
42
  >
41
43
  > This will permanently delete:
44
+ > - `.5/version.json` (version tracking)
45
+ > - `.5/.update-cache.json` (update cache)
46
+ >
47
+ > For Claude Code installs:
42
48
  > - `.claude/hooks/check-updates.js` (update check hook)
43
49
  > - `.claude/commands/5/update.md` (update command)
44
50
  > - `.claude/commands/5/eject.md` (this command)
45
- > - `.5/version.json` (version tracking)
46
- > - `.5/.update-cache.json` (update cache)
51
+ > - The `check-updates.js` hook entry in `.claude/settings.json`
47
52
  >
48
- > The `check-updates.js` hook entry will also be removed from `.claude/settings.json`.
53
+ > For Codex installs:
54
+ > - `.codex/skills/5-update/` (update skill)
55
+ > - `.codex/skills/5-eject/` (this skill)
56
+ > - `.codex/instructions.md` is removed only if it is workflow-managed and no longer needed for remaining installed workflow files
49
57
  >
50
58
  > All other workflow files remain untouched. To restore updates later, reinstall with `npx 5-phase-workflow`.
51
59
 
@@ -61,9 +69,18 @@ Run this command to delete the update-related files:
61
69
  rm -f .claude/hooks/check-updates.js .claude/commands/5/update.md .claude/commands/5/eject.md .5/version.json .5/.update-cache.json
62
70
  ```
63
71
 
72
+ For Codex installs, remove the runtime-appropriate files instead:
73
+
74
+ ```bash
75
+ rm -rf .codex/skills/5-update .codex/skills/5-eject
76
+ rm -f .5/version.json .5/.update-cache.json
77
+ ```
78
+
64
79
  ## Step 4: Clean Up settings.json
65
80
 
66
- Read `.claude/settings.json`. Remove the hook entry from the `hooks.SessionStart` array where the command is `node .claude/hooks/check-updates.js`.
81
+ Claude Code installs only: read `.claude/settings.json`. Remove the hook entry from the `hooks.SessionStart` array where the command is `node .claude/hooks/check-updates.js`.
82
+
83
+ Codex installs do not use `.claude/settings.json` or Claude hooks for updates, so skip this step for Codex.
67
84
 
68
85
  Specifically, find and remove the object in the `SessionStart` array that looks like:
69
86
 
@@ -89,3 +106,5 @@ Tell the user:
89
106
  > Ejected successfully. Update infrastructure has been removed from this installation (was v{packageVersion}).
90
107
  >
91
108
  > To restore update functionality, reinstall with: `npx 5-phase-workflow`
109
+ >
110
+ > If this was a Codex install, use: `npx 5-phase-workflow --codex`
@@ -4,7 +4,6 @@ description: Plans feature implementation by analyzing requirements, identifying
4
4
  allowed-tools: Read, Write, Task, AskUserQuestion
5
5
  user-invocable: true
6
6
  model: opus
7
- context: fork
8
7
  ---
9
8
 
10
9
  <role>
@@ -4,7 +4,6 @@ description: Creates an implementation plan from a feature spec. Phase 2 of the
4
4
  allowed-tools: Read, Write, Task, AskUserQuestion
5
5
  user-invocable: true
6
6
  model: opus
7
- context: fork
8
7
  ---
9
8
 
10
9
  <role>
@@ -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
- context: fork
7
6
  ---
8
7
 
9
8
  <role>
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: 5:reconfigure
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.
3
+ description: Lightweight refresh of project documentation, codebase index, and skills without full Q&A. Re-detects codebase changes, regenerates .5/*.md docs, rebuilds .5/index/, updates CLAUDE.md, and refreshes all skills.
4
4
  allowed-tools: Read, Write, Bash, Glob, Grep, Task, AskUserQuestion
5
5
  user-invocable: true
6
6
  context: fork
@@ -9,7 +9,7 @@ context: fork
9
9
  <role>
10
10
  You are a Project Reconfigurer. You refresh documentation and skills using existing config.json preferences.
11
11
  You do NOT modify user preferences (ticket patterns, review tools, branch conventions, etc.).
12
- You detect codebase changes, confirm with the user, invoke configure-project skill, then report.
12
+ You detect codebase changes, confirm with the user, invoke the configuration refresh skills, then report.
13
13
  After reporting what was updated, you are DONE.
14
14
  </role>
15
15
 
@@ -37,7 +37,7 @@ Your job:
37
37
  ✅ Re-detect codebase patterns and commands (same as configure Steps 1b-1h)
38
38
  ✅ Compare detected state with config.json skill selections
39
39
  ✅ Show summary and ask for confirmation
40
- ✅ Invoke configure-project skill in refresh mode
40
+ ✅ Invoke `configure-docs-index` and `configure-skills` in refresh mode
41
41
  ✅ Update version.json with artifacts and timestamps
42
42
  ✅ Clean up .reconfig-reminder flag
43
43
  ✅ Report what was updated
@@ -117,7 +117,7 @@ Use the existing skills in `.claude/skills/` (from Step 2e) as the source of tru
117
117
 
118
118
  Use `AskUserQuestion` to show a summary and get confirmation. Present:
119
119
 
120
- 1. **Documentation files that will be rewritten** — list `.5/ARCHITECTURE.md`, `.5/TESTING.md`, `.5/CONCERNS.md` (conditional) + CLAUDE.md
120
+ 1. **Documentation files that will be rewritten** — list `.5/ARCHITECTURE.md`, `.5/TESTING.md`, `.5/CONCERNS.md` (conditional), `.5/index/rebuild-index.sh`, `.5/index/*.md`, and `CLAUDE.md`
121
121
  2. **Skills that will be refreshed** — list ALL skills found in `.claude/skills/` (both workflow-generated and user-created)
122
122
  3. **Rules that will be refreshed** (if rules enabled) — list workflow-generated rule files in `.claude/rules/`
123
123
  4. **New patterns detected** (if any) — "These patterns were found in your codebase but don't have skills yet: [list]. Create skills for them?"
@@ -134,10 +134,14 @@ New skills will be created and stale skills removed based on the user's choices.
134
134
 
135
135
  ### Step 5: Regenerate
136
136
 
137
- Invoke the `configure-project` skill in **refresh mode** via the Task tool:
137
+ Invoke the refresh skills in **refresh mode** via the Task tool:
138
138
 
139
139
  ```
140
- Task prompt: "Run configure-project skill in REFRESH MODE.
140
+ Task prompt 1: "Run configure-docs-index skill in REFRESH MODE.
141
+
142
+ Refresh the generated documentation, rebuild the codebase index in `.5/index/`, delete legacy docs if they exist, and update `CLAUDE.md` while preserving user-written sections."
143
+
144
+ Task prompt 2: "Run configure-skills skill in REFRESH MODE.
141
145
 
142
146
  Refresh ALL existing skills in .claude/skills/:
143
147
  - Existing create-* skills: [list from Step 2e]
@@ -150,18 +154,13 @@ Refresh rules in .claude/rules/ (if rules.generate is true):
150
154
  - Existing workflow rules: [list from Step 2f]
151
155
  - Rules to remove: [list from user confirmation, if any]
152
156
  - New rules to create: [if applicable]
153
-
154
- Re-analyze the entire codebase (A1 analysis) and:
155
- 1. Rewrite .5/ARCHITECTURE.md and .5/TESTING.md
156
- 2. Rewrite .5/CONCERNS.md (or delete if no concerns found)
157
- 3. Delete legacy docs if they exist: .5/STACK.md, .5/STRUCTURE.md, .5/CONVENTIONS.md, .5/INTEGRATIONS.md
158
- 4. Update CLAUDE.md (preserve user-written sections)
159
- 5. Refresh ALL skills in .claude/skills/ read current conventions from codebase and update each skill
160
- 6. Create new skills for newly-added patterns
161
- 7. Remove skills the user chose to drop
162
- 8. Refresh all workflow-generated rule files in .claude/rules/ with updated conventions
163
- 9. Create new rule files for newly-detected patterns
164
- 10. Remove rule files the user chose to drop"
157
+ Re-analyze the codebase and:
158
+ 1. Refresh ALL skills in .claude/skills/ — read current conventions from codebase and update each skill
159
+ 2. Create new skills for newly-added patterns
160
+ 3. Remove skills the user chose to drop
161
+ 4. Refresh all workflow-generated rule files in .claude/rules/ with updated conventions
162
+ 5. Create new rule files for newly-detected patterns
163
+ 6. Remove rule files the user chose to drop"
165
164
  ```
166
165
 
167
166
  Use `subagent_type: "general-purpose"` for the Task.
@@ -186,6 +185,7 @@ rm -f .5/.reconfig-reminder
186
185
 
187
186
  Show the user a summary:
188
187
  - List of documentation files updated
188
+ - Mention whether the codebase index script and index files were regenerated
189
189
  - List of skills refreshed
190
190
  - List of new skills created (if any)
191
191
  - List of skills removed (if any)
@@ -197,4 +197,5 @@ Show the user a summary:
197
197
 
198
198
  ## Related Documentation
199
199
  - [configure command](./configure.md) — full Q&A configuration
200
- - [configure-project skill](../../skills/configure-project/SKILL.md) — the skill that does the heavy lifting
200
+ - [configure-docs-index skill](../../skills/configure-docs-index/SKILL.md)
201
+ - [configure-skills skill](../../skills/configure-skills/SKILL.md)
@@ -25,6 +25,12 @@ Read `.5/version.json` and note the current `installedVersion`.
25
25
  npx 5-phase-workflow@latest --upgrade
26
26
  ```
27
27
 
28
+ If this installation is running in Codex (workflow files live in `.codex/` or the workflow command was invoked as a `$5-...` skill), run this instead:
29
+
30
+ ```bash
31
+ npx 5-phase-workflow@latest --codex --upgrade
32
+ ```
33
+
28
34
  ## Step 3: Confirm Upgrade
29
35
 
30
36
  Read `.5/version.json` again. Compare the new `installedVersion` to the previous one.
@@ -34,14 +40,16 @@ Read `.5/version.json` again. Compare the new `installedVersion` to the previous
34
40
 
35
41
  ## Step 4: Show What Changed
36
42
 
37
- 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/`").
43
+ Run `git status` to show the files modified by the upgrade. Summarize the changes for the user using the correct runtime paths:
44
+ - Claude Code installs typically update files in `.claude/commands/5/`, `.claude/skills/`, `.claude/hooks/`, `.claude/templates/`, `.claude/settings.json`, and `.5/version.json`
45
+ - Codex installs typically update files in `.codex/skills/`, `.codex/templates/`, `.codex/references/`, `.codex/instructions.md`, and `.5/version.json`
38
46
 
39
47
  ## Step 5: Ask to Commit
40
48
 
41
49
  Ask the user: "Would you like to commit the upgraded workflow files?"
42
50
 
43
51
  Options:
44
- 1. **Yes** - commit the changes, do not mention claude
52
+ 1. **Yes** - commit the changes, do not mention Claude Code
45
53
  2. **No** - leave changes uncommitted
46
54
 
47
55
  If the user chooses **No**, stop here.
@@ -56,6 +64,11 @@ Build the commit message by applying the pattern:
56
64
  - If the pattern is the conventional format (`feat({ticket-id}): {short-description}`), use: `chore: update 5-Phase Workflow to {new-version}`
57
65
  - If no config or no pattern, use: `update 5-Phase Workflow to {new-version}`
58
66
 
59
- 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`.
67
+ Stage **only** the workflow-managed files shown in `git status`.
68
+
69
+ - For Claude Code installs, this usually means files inside `.claude/commands/5/`, `.claude/skills/`, `.claude/hooks/`, `.claude/templates/`, `.claude/settings.json`, and `.5/version.json`
70
+ - For Codex installs, this usually means files inside `.codex/skills/`, `.codex/templates/`, `.codex/references/`, `.codex/instructions.md`, and `.5/version.json`
71
+
72
+ Never use `git add .` or `git add -A`.
60
73
 
61
74
  Create the commit. Report success to the user.
@@ -0,0 +1,196 @@
1
+ ---
2
+ name: configure-docs-index
3
+ description: Analyzes the codebase, creates project documentation, generates a rebuildable codebase index, and updates CLAUDE.md. Used during /5:implement-feature CONFIGURE.
4
+ allowed-tools: Read, Write, Bash, Glob, Grep
5
+ model: sonnet
6
+ context: fork
7
+ user-invocable: false
8
+ ---
9
+
10
+ # Configure Docs And Index Skill
11
+
12
+ ## Overview
13
+
14
+ This skill handles the documentation and indexing work during Phase 3 (implement-feature) for the CONFIGURE feature. It is called by step-executor to create the project docs, codebase index, and `CLAUDE.md`.
15
+
16
+ It handles one task:
17
+
18
+ - **Analyze Codebase and Create/Update Documentation + Index** - Maps codebase, writes `.5/*.md`, generates `.5/index/*`, and updates `CLAUDE.md`
19
+
20
+ Note: config.json is written directly by `/5:configure` during the Q&A phase.
21
+
22
+ ---
23
+
24
+ ## Modes
25
+
26
+ This skill supports two modes. The analysis (A1), template filling (A2-A3), index generation (A3.5), and CLAUDE.md update (A4-A5) logic is the same in both modes — only the **input source** changes.
27
+
28
+ ### Full Mode (default)
29
+
30
+ Used by `/5:configure` → `/5:implement-feature CONFIGURE` flow.
31
+
32
+ - **Input:** Pattern/command selections from feature spec (`.5/features/CONFIGURE/feature.md`)
33
+ - **Behavior:** Creates documentation, index files, and `CLAUDE.md` from scratch based on feature spec requirements
34
+
35
+ ### Refresh Mode
36
+
37
+ Used by `/5:reconfigure` for lightweight refresh.
38
+
39
+ - **Input:** The Task prompt tells it to refresh documentation and the codebase index
40
+ - **Behavior:** Re-analyzes codebase and overwrites docs, index files, and `CLAUDE.md`
41
+ - **Trigger:** Task prompt includes "REFRESH MODE"
42
+
43
+ In both modes, the analysis and generation logic is identical.
44
+
45
+ ---
46
+
47
+ ## A. Analyze Codebase and Create/Update CLAUDE.md
48
+
49
+ **Process:**
50
+
51
+ ### A1. Codebase Analysis
52
+
53
+ Perform focused analysis to gather data for documentation templates. Only capture information that **cannot be derived** by reading project files directly — skip version numbers, dependency lists, directory layouts, linter configs, and other facts that Claude Code can look up on demand.
54
+
55
+ **Architecture Analysis** (for ARCHITECTURE.md):
56
+ - Identify architectural pattern (MVC, layered, modular, microservices) from directory structure
57
+ - Map layers by directory structure (controllers/, services/, models/, routes/, etc.)
58
+ - Trace data flow patterns (read 2-3 example files from different layers)
59
+ - Identify key abstractions (interfaces, base classes, common patterns)
60
+ - Identify non-obvious conventions: implicit rules not enforced by tooling (e.g., "all services extend BaseService", "barrel exports required per module"). Skip anything in .eslintrc, .prettierrc, tsconfig, etc.
61
+ - Determine where new code should go (new features, tests, utilities)
62
+
63
+ **Testing Analysis** (for TESTING.md):
64
+ - Determine test organization (co-located vs separate `test/` or `spec/`)
65
+ - Identify mocking framework and project-specific mocking conventions
66
+ - Find fixture/factory patterns
67
+ - Note gotchas: setup/teardown quirks, env requirements, flaky areas
68
+
69
+ **Concerns Analysis** (for CONCERNS.md — conditional):
70
+ - Grep for TODO/FIXME/HACK/XXX/DEPRECATED comments across all code
71
+ - Check for common security issues (SQL injection patterns, XSS vulnerabilities)
72
+ - Identify non-obvious integration details: auth flows, required env vars not documented elsewhere, webhook contracts, gotchas with external services
73
+ - Look for performance bottlenecks or scaling limits mentioned in comments/docs
74
+
75
+ ### A2. Fill Templates
76
+
77
+ For each template in `.claude/templates/`:
78
+
79
+ 1. Read template content with Read tool
80
+ 2. Replace placeholders with analyzed data from A1
81
+ 3. **Omit sections entirely if no data was found** — do not write "Not detected" or "None found"
82
+ 4. For CONCERNS.md: if ALL sections would be empty, **do not create the file at all**
83
+
84
+ **Placeholder mapping examples**:
85
+
86
+ ARCHITECTURE.md:
87
+ - `{Pattern name}` → "Layered Architecture" or "MVC" or "Modular Monolith"
88
+ - `{Layer}` → "Controllers", "Services", "Repositories"
89
+ - `{path}` → "src/controllers/", "src/services/"
90
+
91
+ TESTING.md:
92
+ - Describe actual patterns observed, not framework names/versions (those are in config files)
93
+
94
+ CONCERNS.md:
95
+ - `{file paths}` → Actual file paths from grep results
96
+
97
+ ### A3. Write Documentation Files
98
+
99
+ Write filled templates to `.5/` folder:
100
+
101
+ 1. Ensure `.5/` directory exists: `mkdir -p .5`
102
+ 2. Write filled templates:
103
+ - `.5/ARCHITECTURE.md` — always created
104
+ - `.5/TESTING.md` — always created
105
+ - `.5/CONCERNS.md` — **only if concerns were found** (skip if all sections empty)
106
+
107
+ ### A3.5. Generate Codebase Index Script and Index Files
108
+
109
+ Generate a repository-local codebase index that stays generic and works for any language or framework detected in the project.
110
+
111
+ **Requirements:**
112
+ - Create `.5/index/` if it does not exist
113
+ - Generate a script that rebuilds the index at `.5/index/rebuild-index.sh`
114
+ - Make the script self-contained and dependency-light:
115
+ - Prefer portable shell plus standard tools already expected in a dev environment
116
+ - If the project clearly has a better built-in runtime already available (for example Node.js or Python), it is acceptable to generate a small script in that runtime instead, but keep it local to the repo and avoid adding new dependencies
117
+ - The script must inspect the current codebase and write multiple focused Markdown index files into `.5/index/`
118
+ - Include `.5/index/README.md` as a manifest describing what each generated index file contains and how to rebuild the index
119
+ - Group content by concern and adapt to the actual project. Each file should be compact, easy to scan, and optimized for AI/context loading rather than prose documentation.
120
+ - Each generated index file should follow this style:
121
+ - Short title and 1-line purpose statement
122
+ - Bulleted or table-like entries only
123
+ - One entry per route/component/module/model/command as applicable
124
+ - Each entry should include the path and a short descriptor
125
+ - Prefer signatures, exported names, HTTP methods, key fields, and relationships over long explanations
126
+ - Keep entries factual and compact; avoid narrative paragraphs
127
+ - Suggested file shapes:
128
+ - `commands.md` — runnable commands, entrypoints, scripts, key developer workflows
129
+ - `routes.md` — routes, handlers, API endpoints, HTTP methods, notable middleware
130
+ - `modules.md` — modules/packages/components/services and what they own
131
+ - `models.md` — schemas, entities, tables, migrations, key relationships
132
+ - `libraries.md` — shared utilities, helpers, exported functions/classes
133
+ - Suggested categories to create when applicable:
134
+ - Entrypoints / runnable commands
135
+ - Routes / handlers / API surface
136
+ - Components / modules / packages
137
+ - Data models / schemas / migrations
138
+ - Libraries / utilities / shared code
139
+ - Skip categories that do not apply. Do not generate empty placeholder files.
140
+ - The script should overwrite previously generated index files on each run so rebuild is idempotent.
141
+
142
+ ### A4. Create CLAUDE.md
143
+
144
+ Generate CLAUDE.md:
145
+
146
+ CLAUDE.md structure:
147
+ - **Project Overview:** 1-2 sentences from README/package.json
148
+ - **Build & Run Commands:** Build, test, and other detected commands
149
+ - **Workflow Rules:** Include this section verbatim:
150
+ ```
151
+ ## Workflow Rules
152
+ When running `/5:` workflow commands, follow the command instructions exactly as written.
153
+ Do not skip steps, combine phases, or proceed to actions not specified in the current command.
154
+ Each phase produces a specific artifact — do not create artifacts belonging to other phases.
155
+ ```
156
+ - **Coding Guidelines:** The 6 mandatory principles (types, concise docs, short files, extract methods, SRP/DRY, maintainable/modular)
157
+ - **Project Documentation:** Links to whichever `.5/` files were created (only list files that exist)
158
+ - **Codebase Index:** Add a section linking `.5/index/README.md`, the generated index files, and the rebuild script
159
+ - **Index Freshness Rule:** State clearly that if the index files are more than one day old, Claude should regenerate them by running `.5/index/rebuild-index.sh` before relying on them
160
+
161
+ ### A5. Preserve Existing Content
162
+
163
+ If CLAUDE.md already exists:
164
+ - Read current content
165
+ - Identify user-written custom sections (not matching template structure)
166
+ - Preserve under "Custom Documentation" section in new CLAUDE.md
167
+ - Ensure 6 mandatory coding guidelines are retained
168
+
169
+ ---
170
+
171
+ ## Output Contract
172
+
173
+ Returns structured results for each component:
174
+
175
+ ```
176
+ Component A (Documentation + Index): SUCCESS - Created documentation files, codebase index, and CLAUDE.md
177
+ - .5/ARCHITECTURE.md (Pattern: Layered, 4 layers identified)
178
+ - .5/TESTING.md (mocking patterns, gotchas documented)
179
+ - .5/CONCERNS.md (3 TODO items, 1 security note) [or "skipped — no concerns found"]
180
+ - .5/index/rebuild-index.sh (generated index rebuild script)
181
+ - .5/index/*.md (focused codebase index files)
182
+ - CLAUDE.md (updated with references)
183
+ ```
184
+
185
+ Or on failure:
186
+
187
+ ```
188
+ Component A (Documentation + Index): FAILED - Unable to read template files
189
+ ```
190
+
191
+ ## DO NOT
192
+
193
+ - DO NOT overwrite existing user-written CLAUDE.md sections
194
+ - DO NOT include `steps` in config.json
195
+ - DO NOT hardcode conventions - always derive from actual project analysis
196
+ - DO NOT generate empty or placeholder index files