|
| 1 | +--- |
| 2 | +description: Perform a non-destructive cross-artifact consistency and quality analysis across spec.md, plan.md, and tasks.md after task generation. |
| 3 | +--- |
| 4 | + |
| 5 | +## User Input |
| 6 | + |
| 7 | +```text |
| 8 | +$ARGUMENTS |
| 9 | +``` |
| 10 | + |
| 11 | +You **MUST** consider the user input before proceeding (if not empty). |
| 12 | + |
| 13 | +## Pre-Execution Checks |
| 14 | + |
| 15 | +**Check for extension hooks (before analysis)**: |
| 16 | +- Check if `.specify/extensions.yml` exists in the project root. |
| 17 | +- If it exists, read it and look for entries under the `hooks.before_analyze` key |
| 18 | +- If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally |
| 19 | +- Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default. |
| 20 | +- For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions: |
| 21 | + - If the hook has no `condition` field, or it is null/empty, treat the hook as executable |
| 22 | + - If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation |
| 23 | +- For each executable hook, output the following based on its `optional` flag: |
| 24 | + - **Optional hook** (`optional: true`): |
| 25 | + ``` |
| 26 | + ## Extension Hooks |
| 27 | +
|
| 28 | + **Optional Pre-Hook**: {extension} |
| 29 | + Command: `/{command}` |
| 30 | + Description: {description} |
| 31 | +
|
| 32 | + Prompt: {prompt} |
| 33 | + To execute: `/{command}` |
| 34 | + ``` |
| 35 | + - **Mandatory hook** (`optional: false`): |
| 36 | + ``` |
| 37 | + ## Extension Hooks |
| 38 | +
|
| 39 | + **Automatic Pre-Hook**: {extension} |
| 40 | + Executing: `/{command}` |
| 41 | + EXECUTE_COMMAND: {command} |
| 42 | +
|
| 43 | + Wait for the result of the hook command before proceeding to the Goal. |
| 44 | + ``` |
| 45 | +- If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently |
| 46 | +
|
| 47 | +## Goal |
| 48 | +
|
| 49 | +Identify inconsistencies, duplications, ambiguities, and underspecified items across the three core artifacts (`spec.md`, `plan.md`, `tasks.md`) before implementation. This command MUST run only after `/speckit.tasks` has successfully produced a complete `tasks.md`. |
| 50 | +
|
| 51 | +## Operating Constraints |
| 52 | +
|
| 53 | +**STRICTLY READ-ONLY**: Do **not** modify any files. Output a structured analysis report. Offer an optional remediation plan (user must explicitly approve before any follow-up editing commands would be invoked manually). |
| 54 | +
|
| 55 | +**Constitution Authority**: The project constitution (`.specify/memory/constitution.md`) is **non-negotiable** within this analysis scope. Constitution conflicts are automatically CRITICAL and require adjustment of the spec, plan, or tasks—not dilution, reinterpretation, or silent ignoring of the principle. If a principle itself needs to change, that must occur in a separate, explicit constitution update outside `/speckit.analyze`. |
| 56 | +
|
| 57 | +## Execution Steps |
| 58 | +
|
| 59 | +### 1. Initialize Analysis Context |
| 60 | +
|
| 61 | +Run `.specify/scripts/bash/check-prerequisites.sh --json --require-tasks --include-tasks` once from repo root and parse JSON for FEATURE_DIR and AVAILABLE_DOCS. Derive absolute paths: |
| 62 | +
|
| 63 | +- SPEC = FEATURE_DIR/spec.md |
| 64 | +- PLAN = FEATURE_DIR/plan.md |
| 65 | +- TASKS = FEATURE_DIR/tasks.md |
| 66 | +
|
| 67 | +Abort with an error message if any required file is missing (instruct the user to run missing prerequisite command). |
| 68 | +For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot"). |
| 69 | +
|
| 70 | +### 2. Load Artifacts (Progressive Disclosure) |
| 71 | +
|
| 72 | +Load only the minimal necessary context from each artifact: |
| 73 | +
|
| 74 | +**From spec.md:** |
| 75 | +
|
| 76 | +- Overview/Context |
| 77 | +- Functional Requirements |
| 78 | +- Success Criteria (measurable outcomes — e.g., performance, security, availability, user success, business impact) |
| 79 | +- User Stories |
| 80 | +- Edge Cases (if present) |
| 81 | +
|
| 82 | +**From plan.md:** |
| 83 | +
|
| 84 | +- Architecture/stack choices |
| 85 | +- Data Model references |
| 86 | +- Phases |
| 87 | +- Technical constraints |
| 88 | +
|
| 89 | +**From tasks.md:** |
| 90 | +
|
| 91 | +- Task IDs |
| 92 | +- Descriptions |
| 93 | +- Phase grouping |
| 94 | +- Parallel markers [P] |
| 95 | +- Referenced file paths |
| 96 | +
|
| 97 | +**From constitution:** |
| 98 | +
|
| 99 | +- Load `.specify/memory/constitution.md` for principle validation |
| 100 | +
|
| 101 | +### 3. Build Semantic Models |
| 102 | +
|
| 103 | +Create internal representations (do not include raw artifacts in output): |
| 104 | +
|
| 105 | +- **Requirements inventory**: For each Functional Requirement (FR-###) and Success Criterion (SC-###), record a stable key. Use the explicit FR-/SC- identifier as the primary key when present, and optionally also derive an imperative-phrase slug for readability (e.g., "User can upload file" → `user-can-upload-file`). Include only Success Criteria items that require buildable work (e.g., load-testing infrastructure, security audit tooling), and exclude post-launch outcome metrics and business KPIs (e.g., "Reduce support tickets by 50%"). |
| 106 | +- **User story/action inventory**: Discrete user actions with acceptance criteria |
| 107 | +- **Task coverage mapping**: Map each task to one or more requirements or stories (inference by keyword / explicit reference patterns like IDs or key phrases) |
| 108 | +- **Constitution rule set**: Extract principle names and MUST/SHOULD normative statements |
| 109 | +
|
| 110 | +### 4. Detection Passes (Token-Efficient Analysis) |
| 111 | +
|
| 112 | +Focus on high-signal findings. Limit to 50 findings total; aggregate remainder in overflow summary. |
| 113 | +
|
| 114 | +#### A. Duplication Detection |
| 115 | +
|
| 116 | +- Identify near-duplicate requirements |
| 117 | +- Mark lower-quality phrasing for consolidation |
| 118 | +
|
| 119 | +#### B. Ambiguity Detection |
| 120 | +
|
| 121 | +- Flag vague adjectives (fast, scalable, secure, intuitive, robust) lacking measurable criteria |
| 122 | +- Flag unresolved placeholders (TODO, TKTK, ???, `<placeholder>`, etc.) |
| 123 | +
|
| 124 | +#### C. Underspecification |
| 125 | +
|
| 126 | +- Requirements with verbs but missing object or measurable outcome |
| 127 | +- User stories missing acceptance criteria alignment |
| 128 | +- Tasks referencing files or components not defined in spec/plan |
| 129 | +
|
| 130 | +#### D. Constitution Alignment |
| 131 | +
|
| 132 | +- Any requirement or plan element conflicting with a MUST principle |
| 133 | +- Missing mandated sections or quality gates from constitution |
| 134 | +
|
| 135 | +#### E. Coverage Gaps |
| 136 | +
|
| 137 | +- Requirements with zero associated tasks |
| 138 | +- Tasks with no mapped requirement/story |
| 139 | +- Success Criteria requiring buildable work (performance, security, availability) not reflected in tasks |
| 140 | +
|
| 141 | +#### F. Inconsistency |
| 142 | +
|
| 143 | +- Terminology drift (same concept named differently across files) |
| 144 | +- Data entities referenced in plan but absent in spec (or vice versa) |
| 145 | +- Task ordering contradictions (e.g., integration tasks before foundational setup tasks without dependency note) |
| 146 | +- Conflicting requirements (e.g., one requires Next.js while other specifies Vue) |
| 147 | +
|
| 148 | +### 5. Severity Assignment |
| 149 | +
|
| 150 | +Use this heuristic to prioritize findings: |
| 151 | +
|
| 152 | +- **CRITICAL**: Violates constitution MUST, missing core spec artifact, or requirement with zero coverage that blocks baseline functionality |
| 153 | +- **HIGH**: Duplicate or conflicting requirement, ambiguous security/performance attribute, untestable acceptance criterion |
| 154 | +- **MEDIUM**: Terminology drift, missing non-functional task coverage, underspecified edge case |
| 155 | +- **LOW**: Style/wording improvements, minor redundancy not affecting execution order |
| 156 | +
|
| 157 | +### 6. Produce Compact Analysis Report |
| 158 | +
|
| 159 | +Output a Markdown report (no file writes) with the following structure: |
| 160 | +
|
| 161 | +## Specification Analysis Report |
| 162 | +
|
| 163 | +| ID | Category | Severity | Location(s) | Summary | Recommendation | |
| 164 | +|----|----------|----------|-------------|---------|----------------| |
| 165 | +| A1 | Duplication | HIGH | spec.md:L120-134 | Two similar requirements ... | Merge phrasing; keep clearer version | |
| 166 | +
|
| 167 | +(Add one row per finding; generate stable IDs prefixed by category initial.) |
| 168 | +
|
| 169 | +**Coverage Summary Table:** |
| 170 | +
|
| 171 | +| Requirement Key | Has Task? | Task IDs | Notes | |
| 172 | +|-----------------|-----------|----------|-------| |
| 173 | +
|
| 174 | +**Constitution Alignment Issues:** (if any) |
| 175 | +
|
| 176 | +**Unmapped Tasks:** (if any) |
| 177 | +
|
| 178 | +**Metrics:** |
| 179 | +
|
| 180 | +- Total Requirements |
| 181 | +- Total Tasks |
| 182 | +- Coverage % (requirements with >=1 task) |
| 183 | +- Ambiguity Count |
| 184 | +- Duplication Count |
| 185 | +- Critical Issues Count |
| 186 | +
|
| 187 | +### 7. Provide Next Actions |
| 188 | +
|
| 189 | +At end of report, output a concise Next Actions block: |
| 190 | +
|
| 191 | +- If CRITICAL issues exist: Recommend resolving before `/speckit.implement` |
| 192 | +- If only LOW/MEDIUM: User may proceed, but provide improvement suggestions |
| 193 | +- Provide explicit command suggestions: e.g., "Run /speckit.specify with refinement", "Run /speckit.plan to adjust architecture", "Manually edit tasks.md to add coverage for 'performance-metrics'" |
| 194 | +
|
| 195 | +### 8. Offer Remediation |
| 196 | +
|
| 197 | +Ask the user: "Would you like me to suggest concrete remediation edits for the top N issues?" (Do NOT apply them automatically.) |
| 198 | +
|
| 199 | +### 9. Check for extension hooks |
| 200 | +
|
| 201 | +After reporting, check if `.specify/extensions.yml` exists in the project root. |
| 202 | +- If it exists, read it and look for entries under the `hooks.after_analyze` key |
| 203 | +- If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally |
| 204 | +- Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default. |
| 205 | +- For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions: |
| 206 | + - If the hook has no `condition` field, or it is null/empty, treat the hook as executable |
| 207 | + - If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation |
| 208 | +- For each executable hook, output the following based on its `optional` flag: |
| 209 | + - **Optional hook** (`optional: true`): |
| 210 | + ``` |
| 211 | + ## Extension Hooks |
| 212 | +
|
| 213 | + **Optional Hook**: {extension} |
| 214 | + Command: `/{command}` |
| 215 | + Description: {description} |
| 216 | +
|
| 217 | + Prompt: {prompt} |
| 218 | + To execute: `/{command}` |
| 219 | + ``` |
| 220 | + - **Mandatory hook** (`optional: false`): |
| 221 | + ``` |
| 222 | + ## Extension Hooks |
| 223 | +
|
| 224 | + **Automatic Hook**: {extension} |
| 225 | + Executing: `/{command}` |
| 226 | + EXECUTE_COMMAND: {command} |
| 227 | + ``` |
| 228 | +- If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently |
| 229 | +
|
| 230 | +## Operating Principles |
| 231 | +
|
| 232 | +### Context Efficiency |
| 233 | +
|
| 234 | +- **Minimal high-signal tokens**: Focus on actionable findings, not exhaustive documentation |
| 235 | +- **Progressive disclosure**: Load artifacts incrementally; don't dump all content into analysis |
| 236 | +- **Token-efficient output**: Limit findings table to 50 rows; summarize overflow |
| 237 | +- **Deterministic results**: Rerunning without changes should produce consistent IDs and counts |
| 238 | +
|
| 239 | +### Analysis Guidelines |
| 240 | +
|
| 241 | +- **NEVER modify files** (this is read-only analysis) |
| 242 | +- **NEVER hallucinate missing sections** (if absent, report them accurately) |
| 243 | +- **Prioritize constitution violations** (these are always CRITICAL) |
| 244 | +- **Use examples over exhaustive rules** (cite specific instances, not generic patterns) |
| 245 | +- **Report zero issues gracefully** (emit success report with coverage statistics) |
| 246 | +
|
| 247 | +## Context |
| 248 | +
|
| 249 | +$ARGUMENTS |
0 commit comments