> ## Documentation Index
> Fetch the complete documentation index at: https://docs.specpilot.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# The rules

> Every rule SpecPilot writes into your AI IDE's instruction file, and what each one asks of your agent.

SpecPilot writes the same rules into the instruction file of each AI IDE you set up. Your agent reads that file at the start of every session, so these rules apply to everything it does in the project.

## Where the rules go

| AI IDE | Instruction file |
| - | - |
| Claude Code | `CLAUDE.md` |
| GitHub Copilot | `.github/copilot-instructions.md` |
| Codex | `.github/copilot-instructions.md` (Codex's own `CODEX_INSTRUCTIONS.md` has no rules) |
| Cursor | `.cursor/rules/specpilot.mdc`, with front matter that sets `alwaysApply: true` |
| Windsurf | `.windsurfrules` |
| Antigravity | `.antigravity/rules.md` |

Each file starts with your project's name, stack and where the specs are, then the six sections below, in this order.

## Critical mandates

Your agent must never break these.

| # | Rule | What it means |
| - | - | - |
| 1 | No commit unless asked. | Your agent leaves committing to you, or waits until you ask. |
| 2 | No push unless asked. | Nothing leaves your machine until you say so. |
| 3 | No deploy/publish/release unless asked. | The same goes for anything that goes live. |
| 4 | No `.specs/` structure changes: content only. | It edits what's in the spec files. It never adds, renames or moves files or folders. |
| 5 | Update specs after change. Trivial → `planning/tasks.md`. Feature → `project/requirements.md` + `planning/tasks.md`. Architectural → all affected files + `CHANGELOG.md`. | The bigger the change, the more specs it updates. |
| 6 | Never reference file contents without reading first. If unread, say so. | No guessing what a file says. |
| 7 | Never write code or change files unless asked. Ask first. | A question gets an answer, not an edit. |
| 8 | Spec-first gate (scale to task size). Trivial → no gate. Feature → read 1–2 relevant `.specs/` files before coding. Architectural → update all affected specs, present Spec Report, wait for `yes, proceed`. | How much it checks before coding depends on the size of the change. See [Review and Spec Reports](https://docs.specpilot.dev/concepts/review.md). |

## Process mandates

How your agent keeps the specs current while it works.

| Rule | What it means |
| - | - |
| **Spec-First:** Update `.specs/` before writing code. | The specs change first, then the code. |
| **Log all AI interactions** in `.specs/development/prompts.md` with timestamps. | Each request and what came of it gets a row in [prompts.md](https://docs.specpilot.dev/reference/spec-files/prompts.md). |
| **Document decisions** in `.specs/development/context.md`. | Decisions and their reasons go in [context.md](https://docs.specpilot.dev/reference/spec-files/context.md). |
| **Tasks:** use the SpecPilot MCP tools when they're connected, otherwise edit `.specs/planning/tasks.md` and keep its table format. | See the full rule below, [Tasks and lanes](https://docs.specpilot.dev/concepts/tasks-and-lanes.md) and the [Local MCP tools](https://docs.specpilot.dev/mcp/tools.md). |

The tasks rule in full:

> When the SpecPilot MCP tools are connected, use them to add and move tasks. Otherwise edit `.specs/planning/tasks.md` directly and keep its table format: `| ID | Type | Priority | Description |` under `## Backlog`, `## Current Sprint` and `## Review` (Type `feat`, `bug` or `chore`, Priority `P1`, `P2` or `P3`, either may be empty; a table there that is `| ID | Description |` keeps that shape), `| # | ID | Description |` under `## Completed`, one row per task. Finished work goes from Current Sprint to Review, never straight to Completed; a Review row gets its Completed entry (number, CD ID, commit) only once it ends with `Approved <date>`.

## Which spec to read

Your agent reads only what the task needs, so a session doesn't start by loading every spec. The file calls this "Context: read on demand by task type".

| Task type | Read |
| - | - |
| Session start | `.specs/project/project.yaml` |
| Feature / bug | + `project/requirements.md`, `planning/tasks.md` |
| Architecture | + `architecture/architecture.md` |
| Tests | + `quality/tests.md` |
| Security | + `security/threat-model.md`, `security/security-decisions.md` |
| Planning | + `planning/tasks.md`, `planning/roadmap.md` |
| Task ID, decision or a REQ's earlier wording not in a spec file | search the matching `*-archive.md` in `.specs/` (a rewritten REQ: its `### <key>` in `project/requirements-archive.md`) |

## Code philosophy

The order your agent works through before it writes code:

1. Need exist? No → skip. Say why.
2. Already in codebase? → reuse. Not rewrite.
3. Stdlib do it? → use it.
4. Native or installed dep cover it? → use. No new deps.
5. One line do it? → write that.
6. Only then: minimum code that work.
7. Never cut: validation, error handling, security, explicit requirement.

Step 7 is the floor: your agent never trims those to make a diff shorter.

## Code rules

1. No abstraction, interface, factory, or pattern unless asked.
2. No scaffold "for later". Later scaffold itself.
3. Delete before add.
4. Shortest correct diff win.
5. Fix cause, not symptom. One guard in shared function beat guard in every caller.
6. Boring over clever. Clever = 3am bug.
7. Read before write. Never reference code you haven't read.

## Re-anchor

If your agent loses context mid-session, it reads `.specs/project/project.yaml` to restore it. A ready-made prompt is in `prompts.md` under Re-Anchor Prompt, and `/specpilot-reanchor` runs it. See [Slash commands](https://docs.specpilot.dev/slash-commands.md).

## Changing the rules

The file is yours: add your own rules or a section for your repo. SpecPilot never overwrites an instruction file that exists. After an upgrade, [`specpilot backfill`](https://docs.specpilot.dev/reference/cli/backfill) or `/specpilot-backfill` adds a section or mandate that's missing and leaves the rest as it is.

Checked against SpecPilot 2.22.0.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.