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

tools/specnative_mcp.py exposes the repository as MCP resources, tools, and prompts so any MCP-compatible agent (Claude Desktop, Claude Code, OpenCode) can work spec-first without manually navigating the file tree. Requires: pip install mcp.

Quick setup — Claude Code

# Add via CLI
claude mcp add specnative \
  python3 .specnative/specnative_mcp.py \
  -- --repo /path/to/your/project

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

Resources

URIDocument
spec://agentsAGENTS.md — operating contract
spec://context/productagents/PRODUCT.md
spec://context/architectureagents/ARCHITECTURE.md
spec://context/stackagents/STACK.md
spec://context/conventionsagents/CONVENTIONS.md
spec://context/commandsagents/COMMANDS.md
spec://context/decisionsagents/DECISIONS.md
spec://context/roadmapagents/ROADMAP.md
spec://context/traceabilityagents/TRACEABILITY.md
spec://pipelines/cipipelines/CI.md
spec://pipelines/cdpipelines/CD.md
spec://schema.specnative/SCHEMA.md

Tools

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
export_index()Export all metadata as JSON

Prompts

PromptDescription
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
record_decision(title, ctx, dec, cons)Record a persistent decision
close_initiative(initiative)Close and update traceability

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

Repository structure

repo/
├── AGENTS.md              # Agent operating contract — read first
├── README.md              # Navigation index
├── agents/
│   ├── README.md          # Context folder 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
│   ├── SPEC.md            # Active spec (or entry point to specs/)
│   ├── DECISIONS.md       # Persistent decisions and trade-offs
│   ├── ROADMAP.md         # Temporal direction, no implementation
│   ├── TRACEABILITY.md    # Links between artifacts
│   └── 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
└── .specnative/
    ├── SCHEMA.md           # Framework contract (not project content)
    └── CLI.md              # CLI reference

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. Do not ingest the whole repository.

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.

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

Decision test — where to write something

If it disappears when the initiative closesSPEC.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

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 minimal or copy Template-Project-Agents-AI into the target repository. This creates all required folders and placeholder files.

  2. Fill agents/PRODUCT.md

    Problem (what friction exists and for whom), Users (segments, needs, context), Goals (measurable outcomes), Non-goals (explicit exclusions), Differential value (why this solution deserves to exist).

  3. Fill agents/ARCHITECTURE.md

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

  4. Fill agents/STACK.md

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

  5. Fill agents/CONVENTIONS.md

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

  6. Fill agents/COMMANDS.md

    Actual project commands only: build, test, lint, run/start, migrations, and any project-specific operational commands. Never include framework CLI commands here.

  7. Fill agents/ROADMAP.md

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

  8. Create agents/SPEC.md (or agents/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.

  9. Derive tasks/<initiative>/TASKS.md

    One task per implementable unit. Each task: ID, state, owner, dependencies, expected files, observable close criteria, validation command.

  10. Record decisions in agents/DECISIONS.md

    Only persistent trade-offs that future initiatives must respect. Format: DEC-XXXX, date, state, context, decision, consequences, replaces.

  11. Fill pipelines/CI.md and pipelines/CD.md

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

  12. Update agents/TRACEABILITY.md when an initiative closes

    Link spec → tasks → decisions → main artifacts → validation evidence. Update at close, not during execution.

Agent workflow (from AGENTS.md)

  1. Read the README.md of the current folder

    Entry point for navigation in any directory.

  2. Check agents/ROADMAP.md

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

  3. Read agents/PRODUCT.md and relevant technical context

    Load minimum context: ARCHITECTURE.md, STACK.md, CONVENTIONS.md as needed.

  4. Read agents/DECISIONS.md

    Respect persistent trade-offs that condition the current design.

  5. Review or create a SPEC.md

    Use agents/SPEC.md for single active specs; agents/specs/<initiative>/SPEC.md for larger projects.

  6. Derive or read tasks in tasks/

    Follow workflows/PLANNING.md to turn spec into executable task list.

  7. Implement following workflows/IMPLEMENTATION.md

    Verify CI gates from pipelines/CI.md before considering work complete.

  8. Record persistent trade-offs in DECISIONS.md

    Only if the decision must survive beyond the current initiative.

  9. Update TRACEABILITY.md at initiative close

    Link all related artifacts. Not during execution — only at close.

Required states

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.

Spec header (agents/SPEC.md or agents/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 (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 lives in the SpecNative Development repository, not in the adopting project. Invoke it pointing to the project root.

CommandWhat it does
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 to write to disk.
export-traceability Exports traceability matrix linking each spec to its task file, decisions, artifacts, and validation. Use --output file.json.
install Copies the template structure into an existing git repository. Requires clean worktree and creates a dedicated branch. Options: --target, --profile minimal|full, --include-examples, --branch, --force.
# 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

# Export traceability matrix
python3 specnative.py export-traceability --output exports/traceability.json

# Install into existing repository
python3 specnative.py install \
  --target /path/to/repo \
  --profile minimal \
  --include-examples \
  --branch specnative/install-v0.3.1

Standalone installer

install.py bootstraps SpecNative from a GitHub release with no dependencies beyond the Python standard library.

# Download and run
curl -sSL https://github.com/rafex/SpecNative-Development/releases/latest/download/install.py \
  | python3 - --target /path/to/repo

# Or download first, then run
python3 install.py --target /path/to/repo --profile minimal --include-examples