// Mandatory spec folder workflow orchestrating documentation level selection (1-3), template selection, and folder creation for all file modifications through documentation enforcement.
| name | system-spec-kit |
| description | Mandatory spec folder workflow orchestrating documentation level selection (1-3), template selection, and folder creation for all file modifications through documentation enforcement. |
| allowed-tools | ["*"] |
| version | 6.0.0 |
Orchestrates mandatory spec folder creation for all conversations involving file modifications. This skill ensures proper documentation level selection (1-3), template usage, and context preservation through AGENTS.md-enforced workflows.
MANDATORY activation for ALL file modifications:
.opencode/skills/system-spec-kit/templates/*.md)User request patterns:
Rule of thumb: If you're modifying ANY file content → Activate this skill.
Utility templates (handover.md, debug-delegation.md) are available at ANY documentation level. The AI should automatically suggest these when detecting trigger keywords.
Handover Document (handover.md) - Auto-suggest when detecting:
Debug Delegation (debug-delegation.md) - Auto-suggest when detecting:
Rule: When ANY of these keywords are detected, automatically suggest the corresponding utility template and offer to create it in the active spec folder.
| Command | Steps | Description |
|---|---|---|
/spec_kit:complete | 12 | Full end-to-end workflow from spec through implementation |
/spec_kit:plan | 7 | Planning only - spec through plan, no implementation |
/spec_kit:implement | 8 | Execute pre-planned work (requires existing plan.md) |
/spec_kit:research | 9 | Technical investigation and documentation |
/spec_kit:resume | 5/4 | Resume previous session (5 steps confirm, 4 steps auto) |
Mode Suffixes: Add :auto or :confirm to any command except resume.
:auto - Autonomous execution with self-validation:confirm - Interactive with user approval checkpointsTASK CONTEXT
│
├─► Starting new feature / creating spec folder
│ └─► PHASE 1: Planning
│ └─► Command: /spec_kit:plan or /spec_kit:complete
│ └─► Load: level_decision_matrix.md, template_mapping.md
│ └─► Create: spec.md, plan.md, tasks.md (+ checklist.md for L2+)
│
├─► Executing pre-planned work (plan.md exists)
│ └─► PHASE 2: Implementation
│ └─► Command: /spec_kit:implement or /spec_kit:complete
│ └─► Load: level_specifications.md, template_guide.md
│ └─► Verify: checklist.md (Level 2+)
│
├─► Technical investigation needed
│ └─► PHASE 3: Research
│ └─► Command: /spec_kit:research
│ └─► Load: template_guide.md
│ └─► Create: research.md or research-spike.md
│
├─► Resuming previous session
│ └─► PHASE 4: Resume
│ └─► Command: /spec_kit:resume
│ └─► Load: Memory files from spec_folder/memory/
│ └─► Check: .spec-active marker, plan.md status
│
├─► Verifying completed work
│ └─► PHASE 5: Verification
│ └─► Load: checklist.md, quick_reference.md
│ └─► Action: Mark [x] items with evidence
│ └─► ⚠️ P0/P1 items MUST pass before claiming done
│
└─► Quick reference needed
└─► PHASE 6: Reference
└─► Load: quick_reference.md
└─► Contains: Commands, checklists, troubleshooting
def route_conversation_resources(task):
"""
Progressive Enhancement Model:
- Level 1 (Baseline): spec.md + plan.md + tasks.md
- Level 2 (Verification): Level 1 + checklist.md
- Level 3 (Full): Level 2 + decision-record.md + optional research.md/research-spike.md
Utility Templates (any level):
- handover.md → Session continuity for multi-session work
- debug-delegation.md → Sub-agent debugging task delegation
LOC thresholds are SOFT GUIDANCE (not enforcement):
- <100 LOC suggests Level 1
- 100-499 LOC suggests Level 2
- ≥500 LOC suggests Level 3
Enforcement via AGENTS.md discipline - verification required before commits.
"""
# ═══════════════════════════════════════════════════════════════════════════
# TEMPLATES (9 files in .opencode/skills/system-spec-kit/templates/)
# ═══════════════════════════════════════════════════════════════════════════
# Level 1: Baseline (all tasks start here)
# Required: spec.md + plan.md + tasks.md
load("templates/spec.md")
load("templates/plan.md")
load("templates/tasks.md")
# Level 2: Add verification (QA validation needed)
# Required: Level 1 + checklist.md
if task.needs_qa_validation or task.estimated_loc >= 100:
load("templates/checklist.md")
# Level 3: Full documentation (complex/architectural)
# Required: Level 2 + decision-record.md
# Optional: research.md, research-spike.md
if task.is_complex or task.has_arch_impact or task.estimated_loc >= 500:
load("templates/decision-record.md")
if task.needs_research:
load("templates/research.md") # Comprehensive research
load("templates/research-spike.md") # Time-boxed PoC
# ═══════════════════════════════════════════════════════════════════════════
# UTILITY TEMPLATES: Available at ANY level, triggered by keywords
# ═══════════════════════════════════════════════════════════════════════════
# Handover detection - session transfer keywords
handover_keywords = ["handover", "hand over", "for next AI", "next session",
"next agent", "continue later", "pick up later", "resume later",
"pass context", "transfer context", "ending session", "save state",
"multi-session", "ongoing work"]
if task.is_multi_session or any(kw in user_message.lower() for kw in handover_keywords):
suggest("templates/handover.md") # Session continuity
# Debug delegation detection
debug_keywords = ["delegate debug", "sub-agent debug", "parallel debug", "multi-file debug"]
if task.needs_debug_delegation or any(kw in user_message.lower() for kw in debug_keywords):
suggest("templates/debug-delegation.md") # Sub-agent debugging
# ═══════════════════════════════════════════════════════════════════════════
# ASSETS (3 files in ./assets/) - Decision support tools
# ═══════════════════════════════════════════════════════════════════════════
load("assets/level_decision_matrix.md") # LOC thresholds, complexity factors
load("assets/template_mapping.md") # Template-to-level mapping, copy commands
load("assets/parallel_dispatch_config.md") # Complexity scoring, agent dispatch config
# ═══════════════════════════════════════════════════════════════════════════
# REFERENCES (5 files in ./references/) - Detailed documentation
# ═══════════════════════════════════════════════════════════════════════════
load("references/level_specifications.md") # Complete Level 1-3 specifications
load("references/template_guide.md") # Template selection & adaptation rules
load("references/quick_reference.md") # Commands, checklists, troubleshooting
load("references/path_scoped_rules.md") # Path-scoped rule documentation
# ═══════════════════════════════════════════════════════════════════════════
# SCRIPTS (6 files in ./scripts/) - Automation tools
# ═══════════════════════════════════════════════════════════════════════════
# Available scripts (invoke via bash):
# bash("scripts/create-spec-folder.sh", name, level) # Create spec folder with templates
# bash("scripts/check-prerequisites.sh") # Validate spec folder structure
# bash("scripts/calculate-completeness.sh", path) # Calculate placeholder completion %
# bash("scripts/recommend-level.sh", loc, files) # Recommend documentation level
# bash("scripts/archive-spec.sh", path) # Archive completed spec folders
# Note: common.sh is sourced by other scripts (not invoked directly)
# ═══════════════════════════════════════════════════════════════════════════
# CONDITIONAL RESOURCES (loaded when specific features needed)
# ═══════════════════════════════════════════════════════════════════════════
if task.uses_sub_folder_versioning:
load("references/sub_folder_versioning.md") # Full versioning workflow
# Overrides: High risk OR arch impact OR >5 files → bump to higher level
# Enforcement: AGENTS.md discipline - verification required before commits
# Rule: When in doubt → choose higher level
# SUMMARY: 23 total resources
# - 9 templates in: .opencode/skills/system-spec-kit/templates/
# - 3 assets in: ./assets/
# - 5 references in: ./references/
# - 6 scripts in: ./scripts/
MANDATORY: The AI must NEVER autonomously decide whether to use an existing spec folder, create a new one, or skip documentation. This is defined in AGENTS.md Phase 1, Gate 2 (Q1).
The AI must follow this workflow manually and ask the user before proceeding with any file modifications.
When file modification triggers are detected (rename, create, update, fix, implement, etc.), the AI MUST ask the user to explicitly choose:
| Option | Description | Best For |
|---|---|---|
| A) Use existing | Continue in related spec folder | Iterative work, related changes |
| B) Create new | Create new spec folder (specs/###-name/) | New features, unrelated work |
| C) Update related | Update documentation in related folder | Extending existing documentation |
| D) Skip documentation | Proceed without spec folder | Trivial changes (creates tech debt) |
The AI MUST detect these keywords and ask Q1:
🔴 MANDATORY_USER_QUESTION
"Before proceeding with file modifications, please choose:"
A) Use existing spec folder (continue in 006-commands)
B) Create new spec folder (specs/007-new-feature/)
C) Update related spec folder (add to existing documentation)
D) Skip documentation (creates technical debt - use sparingly)
| Document | Purpose | Key Insight |
|---|---|---|
| Conversation Documentation - Main Workflow | Orchestrates spec folder creation for all file modifications | AGENTS.md-enforced workflow with 3-level decision framework |
| Document | Purpose | Key Insight |
|---|---|---|
| assets/level_decision_matrix.md | LOC thresholds and decision factors | LOC is soft guidance; progressive enhancement model |
| assets/template_mapping.md | Template-to-level mapping with copy commands | Always copy from .opencode/skills/system-spec-kit/templates/ - never freehand |
| references/level_specifications.md | Complete Level 1-3 specifications | Progressive enhancement: each level builds on previous |
| references/template_guide.md | Template selection and adaptation rules | Fill ALL placeholders, remove sample content |
| references/quick_reference.md | Commands, checklists, troubleshooting | Pre-implementation checklist is mandatory |
The conversation documentation system uses a progressive enhancement approach where each level BUILDS on the previous:
Level 1 (Baseline): spec.md + plan.md + tasks.md
↓
Level 2 (Verification): Level 1 + checklist.md
↓
Level 3 (Full): Level 2 + decision-record.md + optional research.md/research-spike.md
Utility (any level): handover.md, debug-delegation.md
Level 1: Baseline Documentation (LOC guidance: <100)
spec.md + plan.md + tasks.mdLevel 2: Verification Added (LOC guidance: 100-499)
checklist.mdchecklist.md missingCRITICAL: Checklist as Active Verification Tool
The
checklist.mdis NOT just documentation - it is an ACTIVE VERIFICATION TOOL that the AI MUST use to verify its own work before claiming completion. The checklist serves as:
- A systematic verification protocol (not a passive record)
- An evidence-based completion gate (must mark items with proof)
- A priority-driven blocker (P0/P1 items MUST pass before done)
See Section 5 (RULES) for mandatory checklist verification requirements.
Level 3: Full Documentation (LOC guidance: ≥500)
decision-record.mdresearch-spike.md, research.mddecision-record.md missingLOC thresholds are SOFT GUIDANCE - these factors can push to higher level:
Decision rules:
All 9 templates located in: .opencode/skills/system-spec-kit/templates/
Required templates by level (progressive):
spec.md + plan.md + tasks.md (baseline)checklist.md (adds verification)decision-record.md (adds decision records)Optional templates (Level 3):
research-spike.md → research-spike-[name].md (time-boxed research/POC)research.md → research.md (comprehensive research)Utility templates (any level):
handover.md → Session continuity for multi-session workdebug-delegation.md → Sub-agent debugging task delegationFormat: specs/###-short-name/
Rules:
001, 042, 099 (no padding past 999)Good examples: fix-typo, add-auth, mcp-code-mode, cli-codex
Find next number:
ls -d specs/[0-9]*/ | sed 's/.*\/\([0-9]*\)-.*/\1/' | sort -n | tail -1
AI agent behavior (AGENTS.md Phase 1 - Gate 2):
Start of conversation (file modification detected):
Returning to existing spec folder:
Option D (Skip):
Manual context save:
/save_context command or ask AI to save contextspecs/###-folder/memory/ or sub-folder memory/ if activeDD-MM-YY_HH-MM__topic.mdWhen reusing existing spec folders, the system creates numbered sub-folders to separate iterations while maintaining independent memory contexts.
Quick Reference:
001-original/, 002-new-work/, 003-another/memory/ directory.spec-active points to current sub-folderFull documentation: See sub_folder_versioning.md for complete workflow, naming conventions, and examples.
When returning to an active spec folder, the AI asks two sequential questions:
Combined Flow:
🔴 STAGE 1: SPEC FOLDER
"You have an active spec folder. Continue in '006-commands' or start fresh?"
A) Continue in 006-commands
B) Create new spec folder
D) Skip documentation
[If A chosen AND memory files exist]
🔴 STAGE 2: MEMORY LOADING
"Found 3 previous session files. Load context?"
A) Load most recent
B) Load all recent (1-3)
C) List and select specific
D) Skip (start fresh)
Key Insight: "D" means different things:
AI Actions by Stage 2 Choice:
SpecKit supports smart parallel sub-agent dispatch based on 5-dimension complexity scoring.
Quick Reference:
Full configuration: See parallel_dispatch_config.md for scoring algorithm, thresholds, and override phrases.
ALWAYS determine documentation level (1/2/3) before ANY file changes
ALWAYS copy templates from .opencode/skills/system-spec-kit/templates/ - NEVER create from scratch
ALWAYS fill ALL placeholders in templates
[PLACEHOLDER] with actual content<!-- SAMPLE CONTENT --> blocksALWAYS ask user for spec folder choice (A/B/C/D) when file modification detected
ALWAYS check for related specs before creating new folders
ALWAYS get explicit user approval before file changes
ALWAYS use consistent folder naming
specs/###-short-name/ALWAYS use checklist.md to verify work before completion (Level 2+)
ALWAYS mark checklist items [x] with evidence when verified
ALWAYS complete all P0 and P1 items before claiming done
ALWAYS suggest handover.md when session-ending keywords detected
.opencode/skills/system-spec-kit/templates/handover.mdNEVER create documentation files from scratch - Always copy from .opencode/skills/system-spec-kit/templates/
NEVER skip spec folder creation (unless user explicitly selects Option D)
NEVER make file changes before spec folder creation and user approval
NEVER leave placeholder text in final documentation
[PLACEHOLDER] must be replacedNEVER decide autonomously between update vs create
NEVER claim completion without verifying checklist.md items (Level 2+)
NEVER proceed without spec folder confirmation
Scope grows during implementation
Uncertainty about level selection (confidence <80%)
Template doesn't fit feature requirements
User requests to skip documentation (Option D)
specs/###-short-name/.opencode/skills/system-spec-kit/templates/ (not created from scratch)specs/###/memory/ (manual trigger via /memory:save)checklist.md before claiming completionchecklist.md with verification timestampsSpecKit uses a priority system for validation and enforcement through AGENTS.md discipline.
Enforcement Levels (Priority System):
checklist.md for Level 2)[PLACEHOLDER])Validation Triggers:
/save_context → Context preservation on demandUpstream (feeds into this skill):
Downstream (uses this skill's outputs):
Spec Folder → Implementation Workflow:
system-spec-kit creates spec folderworkflows-code implements from spec + planworkflows-git commits with spec referencesystem-memory preserves conversation to spec/memory/Documentation Quality Workflow:
system-spec-kit creates spec documentationworkflows-documentation validates structure and quality scores.opencode/skills/system-spec-kit/templates/ - All template filesAGENTS.md - Section 2 defines mandatory documentation requirements/spec_kit:complete - Level 3 auto-generation commandRemember: This skill operates as the foundational documentation orchestrator. It enforces structure, template usage, and context preservation for all file modifications.