skills/drift-doctor/SKILL.md
Detect and fix drift in project AGENTS.md files and agent control plane. Use this skill whenever the user wants to audit, recalibrate, refresh, update, or fix their existing AGENTS.md files, or when they mention "drift", "stale AGENTS.md", "outdated agent instructions", "recalibrate", "sync agents", "audit control plane", "AGENTS.md is wrong/old/broken", or when they suspect their agent harness has fallen out of sync with the codebase. Also trigger when a user says things like "my agents keep making wrong assumptions", "Claude doesn't understand the new structure", "we refactored but the AGENTS.md is old", "check if my AGENTS.md is still accurate", or "update my agent docs". This skill is the companion to init-deep — init-deep creates the control plane from scratch, drift-doctor maintains it over time. Do NOT use for initial creation of AGENTS.md (use init-deep instead). Do NOT use for general code review or documentation updates unrelated to agent context.
npx skillsauth add Refinex-Space/Refinex-Skills drift-doctorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
AGENTS.md files go stale. Codebases evolve — modules get added, deleted, renamed, and refactored. Conventions shift as the team makes new decisions. Dependencies get updated. Architecture boundaries move. But the AGENTS.md files that describe all of this stay frozen at whatever point they were last written.
Stale AGENTS.md is worse than no AGENTS.md. Agents follow outdated instructions with full confidence, producing code that violates current conventions, targets deleted modules, or ignores new patterns. This is the architectural entropy problem that OpenAI's harness engineering team addressed with recurring "garbage collection" agents that scan for drift and submit fixes.
Drift-Doctor is that garbage collector for your control plane. It systematically audits every AGENTS.md file against the actual codebase, identifies drift, and proposes precise corrections.
Find every AGENTS.md, CLAUDE.md, and related control file in the project:
find . -name 'AGENTS.md' -o -name 'CLAUDE.md' -o -name '.claude' -type d | grep -v node_modules | grep -v .git
Also check for supporting documentation referenced by these files:
# Extract all file references from AGENTS.md files
grep -rh '\`docs/\|\.md\`\|See \`' */AGENTS.md AGENTS.md 2>/dev/null
Get the actual current project structure (2–3 levels):
find . -type d -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/dist/*' -not -path '*/.next/*' -maxdepth 3 | sort
This becomes the reference against which we check all structural claims in AGENTS.md files.
For each AGENTS.md file found, perform a systematic audit. Read the file, then verify each claim against the actual codebase. Track every discrepancy.
These are the most dangerous because agents use them for navigation.
Checks:
src/core/types/api.ts, docs/architecture.md)How to check:
# Extract all file/directory paths from an AGENTS.md
grep -oE '`[a-zA-Z0-9_./-]+`' AGENTS.md | tr -d '`' | while read path; do
[ ! -e "$path" ] && echo "MISSING: $path"
done
These cause agents to write code that doesn't match current patterns.
Checks:
How to check: Sample recent files (use git log --diff-filter=A --since="30 days ago" --name-only to find recently added files) and compare their patterns against what the AGENTS.md describes.
These cause build/test failures when agents run stale commands.
Checks:
init.sh or setup script is referenced, does it still exist and work?How to check: Read the current package.json scripts section (or equivalent) and compare against documented commands.
These cause agents to use outdated APIs or missing libraries.
Checks:
These are the most subtle — hard invariants that are no longer enforced or no longer true.
Checks:
After the audit, compile a structured drift report. Present it to the user organized by severity:
Critical — Will actively mislead agents into producing broken code:
High — Will cause agents to write inconsistent or non-idiomatic code:
Medium — Reduces agent effectiveness but doesn't cause breakage:
Low — Cosmetic or minor improvements:
Present the report as a concise summary with one section per audited file:
## Drift Report — [Date]
### Root AGENTS.md
- **CRITICAL:** Module map references `src/legacy/` which was deleted in commit abc123
- **HIGH:** Build command `npm test` should be `pnpm test` (migrated package manager)
- **MEDIUM:** No mention of new `src/notifications/` module (added 3 weeks ago)
### src/api/AGENTS.md
- **HIGH:** Error handling section describes try/catch pattern but recent handlers use Result<T>
- **MEDIUM:** Missing mention of rate limiting middleware added to all routes
### src/frontend/AGENTS.md
- **LOW:** React version listed as 18.x but is now 19.x
After the user reviews the drift report, apply fixes. The remediation strategy depends on severity:
Fix immediately. These are actively harmful. For each fix:
Propose fixes but let the user prioritize. Some medium items (like adding AGENTS.md to new modules) may require running a mini version of init-deep's Phase 2A analysis for that specific module.
Batch into a single update. Present all low-severity changes together for quick approval.
If more than 40% of the content in any AGENTS.md file is stale, recommend a full regeneration of that file rather than incremental patching. Use the init-deep skill's analysis approach for the relevant scope. Patching a fundamentally stale file leads to Frankenstein documentation — technically updated but structurally incoherent.
After remediation, suggest preventive measures to the user:
Add AGENTS.md to PR review checklists — When a PR changes module structure, conventions, or hard invariants, the reviewer should check if AGENTS.md needs updating.
Schedule periodic drift-doctor runs — Suggest a cadence based on how active the project is (weekly for fast-moving projects, monthly for stable ones).
Use CI checks for structural drift — A simple CI script can verify that all file paths referenced in AGENTS.md actually exist:
# .github/workflows/agents-md-check.yml
grep -roE '`[a-zA-Z0-9_./-]+\.(ts|js|py|md|json|yaml|toml)`' **/AGENTS.md |
tr -d '`' | while read ref; do
[ ! -e "$ref" ] && echo "::warning::Stale reference: $ref" && exit 1
done
Keep AGENTS.md files short — The shorter the file, the less there is to go stale. If a file has grown past the recommended limits (root ≤ 120 lines, module ≤ 80 lines), it probably contains content that belongs in dedicated docs.
Link, don't inline — When AGENTS.md points to docs/architecture.md instead of inlining architecture details, the architecture doc can be updated independently. AGENTS.md only drifts when the file it points to moves or disappears — which is a much smaller surface area than keeping the content in sync.
In monorepos, each package may have its own AGENTS.md. Check that:
After a major migration (framework, language, architecture), the control plane likely needs near-complete regeneration. Recommend running init-deep on the affected areas rather than trying to patch.
If the project has some AGENTS.md files but they're incomplete or poorly structured (e.g., a single monolithic root file with no module-level files), this is a "structural deficiency" rather than "drift." Recommend init-deep for the areas without coverage, and drift-doctor for the areas with existing (but possibly stale) coverage.
development
Deep initialization of project AGENTS.md hierarchy and control plane for AI coding agents. Use this skill whenever the user wants to set up, initialize, bootstrap, or create AGENTS.md / CLAUDE.md files for their project, or when they mention "init-deep", "harness setup", "control plane", "agent context", "project initialization for agents", or want to make their codebase agent-ready. Also trigger when a user says things like "set up my repo for Claude Code", "make this project work better with agents", "create agent instructions", "bootstrap harness", or "initialize agent docs". This skill handles both existing large codebases (where hierarchical, module-scoped AGENTS.md files are needed) and new/small projects (where brainstorming with the user comes first). Do NOT use this skill for routine code changes, bug fixes, or general documentation — it is specifically for creating the structured agent control plane.
development
Use when adding, fixing, reviewing, or generating code comments, docstrings, Javadoc, JSDoc/TSDoc, rustdoc, SQL comments, or documentation comments for source, markup, configuration, or database files.
development
Enforce production-grade Java development standards when writing, reviewing, or architecting Java code. Covers commenting, core Java idioms (Stream, collections, concurrency, generics), 23 GoF design patterns, SonarQube/Alibaba p3c/Lombok rules, Spring Boot MVC structure, Spring Cloud DDD microservices, MyBatis/JPA/transaction management, exception handling, logging, REST API design, testing, and security. Trigger whenever the user writes Java code, reviews Java code, designs a Spring Boot or Spring Cloud project, implements a design pattern, fixes code smells, discusses architecture, or asks about Java best practices. Also trigger when Java code is pasted for feedback or the user asks about package structure, DTO/VO/PO conventions, or coding standards.
development
Use when starting Harness implementation work that needs an isolated git worktree, especially before executing an approved plan or beginning a scoped feature/fix branch. Select the repository's worktree directory, verify ignored project-local directories, create a `codex/`-prefixed branch by default, run setup and baseline checks, and prevent plan execution on main/master unless the user explicitly allows it.