Skip to content

ChenJazzyBoss/superSpec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

153 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

superSpec

AI-native spec management for Claude Code.

Turn natural language into executable specifications. Catch AI hallucinations before they become bugs.

License: MIT Tests TypeScript

English | ไธญๆ–‡


The problem

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.

The solution

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"]
Loading

Quick start

# 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 init

This 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.

What it does

๐Ÿ“‹ 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.

CLI Commands

superspec init

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 templates

Creates .superspec/ directory structure, injects CLAUDE.md, copies templates and scripts.

superspec validate <spec>

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 analysis

Output (JSON):

{
  "valid": true,
  "issues": [],
  "summary": { "errors": 0, "warnings": 0, "info": 0 },
  "scenarioTypes": {
    "requirements[0]": ["normal", "error", "boundary"]
  }
}

superspec ci

Batch validate all specs.

superspec ci              # Validate all specs
superspec ci --strict     # Strict mode
superspec ci --json       # JSON output

superspec generate <name>

Generate 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 file

superspec update <name>

Incrementally update a spec via Delta JSON.

cat delta.json | superspec update batch-export
superspec update batch-export -f delta.json

superspec diff <name>

Compare current spec with historical version.

superspec diff batch-export                    # Compare with latest snapshot
superspec diff batch-export --from 2026-06-01  # Compare with specific version

superspec history <name>

List all historical snapshots of a spec.

superspec history batch-export

superspec archive <name>

Archive a completed change.

superspec archive add-pdf-export

superspec changes

List in-progress changes.

superspec changes

superspec guard

Check 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 output

Verifies that skill files have proper red flag tables and HARD-GATE tags configured.

superspec validate-modules

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 output

Checks module structure, detects circular dependencies, validates naming conventions.

superspec pipeline show

Display the default workflow definition.

superspec pipeline show

Output:

๐Ÿ“‹ superSpec ้ป˜่ฎคๅทฅไฝœๆต

  ้˜ถๆฎต              ็ฑปๅž‹     ไพ่ต–
  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  brainstorm        ๅฏ้€‰     โ€”
  generate-spec     ๅฟ…้œ€     brainstorm
  validate-spec     ๅฟ…้œ€     generate-spec
  write-plan        ๅฟ…้œ€     validate-spec
  implement         ๅฟ…้œ€     write-plan
  verify            ๅฟ…้œ€     implement
  archive           ๅฟ…้œ€     verify

superspec pipeline next <stage>

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"

superspec pipeline run <name>

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 stage

Execution records are persisted to .superspec/pipeline/<exec-id>.json.

superspec pipeline status [name]

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 id

superspec pipeline list

List all pipeline execution records.

superspec pipeline list

superspec pipeline resume <exec-id>

Resume a failed pipeline execution from the failed stage.

superspec pipeline resume batch-export-20260611100000

superspec change

Manage 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 writing

superspec route

Evaluate 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"     # โ†’ ๐Ÿ”ง Debug

superspec uninstall

Remove all superSpec files from project.

superspec uninstall        # With confirmation
superspec uninstall -y     # Skip confirmation

Spec Format

A 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

Spec Annotations

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 -->

How it works

1. Generate a spec

/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

2. Validate

# 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]

3. Implement

/superspec:write-plan
/superspec:subagent-dev

Claude creates a detailed plan, then implements each task with dual review.

4. Run the pipeline

superspec pipeline run batch-export

Automatically executes programmatic stages (validate-spec, archive) and guides you through AI stages (write-plan, implement, verify). Execution state is persisted โ€” you can resume anytime.

5. Archive

/superspec:archive

Changes are recorded. Specs grow. History is preserved.

Features

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

Why superSpec?

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

The workflow

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
Loading

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.

Running the pipeline

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-export

Programmatic stages (validate-spec, archive) run automatically. AI stages output guidance and wait for completion.

PipelineGuardRunner

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.

Anti-hallucination design

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>

Project structure

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

Acknowledgments

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. ๐Ÿ™

Contributing

Found a bug? Open an issue.

Want to contribute? Fork, branch, PR. All contributions welcome.

Have ideas? Start a discussion.

License

MIT

About

AI-native spec management for Claude Code

Resources

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages