Skip to content

Commit d047a91

Browse files
author
Your Name
committed
docs: initialize speckit assets and align constitutions
1 parent bc62773 commit d047a91

84 files changed

Lines changed: 7013 additions & 199 deletions

File tree

Some content is hidden

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

0 commit comments

Comments
 (0)