framework
npx skills add https://github.com/anton-abyzov/specweave --skill framework
Agent 安装分布
Skill 文档
SpecWeave Framework Expert
I am an expert on the SpecWeave framework – a spec-driven development framework for Claude Code (and other AI coding assistants). I have deep knowledge of its structure, rules, conventions, and best practices.
Core Philosophy
SpecWeave follows spec-driven development with increment-based workflows:
- Specification First – Write WHAT and WHY before HOW
- Incremental Delivery – Ship small, complete features
- Living Documentation – Docs update automatically via hooks
- Source of Truth Discipline – Single source, zero duplication
- Multi-Tool Support – Works with Claude, Cursor, Copilot, and generic AI
Increment-Based Development
What is an Increment?
An increment = a complete feature with:
spec.md– Product requirements (WHAT and WHY) â requiredplan.md– Technical architecture (HOW to implement) â optional, for complex features onlytasks.md– Task breakdown (WORK to do) â requiredmetadata.json– State tracking â required
When to skip plan.md: Bug fixes, simple migrations, hotfixes, and straightforward tasks where spec.md already describes the approach.
spec.md Mandatory Fields
CRITICAL: spec.md YAML frontmatter MUST include project (and board for 2-level structures):
# 1-level structure (single-project or multiProject):
---
increment: 0001-feature-name
project: my-project # REQUIRED
---
# 2-level structure (ADO area paths, JIRA boards, umbrella teams):
---
increment: 0001-feature-name
project: acme-corp # REQUIRED
board: digital-operations # REQUIRED for 2-level
---
Why? Ensures increment syncs to correct location in living docs. Without explicit project/board, sync-specs may fail or place specs in wrong folder.
Detection: Use src/utils/structure-level-detector.ts to determine if 1-level or 2-level structure is needed.
See: ADR-0190
Increment Naming Convention
CRITICAL RULE: All increments MUST use descriptive names, not just numbers!
Format: ####-descriptive-kebab-case-name
Examples:
- â
0001-core-framework - â
0002-core-enhancements - â
0003-intelligent-model-selection - â
0004-plugin-architecture - â
0006-llm-native-i18n - â
0003(too generic, rejected!) - â
0004(no description, rejected!)
Rationale:
- Clear intent at a glance
- Easy to reference in conversation
- Better git history
- Searchable by feature name
- Self-documenting increment folders
Increment Lifecycle
1. Plan â /sw:inc "feature-name"
â PM agent creates spec.md, plan.md, tasks.md, tests.md
2. Execute â /sw:do
â Selects next task, executes, marks complete
3. Validate â /sw:validate 0001
â Checks spec compliance, test coverage
4. Close â /sw:done 0001
â Creates COMPLETION-SUMMARY.md, archives
Increment Discipline
THE IRON RULE: Cannot start increment N+1 until increment N is DONE!
Enforcement:
/sw:incblocks if previous increments incomplete- Use
/sw:statusto check all increments - Use
/sw:doneto close incomplete work --forceflag for emergencies (logged, should be rare)
What “DONE” Means:
- All tasks in
tasks.mdmarked[x] Completed, OR COMPLETION-SUMMARY.mdexists with “â COMPLETE” status, OR- Explicit closure via
/sw:done
Three Options for Closing:
- Adjust Scope – Remove features from spec.md, regenerate tasks
- Move Scope – Transfer incomplete tasks to next increment
- Extend Existing – Update spec.md, add tasks, continue in same increment
Example:
# Check status
/sw:status
# Shows: 0002 (73% complete), 0003 (50% complete)
# Try to start new increment
/sw:inc "0004-new-feature"
# â Blocked! "Close 0002 and 0003 first"
# Close previous work
/sw:done
# Interactive: Choose force-complete, move tasks, or reduce scope
# Now can proceed
/sw:inc "0004-new-feature"
# â
Works! Clean slate
Directory Structure
Root-Level .specweave/ Folder (MANDATORY)
CRITICAL ARCHITECTURE RULE: SpecWeave ONLY supports root-level .specweave/ folders.
Correct Structure:
my-project/
âââ .specweave/ â ONE source of truth (root-level)
â âââ increments/
â â âââ 0001-core-framework/
â â â âââ spec.md
â â â âââ plan.md
â â â âââ tasks.md
â â â âââ tests.md
â â â âââ logs/ â Session logs
â â â âââ scripts/ â Helper scripts
â â â âââ reports/ â Analysis files
â â âââ _backlog/
â âââ docs/
â â âââ internal/ â Strategic docs (NEVER published)
â â â âââ strategy/ â Business strategy
â â â âââ architecture/ â ADRs, RFCs, diagrams
â â â âââ delivery/ â Implementation notes
â â âââ public/ â User-facing docs (can publish)
â âââ logs/
âââ frontend/
âââ backend/
âââ infrastructure/
WRONG (nested .specweave/ folders – NOT SUPPORTED):
my-project/
âââ .specweave/ â Root level
âââ backend/
â âââ .specweave/ â â NESTED - PREVENTS THIS!
âââ frontend/
âââ .specweave/ â â NESTED - PREVENTS THIS!
Why Root-Level Only?
- â Single source of truth
- â Cross-cutting features natural (frontend + backend + infra)
- â No duplication or fragmentation
- â Clear ownership
- â Simplified living docs sync
Multi-Repo Solution: For huge projects with multiple repos, create a parent folder:
my-big-project/ â Create parent folder
âââ .specweave/ â ONE source of truth for ALL repos
âââ auth-service/ â Separate git repo
âââ payment-service/ â Separate git repo
âââ frontend/ â Separate git repo
âââ infrastructure/ â Separate git repo
Source of Truth Discipline
CRITICAL PRINCIPLE: SpecWeave has strict source-of-truth rules!
Three Directories, Three Purposes
src/ â SOURCE OF TRUTH (version controlled)
âââ skills/ â Source for skills
âââ agents/ â Source for agents
âââ commands/ â Source for slash commands
âââ hooks/ â Source for hooks
âââ adapters/ â Tool adapters (Claude/Cursor/Copilot/Generic)
âââ templates/ â Templates for user projects
.claude/ â INSTALLED (gitignored in user projects)
âââ skills/ â Installed from src/skills/
âââ agents/ â Installed from src/agents/
âââ commands/ â Installed from src/commands/
âââ hooks/ â Installed from src/hooks/
.specweave/ â FRAMEWORK DATA (always present)
âââ increments/ â Feature development
âââ docs/ â Strategic documentation
âââ logs/ â Logs and execution history
Golden Rules
- â
ALWAYS edit files in
src/(source of truth) - â
Run install scripts to sync changes to
.claude/ - â NEVER edit files in
.claude/directly (they get overwritten) - â NEVER create new files in project root (use increment folders)
Example Workflow:
# CORRECT: Edit source
vim src/skills/increment-planner/SKILL.md
# Sync to .claude/
npm run install:skills
# Test (skill activates from .claude/)
/sw:inc "test feature"
# WRONG: Edit installed file
vim .claude/skills/increment-planner/SKILL.md # â Gets overwritten!
File Organization Rules
â ALLOWED in Root:
CLAUDE.md(this file)README.md,CHANGELOG.md,LICENSE- Standard config files (
package.json,tsconfig.json,.gitignore) - Build artifacts (
dist/, only if needed temporarily)
â NEVER Create in Root (pollutes repository): All AI-generated files MUST go into increment folders:
â WRONG:
/SESSION-SUMMARY-2025-10-28.md # NO!
/ADR-006-DEEP-ANALYSIS.md # NO!
/ANALYSIS-MULTI-TOOL-COMPARISON.md # NO!
â
CORRECT:
.specweave/increments/0002-core-enhancements/
âââ reports/
â âââ SESSION-SUMMARY-2025-10-28.md
â âââ ADR-006-DEEP-ANALYSIS.md
â âââ ANALYSIS-MULTI-TOOL-COMPARISON.md
âââ logs/
â âââ execution-2025-10-28.log
âââ scripts/
âââ migration-helper.sh
Why?
- â Complete traceability (which increment created which files)
- â Easy cleanup (delete increment folder = delete all files)
- â Clear context (all files for a feature in one place)
- â No root clutter
Hook System
What are Hooks?
Hooks are shell scripts that fire automatically on SpecWeave events:
post-task-completion– After EVERY task completion via TodoWritepre-task-plugin-detect– Before task execution (plugin detection)post-increment-plugin-detect– After increment creationpre-implementation– Before implementation starts
Current Hook: post-task-completion
Fires: After EVERY TodoWrite call Purpose: Notify when work completes
What it does:
- â Detects session end (inactivity-based, 15s threshold)
- â Plays notification sound (macOS/Linux/Windows)
- â Shows completion message
- â
Logs to
.specweave/logs/hooks-debug.log - â Debounces duplicate fires (2s window)
What it does NOT do yet:
- â³ Update
tasks.mdcompletion status - â³ Sync living docs automatically
- â³ Consolidate GitHub/Jira tasks
- â³ Calculate increment progress percentage
Smart Session-End Detection:
Problem: Claude creates multiple todo lists â sound plays multiple times
Solution: Track inactivity gaps between TodoWrite calls
- Rapid completions (< 15s gap) = Claude still working â skip sound
- Long gap (> 15s) + all done = Session ending â play sound!
Hook Configuration
File: .specweave/config.json
{
"hooks": {
"post_task_completion": {
"enabled": true,
"update_tasks_md": false,
"sync_living_docs": false,
"play_sound": true,
"show_message": true
}
}
}
Manual Actions
Until hooks are fully automated, YOU MUST:
- Update
CLAUDE.mdwhen structure changes - Update
README.mdfor user-facing changes - Update
CHANGELOG.mdfor API changes - Update
tasks.mdcompletion status manually (or use TodoWrite carefully)
Plugin Architecture
Core vs. Plugin
Core Framework (always loaded):
- 8 core skills (increment-planner, spec-generator, context-loader, etc.)
- 3 core agents (PM, Architect, Tech Lead)
- 7 core commands (/sw:inc, /sw:do, etc.)
Plugins (opt-in):
specweave-github– GitHub integration (issue sync, PR creation)specweave-jira– Jira integration (task sync)specweave-kubernetes– K8s deployment (planned)specweave-frontend-stack– React/Vue/Angular (planned)specweave-ml-ops– Machine learning (planned)
Context Reduction
Before plugins:
- Simple React app: 50K tokens (ALL 44 skills + 20 agents loaded)
- Backend API: 50K tokens
- ML pipeline: 50K tokens
After plugins:
- Simple React app: Core + frontend-stack + github â 16K tokens (68% reduction!)
- Backend API: Core + nodejs-backend + github â 15K tokens (70% reduction!)
- ML pipeline: Core + ml-ops + github â 18K tokens (64% reduction!)
Four-Phase Plugin Detection
-
Init-Time (during
specweave init):- Scans package.json, directories, env vars
- Suggests plugins: “Found React. Enable frontend-stack? (Y/n)”
-
First Increment (during
/sw:inc):- Analyzes increment description for keywords
- Suggests before creating spec: “This needs kubernetes plugin. Enable? (Y/n)”
-
Pre-Task (before task execution):
- Hook scans task description
- Non-blocking suggestion: “This task mentions K8s. Consider enabling plugin.”
-
Post-Increment (after completion):
- Hook scans git diff for new dependencies
- Suggests for next increment: “Detected Stripe. Enable payment-processing plugin?”
Hybrid Plugin System
SpecWeave plugins support dual distribution:
-
NPM Package (SpecWeave CLI):
npm install -g specweavespecweave plugin install sw-github- Works with ALL tools (Claude, Cursor, Copilot, Generic)
-
Claude Code Marketplace (Native
/plugin):/plugin marketplace add https://github.com/anton-abyzov/specweave/plugin install sw-github@specweave- Best UX for Claude Code users (use HTTPS URL for public repos!)
Plugin Manifests (both required):
plugin.json– Claude Code native formatmanifest.json– SpecWeave custom format (richer metadata)
Multi-Tool Support
SpecWeave works with multiple AI coding assistants:
Claude Code (âââââ 100%)
- Native
.claude/installation - Skills auto-activate
- Hooks fire automatically
- Slash commands work natively
- Agents isolate context
- BEST EXPERIENCE
Cursor 2.0 (ââââ 85%)
AGENTS.mdcompilation- Team commands via dashboard
@contextshortcuts- Shared agent context (8 parallel agents)
- Manual hook triggers
GitHub Copilot (âââ 60%)
.github/copilot/instructions.mdcompilation- Natural language instructions only
- Manual workflows
- No hooks or slash commands
Generic (ââ 40%)
SPECWEAVE-MANUAL.mdfor copy-paste- Manual workflows
- No automation
Recommendation: Use Claude Code for SpecWeave. Other tools work, but you’ll miss the magic.
Key Commands
Increment Lifecycle
/sw:inc "feature-name"– Plan new increment (PM-led process)/sw:do– Execute next task (smart resume)/sw:progress– Show progress, PM gate status, next action/sw:validate 0001– Validate spec, tests, quality/sw:done 0001– Close increment (PM validation)/sw:next– Auto-close if ready, suggest next work
Increment Discipline
/sw:status– Show all increments and completion status/sw:close– Interactive closure of incomplete increments
Documentation Sync
/sw:sync-docs review– Review strategic docs before implementation/sw:sync-docs update– Update living docs from completed increments
External Platform Sync
/sw-github:sync– Bidirectional GitHub sync/sw-jira:sync– Bidirectional Jira sync
Common Questions
Q: Where do I create a new increment?
A: Use /sw:inc "####-descriptive-name". It creates:
.specweave/increments/####-descriptive-name/
âââ spec.md
âââ plan.md
âââ tasks.md
âââ tests.md
Q: Where do I put analysis files?
A: In the increment’s reports/ folder:
.specweave/increments/0002-core-enhancements/reports/
âââ ANALYSIS-XYZ.md
Q: How do I know what tasks are left?
A: Use /sw:progress or read .specweave/increments/####/tasks.md
Q: Can I start a new increment before finishing the current one?
A: NO! The framework blocks you. Use /sw:status to check, /sw:close to close.
Q: Where do I edit skills/agents/commands?
A: Edit in src/ (source of truth), then run npm run install:all to sync to .claude/
Q: How do I know if a plugin is needed?
A: SpecWeave auto-detects! It will suggest plugins during init or increment creation.
Q: Why does the hook play a sound?
A: Session-end detection! If all tasks complete AND you’ve been idle > 15s, it assumes you’re done. Configurable in .specweave/config.json.
Q: How do I disable a hook?
A: Edit hooks/hooks.json and set "enabled": false for that hook.
Activation Keywords
I activate when you ask about:
- SpecWeave rules / conventions / best practices
- Increment naming / structure / lifecycle
- Where files go / directory structure
- Source of truth / what to edit
- Hook system / automation
- Plugin architecture / context reduction
- How to use SpecWeave / getting started
- What is spec.md / plan.md / tasks.md
- Living docs sync
- Increment discipline / closure
- Multi-tool support (Claude/Cursor/Copilot)
When to Use Other Skills/Agents
- increment-planner – Planning NEW increments (/sw:inc)
- PM agent – Leading increment creation (auto-invoked by /sw:inc)
- Architect agent – Designing system architecture
- Tech Lead agent – Code review, best practices
- spec-generator – Creating detailed technical RFCs
- context-loader – Explaining context efficiency
- diagrams-architect – Creating C4/Mermaid diagrams
I focus on framework knowledge. For increment execution, use the PM agent and commands!
Let me help you understand and use SpecWeave correctly! ð
Project-Specific Learnings
Before starting work, check for project-specific learnings:
# Check if skill memory exists for this skill
cat .specweave/skill-memories/framework.md 2>/dev/null || echo "No project learnings yet"
Project learnings are automatically captured by the reflection system when corrections or patterns are identified during development. These learnings help you understand project-specific conventions and past decisions.