> Agent-ready spec from Diff of the Day (2026-11-27, idea 1). Give this file to your coding agent (Claude Code, Codex, Cursor) and ask it to build the P0 requirements first.

# Spec: Docs-versus-code contradiction checker

## Problem Statement
Coding agents read README files, agent instruction files and docs before they touch code. When those documents contradict the code, agents spend about 38% more tokens and often follow the stale text (Microsoft, Nov 2026). Most repos have no cheap way to find these contradictions, so the cost stays invisible.

## Goals
- Find stale claims in a repo's agent-facing docs in under 5 minutes for a repo of up to 50 doc files.
- Report each claim with file, line, status (true, stale, unknown) and evidence.
- Show a before/after token cost for one fixed coding task once the stale claims are fixed.

## Non-Goals
- Fixing the docs automatically: a human decides what is true; auto-edits hide mistakes.
- Checking prose quality or style: out of scope, only verifiable claims matter.
- Supporting every language toolchain: start with one repo you know well.

## User Stories
- As a developer who uses coding agents, I want a list of every concrete claim in my docs so that I can see what an agent will believe.
- As a developer, I want each claim checked against the code so that I know which ones are stale.
- As a developer, I want a short report I can commit so that the repo keeps a record of fixes.
- Edge case: as a developer, I want claims that cannot be checked marked "unknown" so that the tool never guesses.

## Requirements
### P0 (must have)
1. **CLI** `docs-check <repo-path>` that scans README*, CLAUDE.md, AGENTS.md and docs/**/*.md.
   - [ ] Runs on a local path; makes no network calls except to the LLM you configure.
   - [ ] Exits with code 0 when no claim is stale, 1 when at least one is stale.
2. **Claim extraction**: paths, shell commands, script names, endpoints, environment variables, config keys.
   - [ ] Each claim keeps its source file and line number.
3. **Verification** without an LLM where possible: path exists, script exists in package files, env var referenced in code, endpoint string present in code.
   - [ ] Given a doc that names `src/old.ts` and the file does not exist, when the check runs, then the claim is marked stale with the evidence "file not found".
   - [ ] A claim that no rule can check is marked unknown, never true.
4. **Report** `docs-check-report.md`: a table of claim, file:line, status, evidence, sorted stale first.

### P1 (nice to have)
- LLM pass for claims the rules cannot check, with the model's reasoning shown next to the verdict.
- `--json` output for CI.
- A token comparison script: run one fixed agent task before and after fixes and log tokens used.

### P2 (future)
- A GitHub Action that comments the report on pull requests that change docs.
- Support for monorepos with several doc roots.

## Success Metrics
- Leading: on your first repo, at least 5 stale claims found; less than 10% of "stale" verdicts wrong when you review them by hand.
- Lagging: the fixed task uses fewer tokens than before (target: 15% fewer); you keep running the check monthly.

## Open Questions
- Which LLM, if any, for the unknown claims? (you)
- Which repo is the first test case? (you)

## Timeline
One evening for P0. P1 the next evening.

## Agent Instructions
- **Suggested stack**: TypeScript on Node 22, or Python 3.12; no framework; ripgrep for searches.
- **Build order**: claim extractor with unit tests → rule-based verifiers with unit tests → report writer → CLI wrapper → P1 items.
- **Safety**: read-only on the target repo; never edit or delete files in it; no secrets in the report; ask before any network call.
- **Done when**: every P0 acceptance criterion passes and `docs-check` runs on this spec's own repo.

## Sources
- Do inconsistent docs hurt AI coding agents? https://developer.microsoft.com/blog/do-inconsistent-docs-hurt-ai-coding-agents/
