agent-context-audit
Skill0 starsChanged 3 months agoMITView on GitHub
Audit and repair everything AI coding agents read about your codebase that is not the codebase itself — instruction files (CLAUDE.md, AGENTS.md, Cursor/Copilot/Windsurf rules), agent memory, decision-record statuses, skills, permission configs. Finds claims contradicted by current code, finds tools contradicting each other, and graduates repeated feedback into deterministic checks. Run monthly, or whenever agent behavior suggests stale context.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- Xakki/ai-agents-skillstheir own version, first seen Nov 8, 2026
- AI-Builder-Club/skillstheir own version, first seen Jul 27, 2026
- oozoofrog/codex-skills-projecttheir own version, first seen Mar 28, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- AI-Builder-Club/skills★ 1.3ksame name
- Xakki/ai-agents-skills★ 6same name
- oozoofrog/codex-skills-project★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 8 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 70
Every file found is in scope — including files for tools you are not.
- Distinctive: line 109
Verify every concrete claim in each instruction file found in Step 0: the project files, any workspace/parent file's paragraph about this …
- Very specific: line 121
Cross-tool consistency (multi-tool projects only): When several instruction files coexist (say CLAUDE.md + AGENTS.md + .cursor/rules/), …
- Distinctive: line 134
If the project keeps ADRs/decision records:
- Distinctive: line 140
Implemented-but-Proposed: if code verifiably implements the decision, flip to Accepted with a one-line evidence note — unless the owner …
- Distinctive: line 143
Missing supersession markers: when record B deletes what record A prescribed, A gets "Superseded by B" and B gets "Supersedes A." Don't …
- Distinctive: line 161
Duplicate trees: when Step 0 found the same skill name in more than one place (in-repo source, installed copy, a second package), diff the …
- Distinctive: line 197
Before recommending a new check, list existing ones and diff: the rule may already be half-enforced.
- Distinctive: line 206
Record the run: leave a dated completion note wherever the project tracks maintenance cadence, so an audit cycle that stops running goes …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent Context Audit
You are auditing the agent-facing context layer of this project: everything AI coding agents read about the codebase that is not the codebase itself. This context rots silently — the code moves on, the descriptions don't — and a wrong "fact" in an instruction file or memory misleads every future session of every agent that reads it. Humans skim stale docs with a raised eyebrow; agents act on them.
Core rule: the codebase is the authority; context files are claims about
it. Every concrete claim (a path, a CLI form, a field name, a status) gets
verified with ls/grep/git log before being kept. Never "fix" code to
match a context file.
The false-OK hazard: a grep against a moved file returns nothing and reads as "no findings." When a verification grep returns empty, first confirm the target still exists before concluding the claim holds. Empty is not OK; empty is unverified.
Shell portability: quote every glob-bearing argument (--include='*.py',
not --include=*.py) and prefer git ls-files/find over bare globs — in
zsh, an unmatched bare glob aborts the whole command with an error that's
easy to misread as an empty (false-OK) result. This applies to every command
you write during this audit, not just the examples below.
Step 0: Locate the context layer
Different tools keep context in different places. Discover what this project actually has — check every convention, not just the tool running this audit:
# Instruction files (project root and nested)
ls CLAUDE.md AGENTS.md GEMINI.md CONVENTIONS.md .cursorrules .windsurfrules \
.clinerules .github/copilot-instructions.md 2>/dev/null
ls .cursor/rules/ .windsurf/rules/ .github/instructions/ .junie/ 2>/dev/null
find . -maxdepth 3 -name 'CLAUDE.md' -o -maxdepth 3 -name 'AGENTS.md' 2>/dev/null | grep -v node_modules
# User-level instruction files that apply to this project
ls ~/.claude/CLAUDE.md ~/.codex/AGENTS.md 2>/dev/null
# Agent memory (Claude Code: the dir name encodes the project path with
# slashes as dashes — ~/src/foo/bar → "-Users-you-src-foo-bar". Match the
# FULL encoded cwd: a project nested inside another produces two
# plausible-looking prefixes, and grabbing the parent's memory is easy.)
# find, not a bare glob — an unmatched glob aborts the whole command in zsh
find ~/.claude/projects -maxdepth 2 -type d -name memory 2>/dev/null | head
# Skills / reusable prompts — search by MARKER, not by fixed path: skill
# sources often live inside the repo (src/skills/, packages/*/skills/) and
# are symlinked into the standard locations.
git ls-files | grep -iE '(^|/)skill\.md$'
ls .claude/skills/ .claude/agents/ 2>/dev/null
# Which user-level skills belong to THIS project? Resolve the symlinks:
ls -l ~/.claude/skills/ 2>/dev/null | grep -F "$(pwd)"
# Permission & tool configs
ls .claude/settings.json .claude/settings.local.json ~/.claude/settings.json \
.mcp.json .cursor/mcp.json 2>/dev/null
# Decision records
ls docs/adr/ docs/decisions/ 2>/dev/nullEvery file found is in scope — including files for tools you are not. Sections below that target something this project doesn't have are skipped without comment.
Step 1: Memory hygiene
Where the agent keeps per-project memory (files it wrote for itself):
- Session journals and dated notes accumulate; consolidate, then delete. Extract only what is durable and not already recorded in decision records or git history: milestone one-liners, operational gotchas still true, open threads, people/context facts. Merge into topic memories. Detail the repo already records does not belong in memory.
- Rewrite the memory index (
MEMORY.mdor equivalent): one line per memory, grouped by kind (user / working style / project state / reference). - Memories that turn out to be wrong get fixed or deleted — never left standing "for context."
Step 2: Contradiction audit (context bodies vs. code)
First gather recent ground truth — renames, deletions, moved modules:
git log --oneline -50Then check every concrete claim in every memory and instruction file against
it. For scale, a read-only search subagent can do the sweep, but require for
each finding: the stale claim quoted, current reality with file:line
evidence, and a severity — WRONG (actively misleading — fix now),
DATED (harmless history — annotate), OK. Verify WRONG findings
yourself before editing; subagents over-claim.
Classic rot classes: deleted scripts still cited, renamed CLI invocations, retired config fields, dead tool names, conventions that were proposed but never shipped.
Step 3: Instruction-file sync — and cross-tool consistency
Verify every concrete claim in each instruction file found in Step 0: the project files, any workspace/parent file's paragraph about this project, and user-level entries that affect it. Typical checks:
<project-cli> --help # does the documented CLI surface match?
ls <documented paths> # do named modules/dirs still exist?Structure claims (pipeline stages, module lists, "X is powered by Y") must match current architecture — no retired stages described in present tense.
Cross-tool consistency (multi-tool projects only). When several instruction files coexist (say CLAUDE.md + AGENTS.md + .cursor/rules/), they drift from each other: a convention updated in one and not the others means different agents follow different rules in the same repo. Diff them for contradictions — build commands, test invocations, style rules, "always/never" directives. The durable fix is a single source of truth: one canonical file (AGENTS.md is the emerging cross-tool convention) with the tool-specific files reduced to a pointer, an include, or a symlink to it. Flag any substantive rule that exists in only one tool's file — either it belongs to all agents (promote to canonical) or it's tool-specific (mark it so).
Step 4: Decision-record statuses
If the project keeps ADRs/decision records:
grep -l "Status.*Proposed" docs/adr/*.md 2>/dev/null- Implemented-but-Proposed: if code verifiably implements the decision, flip to Accepted with a one-line evidence note — unless the owner explicitly deferred acceptance.
- Missing supersession markers: when record B deletes what record A prescribed, A gets "Superseded by B" and B gets "Supersedes A." Don't rewrite bodies — they're history; only the status header moves.
- Retired subsystems: records describing mechanisms that no longer exist get a dated retirement note.
- Regenerate any index from disk; never hand-maintain it.
Step 5: Skill & rules rot
For each skill, rules file, or reusable prompt (Claude skills, Cursor
.mdc rules, Copilot instruction files, saved prompts): extract every file
path, command, and grep target it references, and verify each one exists. A
rule whose embedded greps point at moved files fails silently (the
false-OK hazard again). Also check each file's background blurbs — pipeline
descriptions, CLI forms — against Step 3 findings. Rules scoped by glob
patterns (Cursor/Copilot applyTo/globs) get their patterns checked too:
a rule scoped to a directory that no longer exists never fires.
Duplicate trees: when Step 0 found the same skill name in more than one place (in-repo source, installed copy, a second package), diff the copies. Divergent duplicates mean one tree is stale documentation being silently served to agents — name the canonical tree and flag the other for sync or deletion.
Step 6: Permission & tool-config hygiene
In each permission/config file the tools keep (agent settings, MCP configs):
- Convert stale command forms to current ones; delete entries naming dead scripts; collapse accumulated one-offs into curated general patterns (keep the capability, cut the noise).
- Scan for credential literals. A key pasted into a permission entry or
MCP config is a leak: it needs rotation, not just deletion of the line.
Rotation is an external, owner-level action — never something this audit
performs itself. Record it as the top-priority action item with
file:line; in the meantime don't reproduce the key's value anywhere in your output. - Tracked vs. local: read-only, team-shareable entries belong in the tracked settings file; personal or mutating ones in the local/gitignored one.
- MCP configs: verify each declared server still resolves (the package exists, the command runs) — dead servers are silent capability loss.
Step 7: Graduation pass
The highest-value step. For each memory or instruction that encodes feedback or a working rule, ask: is this deterministic? If a grep, AST walk, lint rule, or test can enforce it, graduate it: add the check to CI (or the project's invariant script), and shrink the context entry to the rationale plus a pointer to the check. The check becomes the enforcement; the prose stops being load-bearing — and unlike an instruction file, CI binds every agent and every human, whichever tool they use.
Judgment-shaped rules (taste, tone, "prefer root causes over guards") stay as context — a check can't hold them.
Before recommending a new check, list existing ones and diff: the rule may already be half-enforced.
Step 8: Apply, verify, record
- Memory-side and user-level fixes apply directly (they're not in git).
- Repo-side fixes (instruction files, decision records, new checks): run the project's test suite and structural checks, then commit. A new check lands with its first passing run in the same commit.
- Record the run: leave a dated completion note wherever the project tracks maintenance cadence, so an audit cycle that stops running goes visibly stale. No existing convention? Default to a dated line in the memory index (or a project-state memory) — the next audit's Step 0 will find it there.
Bonus: the issue tracker is context too
Where docs, decision records, or memories cite issue numbers (#NNN),
verify against live state (gh issue view NNN --json state,title). A doc
leaning on an open issue that has closed — or a closed one that reopened —
is WRONG/DATED like any other claim. And open issues the codebase shows
resolved get flagged for closure: the tracker is documentation and drifts
like any other.
Output
- Counts: memories consolidated / deleted / fixed; index size before/after.
- Table of WRONG/DATED findings with evidence and what was done.
- Cross-tool contradictions found, and the canonical-file consolidation applied or proposed.
- Decision-record status changes applied.
- Skill/rules and permission issues found and fixed.
- Graduation recommendations (context → check), each with the proposed check's shape.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

