Skip to content

Conversation

@emi-dm
Copy link

@emi-dm emi-dm commented Jan 28, 2026

Summary

Adds a new /speckit.retrospective command for post-implementation analysis that measures spec drift - the deviation between what was specified and what was actually built.

Motivation

The Spec-Driven Development workflow currently covers the full lifecycle from specification through implementation, but lacks a critical feedback loop: learning from completed features. Without retrospective analysis, teams lose valuable insights that could improve future specifications and reduce rework.

The Problem

  • Teams often don't know how much their implementation diverged from the original spec
  • Lessons learned are informal and rarely documented
  • Specification quality issues repeat across features
  • There's no objective metric for "how well did we spec this feature?"

The Solution

The /speckit.retrospective command provides:

  1. Quantified Spec Drift Score - An objective metric showing what percentage of requirements were implemented as specified
  2. Root Cause Analysis - Understanding why deviations occurred (spec gaps, tech constraints, scope evolution, etc.)
  3. Structured Lessons Learned - Actionable improvements categorized by specification, planning, process, and technical domains
  4. Traceability - File-level mapping of what was built vs. what was specified

Expected Impact

  • Improved specification quality over time through documented learnings
  • Reduced rework by identifying common specification gaps
  • Better estimates by understanding where scope typically expands
  • Team alignment through shared understanding of what "done" looks like vs. the spec

Design Decisions

  • Read-only by default: The command analyzes but doesn't modify files, making it safe to run at any time
  • Severity classification: Uses CRITICAL/SIGNIFICANT/MINOR/POSITIVE to prioritize findings (POSITIVE captures improvements over spec)
  • Completeness gate: Warns if less than 50% of tasks are complete, as early analysis may be misleading
  • Reuses existing script infrastructure: Uses check-prerequisites.sh for consistency with other commands

Usage

Run after implementation is complete (or at a significant milestone):

Add /speckit.retrospective command template that performs post-implementation
analysis measuring spec drift - the deviation between specification and
actual implementation.

Features:
- Calculates Spec Drift Score (% of requirements implemented as specified)
- Classifies deviations: CRITICAL, SIGNIFICANT, MINOR, POSITIVE
- Requirement coverage matrix (FR/NFR tracking)
- Success criteria assessment against actual values
- Architecture drift analysis (data model, tech stack, APIs)
- Root cause analysis (when/why deviations occurred)
- Structured lessons learned by category
- Actionable recommendations for future features
- Read-only analysis mode (non-destructive)
Copilot AI review requested due to automatic review settings January 28, 2026 17:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a new /speckit.retrospective command that performs post-implementation analysis to measure spec drift - the deviation between what was specified and what was actually built in a feature. This creates a feedback loop in the Spec-Driven Development workflow by quantifying implementation deviations and generating actionable lessons learned.

Changes:

  • Adds a comprehensive retrospective analysis command with read-only operation
  • Implements spec drift scoring based on requirement adherence
  • Provides structured root cause analysis for deviations with severity classification (CRITICAL/SIGNIFICANT/MINOR/POSITIVE)
  • Generates detailed retrospective reports with traceability and actionable recommendations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…nts and rename spec drift score to spec adherence score
Copilot AI review requested due to automatic review settings February 2, 2026 13:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 11 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

$ARGUMENTS
```

Consider user input before proceeding (if not empty).
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user input consideration statement should use the stronger "You MUST consider" wording to be consistent with all other commands in the codebase. Every other command file (analyze.md, checklist.md, clarify.md, constitution.md, implement.md, plan.md, specify.md, tasks.md, taskstoissues.md) uses "You MUST consider the user input before proceeding (if not empty)." instead of just "Consider user input before proceeding (if not empty)."

Copilot uses AI. Check for mistakes.
### 2. Validate Completeness

```bash
total_tasks=$(grep -c '^\- \[[ Xx]\]' "$TASKS")
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bash regex pattern '^\- \[[ Xx]\]' will match tasks in any state (unchecked [ ], checked [X], or [x]), which is correct for counting total tasks. However, the pattern should be '^- \[[ Xx]\]' (without backslash before the hyphen) as the hyphen doesn't need to be escaped at the beginning of the pattern. This is more consistent with standard grep patterns and avoids potential confusion.

Suggested change
total_tasks=$(grep -c '^\- \[[ Xx]\]' "$TASKS")
total_tasks=$(grep -c '^- \[[ Xx]\]' "$TASKS")

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +46
total_tasks=$(grep -c '^\- \[[ Xx]\]' "$TASKS")
completed_tasks=$(grep -c '^\- \[[Xx]\]' "$TASKS")
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, the pattern '^\- \[[Xx]\]' for completed tasks should be '^- \[[Xx]\]' without escaping the hyphen.

Suggested change
total_tasks=$(grep -c '^\- \[[ Xx]\]' "$TASKS")
completed_tasks=$(grep -c '^\- \[[Xx]\]' "$TASKS")
total_tasks=$(grep -c '^- \[[ Xx]\]' "$TASKS")
completed_tasks=$(grep -c '^- \[[Xx]\]' "$TASKS")

Copilot uses AI. Check for mistakes.
```bash
total_tasks=$(grep -c '^\- \[[ Xx]\]' "$TASKS")
completed_tasks=$(grep -c '^\- \[[Xx]\]' "$TASKS")
completion_rate=$((completed_tasks * 100 / total_tasks))
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The division operation $((completed_tasks * 100 / total_tasks)) will fail with a "division by zero" error if there are no tasks in the file. While this is unlikely in normal usage (since tasks.md should have tasks), it's a potential edge case that should be handled. Consider adding a check or using a safer calculation approach.

Suggested change
completion_rate=$((completed_tasks * 100 / total_tasks))
if [ "$total_tasks" -eq 0 ]; then
completion_rate=0
else
completion_rate=$((completed_tasks * 100 / total_tasks))
fi

Copilot uses AI. Check for mistakes.
### 13. Save Report

1. Write to `FEATURE_DIR/retrospective.md` with YAML frontmatter (feature, branch, date, rates, counts)
2. Commit: `Add retrospective analysis - Spec adherence: X% | Completion: X%`
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message format uses a dash separator "Spec adherence: X% | Completion: X%" but most of the codebase and conventional commit messages would use a colon after "Add retrospective analysis". Consider using "Add retrospective analysis: Spec adherence X%, Completion X%" or following conventional commit format like "feat(retrospective): add analysis report (adherence X%, completion X%)" for better git log readability and consistency.

Suggested change
2. Commit: `Add retrospective analysis - Spec adherence: X% | Completion: X%`
2. Commit: `Add retrospective analysis: Spec adherence X%, Completion X%`

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,220 @@
---
description: Perform a post-implementation retrospective analysis measuring spec drift, implementation deviations, and generating lessons learned for future features.
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CHANGELOG.md should be updated to document the addition of the new /speckit.retrospective command. According to the AGENTS.md guidelines (line 15): "Any changes to init.py for the Specify CLI require a version rev in pyproject.toml and addition of entries to CHANGELOG.md." While this change doesn't modify init.py, it does add a significant new command to the toolkit that should be documented for users. The changelog should include a description of the new retrospective command and its purpose (spec drift analysis, lessons learned, etc.).

Copilot uses AI. Check for mistakes.
Comment on lines +125 to +127
| Metric | Value |
|--------|-------|
| Total/Implemented/Modified/Not Implemented/Unspecified | X |
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table format appears incorrect. Line 127 shows "Total/Implemented/Modified/Not Implemented/Unspecified | X" which suggests multiple metrics crammed into a single row. This should likely be a multi-row table where each metric (Total, Implemented, Modified, Not Implemented, Unspecified) has its own row with a corresponding value, or it should be a multi-column table with separate columns for each metric type. The current format is unclear and won't render properly as a meaningful table.

Suggested change
| Metric | Value |
|--------|-------|
| Total/Implemented/Modified/Not Implemented/Unspecified | X |
| Metric | Total | Implemented | Modified | Not Implemented | Unspecified |
|--------|-------|-------------|----------|------------------|-------------|
| Count | X | X | X | X | X |

Copilot uses AI. Check for mistakes.
Comment on lines +32 to +50
- **Post-Implementation**: Run after implementation complete; warn if <80% tasks done, abort if <50%

## Execution Steps

### 1. Initialize Context

Run `{SCRIPT}` from repo root. Parse JSON for FEATURE_DIR. Derive paths: SPEC, PLAN, TASKS = FEATURE_DIR/{spec,plan,tasks}.md. Abort if missing.

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").

### 2. Validate Completeness

```bash
total_tasks=$(grep -c '^\- \[[ Xx]\]' "$TASKS")
completed_tasks=$(grep -c '^\- \[[Xx]\]' "$TASKS")
completion_rate=$((completed_tasks * 100 / total_tasks))
```

- **≥80%**: Full retrospective | **50-79%**: Warn, partial analysis | **<50%**: Confirm before proceeding
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command states "abort if <50%" in line 32, but the detailed instruction in line 50 says "Confirm before proceeding" for <50% completion. These instructions are inconsistent. Based on the context and safer design (allowing users to proceed if they explicitly confirm), the "Confirm before proceeding" approach is more appropriate than an absolute abort, but the instructions should be consistent.

Copilot uses AI. Check for mistakes.

### 5. Discover Implementation

- Extract file paths from completed tasks + `git log --name-only HEAD~50..HEAD`
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The git log command git log --name-only HEAD~50..HEAD assumes there are at least 50 commits in the repository history. In a new or small repository, this will fail with an error like "fatal: ambiguous argument 'HEAD~50': unknown revision or path not in the working tree." Consider using a safer approach like git log --name-only --since="1 month ago" or wrapping the command with error handling.

Suggested change
- Extract file paths from completed tasks + `git log --name-only HEAD~50..HEAD`
- Extract file paths from completed tasks + `git log --name-only --since="1 month ago"` (or another safe range that works even in small repositories)

Copilot uses AI. Check for mistakes.
Comment on lines +130 to +175
| Req ID | Description | Status | Notes |

### Success Criteria Assessment
| Criterion | Target | Actual | Met? |

### Architecture Drift
| Entity/Component | Specified | Actual | Change Type/Reason |

### Significant Deviations
For each: Severity, Requirements Affected, Specified vs Implemented, Discovery, Root Cause, Impact, Lesson

**Example:**
> #### Auth Method Changed
> - **Severity**: SIGNIFICANT | **Affected**: FR-003, SC-002
> - **Specified**: Email/password with bcrypt | **Implemented**: OAuth2 SSO
> - **Discovery**: Phase 1 | **Cause**: Tech Constraint (email service unavailable)
> - **Impact**: Better UX, added third-party dependency
> - **Lesson**: Specify auth dependencies in planning phase

### Innovations & Best Practices
| Innovation | Description | Benefit | Reusability | Constitution Candidate? |

**Example:**
| Response caching | Redis cache for frequent queries | 85% less DB load, 60% faster | All read-heavy endpoints | Yes - "Cache-First" principle |

### Constitution Compliance
| Article | Title | Status | Notes |
**Violations**: [None / List with justifications]

### Analysis Effectiveness (if applicable)
| Category | Predicted & Found | Predicted & Not Found | Found & Not Predicted |

### Unspecified Implementations
| Addition | Description | Justification | Should Have Been Specified? |

### Task Execution Analysis
| Phase | Planned | Completed | Added | Dropped |

### Lessons Learned
- Specification/Planning/Process/Technical improvements

### Recommendations
- For this feature / For future features / Constitution updates

### Appendix: File Traceability
| File | Created/Modified | Requirements |
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple tables in the report template are missing the required separator row between the header and content rows. According to Markdown table syntax, each table must have a separator row with dashes. The following tables are incomplete:

  • Line 130: "Requirement Coverage Matrix" (missing separator like |--------|-------------|--------|-------|)
  • Line 133: "Success Criteria Assessment" (missing separator)
  • Line 136: "Architecture Drift" (missing separator)
  • Line 150: "Innovations & Best Practices" (missing separator)
  • Line 156: "Constitution Compliance" (missing separator)
  • Line 160: "Analysis Effectiveness" (missing separator)
  • Line 163: "Unspecified Implementations" (missing separator)
  • Line 166: "Task Execution Analysis" (missing separator)
  • Line 175: "Appendix: File Traceability" (missing separator)

Without these separator rows, the tables won't render correctly in most Markdown parsers.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant