Detect stale references and context rot in your AGENTS.md, CLAUDE.md, and AI memory files.
$ npx agents-lint
agents-lint v0.5.0
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Found 3 context files: AGENTS.md, CLAUDE.md, ~/.claude/projects/my-repo/memory/MEMORY.md
File: AGENTS.md Β· 100/100 (A)
β No issues
File: CLAUDE.md Β· 42/100 (F)
β Path does not exist: "./src/services/auth"
β Remove this reference or update to the correct path.
β References NgModules β Angular 14+ uses standalone components
β Update CLAUDE.md to reflect standalone component architecture.
File: ~/.claude/.../memory/MEMORY.md Β· 85/100 (B)
β Memory index link broken: old-project-notes.md
β "old-project-notes.md" no longer exists. Remove this entry or update the link.
Cross-File Consistency (1 issue)
βΉ Path "./src/payments" referenced in AGENTS.md but not in CLAUDE.md
β Consider documenting in all context files, or run --fix to suppress.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Overall: 71/100 Β· 2 errors 1 warning 1 info
AGENTS.md files rot. You write them once, then the codebase evolves β directories move, scripts rename, dependencies change β and the file silently misleads your AI coding agents.
Two 2026 research papers confirmed what many teams had noticed:
"LLM-generated context files reduced task success by 2β3% while increasing cost by over 20%" β ETH Zurich, ICSE 2026
"None of the major coding agents expose the lifecycle hooks to make this architecture easy to build. That's a tooling gap waiting to be filled." β Addy Osmani, Google
agents-lint fills that gap. It's a zero-dependency CLI that verifies your AGENTS.md, CLAUDE.md, and AI memory files stay accurate as your repo evolves.
# Run once (no install)
npx agents-lint
# Install globally
npm install -g agents-lint
# Install as a dev dependency
npm install --save-dev agents-lint# Generate a starter AGENTS.md for this project
agents-lint init
# Lint all context files in the current directory (auto-detected)
agents-lint
# Lint a specific file
agents-lint ./docs/AGENTS.md
# Interactive fix mode β review and apply suggested fixes
agents-lint --fix
# Fail CI if any errors found
agents-lint --max-warnings 0
# JSON output for tooling
agents-lint --format json > report.json
# Quiet mode (errors only)
agents-lint --quiet{
"scripts": {
"lint:agents": "agents-lint --max-warnings 5"
}
}Verifies every path mentioned in your context files (./src/services, ./packages/ui, etc.) still exists on disk.
Validates that npm run <script> commands referenced in your file are present in package.json. Works with workspaces and monorepos.
Detects references to packages not in package.json, and flags deprecated packages (moment, request, tslint, etc.).
Catches outdated patterns for your detected framework:
| Framework | Example check |
|---|---|
| Angular | @NgModule in an Angular 14+ project |
| Angular | @Input()/@Output() decorators (prefer signal-based input()/output() in Angular 17+) |
| Angular | ::ng-deep (deprecated Angular 14+) |
| Angular | Constructor injection (prefer inject() in Angular 17+) |
| Angular | NgClass/NgStyle directives (prefer native class/style bindings) |
| React | ReactDOM.render() (removed in React 19) |
| React | Class component lifecycle methods |
| Next.js | getInitialProps (legacy API) |
| Node.js | CommonJS in ESM projects |
| Symfony | SwiftMailer (removed in Symfony 6), @Route annotations, FOSUserBundle |
| Laravel | String-based routing, make:auth, str_singular()/str_plural() |
| Django | django.conf.urls.url(), ugettext, force_text (all removed in Django 4.0) |
| Zend | Any Zend_/ZendFramework reference (abandoned 2019, superseded by Laminas) |
| PHP (any) | mailhog references (unmaintained, replaced by Mailpit) |
Checks for recommended sections (Setup, Testing, Build) and quality indicators:
- File too short (< 100 chars) or too long (> 15,000 chars β costs 20%+ more)
- Unresolved
TODO/FIXMEmarkers - References to years before 2024
When multiple context files are detected, checks for conflicts between them:
- Package manager conflict β one file says
npm, another saysyarn(error) - Script role conflict β different test or build commands across files (warning)
- Path asymmetry β a significant path mentioned in one file but missing from others (info)
Validates Claude Code memory files (auto-detected from ~/.claude/projects/<repo>/memory/):
- Broken index links β
MEMORY.mdentries pointing to files that no longer exist (error) - Missing frontmatter β individual memory entries missing the
---block (error) - Invalid memory type β
type:must beuser,feedback,project, orreference(warning) - Missing required fields β
nameanddescriptionmust be present in frontmatter (warning)
Every run produces a score from 0 to 100:
| Score | Grade | Meaning |
|---|---|---|
| 90β100 | A | Context files are fresh and accurate |
| 80β89 | B | Minor issues, still reliable |
| 70β79 | C | Some stale references |
| 50β69 | D | Significant context rot |
| 0β49 | F | Agents may produce incorrect or costly outputs |
Errors cost 15 points, warnings 7, infos 2.
agents-lint auto-detects any of these in the repo root and from your Claude Code memory directory:
| File | Used by |
|---|---|
AGENTS.md |
Codex, general |
CLAUDE.md |
Claude Code |
GEMINI.md |
Gemini CLI |
COPILOT.md |
GitHub Copilot |
.cursorrules |
Cursor |
.github/copilot-instructions.md |
GitHub Copilot |
.claude/MEMORY.md |
Claude Code (project-local) |
~/.claude/projects/<repo>/memory/*.md |
Claude Code (user memory) |
The Claude user memory directory is automatically derived from your repo path β no configuration needed.
Pass an explicit path to lint any file: agents-lint ~/.claude/projects/my-repo/memory/MEMORY.md
Run agents-lint --fix to review and apply suggested fixes one at a time:
agents-lint β Fix Mode
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Cross-file issues Β· 1 fixable, 0 advisory
Issue 1/1 [fixable]
βΉ Path "src/tests/helpers.ts" referenced in AGENTS.md but not in CLAUDE.md
Fix: Add "src/tests/helpers.ts" to ignorePatterns in .agents-lint.json
Apply? (y)es / (n)o / (q)uit βΊ y
β Will add to ignorePatterns
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Updated .agents-lint.json β added 1 pattern to ignorePatterns
Fix mode handles:
- Stale path references β remove the line
- Missing sections β append a template section
- Cross-file path asymmetry β add the path to
ignorePatternsin.agents-lint.json
# .github/workflows/agents-lint.yml
name: agents-lint
on:
push:
paths: ['AGENTS.md', 'CLAUDE.md', 'package.json']
schedule:
- cron: '0 9 * * 1' # Weekly β catch silent rot
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npx agents-lint --max-warnings 5The weekly schedule is intentional β context rot happens even when your context files haven't changed, because your codebase evolves around them.
Generate a well-structured starter file based on your project's detected stack:
npx agents-lint initThis creates AGENTS.md with sections for Setup, Structure, Testing, Build, and Conventions β pre-populated from your package.json. Fill in the TODO comments, then run agents-lint to validate.
Place .agents-lint.json in your repo root to override defaults:
{
"requiredSections": ["Architecture", "Deployment"],
"ignorePatterns": ["./legacy", "node_modules", "src/tests/helpers.ts"],
"severity": {
"missingPath": "warn",
"missingScript": "error",
"staleDependency": "warn",
"missingSection": "error"
}
}| Option | Type | Description |
|---|---|---|
requiredSections |
string[] |
Extra section names that must exist |
ignorePatterns |
string[] |
Substrings β matching paths/deps are skipped in all checks including cross-file |
severity.missingPath |
error|warn|info |
Override severity for missing filesystem paths (default: error) |
severity.missingScript |
error|warn|info |
Override for missing npm scripts (default: warn) |
severity.staleDependency |
error|warn|info |
Override for deprecated packages (default: info) |
severity.missingSection |
error|warn|info |
Override for missing recommended sections (default: warn) |
import { lint, lintAll } from 'agents-lint';
// Lint a single file
const report = await lint({
filePath: './AGENTS.md', // optional, auto-detected
repoRoot: process.cwd(), // optional
});
console.log(report.score); // 0β100
console.log(report.errors); // number of errors
console.log(report.results); // per-checker detailed results
// Lint all detected files (including Claude memory files)
const multi = await lintAll({ repoRoot: process.cwd() });
console.log(multi.overallScore); // combined score
console.log(multi.crossCheck); // cross-file consistency results
console.log(multi.files); // list of detected filesUSAGE
agents-lint [file] [options]
agents-lint init
COMMANDS
init Generate a starter AGENTS.md for this project
OPTIONS
--root <path> Repository root (default: cwd)
--fix Interactive mode: review and apply suggested fixes
--format <fmt> text | json (default: text)
--max-warnings <n> Exit with error code 1 if warnings exceed n
--quiet Only show errors
--no-color Disable colored output
--help Show help
--version Show version
EXIT CODES
0 No issues found
1 Warnings or errors found
2 Fatal error (file not found)
-
--fixmode: interactive suggestions for updating stale references and cross-file issues -
agents-lint initβ generate a well-structured AGENTS.md from scratch - Support for
CLAUDE.md,GEMINI.md,.cursorrules,COPILOT.md - Claude Code memory file support β auto-detect and validate
~/.claude/projects/*/memory/ - Cross-file consistency checks across multiple context files
- Custom rules via
.agents-lint.jsonconfig - VS Code extension with inline diagnostics
- Git-blame integration: flag sections that haven't been touched in > 90 days
git clone https://github.com/giacomo/agents-lint
cd agents-lint
npm install
npm run build
node dist/cli.js # test against this repo's own context files
npm test # run the test suite (62 tests, no extra dependencies)Issues and PRs welcome. If you have a checker idea, open an issue first so we can discuss the design.
The AGENTS.md standard was contributed to the Agentic AI Foundation (Linux Foundation) by Anthropic, OpenAI, and Block in late 2025. It's now used by 60,000+ open-source projects.
As adoption grew, so did the problem of stale context. This tool exists to solve that β automatically, in CI, before your agents start giving expensive wrong answers.
MIT Β© Giacomo Barbalinardo