Skip to content

Commit c587a01

Browse files
author
Your Name
committed
chore: reconcile local agent artifacts
1 parent 4d52943 commit c587a01

15 files changed

Lines changed: 2325 additions & 14 deletions

File tree

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

0 commit comments

Comments
 (0)