5-phase-workflow 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +31 -101
  2. package/bin/install.js +168 -176
  3. package/bin/sync-agents.js +59 -54
  4. package/docs/workflow-guide.md +35 -79
  5. package/package.json +2 -2
  6. package/src/agents/step-executor-agent.md +5 -4
  7. package/src/agents/step-orchestrator-agent.md +12 -12
  8. package/src/agents/verification-agent.md +7 -8
  9. package/src/codex-commands/plan.md +65 -0
  10. package/src/commands/5/address-review-findings.md +43 -52
  11. package/src/commands/5/analyze-feature.md +1 -1
  12. package/src/commands/5/configure.md +75 -179
  13. package/src/commands/5/eject.md +0 -1
  14. package/src/commands/5/implement.md +78 -68
  15. package/src/commands/5/lean-check.md +75 -0
  16. package/src/commands/5/reconfigure.md +48 -129
  17. package/src/commands/5/review.md +42 -14
  18. package/src/commands/5/synchronize-agents.md +1 -1
  19. package/src/commands/5/update.md +2 -2
  20. package/src/hooks/dependency-guard.js +150 -0
  21. package/src/hooks/statusline.js +5 -3
  22. package/src/references/configure-tables.md +0 -33
  23. package/src/settings.json +3 -4
  24. package/src/skills/baseline-conventions/SKILL.md +37 -0
  25. package/src/skills/cognitive-load/SKILL.md +52 -0
  26. package/src/skills/configure-agents-md/SKILL.md +72 -0
  27. package/src/skills/configure-rules/SKILL.md +146 -0
  28. package/src/skills/documentation-style/SKILL.md +32 -0
  29. package/src/skills/fowler-code-smells/SKILL.md +25 -0
  30. package/src/skills/review-style/SKILL.md +142 -0
  31. package/src/templates/AGENTS.md +31 -31
  32. package/src/templates/workflow/REVIEW-FINDINGS.md +2 -9
  33. package/src/workflows/5-implement.js +67 -92
  34. package/docs/findings.md +0 -361
  35. package/docs/progress.md +0 -102
  36. package/src/commands/5/apply-review-findings.md +0 -66
  37. package/src/commands/5/commit.md +0 -43
  38. package/src/commands/5/plan.md +0 -189
  39. package/src/commands/5/reply-pr-comments.md +0 -48
  40. package/src/commands/5/split.md +0 -86
  41. package/src/commands/5/triage-pr-comments.md +0 -70
  42. package/src/hooks/config-guard.js +0 -30
  43. package/src/skills/configure-docs-index/SKILL.md +0 -243
  44. package/src/skills/configure-skills/SKILL.md +0 -311
  45. package/src/skills/generate-readme/EXAMPLES.md +0 -168
  46. package/src/skills/generate-readme/SKILL.md +0 -122
  47. package/src/skills/generate-readme/TEMPLATE.md +0 -141
  48. package/src/skills/use-index/SKILL.md +0 -49
  49. package/src/templates/ARCHITECTURE.md +0 -33
  50. package/src/templates/CONCERNS.md +0 -33
  51. package/src/templates/CONVENTIONS.md +0 -74
  52. package/src/templates/TESTING.md +0 -24
  53. package/src/templates/workflow/FIX-PLAN.md +0 -55
  54. package/src/templates/workflow/PLAN-COMPACT.md +0 -42
  55. package/src/templates/workflow/PLAN.md +0 -76
  56. package/src/templates/workflow/REVIEW-SUMMARY.md +0 -53
@@ -1,101 +1,95 @@
1
1
  ---
2
2
  name: 5:implement
3
- description: Executes a unified plan. Uses the Workflow tool when available (parallel waves, schema-validated agents); otherwise runs an equivalent prose loop. Codex always uses the prose loop.
4
- allowed-tools: Agent, Read, Write, Glob, Grep, Bash, Workflow, TaskCreate, TaskUpdate, TaskList
3
+ description: Executes a plan from .5/planning/. Compact plans are implemented inline in this session; full plans run through the Workflow tool when available (parallel waves, schema-validated agents), otherwise an equivalent prose loop. Codex always uses the prose loop. Verifies that the plan was built and works, then runs /5:review.
4
+ allowed-tools: Agent, Read, Write, Edit, Glob, Grep, Bash, Workflow, Skill, AskUserQuestion
5
5
  user-invocable: true
6
- argument-hint: [feature-name]
6
+ argument-hint: [feature-name-or-plan-path]
7
7
  ---
8
8
 
9
9
  <role>
10
- You are an Implementation Orchestrator. Keep your context lean, delegate all code edits, and use `.5/features/{name}/state.json` for cross-session resume. You do NOT write source code yourself.
10
+ You are an Implementation Orchestrator. A compact plan you implement yourself. For a full plan you keep your context lean and delegate every code edit to executor agents.
11
11
  </role>
12
12
 
13
13
  # Implement
14
14
 
15
- ## Step 1: Load Artifacts
15
+ ## Step 1: Load the Plan
16
16
 
17
- Read `plan.md`, `codebase-scan.md` if it exists, and `.5/config.json` if it exists. If `plan.md` is missing, stop and ask the user to run `/5:plan` first, then rerun `/5:implement {feature-name}`.
17
+ Find the plan:
18
18
 
19
- Then read `.5/features/{feature-name}/state.json` if it exists:
19
+ - If the argument is a path to a plan file, use it.
20
+ - Otherwise look in `.5/planning/` for a file named `{argument}.md`, or whose frontmatter has `feature: {argument}`. If several match, use the most recently modified one.
21
+ - Without an argument, use the most recently modified file in `.5/planning/` and name it to the user.
22
+ - If no plan matches, stop and ask the user to plan the feature first — in plan mode on Claude Code, with `$5-plan` on Codex — then rerun `/5:implement`.
20
23
 
21
- - `completed`: tell the user it is already implemented and verified; stop.
22
- - `in-progress`: resume — skip every component listed in `completedComponents`.
23
- - `failed`: ask whether to resume or restart. Restart clears `completedComponents`.
24
+ Plans have no fixed shape. The feature name is the plan's `feature` frontmatter field when it has one, otherwise the file name without `.md`.
24
25
 
25
- A plan is **compact** when `plan.md` frontmatter has `planFormat: compact` (1-2 components, no data migration, no security/auth change, no public API change). `/5:plan` implements compact plans inline as soon as the user approves them, so a compact plan usually already has a `completed` or `failed` state here — the common reasons to reach this command are resuming a failed inline run or re-running after the plan changed. Treat that state exactly as above; do not re-run completed components.
26
+ Read the plan and `.5/config.json` if it exists. Nothing is persisted between runs; a rerun starts over, and executors see work that is already done in the files.
26
27
 
27
- The execution graph — steps, component wiring, model choices, pattern references, verify commands — is derived fresh on every run and lives only in this run. `state.json` persists only what resume needs:
28
+ A plan is **compact** when it changes 1-2 files with no data migration, no security/auth change, and no public API change. Every other plan is **full**.
28
29
 
29
- ```json
30
- {
31
- "feature": "{feature-name}",
32
- "status": "in-progress|completed|failed",
33
- "completedComponents": ["component-name"],
34
- "verification": {"status": "passed|partial|failed", "summary": "one line"},
35
- "startedAt": "{ISO-timestamp}",
36
- "lastUpdated": "{ISO-timestamp}"
37
- }
38
- ```
30
+ Collect the standards once for this run:
39
31
 
40
- Resume matches on component name alone, so component names must always be copied verbatim from the plan's Component Checklist. Write `state.json` with `status: "in-progress"` now if it does not exist.
41
-
42
- Create one task per planned component with `TaskCreate` so the user can see progress, and mark already-completed components as completed.
32
+ - **Repository standards:** the files `.claude/skills/review-style/SKILL.md` step 2 lists that exist in this repository.
33
+ - **Style skills:** the absolute paths of the styles listed under `## Styles` in `.claude/skills/review-style/SKILL.md`. Resolve them from that skill's directory.
43
34
 
44
35
  ## Step 2: Establish Baseline
45
36
 
46
- Run build/test commands from `.5/config.json`. Skip commands set to `none`. Keep the results in context for this run — they are what lets verification tell pre-existing failures apart from new ones. Do not persist them. If baseline fails, warn and continue.
37
+ Record `git rev-parse HEAD` as this run's **fixed point** for the review in Step 4, and the files `git status --porcelain` lists now as **pre-run dirty files**: they hold the user's own uncommitted work.
38
+
39
+ Run build/test commands from `.5/config.json`. Skip commands set to `none`. Keep the results in context for this run — they are what lets verification tell pre-existing failures apart from new ones. If baseline fails, warn and continue.
47
40
 
48
41
  ## Step 3: Run
49
42
 
50
- **If the `Workflow` tool is available, use the Workflow engine (preferred).** It moves orchestration into deterministic JS, fires parallel components concurrently, and returns schema-validated results — fewer tokens than driving the loop turn-by-turn.
43
+ ### Compact plan: implement inline
44
+
45
+ The context is already warm, and an agent for one or two files costs more than it saves. Implement the plan yourself, in this session, with no agents and no Workflow call:
46
+
47
+ - Follow the repository standards first, then the style skills. Follow the patterns the plan names.
48
+ - Make the smallest coherent change: reuse existing code in this codebase first, then the standard library, native platform features, and installed dependencies. Touch only the planned files and what they strictly need (their tests, an import site). Add no new dependency.
49
+ - Then run the **fast-path check** (3c).
51
50
 
52
- 1. Build `args` for the workflow:
51
+ ### Full plan, with the `Workflow` tool (preferred)
52
+
53
+ It moves orchestration into deterministic JS, fires parallel components concurrently, and returns schema-validated results — fewer tokens than driving the loop turn-by-turn.
54
+
55
+ 1. Call `Workflow({name: "5-implement", args})` with:
53
56
 
54
57
  ```json
55
58
  {
56
59
  "feature": "{feature-name}",
57
- "paths": {"plan": ".5/features/{feature-name}/plan.md", "scan": ".5/features/{feature-name}/codebase-scan.md", "config": ".5/config.json"},
58
- "isCompact": true,
59
- "components": [{"name": "...", "action": "create|modify|delete|rename", "file": "...", "sourceFile": null, "description": "...", "dependsOn": []}],
60
- "baseline": [{"command": "...", "status": "passed|failed|skipped", "summary": "one line"}],
61
- "completedComponents": []
60
+ "paths": {"plan": "{plan-path}", "config": ".5/config.json"},
61
+ "standards": {"repo": ["CONTRIBUTING.md"], "styles": ["/abs/path/.claude/skills/fowler-code-smells/SKILL.md"]},
62
+ "baseline": [{"command": "...", "status": "passed|failed|skipped", "summary": "one line"}]
62
63
  }
63
64
  ```
64
65
 
65
- - For a **compact** plan, set `isCompact: true` and parse `components` from the plan's Component Checklist (the workflow builds a trivial single step with no orchestrator agent).
66
- - For a **full** plan, set `isCompact: false` and omit `components` — the workflow's orchestrate phase derives steps itself.
66
+ - `standards` holds the repository standards and style skill paths from Step 1. Executors follow them while writing code.
67
67
  - `baseline` is the array from Step 2 (or `[]`); the workflow's verifier treats those failures as pre-existing and reuses passing results instead of rerunning them.
68
- - `completedComponents` is `[]` for a fresh run, or the array from `state.json` to resume. The workflow re-derives the graph and skips those components by name.
69
- - The workflow reads the config **file** at `paths.config` itself; do not pass build/test/commit settings inline — baseline (Step 2) and auto-commit (Step 5) are run by this command, not the workflow.
68
+ - The workflow reads the config **file** at `paths.config` itself; do not pass build/test/commit settings inline.
70
69
 
71
- 2. Call `Workflow({name: "5-implement", args})`.
72
- 3. When it returns, **merge** (never replace) its `completedComponents` into the existing array and write `state.json` (Step 4). A resumed run reports only the components it ran this invocation. Mark the matching tasks completed with `TaskUpdate`. The workflow does not touch the filesystem itself.
73
- 4. Auto-commit per step (Step 5), then report (Step 6).
70
+ 2. If the returned `verification.inline` is `true` (every component was mechanical and passed, so no verification agent ran), run the **fast-path check** (3c) and take its result as the verification.
71
+ 3. Continue with Step 4.
74
72
 
75
- > The Workflow path persists only after the workflow returns — if a run is interrupted mid-way, this session's progress is not saved and those components run again on the next `/5:implement`. The executor's smallest-coherent-change contract makes a re-touch safe but not free.
73
+ ### Full plan, without the `Workflow` tool (prose loop)
76
74
 
77
- **Otherwise, run the prose loop (fallback).** It produces the same outcome:
75
+ It produces the same outcome.
78
76
 
79
- ### 3a. Derive the execution graph
77
+ #### 3a. Derive the execution graph
80
78
 
81
- - **Compact plan:** build the graph inline from the Component Checklist — one step, `mode: "parallel"` unless components share a file or have a dependency (then `sequential`), `model: "haiku"`. **Do not spawn `step-orchestrator-agent`.**
82
- - **Full plan:** spawn `step-orchestrator-agent` with `plan.md`, `codebase-scan.md`, and config; it returns steps, dependencies, model choices, `patternRefs` (line ranges/symbols), and verify commands.
79
+ Spawn `step-orchestrator-agent` with the plan path and config. It returns steps, dependencies, a model per component, `patternRefs` (line ranges/symbols), and verify commands. Check the graph: non-empty steps, and each component carrying `step`, `mode`, `model`, `patternRefs`, and `verifyCommands`.
83
80
 
84
- Check the returned graph: non-empty steps, every component name copied verbatim from the plan's Component Checklist, and each component carrying `step`, `mode`, `model`, `patternRefs`, and `verifyCommands`.
81
+ #### 3b. Execute steps in waves
85
82
 
86
- ### 3b. Execute steps in waves
83
+ For each step:
87
84
 
88
- For each step, skipping components already in `completedComponents`:
89
-
90
- 1. Pre-check: every dependency component is completed and its files still exist.
91
- 2. Mark the step's tasks in progress with `TaskUpdate`.
92
- 3. Spawn executors:
85
+ 1. Pre-check: every dependency component succeeded and its files still exist.
86
+ 2. Spawn executors with the component's model. Run `opus` at `effort: "medium"`.
93
87
  - **Parallel step: emit all of the step's executor Agent calls in a single message so they run concurrently.**
94
88
  - Sequential step (same-file or dependency): one executor at a time.
95
- - Give each executor only its component block, required `patternRefs`, verify commands, and the inline contract below — do not make it read `step-executor-agent.md`.
89
+ - Give each executor only its component block, required `patternRefs`, verify commands, the standards from Step 1, and the inline contract below — do not make it read `step-executor-agent.md`.
96
90
 
97
91
  ```text
98
- Implement exactly the assigned component. Read only listed patternRefs ranges/symbols and the target file. Make the smallest coherent change, run assigned verify commands, and stop (STATUS: failed) for missing dependencies, unplanned auth/schema/API changes, or unclear product decisions. If verify fails only from pre-existing unrelated issues, report it under DEVIATIONS with the exact evidence and keep STATUS: success — your change is complete. Do not make more than three attempts on the same failing issue.
92
+ Implement exactly the assigned component. Read only listed patternRefs ranges/symbols and the target file. Nothing is persisted between runs, so your work may already be done: for `create`, read the target first when it exists — if it already fulfils the intent, report success with no change; otherwise complete it, never overwrite it blindly. Read the parts of the repository standards and style skills that apply to your target and follow them; repository standards win over the styles. Make the smallest coherent change — reuse existing codebase code first, then stdlib, native platform features, and installed dependencies; touch only the target file and what it strictly needs (its test, an import site) — run assigned verify commands, and stop (STATUS: failed) for missing dependencies, unplanned auth/schema/API changes, or unclear product decisions. If verify fails only from pre-existing unrelated issues, report it under DEVIATIONS with the exact evidence and keep STATUS: success — your change is complete. Do not make more than three attempts on the same failing issue.
99
93
 
100
94
  End with:
101
95
  ---RESULT---
@@ -104,19 +98,19 @@ FILES_CREATED: [comma-separated paths]
104
98
  FILES_MODIFIED: [comma-separated paths]
105
99
  VERIFY: passed | failed | skipped
106
100
  DEVIATIONS: none | {brief list}
101
+ SKIPPED: none | {what you deliberately did not build — add when ...}
107
102
  ERROR: none | {error description}
108
103
  ---END---
109
104
  ```
110
105
 
111
- 4. Parse only the `---RESULT---` block from each executor.
112
- 5. **Once per wave** (not per component), append the succeeded component names to `state.json.completedComponents`, refresh `lastUpdated`, and mark the matching tasks completed. Trust the executor's report — do not re-read files you did not change to confirm them.
106
+ 3. Parse only the `---RESULT---` block from each executor. Trust the executor's report — do not re-read files you did not change to confirm them.
113
107
 
114
- Retry failed components up to twice, escalating to `sonnet`. Never fix code in the orchestrator context.
108
+ Retry failed components up to twice on `opus` at `effort: "medium"`. Never fix code in the orchestrator context.
115
109
 
116
- ### 3c. Verify
110
+ #### 3c. Verify
117
111
 
118
- - **Fast path:** when every component reported `success` with `verify` `passed` or `skipped`, and no component was planned as **or escalated to** `sonnet` (i.e. a mechanical change), verify inline — run the configured build/test once (reuse fresh baseline/component results) and set the verification result directly, skipping `verification-agent`.
119
- - **Otherwise:** spawn `verification-agent` with `plan.md`, the component results, the baseline from Step 2, and config (and `codebase-scan.md` only if needed). It returns:
112
+ - **Fast path:** when every component reported `success` with `verify` `passed` or `skipped`, every component was planned as `haiku`, and none needed a retry, run the **fast-path check** below and skip `verification-agent`.
113
+ - **Otherwise:** spawn `verification-agent` — it checks only that the plan was built and works; quality and correctness come from `/5:review` in Step 4 — on `opus` at `effort: "medium"` when any component was planned as or retried on `opus`, else on `sonnet` — with the plan path, the component results, the baseline from Step 2, the repository standards from Step 1, and config. It returns:
120
114
 
121
115
  ```text
122
116
  ---VERIFICATION---
@@ -124,25 +118,41 @@ STATUS: passed | partial | failed
124
118
  COMPLETENESS: passed | partial | failed
125
119
  INFRASTRUCTURE: passed | failed
126
120
  ACCEPTANCE_CRITERIA: satisfied/total
127
- QUALITY: passed | partial | failed
121
+ SCOPE: passed | drift
128
122
  ERRORS: none | {summary}
129
123
  ---END_VERIFICATION---
130
124
  ```
131
125
 
132
- ## Step 4: Persist Result
126
+ **Fast-path check** — used by compact plans and by the fast path of both full-plan routes:
127
+
128
+ 1. Run the configured build and test commands once (skip any set to `none`). A command that passed in the baseline and fails now sets `STATUS: failed`; a failure the baseline already had is pre-existing and only goes into the report.
129
+ 2. `git status --short` and `git diff HEAD --stat`: every changed file must be a planned target, its test, an import site it needs, or a file a repository standard requires (such as a changelog entry). Anything else is drift.
130
+ 3. Changed dependency manifests or lockfiles: a dependency the plan does not require is drift.
131
+ 4. `git diff HEAD` on the changed files plus the full contents of untracked (`??`) files — `git diff HEAD` omits files not yet committed — read against the plan: work the plan rules out or defers, or abstraction/configurability the plan does not ask for, is drift.
133
132
 
134
- Write `state.json` with the merged `completedComponents`, a one-line `verification` summary condensed from the block above, and `lastUpdated`. Set `status` to `completed` when verification passed; otherwise `failed`, and tell the user to fix the reported issues and rerun `/5:implement {feature-name}` to resume.
133
+ Set `SCOPE: passed | drift`. Drift never changes the verification status; it only goes into the report.
134
+
135
+ ## Step 4: Review
136
+
137
+ Run `/5:review since {fixed-point} files: {run-files} feature: {feature-name} dirty: {dirty-files}` with the fixed point and the pre-run dirty files from Step 2 (`dirty: none` when there are none). `{run-files}` lists the files this run created, modified, or deleted, so changes the user already had stay out of the review. `/5:review` runs every quality check exactly once — the built-in `code-review`, `security-review` for security-sensitive files, and `review-style` against the repository standards and the style skills — saves the findings, fixes the clear ones on its own, and asks the user only about real decisions, one at a time. Run it on every path, and before the auto-commit, so approved fixes land in the same commit.
135
138
 
136
139
  ## Step 5: Auto-commit
137
140
 
138
- If `.5/config.json` `git.autoCommit` is `true`, commit once per completed step:
141
+ If `.5/config.json` `git.autoCommit` is `true`, verification passed, and Step 4 left the code green — no review fix was applied, or `/5:address-review-findings` reported `Review findings addressed: yes` — commit, including the review fixes from Step 4 for those files, once per step for a full plan, once for a compact plan:
139
142
 
140
- 1. Stage only files owned by that step's components: `file` for create/modify/delete, both `sourceFile` and `file` for rename, plus the executor's reported `FILES_CREATED`/`FILES_MODIFIED`. Do not stage unrelated changes.
141
- 2. Build the message from `git.commitMessage.pattern`, replacing `{ticket-id}` with the ticket from the plan frontmatter (or empty) and `{short-description}` with `step {number}: {step-name}`; trim redundant whitespace/punctuation when the ticket is empty.
143
+ 1. Stage only files that step owns: each component's `file` for create/modify/delete, both `sourceFile` and `file` for rename, plus the executors' reported `FILES_CREATED`/`FILES_MODIFIED`. For a compact plan, stage the files you changed. Do not stage unrelated changes. **Never stage a pre-run dirty file** (Step 2), on any plan: it holds the user's own unfinished work. Leave it uncommitted and list it in the report.
144
+ 2. Build the message from `git.commitMessage.pattern`, replacing `{ticket-id}` with the ticket the plan or the branch name gives (or empty) and `{short-description}` with `step {number}: {step-name}` (compact plan: a short summary of the change); trim redundant whitespace/punctuation when the ticket is empty.
142
145
  3. Commit.
143
146
 
144
- No changed files → skip. Commit error → report it and continue; do not retry with broader paths. If `git.autoCommit` is missing/`false`, do not commit.
147
+ When a review fix left build, tests, e2e, or lint failing, do not commit; report it. No changed files → skip. Commit error → report it and continue; do not retry with broader paths. If `git.autoCommit` is missing/`false`, do not commit.
145
148
 
146
149
  ## Step 6: Report
147
150
 
148
- Report: completed/failed component counts, verification status, path to `state.json`, auto-commit count and any failures, and any failed commands, missing tests, or unmet acceptance criteria. Then stop.
151
+ Report: completed/failed component counts, verification status, auto-commit count and any failures, and any failed commands, missing tests, or unmet acceptance criteria. When verification failed, tell the user to fix the reported issues and rerun `/5:implement {feature-name}`. Also list, one line each:
152
+
153
+ - **Review:** the findings count from `/5:review` and how many were fixed.
154
+ - **Scope:** drift findings from verification, plus files an executor touched outside its planned target (the workflow returns these as `extraFiles`). Suggest `/5:lean-check {feature-name}` when there are any.
155
+ - **Skipped:** every non-`none` `SKIPPED` entry from the executors, so deliberate omissions stay visible.
156
+ - **Not committed:** pre-run dirty files the run changed — they also hold the user's earlier work, so the user commits them.
157
+
158
+ Then stop.
@@ -0,0 +1,75 @@
1
+ ---
2
+ name: 5:lean-check
3
+ description: Checks any diff for scope drift and over-engineering — changes that do not trace to the request, new dependencies, reinvented code. Works with or without a workflow plan.
4
+ allowed-tools: Bash, Read, Glob, Grep, Edit, Write, AskUserQuestion
5
+ argument-hint: [base-branch|feature-name] [what was requested]
6
+ user-invocable: true
7
+ model: sonnet
8
+ ---
9
+
10
+ <role>
11
+ You are a Lean Checker. You find what a change added beyond what was asked and what could be smaller.
12
+ You only hunt scope drift and complexity. Correctness, security, and performance belong to `/5:review`.
13
+ </role>
14
+
15
+ # Lean Check
16
+
17
+ ## Step 1: Collect the Diff
18
+
19
+ Resolve a base, then diff the working tree against it — `git diff {base} --stat` and `git diff {base}` cover committed and uncommitted changes together; add untracked files from `git status --short`.
20
+
21
+ A feature name is an argument that has a `.5/features/{argument}/` folder or a plan in `.5/planning/` with `feature: {argument}` in its frontmatter.
22
+
23
+ - A base branch argument (`git rev-parse --verify {argument}` succeeds and it is not a feature name): `base = git merge-base {argument} HEAD`.
24
+ - A feature name or no argument: `base = git merge-base {default-branch} HEAD`, where `{default-branch}` comes from `git symbolic-ref --short refs/remotes/origin/HEAD` (fall back to `main`, then `master`). This includes commits already made by `/5:implement` with `git.autoCommit`. When `HEAD` is the default branch itself, `base = HEAD` (uncommitted changes only).
25
+ - Any other argument is request text for Step 2.
26
+
27
+ No changes → say `Nothing to check.` and stop.
28
+
29
+ ## Step 2: Establish the Request
30
+
31
+ Every finding is judged against what was asked. Take the first that exists:
32
+
33
+ 1. Request text passed as an argument.
34
+ 2. The feature's plan — the file in `.5/planning/` with `feature: {feature-name}` in its frontmatter — when a feature name was passed or the current branch matches a feature. Use what it puts in and out of scope, the success criteria it states, the work it defers, and the files it targets.
35
+ 3. The request from this conversation.
36
+
37
+ None of these → ask the user for one sentence describing what the change should do.
38
+
39
+ ## Step 3: Check
40
+
41
+ Read the diff first; read full files only where a finding needs the surrounding code. Search the codebase before claiming something is reinvented.
42
+
43
+ Tags, one per finding:
44
+
45
+ - `drift:` a file or change that does not trace to the request (unrelated refactor, reformatting, a feature nobody asked for, work the plan rules out or defers). Replacement: revert it.
46
+ - `dep:` a new dependency in a manifest or lockfile. Name what already covers it (stdlib, platform, installed dependency), or `needed` if nothing does.
47
+ - `reuse:` re-implements something that already lives in this codebase. Name the existing symbol and path.
48
+ - `stdlib:` / `native:` hand-rolled code the standard library or platform ships. Name the function or feature.
49
+ - `yagni:` abstraction with one implementation, config nobody sets, a layer with one caller, flexibility nobody asked for.
50
+ - `delete:` dead code, unreachable branches, error handling for impossible cases.
51
+ - `shrink:` same logic, fewer lines. Show the shorter form.
52
+
53
+ Never flag: input validation at trust boundaries, error handling that prevents data loss, security measures, accessibility, one small test for non-trivial logic, or anything the request explicitly asked for.
54
+
55
+ ## Step 4: Report
56
+
57
+ One line per finding, biggest cut first:
58
+
59
+ ```text
60
+ {file}:L{line}: {tag} {what}. {replacement}.
61
+ ```
62
+
63
+ End with `net: -{N} lines, -{M} dependencies possible.` With no findings, output `Lean already. Ship.` and stop.
64
+
65
+ ## Step 5: Offer to Apply
66
+
67
+ Ask the user:
68
+
69
+ - "Apply these cuts?"
70
+ - Options:
71
+ 1. "Apply all" — apply every finding
72
+ 2. "Only drift and dependencies" — revert unrelated changes and new dependencies, leave the rest
73
+ 3. "No, report only"
74
+
75
+ When applying: make only the listed changes, revert `drift:` hunks without touching the rest of the file, remove dependencies with the project's package manager (never by editing a lockfile by hand), then run the configured build/test commands from `.5/config.json` (skip any set to `none`) and report the result. Never commit.
@@ -1,12 +1,12 @@
1
1
  ---
2
2
  name: 5:reconfigure
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 AGENTS.md, and refreshes all skills.
3
+ description: Lightweight refresh of the foifi block in AGENTS.md and the generated rules, without full Q&A. Points plan mode at .5/planning/ and removes the legacy .5/index/. Never touches skills or anything outside the foifi block.
4
4
  allowed-tools: Read, Write, Bash, Glob, Grep, Agent, AskUserQuestion
5
5
  user-invocable: true
6
6
  ---
7
7
 
8
8
  <role>
9
- You are a Project Reconfigurer. You refresh documentation and skills using existing config.json preferences.
9
+ You are a Project Reconfigurer. You refresh the foifi block in AGENTS.md and the workflow-generated rules using existing config.json preferences.
10
10
  You do NOT modify user preferences (ticket patterns, branch conventions, commit patterns, etc.).
11
11
  You detect codebase changes, confirm with the user, invoke the configuration refresh skills, then report.
12
12
  After reporting what was updated, you are DONE.
@@ -16,134 +16,67 @@ After reporting what was updated, you are DONE.
16
16
 
17
17
  ## Overview
18
18
 
19
- Single-command refresh that skips the full Q&A of `/5:configure`. Re-detects codebase state, regenerates documentation and skills based on existing `config.json` preferences.
20
-
21
- **When to use which:**
19
+ Single-command refresh that skips the full Q&A of `/5:configure`. It is also the upgrade path after a major workflow update.
22
20
 
23
21
  | Scenario | Command |
24
22
  |----------|---------|
25
23
  | First-time setup | `/5:configure` |
26
24
  | Change preferences (ticket pattern, commit pattern, etc.) | `/5:configure` |
27
- | Codebase evolved, refresh docs/skills | **`/5:reconfigure`** |
28
- | Add new skill patterns | `/5:configure` |
25
+ | Codebase or standards evolved, refresh the AGENTS.md block and rules | **`/5:reconfigure`** |
26
+ | After a major workflow upgrade | **`/5:reconfigure`** |
29
27
 
30
28
  ## ⚠️ CRITICAL SCOPE CONSTRAINT
31
29
 
32
- **THIS COMMAND REGENERATES DOCS AND SKILLS. IT DOES NOT CHANGE USER PREFERENCES.**
33
-
34
30
  Your job:
35
31
  ✅ Validate that config.json exists
36
- ✅ Re-detect codebase patterns and commands (same as configure Steps 1b-1h)
37
- ✅ Compare detected state with config.json skill selections
32
+ ✅ Re-detect repository standards and rule-relevant file types
38
33
  ✅ Show summary and ask for confirmation
39
- ✅ Invoke `configure-docs-index` and `configure-skills` in refresh mode
40
- ✅ Update version.json with artifacts and timestamps
41
- ✅ Clean up .reconfig-reminder flag
34
+ ✅ Point Claude Code plan mode at `.5/planning/` when it is not yet
35
+ ✅ Invoke `configure-agents-md` and `configure-rules` in refresh mode
36
+ ✅ Remove the legacy `.5/index/` after confirmation
37
+ ✅ Update version.json timestamps and clean up the reminder flags
42
38
  ✅ Report what was updated
43
39
 
44
40
  Your job is NOT:
45
- ❌ Ask preference questions (ticket pattern, branch convention, commit pattern, etc.)
46
- ❌ Modify config.json preferences (only the `skills` section may be updated if user confirms new patterns)
41
+ ❌ Ask preference questions or modify config.json preferences
47
42
  ❌ Skip confirmation — always show what will be regenerated
43
+ ❌ Change anything in AGENTS.md or CLAUDE.md outside the foifi block
44
+ ❌ Create, refresh, or remove any skill — skills belong to the user or to the installer
45
+ ❌ Modify user-created rules
46
+ ❌ Rewrite or delete existing `.5/*.md` docs — earlier versions generated them, but a team may maintain them now
48
47
 
49
48
  ## Process
50
49
 
51
50
  ### Step 1: Validate Config
52
51
 
53
- Read `.5/config.json`. If it does not exist:
54
- - Tell the user: "No configuration found. Please run `/5:configure` first to set up your project."
55
- - **EXIT IMMEDIATELY**
56
-
57
- Read `.5/version.json` for current state (configuredAt, configuredAtCommit).
58
-
59
- ### Step 1b: Check skill-creator plugin
60
-
61
- Check if the skill-creator plugin is available (look for skill-creator tools in the current session):
62
-
63
- - If available: note for later use during skill generation
64
- - If NOT available AND config.json has skill selections (i.e., skills exist in `.claude/skills/`):
65
- - "The skill-creator plugin is not installed. It can improve skill quality."
66
- - Options:
67
- 1. "Install now (recommended)" — run `claude plugin install skill-creator@claude-plugins-official` via Bash
68
- 2. "Skip"
69
- - If "Install now": execute the install command
70
-
71
- ### Step 2: Re-detect Codebase State
72
-
73
- Perform the same detection as configure Steps 1b-1h:
74
-
75
- **2a. Detect project type** — same table as configure Step 1b (package.json deps, build files, etc.)
76
-
77
- **2b. Detect build/test commands** — same as configure Step 1c
78
-
79
- **2c. Detect codebase patterns** — same as configure Step 1g:
80
- - Scan for architectural patterns (Controllers, Services, Components, etc.)
81
- - Use both suffix-based and directory-based globs
82
- - For each pattern: count files, identify location, sample filename
52
+ Read `.5/config.json`. If it does not exist, tell the user: "No configuration found. Please run `/5:configure` first to set up your project." and **EXIT IMMEDIATELY**.
83
53
 
84
- **2d. Detect runnable commands** — same as configure Step 1h:
85
- - Scan package.json scripts, Makefile targets, etc.
86
- - Categorize: Build, Test, Lint, Format, Type Check, etc.
54
+ ### Step 2: Re-detect
87
55
 
88
- **2e. Scan existing skills** — list ALL skills in `.claude/skills/`:
89
- - Read each skill's SKILL.md frontmatter
90
- - Categorize as workflow-generated (create-*, run-*) or user-created
56
+ - **Repository standards** — same as configure Step 1e2. Note each path for the refresh manifest.
57
+ - **AGENTS.md state** — whether it has a foifi block, is a legacy fully generated file (first line starts with `<!-- Generated from the foifi AGENTS.md template`), or has no block yet. Whether `CLAUDE.md` includes `@AGENTS.md`.
58
+ - **Rules** (if `rules.generate` is `true`) — on Codex, the `###` subsections of the `File-Scoped Rules` section in the foifi block of `AGENTS.md`; all of them are workflow-generated. On Claude Code, list `.claude/rules/*.md`. A rule is workflow-generated when it contains `<!-- foifi:generated -->`, or, from earlier versions, when it is named `code-style.md`, `testing.md`, `api-patterns.md`, or `dependencies.md` and you confirm it with the user in Step 3. Everything else is user-created.
59
+ - For each workflow rule, check that its file types still exist (stale), and whether a missing rule from `configure-rules` step 1 now applies (new).
91
60
 
92
- **2f. Scan existing rules** — list ALL rule files in `.claude/rules/`:
93
- - Read each `.md` file
94
- - Note which are workflow-generated (code-style, testing, api-patterns, dependencies) vs user-created
95
- - User-created rules are never modified or removed
61
+ ### Step 3: Confirm with User
96
62
 
97
- ### Step 3: Compare and Prepare Summary
63
+ Use `AskUserQuestion` to show a summary and get confirmation:
98
64
 
99
- Use the existing skills in `.claude/skills/` (from Step 2e) as the source of truth — not config.json. Compare what's installed with what's detected in the codebase:
65
+ 1. **AGENTS.md** — the foifi block will be replaced, appended, or (legacy file) rebuilt with the user's Custom Documentation kept above it. Nothing else changes. `CLAUDE.md` gets `@AGENTS.md` appended when it lacks it.
66
+ 2. **Legacy files that will be removed** — `.5/index/` when it exists.
67
+ 3. **Settings** — `plansDirectory` set to `.5/planning` in `.claude/settings.json`, when it is not already (Claude Code only).
68
+ 4. **Rules** — which workflow rules will be refreshed, created, or removed (multi-select for new and stale ones). For legacy rules without the marker, ask whether foifi may manage them.
100
69
 
101
- - **Existing `create-*` skills** — extract the pattern name from each (e.g., `create-controller` → `controller`)
102
- - **Existing `run-*` skills** — extract the command name from each (e.g., `run-tests` → `tests`)
103
- - **New patterns**: detected in codebase (Step 2c) but no matching `create-*` skill exists → offer to create
104
- - **Stale patterns**: a `create-*` skill exists but the pattern is no longer detected in the codebase → offer to remove or keep
105
- - **New commands**: detected (Step 2d) but no matching `run-*` skill exists → offer to create
106
- - **Stale commands**: a `run-*` skill exists but the command is no longer detected → offer to remove or keep
107
- - **User-created skills** (not matching `create-*` or `run-*` naming) → always refresh with current conventions, never remove
70
+ Options: "Proceed with refresh" or "Cancel".
108
71
 
109
- **Rules comparison** (if `rules.generate` is `true` in config.json):
110
- - **Existing workflow rules** (from Step 2f) — code-style, testing, api-patterns, dependencies
111
- - **Stale rules**: a workflow rule exists but its prerequisite patterns are no longer detected → offer to remove
112
- - **New rules**: patterns detected that could benefit from a rule but none exists yet → offer to create
113
- - **User-created rules** → never modify or remove
72
+ ### Step 4: Build Refresh Manifest
114
73
 
115
- ### Step 4: Confirm with User
116
-
117
- Use `AskUserQuestion` to show a summary and get confirmation. Present:
118
-
119
- 1. **Documentation files that will be rewritten** — list `.5/ARCHITECTURE.md`, `.5/TESTING.md`, `.5/CONCERNS.md` (conditional), `.5/CONVENTIONS.md` (when `conventions.generate` is true), `.5/index/rebuild-index.sh`, `.5/index/*.md`, and `AGENTS.md`
120
- 2. **Skills that will be refreshed** — list ALL skills found in `.claude/skills/` (both workflow-generated and user-created)
121
- 3. **Rules that will be refreshed** (if rules enabled) — list workflow-generated rule files in `.claude/rules/`
122
- 4. **New patterns detected** (if any) — "These patterns were found in your codebase but don't have skills yet: [list]. Create skills for them?"
123
- 5. **Stale patterns** (if any) — "These patterns are in your config but weren't found in the codebase: [list]. Remove them?"
124
- 6. **Stale rules** (if any) — "These rule files no longer have matching patterns in the codebase: [list]. Remove them?"
125
-
126
- Options:
127
- - "Proceed with refresh" — regenerate everything as shown
128
- - "Cancel" — exit without changes
129
-
130
- If there are new or stale patterns, use additional `AskUserQuestion` calls with multiSelect to let the user pick which new patterns to add and which stale patterns to remove.
131
-
132
- New skills will be created and stale skills removed based on the user's choices.
133
-
134
- ### Step 5: Build Refresh Manifest
135
-
136
- Write `.5/reconfigure-manifest.json` with the compact decisions needed by refresh skills:
74
+ Write `.5/reconfigure-manifest.json`:
137
75
 
138
76
  ```json
139
77
  {
140
78
  "mode": "refresh",
141
- "docs": ["ARCHITECTURE.md", "TESTING.md", "CONCERNS.md", "CONVENTIONS.md", "index", "AGENTS.md"],
142
- "skills": {
143
- "refresh": ["skill names"],
144
- "create": ["new skill names"],
145
- "remove": ["stale skill names selected by user"]
146
- },
79
+ "repoStandards": ["paths from Step 2"],
147
80
  "rules": {
148
81
  "refresh": ["rule files"],
149
82
  "create": ["new rule files"],
@@ -152,51 +85,37 @@ Write `.5/reconfigure-manifest.json` with the compact decisions needed by refres
152
85
  }
153
86
  ```
154
87
 
155
- Keep detection details out of the prompt once they are represented in this manifest.
88
+ ### Step 5: Regenerate
156
89
 
157
- ### Step 6: Regenerate
90
+ First, point plan mode at `.5/planning/` exactly as `/5:configure` Step 2.5 describes (Claude Code only — skip on Codex).
158
91
 
159
- Invoke the refresh skills in **refresh mode** via the Agent tool:
92
+ Then invoke the refresh skills in **refresh mode** via the Agent tool (`subagent_type: "general-purpose"`), one after the other — on Codex both write the foifi block of `AGENTS.md`:
160
93
 
161
94
  ```
162
- Task prompt 1: "Run configure-docs-index skill in REFRESH MODE using `.5/reconfigure-manifest.json`. Refresh generated docs, rebuild `.5/index/`, remove legacy docs, and update `AGENTS.md` plus the CLAUDE.md shim while preserving user sections."
95
+ Task prompt 1: "Run configure-agents-md skill in REFRESH MODE using `.5/reconfigure-manifest.json`. Refresh the foifi block in AGENTS.md and the CLAUDE.md include; change nothing outside the block."
163
96
 
164
- Task prompt 2: "Run configure-skills skill in REFRESH MODE using `.5/reconfigure-manifest.json`. Refresh, create, and remove only the skills/rules listed in the manifest."
97
+ Task prompt 2: "Run configure-rules skill in REFRESH MODE using `.5/reconfigure-manifest.json`. Refresh, create, and remove only the rules listed in the manifest."
165
98
  ```
166
99
 
167
- Use `subagent_type: "general-purpose"` for the Agent.
168
-
169
- ### Step 7: Track
100
+ Skip task 2 when `rules.generate` is `false`.
170
101
 
171
- After the skill completes, update `.5/version.json`:
102
+ ### Step 6: Track and Clean Up
172
103
 
173
- 1. Read current version.json
174
- 2. Set `configuredAt` to current ISO timestamp
175
- 3. Set `configuredAtCommit` to current short commit hash (`git rev-parse --short HEAD`)
176
- 4. Write back version.json preserving all other fields
104
+ Update `.5/version.json`: set `configuredAt` to the current ISO timestamp and `configuredAtCommit` to `git rev-parse --short HEAD`, preserving all other fields. Then:
177
105
 
178
- ### Step 8: Clean Up
179
-
180
- Remove the `.5/.reconfig-reminder` and `.5/.migration-v2` flag files if they exist:
181
106
  ```bash
182
- rm -f .5/.reconfig-reminder .5/.migration-v2
107
+ rm -f .5/.reconfig-reminder .5/.migration-v*
108
+ rm -rf .5/index # only when the user confirmed it in Step 3
183
109
  ```
184
110
 
185
- ### Step 9: Report
186
-
187
- Show the user a summary:
188
- - List of documentation files updated (including `.5/CONVENTIONS.md` when applicable)
189
- - Mention whether the codebase index script and index files were regenerated
190
- - List of skills refreshed
191
- - List of new skills created (if any)
192
- - List of skills removed (if any)
193
- - List of rules refreshed (if any)
194
- - List of new rules created (if any)
195
- - List of rules removed (if any)
196
- - Timestamp of reconfiguration
111
+ ### Step 7: Report
112
+
113
+ - How the AGENTS.md block was written, which repository standards it links, and whether `CLAUDE.md` changed
114
+ - Whether `plansDirectory` was set and the legacy `.5/index/` removed
115
+ - Rules refreshed, created, and removed
197
116
  - Suggest running `/clear` to reset context
198
117
 
199
118
  ## Related Documentation
200
119
  - [configure command](./configure.md) — full Q&A configuration
201
- - [configure-docs-index skill](../../skills/configure-docs-index/SKILL.md)
202
- - [configure-skills skill](../../skills/configure-skills/SKILL.md)
120
+ - [configure-agents-md skill](../../skills/configure-agents-md/SKILL.md)
121
+ - [configure-rules skill](../../skills/configure-rules/SKILL.md)