Skip to content

Commit 14a8170

Browse files
fry-lobsterclaude
andauthored
terse: rewrite v0.8.1 command templates — 1998 → 642 lines (68% cut) (#3)
Rewrote all 9 command templates from scratch based on v0.8.1 upstream content, applying the fork's terse philosophy: - Collapsed the ~60-line hook-checking boilerplate duplicated in every file down to one line ("Run hooks.before_X from .specify/extensions.yml if present"). This alone saved ~500 lines across the 9 files. - Cut long example lists (implement.md's per-technology ignore-file enumerations, specify.md's "For AI Generation" prose, good/bad example tables) to 2-3 representative cases. - Removed philosophy prose that restated what the step-by-step already said. - Added explicit output line limits to constrain generated artifacts: spec.md ≤50 lines, plan.md ≤60 lines. - Preserved all v0.8.1 new features: __SPECKIT_COMMAND_X__ template markers (for install-time substitution), .specify/feature.json persistence, branch_numbering sequential/timestamp mode, extension hook points, checklist gate in implement, scripts frontmatter with sh/ps variants. Per-file: specify 327 → 74 plan 152 → 59 tasks 203 → 84 implement 201 → 65 analyze 252 → 95 checklist 364 → 54 clarify 250 → 94 constitution 150 → 76 taskstoissues 99 → 41 Data templates (templates/*.md) left untouched for now; the command- level line-limit instructions constrain output at generation time even if the templates retain their example sections. If still too verbose in practice, data-template trimming can follow in a separate PR. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9125c8a commit 14a8170

9 files changed

Lines changed: 412 additions & 1768 deletions

File tree

templates/commands/analyze.md

Lines changed: 57 additions & 214 deletions
Original file line numberDiff line numberDiff line change
@@ -13,240 +13,83 @@ $ARGUMENTS
1313

1414
You **MUST** consider the user input before proceeding (if not empty).
1515

16-
## Pre-Execution Checks
16+
## Pre-Execution
1717

18-
**Check for extension hooks (before analysis)**:
19-
- Check if `.specify/extensions.yml` exists in the project root.
20-
- If it exists, read it and look for entries under the `hooks.before_analyze` key
21-
- If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
22-
- Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
23-
- For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
24-
- If the hook has no `condition` field, or it is null/empty, treat the hook as executable
25-
- If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
26-
- For each executable hook, output the following based on its `optional` flag:
27-
- **Optional hook** (`optional: true`):
28-
```
29-
## Extension Hooks
18+
Run `hooks.before_analyze` from `.specify/extensions.yml` if present.
3019

31-
**Optional Pre-Hook**: {extension}
32-
Command: `/{command}`
33-
Description: {description}
20+
## Constraints
3421

35-
Prompt: {prompt}
36-
To execute: `/{command}`
37-
```
38-
- **Mandatory hook** (`optional: false`):
39-
```
40-
## Extension Hooks
22+
**READ-ONLY.** Do not modify any files. Output a single analysis report.
4123

42-
**Automatic Pre-Hook**: {extension}
43-
Executing: `/{command}`
44-
EXECUTE_COMMAND: {command}
24+
**Constitution is authoritative.** Conflicts with `/memory/constitution.md` → always CRITICAL. Principles change only via `__SPECKIT_COMMAND_CONSTITUTION__`.
4525

46-
Wait for the result of the hook command before proceeding to the Goal.
47-
```
48-
- If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently
26+
## Steps
4927

50-
## Goal
28+
1. **Setup**: run `{SCRIPT}`. Parse `FEATURE_DIR` + `AVAILABLE_DOCS`. Derive absolute paths:
29+
- `SPEC = FEATURE_DIR/spec.md`
30+
- `PLAN = FEATURE_DIR/plan.md`
31+
- `TASKS = FEATURE_DIR/tasks.md`
5132

52-
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_COMMAND_TASKS__` has successfully produced a complete `tasks.md`.
33+
Abort if any is missing.
5334

54-
## Operating Constraints
35+
2. **Load minimally**:
36+
- `spec.md` → Overview, Functional Requirements, Success Criteria, User Stories, Edge Cases
37+
- `plan.md` → Architecture, data-model refs, phases, constraints
38+
- `tasks.md` → IDs, descriptions, phases, `[P]`, file paths
39+
- `constitution.md` → principles
5540

56-
**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).
41+
3. **Build internal models** (don't emit):
42+
- Requirements inventory: FR-###, SC-### as keys (skip non-buildable outcomes like "reduce tickets by 50%")
43+
- User-action inventory with acceptance criteria
44+
- Task → requirement mapping
45+
- Constitution MUST/SHOULD statements
5746

58-
**Constitution Authority**: The project constitution (`/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_COMMAND_ANALYZE__`.
47+
4. **Detection passes** (max 50 findings; overflow summarized):
48+
- **A. Duplication** — near-duplicate requirements; flag worse phrasing
49+
- **B. Ambiguity** — vague adjectives ("fast", "robust") without metrics; TODO/TKTK/`<placeholder>`
50+
- **C. Underspecification** — verbs with no object; stories missing acceptance; tasks referencing undefined components
51+
- **D. Constitution alignment** — any conflict with MUST principle; missing mandated sections
52+
- **E. Coverage gaps** — requirements with 0 tasks; tasks with no mapped requirement; buildable SCs not reflected in tasks
53+
- **F. Inconsistency** — terminology drift; entity mentioned in plan but not spec (or vice versa); task ordering contradictions; conflicting choices (Next.js vs Vue)
5954

60-
## Execution Steps
55+
5. **Severity**:
56+
- CRITICAL — constitution MUST violation, missing core artifact, zero-coverage blocking baseline
57+
- HIGH — duplicate/conflicting requirement, ambiguous security/perf attribute, untestable acceptance
58+
- MEDIUM — terminology drift, missing NFR coverage, underspecified edge case
59+
- LOW — wording, minor redundancy
6160

62-
### 1. Initialize Analysis Context
61+
6. **Emit report**:
6362

64-
Run `{SCRIPT}` once from repo root and parse JSON for FEATURE_DIR and AVAILABLE_DOCS. Derive absolute paths:
63+
```
64+
## Specification Analysis Report
6565
66-
- SPEC = FEATURE_DIR/spec.md
67-
- PLAN = FEATURE_DIR/plan.md
68-
- TASKS = FEATURE_DIR/tasks.md
66+
| ID | Category | Severity | Location | Summary | Recommendation |
6967
70-
Abort with an error message if any required file is missing (instruct the user to run missing prerequisite command).
71-
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").
68+
## Coverage Summary
7269
73-
### 2. Load Artifacts (Progressive Disclosure)
70+
| Requirement | Has Task? | Task IDs | Notes |
7471
75-
Load only the minimal necessary context from each artifact:
72+
## Constitution Alignment Issues
73+
## Unmapped Tasks
74+
## Metrics
75+
- Total requirements / tasks / coverage % / ambiguity / duplication / critical count
76+
```
7677

77-
**From spec.md:**
78+
Stable IDs prefixed by category initial (`D1`, `A2`, …).
7879

79-
- Overview/Context
80-
- Functional Requirements
81-
- Success Criteria (measurable outcomes — e.g., performance, security, availability, user success, business impact)
82-
- User Stories
83-
- Edge Cases (if present)
80+
7. **Next actions**:
81+
- CRITICAL present → recommend resolving before `__SPECKIT_COMMAND_IMPLEMENT__`
82+
- Only LOW/MEDIUM → may proceed; list improvement suggestions
83+
- Suggest specific follow-up commands
8484

85-
**From plan.md:**
85+
8. **Offer remediation**: ask "Suggest concrete edits for top N?" — never apply automatically.
8686

87-
- Architecture/stack choices
88-
- Data Model references
89-
- Phases
90-
- Technical constraints
87+
9. Run `hooks.after_analyze` if present.
9188

92-
**From tasks.md:**
89+
## Principles
9390

94-
- Task IDs
95-
- Descriptions
96-
- Phase grouping
97-
- Parallel markers [P]
98-
- Referenced file paths
99-
100-
**From constitution:**
101-
102-
- Load `/memory/constitution.md` for principle validation
103-
104-
### 3. Build Semantic Models
105-
106-
Create internal representations (do not include raw artifacts in output):
107-
108-
- **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%").
109-
- **User story/action inventory**: Discrete user actions with acceptance criteria
110-
- **Task coverage mapping**: Map each task to one or more requirements or stories (inference by keyword / explicit reference patterns like IDs or key phrases)
111-
- **Constitution rule set**: Extract principle names and MUST/SHOULD normative statements
112-
113-
### 4. Detection Passes (Token-Efficient Analysis)
114-
115-
Focus on high-signal findings. Limit to 50 findings total; aggregate remainder in overflow summary.
116-
117-
#### A. Duplication Detection
118-
119-
- Identify near-duplicate requirements
120-
- Mark lower-quality phrasing for consolidation
121-
122-
#### B. Ambiguity Detection
123-
124-
- Flag vague adjectives (fast, scalable, secure, intuitive, robust) lacking measurable criteria
125-
- Flag unresolved placeholders (TODO, TKTK, ???, `<placeholder>`, etc.)
126-
127-
#### C. Underspecification
128-
129-
- Requirements with verbs but missing object or measurable outcome
130-
- User stories missing acceptance criteria alignment
131-
- Tasks referencing files or components not defined in spec/plan
132-
133-
#### D. Constitution Alignment
134-
135-
- Any requirement or plan element conflicting with a MUST principle
136-
- Missing mandated sections or quality gates from constitution
137-
138-
#### E. Coverage Gaps
139-
140-
- Requirements with zero associated tasks
141-
- Tasks with no mapped requirement/story
142-
- Success Criteria requiring buildable work (performance, security, availability) not reflected in tasks
143-
144-
#### F. Inconsistency
145-
146-
- Terminology drift (same concept named differently across files)
147-
- Data entities referenced in plan but absent in spec (or vice versa)
148-
- Task ordering contradictions (e.g., integration tasks before foundational setup tasks without dependency note)
149-
- Conflicting requirements (e.g., one requires Next.js while other specifies Vue)
150-
151-
### 5. Severity Assignment
152-
153-
Use this heuristic to prioritize findings:
154-
155-
- **CRITICAL**: Violates constitution MUST, missing core spec artifact, or requirement with zero coverage that blocks baseline functionality
156-
- **HIGH**: Duplicate or conflicting requirement, ambiguous security/performance attribute, untestable acceptance criterion
157-
- **MEDIUM**: Terminology drift, missing non-functional task coverage, underspecified edge case
158-
- **LOW**: Style/wording improvements, minor redundancy not affecting execution order
159-
160-
### 6. Produce Compact Analysis Report
161-
162-
Output a Markdown report (no file writes) with the following structure:
163-
164-
## Specification Analysis Report
165-
166-
| ID | Category | Severity | Location(s) | Summary | Recommendation |
167-
|----|----------|----------|-------------|---------|----------------|
168-
| A1 | Duplication | HIGH | spec.md:L120-134 | Two similar requirements ... | Merge phrasing; keep clearer version |
169-
170-
(Add one row per finding; generate stable IDs prefixed by category initial.)
171-
172-
**Coverage Summary Table:**
173-
174-
| Requirement Key | Has Task? | Task IDs | Notes |
175-
|-----------------|-----------|----------|-------|
176-
177-
**Constitution Alignment Issues:** (if any)
178-
179-
**Unmapped Tasks:** (if any)
180-
181-
**Metrics:**
182-
183-
- Total Requirements
184-
- Total Tasks
185-
- Coverage % (requirements with >=1 task)
186-
- Ambiguity Count
187-
- Duplication Count
188-
- Critical Issues Count
189-
190-
### 7. Provide Next Actions
191-
192-
At end of report, output a concise Next Actions block:
193-
194-
- If CRITICAL issues exist: Recommend resolving before `__SPECKIT_COMMAND_IMPLEMENT__`
195-
- If only LOW/MEDIUM: User may proceed, but provide improvement suggestions
196-
- Provide explicit command suggestions: e.g., "Run __SPECKIT_COMMAND_SPECIFY__ with refinement", "Run __SPECKIT_COMMAND_PLAN__ to adjust architecture", "Manually edit tasks.md to add coverage for 'performance-metrics'"
197-
198-
### 8. Offer Remediation
199-
200-
Ask the user: "Would you like me to suggest concrete remediation edits for the top N issues?" (Do NOT apply them automatically.)
201-
202-
### 9. Check for extension hooks
203-
204-
After reporting, check if `.specify/extensions.yml` exists in the project root.
205-
- If it exists, read it and look for entries under the `hooks.after_analyze` key
206-
- If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
207-
- Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
208-
- For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
209-
- If the hook has no `condition` field, or it is null/empty, treat the hook as executable
210-
- If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
211-
- For each executable hook, output the following based on its `optional` flag:
212-
- **Optional hook** (`optional: true`):
213-
```
214-
## Extension Hooks
215-
216-
**Optional Hook**: {extension}
217-
Command: `/{command}`
218-
Description: {description}
219-
220-
Prompt: {prompt}
221-
To execute: `/{command}`
222-
```
223-
- **Mandatory hook** (`optional: false`):
224-
```
225-
## Extension Hooks
226-
227-
**Automatic Hook**: {extension}
228-
Executing: `/{command}`
229-
EXECUTE_COMMAND: {command}
230-
```
231-
- If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently
232-
233-
## Operating Principles
234-
235-
### Context Efficiency
236-
237-
- **Minimal high-signal tokens**: Focus on actionable findings, not exhaustive documentation
238-
- **Progressive disclosure**: Load artifacts incrementally; don't dump all content into analysis
239-
- **Token-efficient output**: Limit findings table to 50 rows; summarize overflow
240-
- **Deterministic results**: Rerunning without changes should produce consistent IDs and counts
241-
242-
### Analysis Guidelines
243-
244-
- **NEVER modify files** (this is read-only analysis)
245-
- **NEVER hallucinate missing sections** (if absent, report them accurately)
246-
- **Prioritize constitution violations** (these are always CRITICAL)
247-
- **Use examples over exhaustive rules** (cite specific instances, not generic patterns)
248-
- **Report zero issues gracefully** (emit success report with coverage statistics)
249-
250-
## Context
251-
252-
{ARGS}
91+
- **Never modify files.**
92+
- **Never hallucinate missing sections** — report them as absent.
93+
- **Constitution violations are always CRITICAL.**
94+
- Cite specific instances, not generic patterns.
95+
- Deterministic: same input → same IDs and counts.

0 commit comments

Comments
 (0)