# SPARDA

Deterministic local verification gate for AI backend edits. It maps routes to a behavior graph and blocks changes that drop guards or invariants.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 8
- Author: zakariagharzouli
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/zakariagharzouli/sparda
- Updated: 2026-09-16
- HTML: https://affpapa.org/en/nevibecode/mcp/sparda

## What it does

SPARDA parses backend handlers, database queries, and state mutations into a Unified Behavior Graph (`.sparda/ubg.json`). It natively inspects route trees in Express, FastAPI, Flask, Next.js, NestJS, and Medusa. Codebases on other stacks can feed in OpenAPI specifications instead.

During live editing, the `gate` command compares graph snapshots across revisions. If an agent deletes a guard or exposes a protected route, the process terminates with exit code 2. When tied to Claude Code's `PostToolUse` hook, this immediately halts the agent's modification loop. The `apocalypse` command runs pre-deploy checks and emits SARIF findings for CI.

Running the tool requires Node.js 18 or higher. Analysis stays entirely on the local machine without cloud services or external API keys. When visibility across the codebase is incomplete, the engine marks the result as `PROVEN (PARTIAL)` or `PREMISE NOT VERIFIED` rather than returning an unearned green check.

## Requirements
- Needs: Node.js (commands run via npx)
- Environment variables: `SPARDA_FLYWHEEL`, `SPARDA_RECORD_SEQUENCES` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add --env SPARDA_FLYWHEEL=<SPARDA_FLYWHEEL> --env SPARDA_RECORD_SEQUENCES=<SPARDA_RECORD_SEQUENCES> --transport stdio sparda -- npx -y sparda-mcp
```
Replace <…> with your own values

### Codex

**Platform CLI**
```bash
codex mcp add sparda --env SPARDA_FLYWHEEL=<SPARDA_FLYWHEEL> --env SPARDA_RECORD_SEQUENCES=<SPARDA_RECORD_SEQUENCES> -- npx -y sparda-mcp
```
Replace <…> with your own values

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "sparda": {
            "command": "npx",
            "args": [
                "-y",
                "sparda-mcp"
            ],
            "env": {
                "SPARDA_FLYWHEEL": "<SPARDA_FLYWHEEL>",
                "SPARDA_RECORD_SEQUENCES": "<SPARDA_RECORD_SEQUENCES>"
            }
        }
    }
}
```
Replace <…> with your own values

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "sparda": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "sparda-mcp"
            ],
            "env": {
                "SPARDA_FLYWHEEL": "<SPARDA_FLYWHEEL>",
                "SPARDA_RECORD_SEQUENCES": "<SPARDA_RECORD_SEQUENCES>"
            }
        }
    }
}
```
Replace <…> with your own values

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e SPARDA_FLYWHEEL=<SPARDA_FLYWHEEL> -e SPARDA_RECORD_SEQUENCES=<SPARDA_RECORD_SEQUENCES> sparda npx -y sparda-mcp
```
Replace <…> with your own values

## When to use it
- Block AI edits that drop route guards or authorization checks
- Interrupt agent modification loops when regressions occur
- Generate a deterministic behavior graph for backend handlers
- Verify transactional safety before deployment via CI gates

## Example prompts
- Run sparda apocalypse to verify that recent edits kept all route guards intact
- Generate the Unified Behavior Graph for our Next.js backend using ubg
- Run the prove command and print the verification verdict with coverage

## Similar
- [nestjs-best-practices](https://affpapa.org/en/nevibecode/skills/nestjs-best-practices.md) — skill · 30500 installs
- [Python Backend Architecture Review](https://affpapa.org/en/nevibecode/skills/python-backend-architecture-review.md) — skill · 503 installs
- [nestjs-expert](https://affpapa.org/en/nevibecode/skills/httpsgithubcomjeffallan-nestjs-expert.md) — skill · 5900 installs
- [nestjs-patterns](https://affpapa.org/en/nevibecode/skills/nestjs-patterns.md) — skill · 5000 installs
- [Python Security Scan](https://affpapa.org/en/nevibecode/skills/python-security-scan.md) — skill · 540 installs
- [convex-reviewer](https://affpapa.org/en/nevibecode/skills/convex-reviewer.md) — skill · 36400 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
