بنقرة واحدة
speckit-extract-run
// Extract knowledge, guidelines, and ADRs from one or more completed spec directories into the project documentation system.
// Extract knowledge, guidelines, and ADRs from one or more completed spec directories into the project documentation system.
Archive a feature specification into main project memory after merge, resolving gaps and conflicts
Run the full speckit workflow end-to-end — specify, plan, critique, tasks, implement, review, extract — making all decisions autonomously.
Perform a dual-lens critical review of the specification and plan from both product strategy and engineering risk perspectives before implementation.
Run a session retrospective that surfaces context-management gaps and routes them to approved follow-up actions.
Produce a flow-level summary of the current Claude Code session — executive summary, chronological timeline, and outcomes — written into the active feature directory next to spec.md / plan.md.
| name | speckit-extract-run |
| description | Extract knowledge, guidelines, and ADRs from one or more completed spec directories into the project documentation system. |
| compatibility | Requires spec-kit project structure with .specify/ directory |
| metadata | {"author":"github-spec-kit","source":"extract:commands/extract.md"} |
$ARGUMENTS
You MUST consider the user input before proceeding (if not empty).
Goal: Analyze one or more completed spec directories and extract durable knowledge into the project's documentation system (dev/knowledge/, dev/guidelines/, dev/adr/), then mark each spec as extracted.
This command accepts multiple specs as input (space-separated) and processes them sequentially. It operationalizes the documentation lifecycle: specs/ → knowledge/ or guidelines/ (see dev/guidelines/markdown.md).
Parse arguments — split $ARGUMENTS into individual spec identifiers (space-separated). If $ARGUMENTS is empty, list available spec directories and ask the user to pick one or more.
Resolve each spec directory:
specs/NNN-* or NNN-*, resolve to REPO_ROOT/specs/NNN-*graphql-name-lookup, search specs/ for a matching directoryValidate each resolved spec:
spec.md MUST exist — skip that spec with an error if missingresearch.md SHOULD exist — warn if missing ("No ADRs can be extracted without research.md") but continueCheck extraction status for each spec:
EXTRACTED.md exists in the spec directory, warn the user that this spec was previously extractedspecs/archive/ — if so, it was previously extracted and archivedSummarize resolved specs — before proceeding, print the list of specs that will be processed:
Processing N spec(s):
1. specs/<spec-name-1>
2. specs/<spec-name-2>
...
Load existing documentation index (once, shared across all specs):
dev/knowledge/ (recursively)dev/guidelines/ (recursively)dev/adr/ to determine the next ADR numberLoad spec artifacts — for each spec, read all available files from its directory:
research.md (primary source for ADRs)spec.md (context, scope decisions)data-model.md (schema changes, new methods — if exists)contracts/ (API changes — if exists)plan.md (architectural context — if exists)Repeat the following steps for each resolved spec directory. Tag every finding with the source spec name so the extraction plan in Phase 2 groups items by spec.
Parse each ## R# section in research.md. For each entry:
Also scan spec.md for scope decisions or trade-offs in the Clarifications or Assumptions sections that represent architectural choices worth recording.
Scan for content that describes how the system works after the feature:
| Source | What to look for | Target file |
|---|---|---|
data-model.md | New entities, fields, relationships, constraints | dev/knowledge/backend/data-models.md |
contracts/ | New or changed GraphQL queries, mutations, types | dev/knowledge/backend/api.md |
research.md | New service patterns, architectural patterns | dev/knowledge/backend/services.md or relevant file |
spec.md | New concepts or domain terminology | dev/knowledge/backend/overview.md or relevant file |
For each finding, map it to a specific existing knowledge file and section. If no existing file fits, propose a new file with a name following kebab-case.md convention.
Scan research.md for implementation patterns that establish repeatable, prescriptive conventions for future code:
dev/guidelines/backend/python.md or dev/guidelines/cyclopts.mddev/guidelines/backend/python.mddev/guidelines/backend/graphql.md (create if needed)Only extract patterns that are prescriptive (should be followed in future code). Do NOT extract patterns that are merely descriptive of how this specific feature works — those belong in knowledge.
For each piece of spec content not classified above, note it with a reason:
plan.md, quickstart.md) — no durable knowledgePresent findings in a structured extraction plan. When processing multiple specs, group the plan by spec. Use a global numbering scheme across all specs so that item numbers are unique (e.g., spec 1 items are 1–4, spec 2 items are 5–8).
Use this format:
## Extraction Plan
### specs/<spec-name-1>
#### ADRs to Create (<count>)
| # | Source | Title | Target File |
|---|--------|-------|-------------|
| 1 | R1 | <title> | dev/adr/adr-NNN-<slug>.md |
| 2 | R2 | <title> | dev/adr/adr-NNN-<slug>.md |
#### Knowledge Updates (<count>)
| # | Target File | Section | Change | Summary |
|---|-------------|---------|--------|---------|
| 3 | dev/knowledge/backend/api.md | Queries | UPDATE | <what changes> |
#### Guidelines Updates (<count>)
| # | Target File | Section | Change | Summary |
|---|-------------|---------|--------|---------|
| 4 | dev/guidelines/backend/python.md | Error Handling | UPDATE | <what changes> |
#### Skipped (with reasons)
| Source | Reason |
|--------|--------|
| plan.md | Execution artifact — no durable knowledge |
---
### specs/<spec-name-2>
#### ADRs to Create (<count>)
| # | Source | Title | Target File |
|---|--------|-------|-------------|
| 5 | R1 | <title> | dev/adr/adr-NNN-<slug>.md |
...
When processing a single spec, omit the per-spec grouping headers and use the simpler flat format (same as the multi-spec table structure but without the ### specs/<name> wrapper).
After presenting, tell the user:
Actions:
approve all— proceed with all extractions across all specsapprove spec <name>— approve all items for a specific specapprove adrs/approve knowledge/approve guidelines— approve by category (across all specs)skip N— skip a specific numbered itemedit N— modify a specific item before writinggroup N,M— merge multiple ADR items into a single ADR
Wait for user response before proceeding. Do NOT write any files until the user approves.
For each approved item across all specs, write the content. ADR numbering is sequential across all specs (i.e., if spec 1 creates ADR-005 and ADR-006, spec 2 starts at ADR-007).
Create new files in dev/adr/ using this format:
# ADR-NNN: <Title>
**Status**: Accepted
**Date**: <today's date YYYY-MM-DD>
**Source**: specs/archive/<spec-name>/research.md (R#)
## Context
<What is the issue that motivates this decision? Derive from the feature context in spec.md and the specific problem the R# entry addresses.>
## Decision
<What was decided. Taken from the Decision field of the R# entry.>
## Consequences
<What becomes easier or harder as a result. Synthesize from the Rationale and any implementation notes.>
## Alternatives Considered
<What other options were evaluated and why they were rejected. Taken from the Alternatives considered field.>
Numbering: Read existing files in dev/adr/ to find the highest existing ADR number. Start new ADRs at the next sequential number. Zero-pad to 3 digits (e.g., adr-001, adr-012).
File naming: adr-NNN-kebab-case-short-title.md (e.g., adr-001-schema-changes-without-migrations.md).
For each knowledge update:
<!-- Extracted from specs/<spec-name> on YYYY-MM-DD -->Same approach as knowledge updates:
<!-- Extracted from specs/<spec-name> on YYYY-MM-DD -->If creating a new guidelines file, follow the standard structure:
# <Topic> Guidelines
## Overview
<Brief description of what this document covers.>
## <Sections...>
Perform the following steps for each spec that had approved extractions.
Write EXTRACTED.md in each spec directory:
# Extraction Record
**Extracted on**: <YYYY-MM-DD>
**Extracted by**: speckit.extract
## ADRs Created
- <path to ADR file> (from R#)
- ...
## Knowledge Updated
- <path to knowledge file> (<section name>)
- ...
## Guidelines Updated
- <path to guidelines file> (<section name>)
- ...
## Archive
Spec directory moved to `specs/archive/<spec-name>/` as a historical record.
For each spec:
spec.md, update or add the status field to: **Status**: Extractedspecs/archive/:
mkdir -p specs/archive
mv specs/<spec-name> specs/archive/<spec-name>
This makes it immediately clear which specs have been processed and which are still active.After all specs have been processed, update dev/README.md once with all new files:
dev/knowledge/, dev/guidelines/, or dev/adr/:
dev/README.md- [filename.md](path/to/filename.md) - Brief descriptiondev/adr/ now has content and there is no "Current ADRs" section in the README, create one following the pattern of the existing sections.Print a combined summary covering all processed specs:
## Extraction Complete
**Date**: YYYY-MM-DD
**Specs processed**: N
### Per-Spec Summary
| Spec | ADRs | Knowledge | Guidelines | Status |
|------|------|-----------|------------|--------|
| specs/<spec-name-1> | N | N | N | archived |
| specs/<spec-name-2> | N | N | N | archived |
### Totals
- N ADR(s) created in dev/adr/
- N knowledge file(s) updated
- N guideline file(s) updated
### Archived
- specs/<spec-name-1> → specs/archive/<spec-name-1>
- specs/<spec-name-2> → specs/archive/<spec-name-2>
### Files Created/Modified
- <list each file path>
### Next Steps
- Review the created ADRs for accuracy
- Verify knowledge and guideline updates read well in context
specs/archive/ before moving if it does not existSource paths must reference the archive location (specs/archive/<spec-name>/) since the spec will be moved there'I'\''m Groot' (or double-quote if possible: "I'm Groot")