AI-native spec management for Claude Code.
Turn natural language into executable specifications. Catch AI hallucinations before they become bugs.
English | ไธญๆ
You tell Claude Code: "Add batch export to the system."
It writes 500 lines of code. Tests pass. You merge.
Three days later you discover:
- PDF export was never mentioned but Claude assumed it
- Error handling covers 2 of 7 failure modes
- The "edge case" tests are actually happy-path tests with different data
The spec was in your head. Claude couldn't see it.
superSpec sits between your intent and Claude's code. It forces a structured spec to exist before any code is written, then validates that the code actually matches.
flowchart LR
You["๐ค You"] -- "batch export" --> BS["๐ง Brainstorm<br/>Route Evaluator"]
BS -->|"๐ Lightweight"| GS["๐ generate-spec"]
BS -->|"๐ฆ Full"| CH["๐ Change Dir"]
GS --> V["โ
validate-spec<br/>+ SkillGuard"]
CH --> V
V -->|"verified spec"| CC["๐ค Claude Code"]
CC -->|"code + evidence"| AR["๐ฆ archive"]
AR --> LS["๐ Living Specs"]
# 1. Clone and build superspec
git clone https://github.com/ChenJazzyBoss/superSpec.git
cd superSpec
npm install
npm run build
npm run bundle-validate
# 2. Go to YOUR project and initialize
cd /path/to/your-project
node /path/to/superSpec/bin/superspec.js initThis creates .superspec/ and .claude/ in your project. Then in Claude Code:
/generate-spec
Claude will ask you questions, generate a structured spec, and validate it โ before writing any code.
๐ Structured specs โ Requirements use SHALL/MUST, scenarios use Given/When/Then. No ambiguity.
โ Auto-validation โ 9 built-in rules catch missing scenarios, vague words, and incomplete coverage.
๐ Deep analysis โ Optional --deep mode detects logical contradictions between scenarios and coverage gaps in requirements.
๐ Auto diagrams โ Add <!-- DIAGRAM:flowchart --> to your spec, and Mermaid diagrams are generated and embedded automatically.
๐ Source tracking โ Add <!-- source: src/foo.ts --> to link specs to code. Get warned when source files change but spec doesn't.
๐ท๏ธ Scenario classification โ Scenarios are auto-tagged as normal/error/boundary. Missing error scenarios trigger warnings.
๐ Delta changes โ Describe what changed, not the whole file. Merge conflicts become impossible.
๐ก๏ธ Anti-hallucination โ Red flag tables and checklists prevent Claude from skipping steps or faking completion.
๐ SkillGuard โ Programmatic detection of AI skip patterns. Run superspec guard to verify skill configuration.
๐ Init Template โ Collect human context before spec generation. Solves the "AI can't read your mind" problem.
๐ฆ Multi-artifact validation โ Validate module lists with superspec validate-modules. Circular dependency detection included.
๐ค Subagent orchestration โ Dual-review pipeline: implement โ spec-check โ code-review. Every task.
Initialize superSpec in your project.
superspec init # Default setup
superspec init --interactive # Interactive configuration
superspec init --ci # Include GitHub Actions workflow
superspec init --template web-api # Use Web API template
superspec init --list-templates # List available templatesCreates .superspec/ directory structure, injects CLAUDE.md, copies templates and scripts.
Validate a spec file.
superspec validate batch-export # By spec name
superspec validate .superspec/specs/batch-export/spec.md # By file path
superspec validate batch-export --strict # WARNING = failure
superspec validate batch-export --deep # Logical consistency analysisOutput (JSON):
{
"valid": true,
"issues": [],
"summary": { "errors": 0, "warnings": 0, "info": 0 },
"scenarioTypes": {
"requirements[0]": ["normal", "error", "boundary"]
}
}Batch validate all specs.
superspec ci # Validate all specs
superspec ci --strict # Strict mode
superspec ci --json # JSON outputGenerate test code skeleton from spec.
superspec generate batch-export # TypeScript (default)
superspec generate batch-export -l python # Python
superspec generate batch-export -o test/batch.test.ts # Write to fileIncrementally update a spec via Delta JSON.
cat delta.json | superspec update batch-export
superspec update batch-export -f delta.jsonCompare current spec with historical version.
superspec diff batch-export # Compare with latest snapshot
superspec diff batch-export --from 2026-06-01 # Compare with specific versionList all historical snapshots of a spec.
superspec history batch-exportArchive a completed change.
superspec archive add-pdf-exportList in-progress changes.
superspec changesCheck skill file's anti-hallucination configuration.
superspec guard src/skills/generate-spec/SKILL.md # Check skill config
superspec guard src/skills/validate-spec/SKILL.md --json # JSON outputVerifies that skill files have proper red flag tables and HARD-GATE tags configured.
Validate module list files.
superspec validate-modules modules.md # Validate module list
superspec validate-modules modules.md -p my-project # With project name
superspec validate-modules modules.md --json # JSON outputChecks module structure, detects circular dependencies, validates naming conventions.
Display the default workflow definition.
superspec pipeline showOutput:
๐ superSpec ้ป่ฎคๅทฅไฝๆต
้ถๆฎต ็ฑปๅ ไพ่ต
โโโโโโโโโโโโโโโโ โโโโโโโโ โโโโโโโโโโโโโโโโโโ
brainstorm ๅฏ้ โ
generate-spec ๅฟ
้ brainstorm
validate-spec ๅฟ
้ generate-spec
write-plan ๅฟ
้ validate-spec
implement ๅฟ
้ write-plan
verify ๅฟ
้ implement
archive ๅฟ
้ verify
Query the recommended next step for a given stage.
superspec pipeline next brainstorm # โ generate-spec
superspec pipeline next validate-spec # โ write-plan
superspec pipeline next archive # โ "reached end of workflow"Run the pipeline for a spec โ auto-executes programmatic stages (validate-spec, archive) and outputs guidance for AI stages.
superspec pipeline run batch-export # Run from validate-spec
superspec pipeline run batch-export --from write-plan # Resume from a specific stageExecution records are persisted to .superspec/pipeline/<exec-id>.json.
View pipeline execution status.
superspec pipeline status # Latest execution
superspec pipeline status batch-export # Latest for this spec
superspec pipeline status --exec <id> # By execution idList all pipeline execution records.
superspec pipeline listResume a failed pipeline execution from the failed stage.
superspec pipeline resume batch-export-20260611100000Manage change lifecycle (unified model for new features and modifications).
superspec change create <name> # Create change directory with proposal
superspec change create <name> --why "..." # With description
superspec change list # List all changes
superspec change status <name> # Show change phase and capabilities
superspec change apply <name> # Merge delta specs into main specs
superspec change apply <name> --dry-run # Validate without writingEvaluate user intent and recommend a path.
superspec route "add export button" # โ ๐ Lightweight
superspec route "implement full auth" -c 3 # โ ๐ฆ Full
superspec route "modify export format" # โ ๐ฆ Full (modification)
superspec route "export feature crashed" # โ ๐ง DebugRemove all superSpec files from project.
superspec uninstall # With confirmation
superspec uninstall -y # Skip confirmationA spec file uses structured Markdown:
# Feature Name
## Purpose
Description of what this feature does and why it's needed.
Must be at least 50 characters.
<!-- DIAGRAM:flowchart -->
## Requirements
### Requirement: Requirement Name
The system SHALL do something specific.
#### Scenario: Normal flow
Given some precondition
When some action
Then expected result
#### Scenario: Exception handling
Given some precondition
When an error occurs
Then error is handled gracefully
#### Scenario: Boundary condition
Given edge case data
When processing
Then system handles correctly| Annotation | Purpose | Example |
|---|---|---|
<!-- DIAGRAM:flowchart --> |
Auto-generate flowchart | Embedded after validation |
<!-- DIAGRAM:state --> |
Auto-generate state diagram | Embedded after validation |
<!-- source: path --> |
Link to source code | <!-- source: src/core/foo.ts --> |
/superspec:generate-spec
Claude asks about your requirements, then produces:
# Batch Export
## Purpose
System needs to export data in CSV, XLSX, and PDF formats
for various business workflows...
## Requirements
### Requirement: Format Support
System SHALL support CSV, XLSX, and PDF export formats.
#### Scenario: Normal flow - CSV export
Given user is on the data list page
When selecting CSV format and clicking export
Then system generates and downloads a CSV file
#### Scenario: Exception - Export failure
Given user is on the data list page
When an error occurs during export
Then system displays error message and logs the issue# Basic validation (format + rules + scenario classification)
node .superspec/scripts/validate.js .superspec/specs/batch-export/spec.md
# Deep validation (+ logical consistency analysis)
node .superspec/scripts/validate.js .superspec/specs/batch-export/spec.md --deepโ
valid: true
errors: 0, warnings: 0, info: 0
scenarioTypes:
requirements[0]: [normal, error, boundary]
/superspec:write-plan
/superspec:subagent-dev
Claude creates a detailed plan, then implements each task with dual review.
superspec pipeline run batch-exportAutomatically executes programmatic stages (validate-spec, archive) and guides you through AI stages (write-plan, implement, verify). Execution state is persisted โ you can resume anytime.
/superspec:archive
Changes are recorded. Specs grow. History is preserved.
| Feature | What it means |
|---|---|
| ๐ Spec generation | Natural language โ structured spec with validation |
| โ 9 validation rules | Catches missing SHALL, vague words, incomplete scenarios |
| ๐ Deep analysis | --deep mode: logical contradiction detection, coverage gap analysis |
| ๐ Auto diagrams | <!-- DIAGRAM:flowchart/state --> โ Mermaid diagrams embedded automatically |
| ๐ Source tracking | <!-- source: path --> โ warns when code changes but spec doesn't |
| ๐ท๏ธ Scenario classification | Auto-tags normal/error/boundary scenarios, warns on missing error cases |
| ๐ Delta merge | Incremental spec changes, no full-file rewrites |
| ๐ก๏ธ Anti-hallucination | Red flags, checklists, evidence verification |
| ๐ SkillGuard | Programmatic detection of AI skip patterns |
| ๐ Init Template | Collect human context before spec generation, 4 project-type templates (general/web-api/cli/library) |
| ๐ฆ Multi-artifact validation | Module list validation with circular dependency detection |
| ๐ค Subagent pipeline | Implement โ spec-check โ code-review per task |
| ๐ Skill pipeline | 7-stage DAG workflow with pre/post conditions, context passing, and retry |
| ๐ Pipeline run | pipeline run/status/list/resume โ auto-execute programmatic stages, persist execution records, resume from failures |
| ๐ Unified change model | Change directory with proposal โ delta spec โ apply lifecycle (inspired by OpenSpec) |
| ๐งญ Central router | Brainstorm skill routes new features to unified pipeline, bugs to debug path |
| ๐ Specs apply engine | Merge delta specs (ADDED/MODIFIED/REMOVED/RENAMED) into main specs with dry-run validation |
| ๐ก๏ธ PipelineGuardRunner | SkillGuard hooks integrated into pipeline execution: beforeExecute, onOutput, onCompletion |
| ๐งญ Skill routing | Every skill has a "Next Step" section, queryable via pipeline next |
| โ๏ธ Config layers | Global โ project โ change, with priority merge |
| ๐ฆ Archive system | Full change lifecycle: draft โ in-progress โ review โ done |
| ๐งช Test generation | TypeScript (vitest) and Python (pytest) skeletons |
| ๐ CI integration | GitHub Actions workflow for PR validation |
| Traditional spec tools | superSpec | |
|---|---|---|
| When | Written after code | Written before code |
| Format | Word docs, Confluence | Structured Markdown with validation |
| Enforcement | Honor system | Programmatic rules, 0 tolerance |
| AI awareness | None | Built for Claude Code workflows |
| Change tracking | Full file rewrites | Delta merge with conflict detection |
| Verification | "Looks good to me" | Evidence-driven, must run commands |
flowchart TD
User["๐ค User Input"] --> Router["๐งญ Route Evaluator"]
Router -->|"๐ Lightweight<br/>(simple feature)"| Spec["๐ generate-spec"]
Router -->|"๐ฆ Full<br/>(complex / change)"| Change["๐ Change Dir<br/>proposal โ delta-spec"]
Router -->|"๐ง Debug<br/>(bug / failure)"| Debug["๐ debug"]
Change --> Spec
Spec --> Validate["โ
validate-spec<br/>(auto)"]
Validate -->|pass| Plan["๐ write-plan"]
Validate -->|fail| Spec
Plan --> Implement["๐จ implement"]
Implement --> Verify["๐งช verify"]
Verify -->|pass| Archive["๐ฆ archive<br/>(auto)"]
Verify -->|fail| Implement
style Router fill:#f9f,stroke:#333
style Validate fill:#9f9,stroke:#333
style Archive fill:#9f9,stroke:#333
style Debug fill:#ff9,stroke:#333
Three adaptive paths based on complexity assessment. Programmatic stages (validate-spec, archive) run automatically via pipeline run. AI stages output guidance and wait for completion.
Use superspec pipeline run to automate the workflow:
# Start pipeline (auto-runs validate-spec)
superspec pipeline run batch-export
# Output shows stage status + next step guidance
# ๐ ็ฎก้ๆง่ก: batch-export-20260611100000
# โ
validate-spec completed (150ms)
# โณ write-plan pending โ needs AI
#
# ๐ ไธไธๆญฅๆไฝๆๅผ:
# ้ถๆฎต: write-plan
# ๆ่ฝ: write-plan
# ๆไฝ: ่ฎกๅ็ๆๅ๏ผ่ฟ่ก superspec pipeline run <name> --from implement ็ปง็ปญ็ฎก้
# After AI completes write-plan, resume pipeline
superspec pipeline run batch-export --from implement
# Check pipeline status anytime
superspec pipeline status batch-exportProgrammatic stages (validate-spec, archive) run automatically. AI stages output guidance and wait for completion.
The pipeline integrates SkillGuard at runtime. Every stage execution goes through anti-hallucination checks:
Stage starts โ SkillGuard.beforeExecute() โ check red flag table & HARD-GATE
Stage runs โ handler(context)
Stage output โ SkillGuard.onOutput() โ detect skip patterns & red flags
Stage ends โ SkillGuard.onCompletion() โ verify evidence
If a skill file lacks a red flag table, the stage is blocked โ not warned, blocked.
Every high-risk skill has:
Red flag table โ Common excuses and why they're wrong:
| Excuse | Reality |
|---|---|
| "Should be fine" | Run the verification command |
| "Subagent said it's done" | Subagents hallucinate completion |
| "Tests passed before" | Before โ now |
Completion checklist โ Must check every box before declaring done:
- Verification command actually ran
- Full output read, exit code checked
- Zero failures
XML tag constraints โ Behavioral guards in skill definitions:
<HARD-GATE>
No fresh evidence = no completion claim. No exceptions.
</HARD-GATE>superSpec/
โโโ bin/superspec.js # CLI entry point
โโโ CLAUDE.md # Project AI behavior guide
โโโ src/
โ โโโ cli/index.ts # CLI commands
โ โโโ core/
โ โ โโโ validator.ts # Validation engine
โ โ โโโ spec-parser.ts # Markdown parser
โ โ โโโ spec-schema.ts # Zod schemas
โ โ โโโ module-schema.ts # Module list schemas
โ โ โโโ module-parser.ts # Module list parser
โ โ โโโ module-validator.ts # Module list validator
โ โ โโโ deep-analysis.ts # Logical consistency check
โ โ โโโ diagram-generator.ts # Auto Mermaid diagrams
โ โ โโโ source-tracker.ts # Spec-code sync tracking
โ โ โโโ delta-merge.ts # Incremental spec updates
โ โ โโโ change-lifecycle.ts # Change directory management
โ โ โโโ delta-spec-parser.ts # Markdown delta spec parser
โ โ โโโ specs-apply.ts # Delta โ main spec merge engine
โ โ โโโ route-evaluator.ts # Intent detection & path routing
โ โ โโโ anti-rationalization/ # SkillGuard system
โ โ โโโ pipeline/ # Skill orchestration pipeline
โ โ โ โโโ executor.ts # Pipeline execution engine
โ โ โ โโโ runner.ts # CLI runtime (run/status/list/resume)
โ โ โ โโโ guard-runner.ts # SkillGuard integration
โ โ โ โโโ context.ts # Stage-to-stage context passing
โ โ โ โโโ conditions.ts # Pre/post condition checks
โ โ โ โโโ retry.ts # Failure classification & retry
โ โ โ โโโ workflow.ts # Default 7-stage DAG definition
โ โ โโโ rules/ # Validation rules
โ โ โโโ diagrams/ # Diagram generators
โ โ โโโ config/ # Configuration system
โ โโโ adapters/ # Test code generators
โ โโโ ci/ # CI runner
โโโ templates/ # Project templates
โ โโโ spec-template.md # Spec scaffold
โ โโโ init-spec-template.md # Init Template for context collection
โ โโโ change/ # Change lifecycle templates
โ โโโ init-templates/ # Project-type templates
โ โโโ general.md # General project
โ โโโ web-api.md # Web API project
โ โโโ cli.md # CLI tool project
โ โโโ library.md # Library/SDK project
โโโ test/ # Test suite (558 tests)
โโโ dist/ # Build output
superSpec stands on the shoulders of two excellent projects:
OpenSpec โ The specs/changes/archive directory model and behavior contract spec format were directly inspired by OpenSpec's approach to structured specification management. Their insight that "specs are living documents, not one-time artifacts" shaped superSpec's core architecture.
superpowers-zh โ The runtime behavioral constraints (XML tags, anti-hallucination patterns, subagent orchestration) were influenced by superpowers-zh's methodology for controlling AI agent behavior during coding sessions.
Thank you both for open-sourcing your ideas. ๐
Found a bug? Open an issue.
Want to contribute? Fork, branch, PR. All contributions welcome.
Have ideas? Start a discussion.
MIT