# Spec drift: how to keep specs and code in sync

Canonical: https://specscore.md/articles/spec-drift/

Last updated: 30 November 2026. SpecScore commands checked against specscore-cli v0.59.5 (published 28 November 2026) and against dogfood.yml in this repository. OpenSpec, Spec Kit, and Kiro pages were read on 30 November 2026.

Spec drift, also called specification drift, is the gap where the specification says one thing and the code does another. [Spec-driven development](https://specscore.md/spec-driven-development/) (SDD) is the practice of writing that specification before the code and checking the code against it. [Continuous integration](https://specscore.md/articles/lint-specs-in-ci/) (CI) is an automatic check on every proposed change. An [acceptance criterion](https://specscore.md/articles/acceptance-criteria/) (AC) is a condition that must be true before a change counts as done. Living documentation is a specification that is updated when the behavior changes, so the document still describes the code.

## Why specs and code fall out of sync

Documentation drift is the wider case: a document of any kind no longer matches the product. Spec drift is that gap for the specification. Spec-driven development drift is the same gap after a team has already chosen the specification as the source of truth, and the code has since moved on without it.

AI coding agents make the gap easy to open. The specification is edited in the chat and never written back to a file. The [OpenSpec README](https://github.com/Fission-AI/OpenSpec) says AI coding assistants are unpredictable when requirements live only in chat history, which is why that project keeps a spec layer you agree on before code is written. A transcript is not a file a later session, or a reviewer, can diff.

The code changes and the specification file is left as it was. A pull request that touches only the implementation leaves the specification describing the old behavior. The next agent then reads a stale file and treats it as current.

The specification lives in a tool outside the repository. A reviewer of the code change cannot see the specification diff, because the specification is not in the same commit. [spec management in git](https://specscore.md/articles/spec-management/) is the practice of keeping that file in the repository, where the diff is visible.

## How to detect spec drift

Keep the specification as files in the same git repository as the code. A change to the specification is then a diff, the same way a change to the code is. Review that diff in the same pull request as the code. If the behavior changed and the specification diff is missing, the review asks whether the behavior actually stayed the same.

Lint the specification format in CI. A structural failure — a missing section, a broken reference, a status the format does not allow, an index row that does not match its feature file — fails the pull request before merge. That check does not prove a sentence still matches the code. It does catch the specification becoming internally inconsistent while the code moves. [What SpecScore validates](https://specscore.md/validators/) lists both halves.

Write acceptance criteria that can be checked. A criterion names an observable condition. A person can apply it while reading the diff. Where the repository also has an executable scenario for that criterion, a command can run the scenario and report pass or fail. The [acceptance criteria article](https://specscore.md/articles/acceptance-criteria/) is the writing guide.

## What SpecScore checks today

The format is Markdown in the public repository [specscore/specscore](https://github.com/specscore/specscore), under the [CC BY 4.0 licence](https://github.com/specscore/specscore/blob/main/LICENSE). In this repository the specification tree is `spec/`. A feature is a directory with a `README.md`. The command-line interface (CLI) is `specscore`, in the public repository [specscore/specscore-cli](https://github.com/specscore/specscore-cli), under the [Apache-2.0 licence](https://github.com/specscore/specscore-cli/blob/main/LICENSE).

The [CLI README at release v0.59.5](https://github.com/specscore/specscore-cli/blob/v0.59.5/README.md), published [28 November 2026](https://github.com/specscore/specscore-cli/releases/tag/v0.59.5), documents `specscore spec lint` as the command that lints the current spec tree. This repository’s workflow, [dogfood.yml](https://github.com/specscore/specscore/blob/main/.github/workflows/dogfood.yml), pins `SPECSCORE_VERSION` to `v0.39.1` and runs `specscore spec lint` on pull requests and on pushes to main. The job does not pass `--fix`. The step fails when the command exits non-zero.

That command checks structure: links, required sections, status, and an index row that does not match its feature file. It does not decide whether the code implements the requirement. A sentence that has drifted from the code still needs a person to read the diff. [spec management in git](https://specscore.md/articles/spec-management/) states that limit, and the [validators page](https://specscore.md/validators/) lists drift between the specification and the code among the things the linter does not catch.

The same README documents `specscore rehearse run`. It executes Markdown acceptance scenarios that name the acceptance criterion they verify, and it reports pass or fail for each scenario. That checks the scenarios the repository already contains. It does not, by itself, compare every sentence in the specification to the codebase. [dogfood.yml](https://github.com/specscore/specscore/blob/main/.github/workflows/dogfood.yml) runs the linter and does not call rehearse.

## A short checklist

Use this when a change can move the specification and the code apart, including a change an AI coding agent makes.

1. Keep the specification as files in the same git repository as the code.
2. When behavior changes, update the specification in the same pull request as the code.
3. Run `specscore spec lint` in CI so a structurally broken specification fails the pull request. This repository does that in [dogfood.yml](https://github.com/specscore/specscore/blob/main/.github/workflows/dogfood.yml).
4. Write [acceptance criteria](https://specscore.md/articles/acceptance-criteria/) a person can check. Where the repository has executable scenarios, run `specscore rehearse run`.
5. Do not leave the only copy of the specification in a chat transcript, or in a tool the pull request cannot diff.

## How OpenSpec, Spec Kit, and Kiro describe staying in sync

The notes below are from those projects’ own pages, read on 30 November 2026. They are not a ranking, and they do not count how often drift happens.

[OpenSpec](https://github.com/Fission-AI/OpenSpec) stores each proposed change as a folder under `openspec/changes/` with `proposal.md`, `specs/`, `design.md`, and `tasks.md`. The [CLI reference](https://github.com/Fission-AI/OpenSpec/blob/main/docs/cli.md) describes `openspec validate` as a check of changes and specs for structural issues, including a change’s MODIFIED requirements against the main specs they would replace. The same page shows `openspec validate --all --json` with JSON (JavaScript Object Notation) output for CI and scripts. Its `--archived` option checks that archived changes have every `tasks.md` checkbox ticked. [OpenSpec alternatives](https://specscore.md/alternatives/openspec/) compares that workflow with other tools.

The [GitHub Spec Kit agentic SDD reference](https://github.github.io/spec-kit/reference/agentic-sdd.html), in the public repository [github/spec-kit](https://github.com/github/spec-kit), describes `/speckit.analyze` as a read-only check across `spec.md`, `plan.md`, and `tasks.md`. It reports conflicts, gaps, and ambiguities, and it never edits files. The page says to run it before implementation, and that you can run it again after implementation as an extra review. `/speckit.converge` assesses the codebase against that feature’s spec, plan, and tasks after `/speckit.implement`. It is append-only: it reports that the implementation converged, or it appends remaining work as tasks. The page presents both as slash commands a coding agent runs.

[Kiro’s specs documentation](https://kiro.dev/docs/specs/) says a spec is `requirements.md`, `design.md`, and `tasks.md`. The [best-practices page](https://kiro.dev/docs/specs/best-practices/), which prints “Page updated: September 25, 2026”, says to store specs in the project repository alongside the code. After requirements or design change, it says to open `tasks.md` and choose Sync Files so the tasks map to the new requirements. If some tasks are already implemented, Sync Files marks completed tasks, or you can ask in a spec session. The [Introducing Kiro](https://kiro.dev/blog/introducing-kiro/) post says specs stay synced with the evolving codebase: you can author code and ask Kiro to update specs, or update specs manually to refresh tasks. That post also says each user story includes acceptance criteria in EARS (Easy Approach to Requirements Syntax); the [EARS article](https://specscore.md/articles/ears-requirements/) explains that sentence pattern.

## FAQ

### What is spec drift?

Spec drift is the gap where the specification says one thing and the code does another. Specification drift is the same gap. Living documentation is the opposite: the specification is updated when the behavior changes, so the document still describes the code.

### How do you prevent spec drift with AI coding agents?

Keep the specification as files in the repository, change those files in the same pull request as the code, and run a format check in CI. An agent that edits the specification only in chat, or changes the code without updating the file, leaves the two out of sync. Review the diff before you merge. The checklist on this page is the short version.

### Can CI detect spec drift?

CI can fail the pull request when the specification’s structure is wrong, if the job runs a checker. In this repository, [dogfood.yml](https://github.com/specscore/specscore/blob/main/.github/workflows/dogfood.yml) runs `specscore spec lint`. That command reports structural problems, including an index row that does not match its feature file. It does not decide whether a sentence still describes the code. The OpenSpec CLI reference shows `openspec validate --all --json` for CI and scripts; that command validates OpenSpec changes and specs for structural issues. GitHub Spec Kit’s `/speckit.analyze` and `/speckit.converge` commands are agent commands on the [agentic SDD page](https://github.github.io/spec-kit/reference/agentic-sdd.html), which describes them as steps a coding agent runs.

## Sources

SpecScore commands read 30 November 2026 from the specscore-cli v0.59.5 README (release published 28 November 2026) and from dogfood.yml in specscore/specscore. OpenSpec, Spec Kit, and Kiro pages were read the same day. The Kiro best-practices page prints “Page updated: September 25, 2026”. The Introducing Kiro post is dated 14 July 2025.

- [specscore/specscore](https://github.com/specscore/specscore)
- [specscore/specscore — CC BY 4.0 licence](https://github.com/specscore/specscore/blob/main/LICENSE)
- [specscore/specscore-cli](https://github.com/specscore/specscore-cli)
- [specscore-cli — Apache-2.0 licence](https://github.com/specscore/specscore-cli/blob/main/LICENSE)
- [specscore-cli v0.59.5 — README (specscore spec lint, specscore rehearse run)](https://github.com/specscore/specscore-cli/blob/v0.59.5/README.md)
- [specscore-cli v0.59.5 release (28 November 2026)](https://github.com/specscore/specscore-cli/releases/tag/v0.59.5)
- [specscore/specscore — dogfood.yml (CLI v0.39.1)](https://github.com/specscore/specscore/blob/main/.github/workflows/dogfood.yml)
- [Fission-AI/OpenSpec — README](https://github.com/Fission-AI/OpenSpec)
- [Fission-AI/OpenSpec — docs/cli.md (openspec validate)](https://github.com/Fission-AI/OpenSpec/blob/main/docs/cli.md)
- [github/spec-kit](https://github.com/github/spec-kit)
- [GitHub Spec Kit — agentic SDD reference](https://github.github.io/spec-kit/reference/agentic-sdd.html)
- [Kiro — Specs](https://kiro.dev/docs/specs/)
- [Kiro — Specs best practices](https://kiro.dev/docs/specs/best-practices/)
- [Kiro — Introducing Kiro](https://kiro.dev/blog/introducing-kiro/)

## Related

- [Spec management: specification management in git](https://specscore.md/articles/spec-management/)
- [Lint specs in CI with a spec linter](https://specscore.md/articles/lint-specs-in-ci/)
- [How to write acceptance criteria AI agents can verify](https://specscore.md/articles/acceptance-criteria/)
- [Spec-driven development](https://specscore.md/spec-driven-development/)
- [OpenSpec alternatives](https://specscore.md/alternatives/openspec/)
- [What SpecScore validates](https://specscore.md/validators/)
- [CLI](https://specscore.md/cli/)
- [EARS requirements syntax explained, with examples](https://specscore.md/articles/ears-requirements/)
