ctxlint
[Add to Yaw MCP]
One click adds this to your local Yaw MCP config so it's available in every Yaw Terminal session. Or install manually below.
[npm version]
[License: MIT]
[GitHub stars]
[MCP Compliance]
Lint your AI agent context files, MCP server configs, and session data against your actual codebase. Context linting + MCP config linting + session auditing. 16 AI tools, 8 MCP clients, cross-project consistency, auto-fix. Works as a CLI, CI step, pre-commit hook, or MCP server.
Your CLAUDE.md is lying to your agent. Your .mcp.json has a hardcoded API key. ctxlint catches both.
Why ctxlint?
Every AI coding tool ships a context file: CLAUDE.md, .cursorrules, AGENTS.md, .mcp.json. These files are the single most important interface between you and your agent — they tell it what to build, how to test, where things live.
But context files rot fast. You rename a file, change a build script, or switch from Jest to Vitest — and your CLAUDE.md still says the old thing. Your agent follows those stale instructions faithfully, then fails. You lose 10 minutes debugging what turns out to be a wrong path in line 12 of a markdown file.
Multiply that across a team with 5 context files, 3 MCP configs, and 2 people who touched the build system last week — and you have a real problem with no existing solution.
ctxlint is a linter purpose-built for this. It reads your context files, cross-references them against your actual codebase, and catches the drift before your agent does.
- Instant startup — ships as a single self-contained bundle with zero runtime dependencies.
npx downloads a ~400 KB tarball and starts immediately
- Catches real problems — broken paths, wrong commands, stale references, contradictions across files
- Smart suggestions — detects git renames and fuzzy-matches to suggest the right path
- Auto-fix —
--fix rewrites broken paths automatically using git history
- Token-aware — shows how much context window your files consume and flags redundant content
- Every AI tool — supports Claude Code, Cursor, Copilot, Windsurf, Gemini, Cline, Aider, and 9 more
- Multiple outputs — text, JSON, and SARIF (GitHub Code Scanning)
- MCP server — 7 tools for IDE/agent integration with tool annotations for auto-approval
- Watch mode —
--watch re-lints automatically when context files change
Install
Run directly (no install needed):
Project install (recommended for teams)
Then add to your package.json scripts:
Global install
Useful if you want ctxlint available in every project without per-project setup.
What It Checks
Supported Context Files
MCP Server Config Linting
ctxlint also lints MCP server configuration files — the JSON configs that tell AI clients which tools to connect to. These are context interfaces too: they shape what your agent can do.
What MCP config files are scanned
With --mcp-global, also scans Claude Desktop, Cursor, Windsurf, and Amazon Q global configs.
What MCP config checks catch
Example MCP config output
MCP Config Linting Specification
The full specification for MCP config linting rules, the cross-client config landscape, and a machine-readable rule catalog are published as open specifications:
MCP_CONFIG_LINT_SPEC.md — the full lint-rule set (rule count in the Specifications family table), the complete client/format reference, and implementation guidance. Tool-agnostic — any linter can implement it.
mcp-config-lint-rules.json — Machine-readable rule catalog for programmatic consumption by AI agents, CI systems, and other tools.
Session Linting
ctxlint can audit AI agent session data — history files and memory entries — for cross-project consistency. Session checks compare your current project against sibling repos to catch drift and missing setup.
Session checks are opt-in because they access files outside the project directory (agent history in your home directory, sibling repos in the parent directory).
What session files are scanned
Checks whose signal is what the agent did (commands run, files written or read) also read the current project's Claude Code session transcripts, ~/.claude/projects/<encoded-project>/*.jsonl, bounded to the 5 most recent.
What session checks catch
Session Linting Specification
Example Output
Options
Available checks: paths, commands, staleness, tokens, tier-tokens, redundancy, contradictions, frontmatter, ci-coverage, ci-secrets, content-secrets, hook-coverage, mcp-schema, mcp-security, mcp-commands, mcp-deprecated, mcp-env, mcp-urls, mcp-consistency, mcp-redundancy, session-missing-secret, session-diverged-file, session-missing-workflow, session-stale-memory, session-duplicate-memory, session-loop-detection, session-memory-index-overflow, session-shared-temp-path, session-unverified-gate-claimed-clean, session-default-branch-accumulation, session-unresolvable-sha, session-large-read, skill-frontmatter, skill-broken-ref, skill-trigger-collision, skill-orphaned, skill-dead-tool-restriction
Passing any mcp-* check name implies --mcp. Passing any session-* check name implies --session. Passing any skill-* check name implies --skills.
Watch Mode
Re-lints automatically when any context file, MCP config, or package.json changes. Useful during development when you're editing context files alongside code.
Use in CI
Exit Codes
In non-strict mode ctxlint always exits 0 — it's a reporting tool by default. Pass --strict to enforce in CI.
GitHub Action
Or with options:
SARIF Output (GitHub Code Scanning)
Auto-fix
When a broken path was renamed in git or has a close match in the project, --fix rewrites the context file automatically.
Pre-commit Hook
Built-in
Sets up a git pre-commit hook that runs ctxlint --strict before each commit.
pre-commit framework
Add to your .pre-commit-config.yaml:
Config File
Create a .ctxlintrc or .ctxlintrc.json in your project root:
The contextFiles array adds custom file patterns to scan alongside the built-in list. Useful for project-specific context files like CONVENTIONS.md.
The exclude array is its counterpart: globs of context files to drop from the scan entirely. Use it for files that are not this project's agent context at all — test fixtures, example projects, vendored templates.
exclude removes files, where ignore / ignoreRules / .ctxlintignore suppress findings. That distinction matters for the cross-file checks: contradictions and redundancy/duplicate-content compare the discovered set and report against the literal (project) path, which no per-file glob can match. Excluding the files is the only way to silence a conflict between two files you never wanted linted. Reach for .ctxlintignore when a real context file has one noisy finding; reach for exclude when the file shouldn't be in the corpus.
Config Reference
Config file resolution order: .ctxlintrc → .ctxlintrc.json in the project root. Use --config <path> to point elsewhere. CLI flags override config fields.
CLI flags override config file settings. Use --config <path> to load a config from a custom location.
Ignore file (.ctxlintignore)
A .ctxlintignore file in the project root suppresses findings without touching .ctxlintrc. Each line is one rule, checkName [fileGlob] [# reason]:
checkName is a name from the Available checks list under Options (paths, tokens, mcp-security, ...), not a rule ID. A name that is not a check is not rejected: the rule never matches, so it is reported as never fired.
fileGlob is optional. Without one, the rule covers every file. With one, it covers only findings in files whose path matches — the project-relative path ctxlint prints, with forward slashes on every platform, and dotfiles included. Cross-file findings from contradictions and redundancy/duplicate-content are reported against the path (project); match them with that literal (contradictions (project)).
# reason needs a space before the #. In paths#legacy, the whole token is read as the check name. Only the first two tokens are read, so there is no message regex here; use ignoreRules for that.
- Rules with a glob are applied first, in file order, then rules without one together with
ignoreRules. A finding is dropped by the first rule that matches it.
- Dropped counts, rules that dropped nothing, and rules without a reason are listed in the same "Ignore rules" report as
ignoreRules.
--no-ignore-file skips the file for a run; ignoreRules still apply. --watch re-lints when the file changes.
Use as MCP Server
ctxlint ships with an MCP server that exposes seven tools (ctxlint_audit, ctxlint_mcp_audit, ctxlint_session_audit, ctxlint_skill_audit, ctxlint_validate_path, ctxlint_token_report, ctxlint_fix). All read-only tools declare annotations so MCP clients can skip confirmation dialogs.
Launch it with the serve subcommand (or the equivalent --mcp-server flag, kept for back-compat):
With Claude Code
With .mcp.json (Claude Code project config, Cursor, Windsurf)
Create .mcp.json in your project root:
macOS / Linux / WSL:
Windows:
Tip: This file is safe to commit — it contains no secrets.
With VS Code / GitHub Copilot
Add to .vscode/mcp.json:
With Claude Desktop
Add to your Claude Desktop config (claude_desktop_config.json):
JSON Output
Returns structured JSON with all file results, issues, and summary — useful for building integrations or dashboards.
Specifications
ctxlint is the reference implementation of four open specifications for linting AI agent interfaces. These specs are tool-agnostic — any linter, IDE extension, or CI system can implement them.
All specs include machine-readable rule catalogs for programmatic consumption:
Also By Yaw Labs
- Yaw — The AI-native terminal
License
MIT
[Follow @YawLabs on X]