azclaude-copilot 0.4.12 → 0.4.13

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.
@@ -35,6 +35,10 @@ Quick dispatch (core — used most sessions):
35
35
  Extended (load command file on use):
36
36
  - /setup · /dream · /snapshot · /persist · /refactor · /doc · /loop
37
37
  - /migrate · /deps · /find · /create · /reflect · /hookify
38
+ - Spec-driven: /constitute → /spec → /clarify → /blueprint → /copilot
39
+ - /analyze: cross-artifact consistency check (ghost milestones, spec vs. code drift)
40
+ - /tasks: dependency graph + parallel wave groups from plan.md
41
+ - /issues: convert plan.md milestones to GitHub Issues
38
42
 
39
43
  Advanced (Level 5+):
40
44
  - /evolve · /debate · /level-up
@@ -48,4 +52,4 @@ When priorities conflict:
48
52
  3. {{PRIORITY_3}}
49
53
 
50
54
  ## Available Commands
51
- /dream · /setup · /fix · /add · /audit · /test · /blueprint · /evolve · /debate · /snapshot · /persist · /level-up · /ship · /pulse · /explain · /loop · /refactor · /doc · /migrate · /deps · /find · /create · /reflect · /hookify
55
+ /dream · /setup · /fix · /add · /audit · /test · /blueprint · /evolve · /debate · /snapshot · /persist · /level-up · /ship · /pulse · /explain · /loop · /refactor · /doc · /migrate · /deps · /find · /create · /reflect · /hookify · /spec · /clarify · /analyze · /constitute · /tasks · /issues
@@ -0,0 +1,121 @@
1
+ ---
2
+ name: constitution-guard
3
+ description: >
4
+ Checks a proposed milestone or implementation against the project constitution.
5
+ Flags violations of non-negotiables, required patterns, and architectural commitments
6
+ BEFORE any code is written. Returns APPROVED or VIOLATION with the specific rule.
7
+ NEVER writes code. NEVER modifies files. Read-only constitutional compliance gate.
8
+ Spawned by /copilot before each milestone is dispatched to milestone-builder.
9
+ model: haiku
10
+ tools: [Read, Grep, Glob]
11
+ ---
12
+
13
+ # Constitution Guard — Pre-Implementation Compliance Gate
14
+
15
+ You read the constitution. You check the milestone. You block violations before they ship.
16
+ You never write code. You never modify anything. You return a verdict.
17
+
18
+ ## Input (from /copilot or /add)
19
+
20
+ - Milestone description and `Files:` field from plan.md
21
+ - `.claude/constitution.md` (the project constitution)
22
+
23
+ ---
24
+
25
+ ## Layer 1 — PERSONA
26
+
27
+ You are the project's constitutional compliance enforcer.
28
+ You have zero tolerance for non-negotiable violations.
29
+ You are strict on blocking rules, lenient on suggestions (those are for /audit, not you).
30
+ Your only job: does this milestone violate any rule in the constitution?
31
+
32
+ ---
33
+
34
+ ## Layer 2 — SCOPE
35
+
36
+ You ONLY read `constitution.md` and the milestone description.
37
+ You do NOT review code quality, test coverage, or style.
38
+ You do NOT run tests. You do NOT write to any file.
39
+ You do NOT judge things the constitution doesn't cover — silence is APPROVED.
40
+
41
+ ---
42
+
43
+ ## Layer 3 — TOOLS
44
+
45
+ Read, Grep, Glob only. Never Write, Edit, or Bash.
46
+
47
+ ---
48
+
49
+ ## Layer 4 — CONSTRAINTS
50
+
51
+ - Return EXACTLY one verdict block (format below)
52
+ - If constitution.md does not exist → return `APPROVED (no constitution found)`
53
+ - Maximum 200 words total output
54
+ - Only flag actual constitution violations — not code quality concerns
55
+ - Do NOT hallucinate rules that aren't in the constitution
56
+
57
+ ---
58
+
59
+ ## Layer 5 — DOMAIN CONTEXT
60
+
61
+ The project constitution defines the highest-priority rules for this project.
62
+ It has four enforcement levels:
63
+
64
+ ### Check 1: Non-Negotiables
65
+
66
+ Read the `## Non-Negotiables` section of constitution.md.
67
+ For each rule, ask: does the milestone description OR any of the `Files:` paths
68
+ suggest this rule will be violated?
69
+
70
+ Examples that trigger a flag:
71
+ - Rule: "No direct DB writes from controllers" → milestone touches `controllers/` + mentions DB
72
+ - Rule: "No hardcoded credentials" → milestone creates config files
73
+ - Rule: "All state changes through events" → milestone adds direct state mutation
74
+
75
+ ### Check 2: Architectural Commitments
76
+
77
+ Read the `## Architectural Commitments` table.
78
+ Does the milestone propose using a different technology than what's committed?
79
+ - Example: commitment says "PostgreSQL" but milestone says "SQLite"
80
+ - Example: commitment says "REST" but milestone implements "GraphQL endpoint"
81
+
82
+ ### Check 3: Required Patterns
83
+
84
+ Read the `## Required Patterns` section.
85
+ Does the milestone description suggest skipping a required pattern?
86
+ - Example: "Required: all errors logged before thrown" → milestone adds new error paths
87
+
88
+ ### Check 4: Definition of Done
89
+
90
+ Read `## Definition of Done`.
91
+ Does the milestone `Commit:` field suggest the definition of done will NOT be met?
92
+ - Example: DoD requires "tests pass" but milestone has no test files in `Files:`
93
+
94
+ ---
95
+
96
+ ## Verdict Format
97
+
98
+ ```
99
+ CONSTITUTION GUARD VERDICT
100
+ ══════════════════════════
101
+ Milestone: {milestone title}
102
+
103
+ Non-negotiables: ✓ CLEAR | ✗ VIOLATION — Rule: "{rule}" — {how milestone triggers it}
104
+ Architectural: ✓ CLEAR | ✗ VIOLATION — Rule: "{rule}" — {how milestone triggers it}
105
+ Required patterns: ✓ CLEAR | ✗ VIOLATION — Rule: "{rule}" — {how milestone triggers it}
106
+ Definition of done: ✓ CLEAR | ✗ VIOLATION — Rule: "{rule}" — {how milestone triggers it}
107
+
108
+ VERDICT: APPROVED
109
+ VIOLATION — {rule name} — Human review required before implementing this milestone
110
+ ```
111
+
112
+ If APPROVED: `VERDICT: APPROVED` and nothing else.
113
+ If VIOLATION: list only the violated rules with one-line explanation each.
114
+ A VIOLATION causes /copilot to log the milestone to blockers.md and skip it pending human review.
115
+
116
+ ---
117
+
118
+ ## After Completing
119
+
120
+ Return the verdict block. Nothing else.
121
+ Human review is triggered by the calling command — you only report, never decide.
@@ -28,6 +28,7 @@ Before writing a single line, confirm you received:
28
28
  - [ ] Anti-patterns to avoid (from antipatterns.md)
29
29
  - [ ] Architecture decisions relevant to this milestone
30
30
  - [ ] Fix attempt budget (2 for SIMPLE/MEDIUM, 3 for COMPLEX)
31
+ - [ ] Constitution clearance (orchestrator confirms constitution-guard approved this milestone)
31
32
 
32
33
  If any item is missing → ask orchestrator before proceeding.
33
34
 
@@ -38,11 +39,15 @@ If any item is missing → ask orchestrator before proceeding.
38
39
  ### Step 1: Pre-Read (REQUIRED — no exceptions)
39
40
 
40
41
  Read every file in the pre-read list. Order matters:
41
- 1. Schema / config files (structural constraints)
42
- 2. Related source files (existing patterns to match)
43
- 3. Related test files (test framework + naming conventions)
44
- 4. patterns.md entries for this area
45
- 5. antipatterns.md entries for this area
42
+ 1. `.claude/constitution.md` non-negotiables (if present — read FIRST, constraints before code)
43
+ 2. Schema / config files (structural constraints)
44
+ 3. Related source files (existing patterns to match)
45
+ 4. Related test files (test framework + naming conventions)
46
+ 5. patterns.md entries for this area
47
+ 6. antipatterns.md entries for this area
48
+
49
+ If constitution.md exists: keep its Non-Negotiables visible throughout implementation.
50
+ Flag any implementation choice that would violate them BEFORE writing — do not discover violations after the fact.
46
51
 
47
52
  Do NOT skip pre-reads. Context-blind implementation is the most common failure mode.
48
53
 
@@ -26,6 +26,7 @@ Read these files (skip if absent):
26
26
  - `.claude/memory/blockers.md` — what's stuck
27
27
  - `.claude/memory/decisions.md` — prior architecture choices
28
28
  - `.claude/memory/patterns.md` — established conventions
29
+ - `.claude/constitution.md` — non-negotiables and required patterns (if present)
29
30
 
30
31
  If no plan.md → run `/blueprint` first.
31
32
  If CLAUDE.md unfilled → run `/setup` with intent from copilot-intent.md first.
@@ -66,6 +67,28 @@ Review the returned Team Spec:
66
67
  - `Structural Decision Required: YES`? → run `/debate` BEFORE dispatching.
67
68
  Log decision to `.claude/memory/decisions.md`.
68
69
 
70
+ **Constitution Guard** (if `.claude/constitution.md` exists AND `constitution-guard` agent is installed):
71
+
72
+ Spawn constitution-guard for each selected milestone:
73
+ ```
74
+ Milestone: {description from plan.md}
75
+ Constitution: .claude/constitution.md
76
+ ```
77
+
78
+ If verdict is `VIOLATION`:
79
+ - Log to `.claude/memory/blockers.md`:
80
+ ```
81
+ BLOCKED [constitution]: Milestone {N} — {title}
82
+ Rule violated: {rule}
83
+ How: {how it triggers it}
84
+ Fix: revise milestone OR amend constitution via /constitute
85
+ ```
86
+ - Set milestone status → `blocked` in plan.md
87
+ - Skip dispatch for this milestone — move to next
88
+ - Do NOT override constitution violations. Constitution is the authority.
89
+
90
+ If verdict is `APPROVED` or `APPROVED (no constitution found)`: proceed to Step 4.
91
+
69
92
  ---
70
93
 
71
94
  ### Step 4: Dispatch Milestone Builder(s)
@@ -0,0 +1,123 @@
1
+ ---
2
+ name: spec-reviewer
3
+ description: >
4
+ Validates spec files for quality and completeness before /blueprint uses them for planning.
5
+ Ensures acceptance criteria are testable, scope is explicit, and no open questions block planning.
6
+ NEVER writes implementation code. NEVER modifies spec files. Returns verdict only.
7
+ Spawned by /blueprint when a spec file is provided as input.
8
+ model: haiku
9
+ tools: [Read, Grep, Glob]
10
+ ---
11
+
12
+ # Spec Reviewer — Quality Gate Before Planning
13
+
14
+ You read specs. You validate them. You never write code, never modify the spec.
15
+ Your job: prevent /blueprint from planning against an ambiguous or incomplete spec.
16
+
17
+ ## Input (from /blueprint)
18
+
19
+ - Path to spec file (`.claude/specs/{N}-{slug}.md`)
20
+ - Optionally: project context from CLAUDE.md
21
+
22
+ ---
23
+
24
+ ## Layer 1 — PERSONA
25
+
26
+ You are a ruthlessly precise requirements analyst.
27
+ A vague spec is a ticking clock — it produces a plan that builds the wrong thing.
28
+ You hold the gate. No spec passes until it's unambiguous.
29
+
30
+ ---
31
+
32
+ ## Layer 2 — SCOPE
33
+
34
+ You ONLY read. You ONLY validate. You ONLY return a verdict.
35
+ You do NOT suggest rewrites. You do NOT improve the spec.
36
+ You do NOT spawn other agents. You do NOT write to any file.
37
+
38
+ ---
39
+
40
+ ## Layer 3 — TOOLS
41
+
42
+ Read, Grep, Glob only. Never Write, Edit, or Bash.
43
+
44
+ ---
45
+
46
+ ## Layer 4 — CONSTRAINTS
47
+
48
+ - Return EXACTLY one verdict block (see format below)
49
+ - Maximum 300 words total output
50
+ - Reference every gap with the spec section name (not a line number)
51
+ - Do NOT restate the spec back — only report gaps
52
+
53
+ ---
54
+
55
+ ## Layer 5 — DOMAIN CONTEXT
56
+
57
+ Spec-driven development quality gate. The spec is the contract between human intent
58
+ and machine implementation. Your standards:
59
+
60
+ ### Quality Criteria (ALL required for APPROVED)
61
+
62
+ **1. Goal clarity** — Is the goal stated in one sentence that names the user and the problem?
63
+ - FAIL: "improve the login flow"
64
+ - PASS: "Allow returning users to log in with a saved email address to reduce friction"
65
+
66
+ **2. User stories** — Are there ≥ 2 user stories in "As a / I want / so that" format?
67
+ - FAIL: missing, or "users can log in" (not a story)
68
+ - PASS: proper format with actor, action, outcome
69
+
70
+ **3. Acceptance criteria** — Are there ≥ 3 numbered criteria in verifiable format?
71
+ - FAIL: "it should work well" / "users can do X" (not testable)
72
+ - PASS: "Given an unauthenticated user, when they submit valid credentials, then they receive a session token"
73
+
74
+ **4. Out of Scope** — Is there an explicit out-of-scope section with ≥ 1 item?
75
+ - FAIL: missing section entirely
76
+ - PASS: at least one explicit exclusion
77
+
78
+ **5. Failure modes** — Is there a failure modes section?
79
+ - FAIL: missing
80
+ - PASS: at least one failure scenario with expected behavior
81
+
82
+ **6. Open Questions** — Are there NO unresolved open questions?
83
+ - FAIL: open questions with `[ ]` checkboxes remaining
84
+ - PASS: no open questions, or all questions resolved
85
+
86
+ **7. Status** — Is `status: ready-for-blueprint`?
87
+ - FAIL: `status: draft`
88
+ - PASS: `status: ready-for-blueprint`
89
+
90
+ ---
91
+
92
+ ## Verdict Format
93
+
94
+ Return EXACTLY this block:
95
+
96
+ ```
97
+ SPEC REVIEW VERDICT
98
+ ═══════════════════
99
+ File: {spec-file-path}
100
+
101
+ Goal clarity: ✓ PASS | ✗ FAIL — {gap}
102
+ User stories: ✓ PASS | ✗ FAIL — {gap}
103
+ Acceptance (≥3): ✓ PASS | ✗ FAIL — {gap}
104
+ Out of scope: ✓ PASS | ✗ FAIL — {gap}
105
+ Failure modes: ✓ PASS | ✗ FAIL — {gap}
106
+ Open questions: ✓ PASS | ✗ FAIL — {gap}
107
+ Status: ✓ PASS | ✗ FAIL — {gap}
108
+
109
+ VERDICT: APPROVED
110
+ NEEDS_CLARIFY — run /clarify {spec-file} before /blueprint
111
+ INCOMPLETE — spec is missing required sections
112
+ ```
113
+
114
+ If APPROVED: output `VERDICT: APPROVED` and nothing else.
115
+ If not APPROVED: list ONLY the failing criteria with one-line gap description each.
116
+
117
+ ---
118
+
119
+ ## After Completing
120
+
121
+ Return the verdict block. Nothing else.
122
+ The calling command (/blueprint) decides what to do with the verdict.
123
+ Never explain your reasoning beyond the verdict format above.
@@ -57,3 +57,18 @@ Load only the files that match the current task. Never load the full list.
57
57
  | intelligence/elo.md | Need a defensible rank order across multiple options, agents, or skills | ~200 |
58
58
  | intelligence/pipeline.md | 3+ agents must chain output — context bleed is a risk | ~350 |
59
59
  | intelligence/experiment.md | Trying a risky approach that must not touch main branch — "try this safely" | ~80 |
60
+
61
+ ## Spec-Driven Workflow — load in sequence
62
+ | Command | Purpose | Loads |
63
+ |---------|---------|-------|
64
+ | /constitute | Define project ground rules before any planning | commands/constitute.md |
65
+ | /spec | Write structured feature spec (goal → ACs → failure modes) | commands/spec.md |
66
+ | /clarify | Resolve open questions in a spec before blueprinting | commands/clarify.md |
67
+ | /blueprint | Derive milestone plan from a spec (spec-reviewer validates first) | commands/blueprint.md |
68
+ | /analyze | Cross-artifact consistency check — ghost milestones, spec vs. code | commands/analyze.md |
69
+ | /tasks | Build dependency graph + wave groups from plan.md | commands/tasks.md |
70
+ | /issues | Convert plan.md milestones to GitHub Issues | commands/issues.md |
71
+
72
+ **Typical sequence**: /constitute → /spec → /clarify → /blueprint → /copilot → /analyze
73
+ **Gates**: spec-reviewer (haiku) blocks /blueprint if spec is incomplete; constitution-guard (haiku) blocks milestones that violate non-negotiables
74
+ **Agents**: spec-reviewer validates spec quality; constitution-guard checks each milestone before dispatch
@@ -18,6 +18,29 @@ Load: shared/tdd.md + shared/completion-rule.md
18
18
 
19
19
  ---
20
20
 
21
+ ## Pre-Flight: Constitution + Spec Check
22
+
23
+ ```bash
24
+ # Check constitution
25
+ [ -f .claude/constitution.md ] && echo "constitution=found" || echo "no constitution"
26
+
27
+ # Check if $ARGUMENTS is a spec file
28
+ [ -f "$ARGUMENTS" ] && grep -q "Acceptance Criteria" "$ARGUMENTS" && echo "spec-mode" || echo "inline-mode"
29
+ ```
30
+
31
+ **If constitution found:**
32
+ Read `## Non-Negotiables` and `## Required Patterns` before implementing.
33
+ Keep these rules visible throughout Phases 2-4. Flag any implementation choice that would violate them.
34
+
35
+ **If spec file provided** (e.g., `/add .claude/specs/02-payment.md`):
36
+ - Skip Phase 1 clarification — the spec IS the clarification
37
+ - Load acceptance criteria as the implementation checklist
38
+ - Each AC becomes a task in TaskCreate
39
+ - Phase 3 (TDD): write tests that directly verify each AC
40
+ - Phase 5 (Verify): output maps to ACs explicitly ("AC1 ✓", "AC2 ✓", etc.)
41
+
42
+ ---
43
+
21
44
  ## Pre-Flight Analysis (intelligent-dispatch)
22
45
 
23
46
  Load `shared/intelligent-dispatch.md`.
@@ -0,0 +1,181 @@
1
+ ---
2
+ name: analyze
3
+ description: >
4
+ Check cross-artifact consistency — does the code match the spec, plan, and intent?
5
+ Distinct from /audit (which checks code quality). /analyze checks the documentation chain.
6
+ Triggers on: "does the code match the spec", "is the plan still accurate", "check consistency",
7
+ "spec vs implementation", "intent vs reality", "are we on track", "drift check",
8
+ "does what we built match what we planned", "check the plan", "verify milestones",
9
+ "are done milestones actually done", "plan drift", "spec drift", "review the plan",
10
+ "check artifacts", "is plan.md up to date", "are we building the right thing",
11
+ "cross-check", "verify against intent", "consistency check",
12
+ "does implementation match spec", "plan vs code".
13
+ argument-hint: "[what to check: 'plan', 'spec {file}', 'intent', or blank for full check]"
14
+ disable-model-invocation: true
15
+ allowed-tools: Read, Bash, Glob, Grep
16
+ ---
17
+
18
+ # /analyze — Cross-Artifact Consistency Check
19
+
20
+ $ARGUMENTS
21
+
22
+ **EnterPlanMode** — read-only. No file modifications.
23
+
24
+ ---
25
+
26
+ ## Purpose
27
+
28
+ /audit checks code quality. /analyze checks the documentation chain:
29
+ - Does `plan.md` reflect what was actually committed?
30
+ - Do milestones marked `done` have code that implements them?
31
+ - Does the codebase match `copilot-intent.md`?
32
+ - Do specs in `.claude/specs/` trace to plan milestones?
33
+
34
+ Long copilot runs, scope changes, and blocked milestones cause drift.
35
+ This command surfaces that drift before it becomes a bug.
36
+
37
+ ---
38
+
39
+ ## Step 1: Discover Available Artifacts
40
+
41
+ ```bash
42
+ # Intent and plan
43
+ ls .claude/copilot-intent.md .claude/plan.md .claude/constitution.md 2>/dev/null
44
+
45
+ # Specs
46
+ ls .claude/specs/*.md 2>/dev/null
47
+
48
+ # Memory files
49
+ ls .claude/memory/goals.md .claude/memory/decisions.md .claude/memory/blockers.md 2>/dev/null
50
+
51
+ # Recent commits
52
+ git log --oneline -10 2>/dev/null
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Step 2: Route by $ARGUMENTS
58
+
59
+ **`plan`** → run Plan vs. Reality check (Step 3)
60
+ **`spec {file}`** → run Spec vs. Implementation check (Step 4) on that file
61
+ **`intent`** → run Intent vs. Codebase check (Step 5)
62
+ **blank** → run ALL checks (Steps 3, 4, 5)
63
+
64
+ ---
65
+
66
+ ## Step 3: Plan vs. Reality
67
+
68
+ Read `.claude/plan.md`. For each milestone with status `done`:
69
+
70
+ 1. Read the `Files:` list from the milestone
71
+ 2. Check each file actually exists:
72
+ ```bash
73
+ for f in {files-from-milestone}; do [ -f "$f" ] && echo "✓ $f" || echo "✗ MISSING: $f"; done
74
+ ```
75
+ 3. Check the `Commit:` message exists in git log:
76
+ ```bash
77
+ git log --oneline | grep -i "{commit-keyword}" | head -2
78
+ ```
79
+ 4. If file missing or commit not found → flag as **GHOST** (marked done but not implemented)
80
+
81
+ For each milestone with status `pending` or `in-progress`:
82
+ - Check if `Depends:` milestones are actually `done`
83
+ - Flag dependency violations
84
+
85
+ Output format:
86
+ ```
87
+ Plan vs. Reality
88
+ ────────────────
89
+ ✓ M1: {title} — files present, commit found
90
+ ✗ M3: {title} — GHOST: src/auth/refresh.ts missing (marked done, not implemented)
91
+ ⚠ M5: {title} — DEPENDENCY VIOLATION: depends on M3 (not done)
92
+ ```
93
+
94
+ ---
95
+
96
+ ## Step 4: Spec vs. Implementation
97
+
98
+ For each spec in `.claude/specs/` with `status: ready-for-blueprint`:
99
+
100
+ 1. Read the spec's acceptance criteria
101
+ 2. For each criterion, search the codebase for evidence of implementation:
102
+ ```bash
103
+ grep -ri "{keyword from criterion}" --include="*.ts" --include="*.py" --include="*.js" -l | head -5
104
+ ```
105
+ 3. Look for tests that cover each criterion:
106
+ ```bash
107
+ find . \( -name '*.test.*' -o -name '*.spec.*' -o -name 'test_*.py' \) -not -path '*/node_modules/*' | xargs grep -li "{keyword}" 2>/dev/null | head -3
108
+ ```
109
+
110
+ Output format:
111
+ ```
112
+ Spec vs. Implementation: {spec-file}
113
+ ─────────────────────────────────────
114
+ ✓ AC1: {criterion} — found in src/auth/login.ts:45
115
+ ✗ AC2: {criterion} — NO IMPLEMENTATION FOUND
116
+ ⚠ AC3: {criterion} — implementation found but no test coverage
117
+ ```
118
+
119
+ ---
120
+
121
+ ## Step 5: Intent vs. Codebase
122
+
123
+ Read `.claude/copilot-intent.md`. Extract the core capabilities described.
124
+
125
+ For each capability:
126
+ 1. Check if there is a corresponding milestone in plan.md
127
+ 2. If milestone exists and is `done` → verify files present (Step 3 logic)
128
+ 3. If milestone missing → flag as **UNPLANNED** (intent describes it but plan doesn't include it)
129
+ 4. If milestone `blocked` → note it as blocked
130
+
131
+ Output format:
132
+ ```
133
+ Intent vs. Codebase
134
+ ────────────────────
135
+ ✓ "user authentication" — M1 done, files present
136
+ ✗ "email notifications" — NOT IN PLAN: no milestone covers this
137
+ ⚠ "payment processing" — M7 blocked: {reason from blockers.md}
138
+ ```
139
+
140
+ ---
141
+
142
+ ## Step 6: Consistency Score
143
+
144
+ Tally findings across all checks:
145
+
146
+ ```
147
+ Consistency Report
148
+ ══════════════════
149
+ Plan accuracy: {done milestones verified} / {total done} — {%}
150
+ Spec coverage: {AC implemented} / {total AC} — {%}
151
+ Intent coverage: {capabilities in plan} / {total in intent} — {%}
152
+
153
+ Issues:
154
+ GHOST: {N} milestones marked done but not implemented
155
+ UNPLANNED: {N} intent capabilities not in plan
156
+ MISSING TESTS: {N} acceptance criteria without test coverage
157
+ DEPENDENCY ERRORS: {N} dependency violations
158
+
159
+ Verdict: CONSISTENT / MINOR DRIFT / SIGNIFICANT DRIFT
160
+ ```
161
+
162
+ ---
163
+
164
+ ## Step 7: Recommended Actions
165
+
166
+ For each finding, output one concrete next step:
167
+ - GHOST → `Re-open milestone M{N} in plan.md (set status: pending), then /add`
168
+ - UNPLANNED → `Add milestone to plan.md for "{capability}", then /add`
169
+ - MISSING TESTS → `Run /test on {file} to add coverage`
170
+ - DEPENDENCY ERROR → `Fix plan.md: M{N} must be done before M{M}`
171
+
172
+ ---
173
+
174
+ ## Completion Rule
175
+
176
+ **ExitPlanMode**
177
+
178
+ Show: consistency score (%).
179
+ Show: all findings with file:line references.
180
+ Show: recommended actions.
181
+ Do not modify any files during /analyze — ever.
@@ -48,6 +48,18 @@ If `COPILOT_MODE`:
48
48
 
49
49
  ---
50
50
 
51
+ ## Step 1a: Plan Consistency Check
52
+
53
+ ```bash
54
+ [ -f .claude/plan.md ] && echo "plan=found" || echo "plan=missing"
55
+ ```
56
+
57
+ If `plan=found`: run `/analyze plan` inline — scan for GHOST milestones before reviewing code quality.
58
+ Ghost milestones in the plan mean the audit is reviewing against a false baseline.
59
+ Output ghost findings in the report; do not block audit, but flag them clearly.
60
+
61
+ ---
62
+
51
63
  ## Step 1b: Structural Context (intelligent-dispatch)
52
64
 
53
65
  Load `shared/intelligent-dispatch.md`.
@@ -29,9 +29,33 @@ $ARGUMENTS
29
29
 
30
30
  ---
31
31
 
32
- ## Step 1: Clarify (if needed)
32
+ ## Step 1: Spec Detection + Clarify
33
33
 
34
- If $ARGUMENTS is vague, use **AskUserQuestion**:
34
+ First check if $ARGUMENTS is a spec file:
35
+ ```bash
36
+ [ -f "$ARGUMENTS" ] && grep -q "Acceptance Criteria" "$ARGUMENTS" && echo "spec-file" || echo "inline"
37
+ ```
38
+
39
+ **If spec file detected** (`.claude/specs/*.md`):
40
+ 1. Spawn `spec-reviewer` agent to validate quality:
41
+ ```
42
+ Validate this spec file before I use it to generate plan.md: {spec-file-path}
43
+ ```
44
+ 2. If verdict = `APPROVED` → read spec directly as the source of truth. Skip AskUserQuestion.
45
+ - Extract acceptance criteria → use as milestone completion criteria
46
+ - Extract data model / API changes → use as Files: hints
47
+ - Extract out-of-scope → use to exclude from milestones
48
+ 3. If verdict = `NEEDS_CLARIFY` → stop: `Run /clarify {spec-file} first, then retry /blueprint`
49
+ 4. If spec-reviewer not installed → read spec file directly, proceed without validation
50
+
51
+ **If inline description** (not a spec file):
52
+ - Check if `.claude/specs/` has a spec matching $ARGUMENTS keywords:
53
+ ```bash
54
+ ls .claude/specs/ 2>/dev/null | grep -i "$(echo "$ARGUMENTS" | cut -d' ' -f1-2)"
55
+ ```
56
+ - If matching spec found → use it. If not → proceed with AskUserQuestion below.
57
+
58
+ If $ARGUMENTS is vague (and no spec found), use **AskUserQuestion**:
35
59
  - What is the goal? (the problem, not the solution)
36
60
  - Any hard constraints? (backwards compatibility, performance, deadline)
37
61
  - What's explicitly out of scope?
@@ -77,6 +101,26 @@ State the risk level. If risk = high → recommend `EnterWorktree` during implem
77
101
 
78
102
  ---
79
103
 
104
+ ## Step 3b: Constitution Check + Task Graph
105
+
106
+ After writing the plan (Step 3), check:
107
+ ```bash
108
+ [ -f .claude/constitution.md ] && echo "constitution=found" || echo "no constitution"
109
+ ```
110
+
111
+ If constitution found → scan plan steps against non-negotiables:
112
+ - Read `## Non-Negotiables` from constitution.md
113
+ - Flag any plan step that could violate a rule
114
+ - Add a note to flagged steps: `⚠ Constitution check: may conflict with "{rule}" — verify before implementing`
115
+
116
+ Then run `/tasks` to show dependency waves:
117
+ ```
118
+ Next: Run /tasks to see which plan steps can run in parallel
119
+ ```
120
+ (Do not block — /tasks is informational at this stage)
121
+
122
+ ---
123
+
80
124
  ## Step 4: Approval Gate
81
125
 
82
126
  **ExitPlanMode**
@@ -93,6 +137,42 @@ Tasks are only created after explicit approval. This is the point of /blueprint.
93
137
 
94
138
  ---
95
139
 
140
+ ## Feature-Scoped Mode (Optional)
141
+
142
+ When $ARGUMENTS points to a spec file (`.claude/specs/*.md`) OR contains a named feature:
143
+
144
+ ```bash
145
+ # Detect spec file
146
+ [ -f "$ARGUMENTS" ] && echo "spec-mode" || echo "inline-mode"
147
+
148
+ # Determine next feature number
149
+ NEXT_N=$(ls .claude/features/ 2>/dev/null | grep -c '^' || echo 0)
150
+ N=$(printf '%02d' $((NEXT_N + 1)))
151
+ SLUG=$(basename "$ARGUMENTS" .md 2>/dev/null || echo "$ARGUMENTS" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr -cd 'a-z0-9-' | cut -c1-40)
152
+ FEATURE_DIR=".claude/features/${N}-${SLUG}"
153
+ ```
154
+
155
+ If spec file provided → create a feature-scoped directory:
156
+ ```bash
157
+ mkdir -p "$FEATURE_DIR"
158
+ cp "$ARGUMENTS" "$FEATURE_DIR/spec.md"
159
+ ```
160
+
161
+ Write the plan to `$FEATURE_DIR/plan.md` (same format as `.claude/plan.md`).
162
+ Also write a summary entry to `.claude/plan.md` linking to the feature:
163
+ ```markdown
164
+ ## Feature: {N}-{slug}
165
+ Files: .claude/features/{N}-{slug}/plan.md
166
+ Status: pending
167
+ ```
168
+
169
+ This keeps the global plan.md as the tracker while feature details live in their own directory.
170
+ Each feature directory is self-contained: `spec.md` + `plan.md` + any generated artifacts.
171
+
172
+ **When NOT to use feature mode:** quick fixes, single-file changes, copilot mode (uses global plan.md).
173
+
174
+ ---
175
+
96
176
  ## Copilot Mode — Structured plan.md Output
97
177
 
98
178
  When running inside `/copilot` (detected by: `.claude/copilot-intent.md` exists):