Audit Claude Code rules and CLAUDE.md/AGENTS.md files for staleness, quality, and drift. Use when asked to audit rules, check stale CLAUDE.md, check stale AGENTS.md, review rules freshness, assess rules quality, improve my rules, find dead globs in rules, check if rules are up to date, review progressive disclosure setup, find contradictory rules, or optimize Claude Code memory files.
72
88%
Does it follow best practices?
Impact
—
No eval scenarios have been run
Advisory
Suggest reviewing before use
This skill audits and improves Claude Code memory files — .claude/rules/*.md, CLAUDE.md, CLAUDE.local.md, and their AGENTS.md/AGENTS.local.md equivalents. AGENTS.md is a third-party alternative that uses the exact same rules, frontmatter, and progressive disclosure conventions as CLAUDE.md but with a different filename. This skill treats both identically.
Use this skill when asked to:
Before auditing, discover all memory files in the project:
find .claude/rules -name "*.md" -type f 2>/dev/null | sortfind . \( -name "CLAUDE.md" -o -name "CLAUDE.local.md" -o -name "AGENTS.md" -o -name "AGENTS.local.md" \) | grep -v node_modules | grep -v .git | sortNote: AGENTS.md is a third-party alternative to CLAUDE.md that uses the exact same format, frontmatter, and rules conventions. Treat AGENTS.md files identically to CLAUDE.md files throughout the audit.
For each rule file, extract the paths: frontmatter to determine scope:
# Extract paths from YAML frontmatter
sed -n '/^---$/,/^---$/p' "$rule_file" | grep -A 50 '^paths:' | grep '^ *- ' | sed 's/^ *- *//'paths: frontmatter — loaded on every sessionpaths: with glob patterns — loaded only when Claude reads matching filesClassify each file:
paths: → scoped rules (note the globs)paths: → global rulesCLAUDE.md or AGENTS.md → always loaded (ancestor of cwd)CLAUDE.md/AGENTS.md files → loaded lazily when Claude reads files in that subtreeFor each discovered memory file, perform these checks:
For each glob pattern in paths:, verify files actually match:
# Test if a glob matches any files
shopt -s globstar nullglob
files=( $glob_pattern )
if [ ${#files[@]} -eq 0 ]; then
echo "STALE: glob '$glob_pattern' matches no files"
fiCommon causes: directories renamed, file extensions changed, code moved to a different location.
Extract file paths mentioned in rule content and verify they exist:
# Find file references in rule content (paths like src/foo/bar.ts, ./config/x.json)
grep -oE '`[a-zA-Z0-9_./-]+\.[a-zA-Z]{1,5}`' "$rule_file" | tr -d '`' | while read -r ref; do
[ ! -e "$ref" ] && echo "BROKEN REF: $ref in $rule_file"
doneFor key identifiers mentioned in rules (function names, class names, type names, command names):
grep or Grep toolFor rules describing code conventions or patterns:
configure() method")For nested CLAUDE.md and AGENTS.md files, verify:
Assign each file a score:
| Score | Criteria |
|---|---|
| fresh | All globs match files, referenced files exist, described patterns verified in code |
| needs-review | File not modified in 60+ days, or described patterns appear in <50% of matching files, or minor drift detected |
| stale | Dead globs, references to deleted files, instructions contradicted by current code |
Produce a structured report with:
| Topic | Reference File | Key Contents |
|---|---|---|
| What makes effective rules and CLAUDE.md/AGENTS.md | references/quality-patterns.md | Root CLAUDE.md/AGENTS.md guidelines, scoped rules best practices, progressive disclosure tiers, emphasis patterns |
| Common mistakes to avoid | references/anti-patterns.md | Kitchen sink files, volatile imports, negative-only constraints, linter duplication, redundancy |
| Detecting drift and staleness | references/staleness-detection.md | Dead globs, referenced file drift, API pattern drift, version pinning, convention drift, scoring |
| CI integration with GitHub Actions | references/github-workflow-guide.md | Workflow architecture, setup instructions, cost optimization, claude-code-action configuration |
For automated freshness checks on every PR, see references/github-workflow-guide.md. The workflow uses claude-code-action to review affected rules when code changes and posts findings as PR comments.
To install the CI workflow automatically, use the /install-rules-audit command.
dd10cc1
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.