Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions templates/commands/analyze.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ You **MUST** consider the user input before proceeding (if not empty).

## Goal

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`.
Identify inconsistencies, duplications, ambiguities, and underspecified items across the three core artifacts (`spec.md`, `plan.md`, `tasks.md`) before implementation. When `data-model.md` exists, also check constrained-field task citations and constraint consistency against it. This command MUST run only after `__SPECKIT_COMMAND_TASKS__` has successfully produced a complete `tasks.md`.

## Operating Constraints

Expand All @@ -68,6 +68,7 @@ Run `{SCRIPT}` once from repo root and parse JSON for FEATURE_DIR and AVAILABLE_
- SPEC = FEATURE_DIR/spec.md
- PLAN = FEATURE_DIR/plan.md
- TASKS = FEATURE_DIR/tasks.md
- DATA_MODEL = FEATURE_DIR/data-model.md (optional)

Abort with an error message if any required file is missing (instruct the user to run missing prerequisite command).
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").
Expand Down Expand Up @@ -99,6 +100,11 @@ Load only the minimal necessary context from each artifact:
- Parallel markers [P]
- Referenced file paths

**From data-model.md (if present):**

- Entity and exact field names, canonical source locations, and explicit constraints (max/min length, nullable/required, enum values, validation rules), including constraints encoded in field types
- If absent or no constrained fields exist, constrained-field checks are not applicable; do not invent fields or constraints or fail analysis for the missing optional document

**From constitution:**

- Load `/memory/constitution.md` for principle validation
Expand All @@ -110,6 +116,8 @@ Create internal representations (do not include raw artifacts in output):
- **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%").
- **User story/action inventory**: Discrete user actions with acceptance criteria
- **Task coverage mapping**: Map each task to one or more requirements or stories (inference by keyword / explicit reference patterns like IDs or key phrases)
- **Constrained-field inventory** (when applicable): Record each canonical `Entity.field`, its constraints, and its location in data-model.md; keep identically named fields on different entities distinct
- **Field citation mapping** (when applicable): Map explicit data-model.md references with exact `Entity.field` identities to implementing task IDs and task locations; retain unresolved references and task-stated constraints for the detection passes
- **Constitution rule set**: Extract principle names and MUST/SHOULD normative statements

### 4. Detection Passes (Token-Efficient Analysis)
Expand Down Expand Up @@ -142,20 +150,25 @@ Focus on high-signal findings. Limit to 50 findings total; aggregate remainder i
- Requirements with zero associated tasks
- Tasks with no mapped requirement/story
- Success Criteria requiring buildable work (performance, security, availability) not reflected in tasks
- Each constrained field without an explicit `data-model.md` + `Entity.field` citation in at least one implementing task. Generic document/entity references, bare field names, and test-only references do not count; a shared implementing task may cite multiple fields, including fields implemented before later stories
- Require an explicit association between each cited field and its canonical definition. Mere co-occurrence of a document reference and a field mention is not a citation; for example, task prose setting `Request.SuspendReason` to 500 is not a citation just because the task cites data-model.md for `Request.Remark`
- Report unresolved field citations with their task IDs and locations; they must not be guessed as aliases or counted as coverage for another field. Also report any canonical field left uncovered

#### F. Inconsistency

- Terminology drift (same concept named differently across files)
- Data entities referenced in plan but absent in spec (or vice versa)
- Task ordering contradictions (e.g., integration tasks before foundational setup tasks without dependency note)
- Conflicting requirements (e.g., one requires Next.js while other specifies Vue)
- Task-stated field constraints that contradict data-model.md, even when a valid citation is present. Compare any clearly identified field's task prose even when its citation is missing; check length, nullable/required status, enum values, and validation rules
- For each field mismatch, identify the exact `Entity.field`, task ID, canonical and task-stated restrictions, and both source locations. Do not flag citation-only tasks or semantically matching paraphrases for omitting/rewording constraint values. Do not invent canonical values when the source restriction is unclear; use the existing ambiguity/underspecification passes for unclear definitions

### 5. Severity Assignment

Use this heuristic to prioritize findings:

- **CRITICAL**: Violates constitution MUST, missing core spec artifact, or requirement with zero coverage that blocks baseline functionality
- **HIGH**: Duplicate or conflicting requirement, ambiguous security/performance attribute, untestable acceptance criterion
- **HIGH**: Duplicate or conflicting requirement, ambiguous security/performance attribute, untestable acceptance criterion, missing/unresolved constrained-field citations (Coverage), or contradictory task constraints (Inconsistency); retain CRITICAL escalation above
- **MEDIUM**: Terminology drift, missing non-functional task coverage, underspecified edge case
- **LOW**: Style/wording improvements, minor redundancy not affecting execution order

Expand All @@ -176,6 +189,13 @@ Output a Markdown report (no file writes) with the following structure:
| Requirement Key | Has Task? | Task IDs | Notes |
|-----------------|-----------|----------|-------|

**Constrained-Field Coverage (when applicable):**

| Field (`Entity.field`) | Canonical Location | Implementing Task IDs | Coverage / Consistency Notes |
|------------------------|--------------------|-----------------------|------------------------------|

Use the existing finding table for field findings, including source locations and actionable recommendations. Field findings share the 50-finding limit and overflow summary; do not change the existing requirement coverage denominator or FR/SC coverage table semantics.

**Constitution Alignment Issues:** (if any)

**Unmapped Tasks:** (if any)
Expand Down
10 changes: 7 additions & 3 deletions templates/commands/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ You **MUST** consider the user input before proceeding (if not empty).
3. **Execute task generation workflow**:
- Load plan.md and extract tech stack, libraries, project structure
- Load spec.md and extract user stories with their priorities (P1, P2, P3, etc.)
- If data-model.md exists: Extract entities and map to user stories
- If data-model.md exists: Extract entities and constrained fields, including constraints encoded in field types, and map to user stories
- If contracts/ exists: Map interface contracts to user stories
- If research.md exists: Extract decisions for setup tasks
- Generate tasks organized by user story (see Task Generation Rules below)
- Generate dependency graph showing user story completion order
- Create parallel execution examples per user story
- Validate task completeness (each user story has all needed tasks, independently testable)
- If data-model.md has constrained fields: Verify every constrained field has an explicit, resolving citation to `data-model.md` and its `Entity.field` in at least one implementing task; correct missing or unresolved citations before returning tasks.md
4. **Generate tasks.md**: Use TASKS_TEMPLATE_CONTENT (from the JSON output above) as the structure. For compatibility with older setup scripts that omit TASKS_TEMPLATE_CONTENT, read TASKS_TEMPLATE instead. Fill with:
- Correct feature name from plan.md
Expand Down Expand Up @@ -138,7 +139,7 @@ Output path to generated tasks.md and summary:
Context for task generation: {ARGS}
The tasks.md should be immediately executable - each task must be specific enough that an LLM can complete it without additional context.
The tasks.md should be immediately executable - each task must be specific enough that an LLM can complete it without context beyond the feature's design documents. This does not require copying those documents into task descriptions.
## Task Generation Rules
Expand Down Expand Up @@ -197,7 +198,10 @@ Every task MUST strictly follow this format:
- Map each entity to the user story(ies) that need it
- If entity serves multiple stories: Put in earliest story or Setup phase
- Relationships → service layer tasks in appropriate story phase
- For each field with constraints in data-model.md (max length, nullable/required, enum values, validation rules), quote the constraint verbatim in the task description so it is not left to implementation-time discretion
- data-model.md is the canonical source for field constraints (max/min length, nullable/required, enum values, validation rules), including constraints encoded in field types
- Cite each constrained field explicitly using `data-model.md` and its exact `Entity.field` in the implementing task description; plain text or links are acceptable when both are unambiguous. A shared implementing task may cite multiple fields
- Associate each cited field explicitly with its canonical definition. A field mention elsewhere in the task is not a citation merely because other fields in that task cite data-model.md
- Use citations instead of duplicated constraint prose. Do not require verbatim copies of constraints in tasks.md. Do not restate unchanged constraints; state a constraint only when the task adds to or narrows the canonical rule, and identify that task-specific addition or narrowing. Task-specific constraints MUST NOT contradict the canonical field definition

4. **From Setup/Infrastructure**:
- Shared infrastructure → Setup phase (Phase 1)
Expand Down
Loading
Loading