SpecNative AI Agent Guide

For AI Agents

SpecNative — how to work with this framework

SpecNative repositories encode project context in versioned files so agents can plan and implement work without reconstructing context from conversation history. Read AGENTS.md first. Navigate via README.md files. Load only what you need for the current task.

MCP server — v0.7

.specnative/specnative_mcp.py exposes the repository as MCP resources, tools, and prompts so any agent works spec-first without navigating files manually. Installed automatically with its own venv. Supports stdio and SSE transport.

Quick setup — Claude Code

# Add via CLI (from project root)
claude mcp add specnative \
  "$(pwd)/.specnative/.venv/bin/python3" \
  "$(pwd)/.specnative/specnative_mcp.py" \
  -- --repo "$(pwd)"

# Or add to .claude/mcp_settings.json
{
  "mcpServers": {
    "specnative": {
      "command": "/your/project/.specnative/.venv/bin/python3",
      "args": ["/your/project/.specnative/specnative_mcp.py",
               "--repo", "/your/project"]
    }
  }
}

Resources

URIDocument
spec://agentsAGENTS.md — meta-index and MCP reference
spec://sessionspec-native/SESSION.md — active work state
spec://context/productspec-native/PRODUCT.md
spec://context/architecturespec-native/ARCHITECTURE.md
spec://context/stackspec-native/STACK.md
spec://context/conventionsspec-native/CONVENTIONS.md
spec://context/commandsspec-native/COMMANDS.md
spec://context/decisionsspec-native/DECISIONS.md
spec://context/roadmapspec-native/ROADMAP.md
spec://context/traceabilityspec-native/TRACEABILITY.md
spec://pipelines/cispec-native/pipelines/CI.md
spec://pipelines/cdspec-native/pipelines/CD.md
spec://schema.specnative/SCHEMA.md

Tools — query

ToolDescription
status()Spec states and task count summary
validate()Check all required files exist
list_specs()All specs with ID, state, owner
list_tasks(initiative)Tasks for an initiative
read_spec(initiative)Read a spec file
read_context(document)Read any context doc by name (includes session)
export_index()Export all metadata as JSON
context_snapshot(initiative?)Full context dump for new-agent onboarding

Tools — multi-agent continuity

ToolDescription
resume()Read SESSION.md and return structured continuity summary
checkpoint(initiative, task_id, intent, next_steps, …)Save active work state before pausing or switching agents
update_task(initiative, task_id, state, notes?)Update task state in TASKS.md directly from MCP
log_decision(title, context, decision, consequences)Append a new decision to DECISIONS.md

Tools — project definition

ToolDescription
health_check()Scan spec-native/ for empty docs, missing files, stale session, specs without tasks
suggest_next()Top 3 recommended actions based on roadmap and current state
refine_document(document, what_changed, new_content)Overwrite a context doc with new content
read_template(document)Return expected empty structure for any spec-native/ document (11 types)
update_section(document, section_heading, content)Update or add a single section without touching the rest of the file

Tools — archetypes (v0.7)

ToolDescription
list_archetypes()List all archetypes: built-in and user-defined in .specnative/archetypes/
read_archetype(name)Preview all documents of an archetype before applying
apply_archetype(name, force?)Write archetype documents to spec-native/; skips already-filled docs unless force=True

Tools — templates (v0.7)

ToolDescription
list_templates(type?)List spec templates and/or decision snippets: built-in + local in .specnative/templates/
apply_spec_template(template, initiative)Create spec-native/specs/{initiative}/SPEC.md from a template
apply_decision_snippet(name)Append a decision snippet to DECISIONS.md with auto DEC-XXXX numbering

Prompts

PromptDescription
init_project_guided(name, problem, users, goals, …)Fill all core docs from developer interview answers
start_initiative(name, problem)Begin a new spec-driven initiative
plan_tasks(initiative)Derive tasks from a spec
implement_task(initiative, task_id)Implement a specific task
review_against_spec(initiative)Review against acceptance criteria
handoff(summary, next_steps, decisions?)Generate structured SESSION.md handoff for next agent
record_decision(title, ctx, dec, cons)Record a persistent decision
close_initiative(initiative)Close and update traceability

Full configuration for OpenCode, Claude Desktop, Codex, and SSE transport: .specnative/MCP.md

Repository structure

repo/
├── AGENTS.md              # Meta-index: what is SpecNative, MCP reference — read first
├── spec-native/
│   ├── README.md          # Context folder navigation index
│   ├── PRODUCT.md         # Problem, users, goals (permanent)
│   ├── ARCHITECTURE.md    # System structure and boundaries
│   ├── STACK.md           # Tech stack and version constraints
│   ├── CONVENTIONS.md     # Code rules, naming, testing
│   ├── COMMANDS.md        # Project dev/test/build commands only
│   ├── DECISIONS.md       # Persistent decisions and trade-offs
│   ├── ROADMAP.md         # Temporal direction, no implementation
│   ├── TRACEABILITY.md    # Links between artifacts
│   ├── SESSION.md         # Active work state (multi-agent continuity)
│   ├── specs/
│   │   └── <initiative>/SPEC.md
│   ├── tasks/
│   │   └── <initiative>/TASKS.md
│   ├── workflows/
│   │   ├── PLANNING.md
│   │   ├── IMPLEMENTATION.md
│   │   └── REVIEW.md
│   └── pipelines/
│       ├── CI.md          # Automated validation gates
│       └── CD.md          # Delivery process and environments
├── .claude/commands/      # Slash commands: /spec-init /spec-update /spec-status /spec-handoff
├── codex.toml             # Codex CLI prompt commands
├── opencode.json          # OpenCode MCP + commands + instructions
└── .specnative/
    ├── SCHEMA.md           # Framework contract (not project content)
    ├── MCP.md              # MCP server configuration per agent
    ├── specnative_mcp.py   # MCP server (installed automatically)
    ├── archetypes/         # Custom archetypes (user-defined)
    │   └── README.md
    └── templates/          # Reusable spec templates + decision snippets
        ├── specs/          # Spec templates (.md with +++ front matter)
        └── decisions/      # Decision snippets (.md with +++ front matter)

Files in uppercase are context for agents. README.md files are navigation indexes, not the source of truth. Load the minimum context needed for the current task. SESSION.md persists active work state across agents.

Document ownership — one truth per document

Each document owns one semantic domain. Never duplicate information across files. Update the source of truth, not a parallel summary. All documents live under spec-native/.

Document Owns Does not own
spec-native/PRODUCT.md Problem, target users, goals, non-goals, differential value Implementation, technical decisions
spec-native/specs/*/SPEC.md What must be built in this initiative: requirements, scope, acceptance criteria, risks Persistent trade-offs (→ DECISIONS), product vision (→ PRODUCT), direction (→ ROADMAP)
spec-native/DECISIONS.md Persistent trade-offs that future initiatives must respect What will be built (→ SPEC), temporal priorities (→ ROADMAP)
spec-native/ROADMAP.md What comes first and why (temporal direction) How to implement, specific trade-offs
spec-native/ARCHITECTURE.md System modules, boundaries, data flows, architectural constraints What to build, why decisions were made
spec-native/STACK.md Languages, runtimes, frameworks, versions, prohibited tech System structure, code conventions
spec-native/CONVENTIONS.md Naming rules, code style, testing approach, commit/PR conventions Project commands, tech stack
spec-native/COMMANDS.md Project-specific commands: build, test, lint, run, migrations Framework CLI commands (specnative.py), deployment scripts
spec-native/tasks/**/TASKS.md Executable plan: tasks with state, owner, dependencies, close criteria Requirements (→ SPEC), persistent decisions (→ DECISIONS)
spec-native/TRACEABILITY.md Cross-artifact links: spec → tasks → decisions → artifacts → validation Content of any linked document
spec-native/SESSION.md Active work state: current agent, initiative, task, intent, next steps Spec content, decisions, product vision
spec-native/pipelines/CI.md Automated gate definitions, triggers, required checks Local dev commands, implementation logic
spec-native/pipelines/CD.md Delivery process, environments, promotion gates, rollback Deployment scripts, credentials

Decision test — where to write something

If it disappears when the initiative closesspecs/*/SPEC.md

If it must be respected in the next initiativeDECISIONS.md

If it explains the productPRODUCT.md

If it sets temporal priorityROADMAP.md

If it describes system structureARCHITECTURE.md

If it defines automated validation gatespipelines/CI.md

If it describes how code reaches productionpipelines/CD.md

If it is the active work state right nowSESSION.md

How to generate the full template

Follow these steps in order when helping a user create a SpecNative repository from scratch. Each step populates one document with the right scope.

  1. Bootstrap the structure

    Run python3 install.py --target /path/to/repo --profile team. This creates all required folders, placeholder files, agent commands, and configures opencode.json and codex.toml automatically.

  2. Initialize project context — guided

    Use /spec-init (Claude Code), spec-init prompt (OpenCode/Codex), or python3 specnative.py init (CLI without agent). The wizard interviews the developer and fills all five core documents.

  3. Fill spec-native/PRODUCT.md

    Problem (what friction exists and for whom), Users (segments, needs, context), Goals (measurable outcomes), Non-goals (explicit exclusions), Differential value. Use refine_document('product', …) to update via MCP.

  4. Fill spec-native/ARCHITECTURE.md

    System modules and their responsibilities, module boundaries and data flows, key architectural constraints. No implementation detail.

  5. Fill spec-native/STACK.md

    Languages and runtimes with exact versions, frameworks and libraries, infrastructure and tooling, constraints and prohibited technologies.

  6. Fill spec-native/CONVENTIONS.md

    Naming conventions (files, classes, variables), code style and formatting rules, testing approach (unit / integration / e2e), commit and PR conventions.

  7. Fill spec-native/COMMANDS.md

    Actual project commands only: build, test, lint, run/start, migrations. Never include framework CLI commands here.

  8. Fill spec-native/ROADMAP.md

    Current priorities in order with rationale. Rough time horizon. No implementation detail, no spec content.

  9. Create spec-native/specs/<initiative>/SPEC.md

    ID, state, owner, creation/update dates. Summary, problem, objective. Scope (includes / excludes). Functional and non-functional requirements. Acceptance criteria (Given / When / Then). Dependencies and risks. Execution plan. Validation plan. Use MCP prompt start_initiative().

  10. Derive spec-native/tasks/<initiative>/TASKS.md

    One task per implementable unit. Each task: ID, state, owner, dependencies, expected files, observable close criteria, validation command. Use MCP prompt plan_tasks().

  11. Record decisions in spec-native/DECISIONS.md

    Only persistent trade-offs that future initiatives must respect. Format: DEC-XXXX, date, state, context, decision, consequences, replaces. Use MCP tool log_decision() for quick inline recording.

  12. Fill spec-native/pipelines/CI.md and pipelines/CD.md

    CI: platform, triggers, mandatory and optional gates, failure policy. CD: environments, release process, promotion gates, rollback process.

  13. Use checkpoint() at each session pause

    Call checkpoint(initiative, task_id, intent, next_steps) before ending any session. The next agent — regardless of tool — calls resume() to continue exactly from here.

  14. Update spec-native/TRACEABILITY.md when an initiative closes

    Link spec → tasks → decisions → main artifacts → validation evidence. Update at close, not during execution. Use MCP prompt close_initiative().

Agent workflow (from AGENTS.md)

  1. Check for active session

    Call resume() — if SESSION.md state is not idle, read what the previous agent left and continue from there.

  2. Load minimum context

    Call context_snapshot() for a full dump, or read individual docs via read_context().

  3. Check spec-native/ROADMAP.md

    Confirm the initiative aligns with current project direction before creating a spec.

  4. Read spec-native/DECISIONS.md

    Respect persistent trade-offs that condition the current design.

  5. Review or create a SPEC.md in spec-native/specs/

    Use MCP prompt start_initiative() for new initiatives.

  6. Derive or read tasks in spec-native/tasks/

    Follow spec-native/workflows/PLANNING.md or use MCP prompt plan_tasks().

  7. Implement following spec-native/workflows/IMPLEMENTATION.md

    Use update_task() to mark tasks in_progress and done. Verify CI gates from spec-native/pipelines/CI.md.

  8. Record persistent trade-offs with log_decision()

    Only if the decision must survive beyond the current initiative.

  9. Checkpoint before pausing

    Call checkpoint(initiative, task_id, intent, next_steps) before every session end.

  10. Update TRACEABILITY.md at initiative close

    Link all related artifacts. Use MCP prompt close_initiative().

Required states

SESSION.md

idle in_progress blocked waiting_handoff

Updated by checkpoint() and handoff(). Reset to idle by close_initiative().

Specs

draft active blocked done superseded
StateMeaning
draftBeing written, not yet committed for implementation
activeCurrently being implemented
blockedCannot proceed due to external dependency or decision
doneAll acceptance criteria met and validated
supersededReplaced by a newer spec (link the replacement)

Tasks

todo in_progress blocked done

Decisions

proposed accepted deprecated replaced

Optional TOML metadata

TOML blocks are optional. The base contract is documentary — documents are valid without TOML. Add TOML blocks when you want validate, status, and export CLI commands to work automatically. Place the block near the top of the file. SESSION.md uses +++ TOML front matter (not a ```toml block).

Spec header (spec-native/specs/**/SPEC.md)

```toml
artifact_type = "spec"
id            = "SPEC-0001"
state         = "draft"
owner         = "team-name"
created_at    = "YYYY-MM-DD"
updated_at    = "YYYY-MM-DD"
replaces      = "none"
related_tasks       = ["TASK-0001"]
related_decisions   = ["DEC-0001"]
artifacts           = ["src/example/*"]
validation          = ["pytest", "manual walkthrough"]
```

Task file header (spec-native/tasks/**/TASKS.md)

```toml
artifact_type = "task_file"
initiative    = "initiative-name"
spec_id       = "SPEC-0001"
owner         = "team-name"
state         = "todo"
```

Individual task block

```toml
id             = "TASK-0001"
title          = "Task title"
state          = "todo"
owner          = "team-name"
dependencies   = []
expected_files = ["src/example.py"]
close_criteria = "Observable closure condition"
validation     = ["pytest tests/example_test.py"]
```

CLI reference

tools/specnative.py — invoke it from the project root. Use init and update when no agent is available.

CommandWhat it does
init [--target .] [--force] Interactive wizard: interviews the developer in the terminal and fills spec-native/ core documents with real project content. Alternative to /spec-init when no agent is available.
update [--target .] [--doc NAME] Runs a health check, shows gaps, and guides iterative refinement. Use --doc product|stack|architecture|conventions|commands|roadmap to target one document.
status Shows each spec with its state and a summary of task states (todo, in_progress, done, blocked counts).
validate Checks all required files exist and that TOML blocks (when present) have valid states and required fields.
export-index Exports all specs and task files with TOML metadata as JSON. Use --output file.json.
export-traceability Exports traceability matrix linking each spec to its task file, decisions, artifacts, and validation.
# Interactive project setup (no agent needed)
python3 specnative.py init

# Detect gaps and refine iteratively
python3 specnative.py update
python3 specnative.py update --doc stack

# Show spec and task state overview
python3 specnative.py status

# Validate required files and TOML consistency
python3 specnative.py validate

# Export full index
python3 specnative.py export-index --output exports/index.json

Archetypes & templates (via MCP tools)

# List available archetypes (built-in + local)
list_archetypes()

# Preview an archetype before applying
read_archetype('java-hexagonal')

# Apply to spec-native/ (skips filled docs)
apply_archetype('java-hexagonal')
apply_archetype('java-hexagonal', force=True)   # overwrite all

# List templates
list_templates()                  # both spec + decision
list_templates('spec')
list_templates('decision')

# Create SPEC.md from template
apply_spec_template('feature-rest-endpoint', 'user-auth')

# Append decision to DECISIONS.md (auto DEC-XXXX)
apply_decision_snippet('jwt-authentication')

Built-in archetypes

NameStackPatternDocuments
java-hexagonal Java 21 + Spring Boot 3 Hexagonal / Ports & Adapters ARCHITECTURE, STACK, CONVENTIONS, COMMANDS, DECISIONS, ROADMAP

Built-in spec templates

NameFor
feature-rest-endpointNew REST endpoint initiative
db-migrationDatabase migration with Flyway/Liquibase
module-refactorModule or layer refactoring

Built-in decision snippets

NameFor
jwt-authenticationJWT for stateless authentication
hexagonal-portsDomain/infrastructure separation via ports
database-choiceDatabase technology selection

Standalone installer

install.py bootstraps SpecNative from a GitHub release with no dependencies beyond the Python standard library. Installs agent commands, configures opencode.json and codex.toml, and sets up the MCP venv.

# Minimal — AI context layer only
curl -sSL https://github.com/rafex/SpecNative-Development/releases/latest/download/install.py \
  | python3 - --target /path/to/repo --profile context

# Team (default) — full lifecycle + CI/CD
curl -sSL https://github.com/rafex/SpecNative-Development/releases/latest/download/install.py \
  | python3 - --target /path/to/repo --profile team

# Repair broken MCP (no branch, no worktree check)
python3 install.py --reinstall --target /path/to/repo