ctxlint

io.github.YawLabs由 GitHub 账号 YawLabs 发布v0.28.1更新于 Nov 7, 2026

Lint AI agent context files (CLAUDE.md, AGENTS.md, etc.) against your actual codebase

概览

AI 生成的概览

对照实际代码库检查 AI 代理上下文文件、MCP 配置、会话数据与技能定义,并可自动修复失效路径。

可以做什么
  • 审计 CLAUDE.md、AGENTS.md、.cursorrules 等上下文文件中的失效路径、错误命令、相互矛盾、frontmatter 问题与 token 浪费
  • 检查 MCP 服务器配置文件的 schema 错误、硬编码密钥、已弃用传输方式、环境变量语法与跨客户端不一致
  • 审计代理会话数据与记忆条目中的过期或重复内容、命令循环、缺失密钥及同级仓库间配置漂移
  • 审计技能与子代理定义中的 frontmatter 问题、失效引用、触发冲突与失效工具限制
  • 校验单个被引用的路径并给出 git 重命名建议,或输出各文件的 token 用量明细
  • 借助 git 历史与模糊匹配自动修复失效路径,支持 dryRun 预览
适用场景
适用于项目中代理上下文文件或 MCP 配置随代码、脚本和路径变化而失效,希望助手在代理照做之前发现过期指令的场景。也适合在多个仓库间统一配置与技能定义的团队。
运行要求
以本地 stdio 进程运行,来自 npm 包 @yawlabs/ctxlint(可用 npx 或项目/全局安装),需要 Node.js。未声明任何认证、环境变量或请求头。会话与技能审计会读取项目目录之外的文件,例如主目录中的代理历史与同级仓库。
安装前请注意
修复工具在 dryRun 不为 true 时会写入上下文文件,建议先预览。审计会读取项目之外的代理历史、记忆文件与同级仓库,MCP 配置检查还会查找硬编码密钥;报告中密钥值仅保留短前缀。应用修复前请先核对结果。

安装

在 SourceWeft 中

  1. 打开 控制台中的 ctxlint,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

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):

bash
npx -y @yawlabs/ctxlint@latest

Project install (recommended for teams)

bash
npm install -D @yawlabs/ctxlint# orpnpm add -D @yawlabs/ctxlint

Then add to your package.json scripts:

json
{  "scripts": {    "lint:ctx": "ctxlint --strict"  }}

Global install

bash
npm install -g @yawlabs/ctxlint

Useful if you want ctxlint available in every project without per-project setup.

What It Checks

CheckWhat it finds
Broken pathsFile references in context that don't exist in your project
Wrong commandsBuild/test commands that don't match your package.json scripts or Makefile targets, and Gradle project paths or Maven -pl modules your build doesn't declare
Stale contextContext files not updated after recent code changes
Token wasteHow much context window your files consume per session
RedundancyContent the agent can already infer (e.g. "We use React" when react is in package.json)
ContradictionsConflicting directives across context files (e.g. "use Jest" in one, "use Vitest" in another)
FrontmatterInvalid or missing YAML frontmatter in Cursor .mdc, Copilot instructions, and Windsurf rules
CI coverageRelease/deploy workflows in .github/workflows/ not documented in any context file
CI secretsSecrets used in CI workflows (${{ secrets.X }}) not mentioned in context files
Inline secretsReal secrets pasted into context files — private-key headers, AWS/GitHub/Anthropic/OpenAI/npm/Slack/Google/Stripe token shapes. Messages never echo the secret (6-char redacted prefix only)
Dead hooksPreToolUse hooks / permissions entries in .claude/settings.json pointing at scripts that no longer exist (a dead gate silently no-ops). Scans project .claude/settings.json[.local] by default; pass --hooks-global to also scan the user-global ~/.claude/settings.json
Missing secretsGitHub secrets set on sibling repos but missing from current project
Diverged configsCanonical config files (CI, tsconfig, etc.) drifting across sibling projects
Missing workflowsGitHub Actions workflows present in 2+ siblings but absent here
Stale memoryClaude Code memory entries referencing paths that no longer exist
Duplicate memoryNear-duplicate memories across projects (>60% content overlap)
Loop detectionAgent stuck in loops — repeated commands or cyclic patterns in session history
Memory overflowMEMORY.md past Claude Code's 200-line / 25KB session-load cap — entries beyond it are invisible to the agent
Shared temp pathA fixed temp path (e.g. /tmp/pkg.bak) the agent writes and later reads back — any concurrent session can overwrite it in between
Unverified gateA lint/typecheck/test/build run that errored or printed nothing, followed by agent prose claiming it passed
Default-branch edits10+ files edited on main/master with no intervening commit or branch-away
Unresolvable SHAA memory cites a commit SHA that does not resolve in this repository
Large readsWhole-file Reads of 4,000+ tokens, with an estimate of the tokens they re-send as cached context on later turns (an info-level baseline)

Supported Context Files

FileTool
CLAUDE.md, CLAUDE.local.md, .claude/rules/*.mdClaude Code
AGENTS.md, AGENT.md, AGENTS.override.mdAAIF / Multi-agent standard
.cursorrules, .cursor/rules/*.md, .cursor/rules/*.mdc, .cursor/rules/*/RULE.mdCursor
.github/copilot-instructions.md, .github/instructions/*.md, .github/git-commit-instructions.mdGitHub Copilot
.windsurfrules, .windsurf/rules/*.mdWindsurf
GEMINI.mdGemini CLI
.clinerulesCline
.aiderulesAider
.aide/rules/*.mdAide / Codestory
.amazonq/rules/*.mdAmazon Q Developer
.goose/instructions.md, .goosehintsGoose by Block
.junie/guidelines.md, .junie/AGENTS.mdJetBrains Junie
.aiassistant/rules/*.mdJetBrains AI Assistant
.continuerules, .continue/rules/*.mdContinue
.rulesZed
replit.mdReplit

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.

bash
# Lint context files + MCP configsnpx @yawlabs/ctxlint@latest --mcp
# Lint only MCP configsnpx @yawlabs/ctxlint@latest --mcp-only
# Include global/user-level configs (Claude Desktop, Cursor, Windsurf, etc.)npx @yawlabs/ctxlint@latest --mcp-global

What MCP config files are scanned

FileClient
.mcp.jsonClaude Code (universal project config)
.cursor/mcp.jsonCursor
.vscode/mcp.jsonVS Code / GitHub Copilot
.amazonq/mcp.jsonAmazon Q Developer
.continue/mcpServers/*.jsonContinue

With --mcp-global, also scans Claude Desktop, Cursor, Windsurf, and Amazon Q global configs.

What MCP config checks catch

CheckWhat it finds
SchemaInvalid JSON, wrong root key (servers vs mcpServers), missing required fields
SecurityHardcoded API keys and Bearer tokens in git-tracked config files
CommandsMissing cmd /c wrapper for npx on Windows, broken file paths in args
DeprecatedSSE transport usage (deprecated March 2025, use Streamable HTTP)
Env varsWrong env var syntax for the client (${VAR} vs ${env:VAR} vs ${{ secrets.VAR }})
URLsMalformed URLs, localhost in project configs, missing path component
ConsistencySame server configured differently across client configs
RedundancyDisabled servers, identical configs at multiple scopes

Example MCP config output

MCP Configs  .mcp.json    ✗ mcp-security    Server "api": hardcoded Bearer token in a git-tracked file    ✗ mcp-deprecated  Server "old-svc": SSE transport is deprecated — use "http"    ✓ mcp-schema    ✓ mcp-commands  .cursor/mcp.json    ✗ mcp-env  Server "api": Cursor uses ${env:VAR}, not ${VAR}    ✓ mcp-schema  .vscode/mcp.json    ✗ mcp-schema  .vscode/mcp.json must use "servers" as root key, not "mcpServers"
Cross-file    ⚠ Server "api" is configured differently in .mcp.json and .cursor/mcp.json    ℹ Server "db" is in .mcp.json but missing from .cursor/mcp.json
Summary: 3 errors, 2 warnings, 1 info

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.

bash
# Lint context files + session datanpx @yawlabs/ctxlint@latest --session
# Lint only session datanpx @yawlabs/ctxlint@latest --session-only

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

AgentHistoryMemory
Claude Code~/.claude/history.jsonl~/.claude/projects/*/memory/*.md
Codex CLI~/.codex/history.jsonl—

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

CheckWhat it finds
Missing secretsgh secret set ran on 2+ sibling repos but not this one
Diverged configsShared config files (CI workflows, tsconfig, .prettierrc, etc.) with 20-90% line overlap — enough to be related, different enough to be drifting
Missing workflowsGitHub Actions workflows in 2+ siblings but absent from this project
Stale memoryMemory entries referencing file paths that no longer exist
Duplicate memoryNear-duplicate memory entries across projects (>60% overlap)
Loop detectionAgent stuck in a loop — 3+ consecutive identical commands, or cyclic A,B,A,B patterns
Memory index overflowMEMORY.md exceeds Claude Code's documented 200-line / 25KB session-load cap, so entries past the cap are invisible to the agent
Shared temp pathA fixed temp path (e.g. /tmp/pkg.bak) the agent writes and later reads back — any concurrent session can overwrite it in between
Unverified gateA lint/typecheck/test/build run that errored or printed nothing, followed by agent prose claiming it passed
Default-branch edits10+ files edited on main/master with no intervening commit or branch-away
Unresolvable SHAA memory cites a commit SHA that does not resolve in this repository
Large readsWhole-file Reads of 4,000+ tokens, with an estimate of the tokens they re-send as cached context on later turns (an info-level baseline)

Session Linting Specification

Example Output

ctxlint v0.28.1
Scanning /Users/you/my-app...
Found 2 context files (1,847 tokens total)  CLAUDE.md (1,203 tokens, 42 lines)  AGENTS.md -> CLAUDE.md (symlink)
CLAUDE.md  ✗ Line 12: src/auth/middleware.ts does not exist    → Did you mean src/middleware/auth.ts? (renamed 14 days ago)  ✗ Line 8: "pnpm test" — script "test" not found in package.json  ⚠ Last updated 47 days ago. src/routes/ has 8 commits since.  ⚠ testing framework conflict: "Vitest" in CLAUDE.md vs "Jest" in AGENTS.md  ℹ Line 3: "Express" is in package.json dependencies — agent can infer this
Summary: 2 errors, 2 warnings, 1 info  Token usage: 1,203 tokens per agent session  Estimated waste: ~55 tokens (redundant content)

Options

Usage: ctxlint [options] [command] [path]
Arguments:  path                 Project directory to scan (default: ".")
Options:  --strict                  Exit code 1 on any warning or error (for CI)  --checks <list>           Comma-separated checks to run (see below)  --ignore <list>           Comma-separated checks to skip  --fix                     Auto-fix broken paths using git history and fuzzy matching  --fix-dry-run             Preview --fix changes without writing  --yes                     Skip interactive confirmation prompts (required for --fix in TTY)  --follow-symlinks         Allow --fix to write through symlinks (default: skip)  --format <fmt>            Output format: text, json, or sarif (default: text)  --tokens                  Show token breakdown per file  --verbose                 Show passing checks too  --quiet                   Suppress all output except errors (exit code only)  --config <path>           Path to config file (default: .ctxlintrc in project root)  --depth <n>               Max subdirectory depth to scan (default: 2)  --mcp                     Enable MCP config linting alongside context file checks  --mcp-only                Run only MCP config checks, skip context file checks  --mcp-global              Also scan user/global MCP config files (implies --mcp)  --session                 Enable session audit checks (cross-project consistency)  --session-only            Run only session checks, skip context and MCP checks  --skills                  Run agent-skill checks (~/.claude/skills + ~/.claude/agents)  --skills-only             Run only agent-skill checks, skip everything else  --hooks-global            Also scan the user-global ~/.claude/settings.json in the                            dead-hook check (default scans project .claude/ only)  --mcp-server              Start the MCP server (alias: `serve` subcommand)  --lsp                     Start in LSP server mode (JSON-RPC over stdio for editor integration)  --no-ignore-file          Disable .ctxlintignore suppression (see all findings)  --watch                   Re-lint on context file changes  -V, --version             Output the version number  -h, --help                Display help
Commands:  init                 Set up a git pre-commit hook  serve                Start the MCP server (same as --mcp-server)

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

bash
npx @yawlabs/ctxlint@latest --watch

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

yaml
- name: Lint context files  run: npx @yawlabs/ctxlint@latest --strict

Exit Codes

CodeMeaning
0Success — no issues, or issues below the strict threshold
1Strict mode caught at least one error or warning (--strict is set)
2Config error, invalid CLI option, or internal failure

In non-strict mode ctxlint always exits 0 — it's a reporting tool by default. Pass --strict to enforce in CI.

GitHub Action

yaml
- name: Lint context files  uses: yawlabs/ctxlint-action@v1

Or with options:

yaml
- name: Lint context files  uses: yawlabs/ctxlint-action@v1  with:    args: '--strict --mcp'

SARIF Output (GitHub Code Scanning)

yaml
- name: Lint context files  run: npx @yawlabs/ctxlint@latest --format sarif > ctxlint.sarif
- name: Upload SARIF  uses: github/codeql-action/upload-sarif@v3  with:    sarif_file: ctxlint.sarif

Auto-fix

bash
npx @yawlabs/ctxlint@latest --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

bash
npx @yawlabs/ctxlint@latest init

Sets up a git pre-commit hook that runs ctxlint --strict before each commit.

pre-commit framework

Add to your .pre-commit-config.yaml:

yaml
repos:  - repo: https://github.com/yawlabs/ctxlint    rev: v0.28.1    hooks:      - id: ctxlint

Config File

Create a .ctxlintrc or .ctxlintrc.json in your project root:

json
{  "checks": ["paths", "commands", "tokens", "contradictions", "frontmatter"],  "ignore": ["redundancy"],  "ignoreRules": [    { "check": "paths", "match": "^docs/archive/", "reason": "archived docs cite removed files" }  ],  "strict": true,  "tokenThresholds": {    "info": 500,    "warning": 2000,    "error": 5000,    "aggregate": 4000,    "tierBreakdown": 1000,    "tierAggregate": 4000  },  "contextFiles": ["CONVENTIONS.md", "docs/ai-rules.md"],  "exclude": ["fixtures/**", "examples/**"]}

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

FieldTypeDefaultMeaning
checksstring[]all checksChecks to run. Check names include paths, commands, tokens, tier-tokens, redundancy, contradictions, frontmatter, staleness, ci-coverage, ci-secrets, content-secrets, hook-coverage, plus any mcp-* / session-* / skill-*.
ignorestring[][]Checks to skip, evaluated after checks.
ignoreRulesobject[][]Per-finding suppression, finer than ignore: each rule drops only the findings it matches, and the first matching rule wins. Rules that never fire, and rules missing a reason, are listed in the text report and in JSON _meta.ignoreReport.
ignoreRules[].checkstringrequiredThe check the rule applies to, by exact name (paths, session-stale-memory, ...).
ignoreRules[].matchstringnoneRegex tested against the finding's message. A rule with neither match nor pathPattern drops every finding of its check; with both, both must match.
ignoreRules[].pathPatternstringnoneRegex tested against each path a finding names; the rule fires only when every path matches. Honored only for session-stale-memory: on any other check the rule never fires, and loading the config prints a warning.
ignoreRules[].reasonstringnoneWhy the finding is suppressed. Optional, but rules without one are listed in the report for review.
strictbooleanfalseExit non-zero on any warning or error.
tokenThresholdsobjectsee belowPer-file and cross-file token thresholds.
tokenThresholds.infonumber1000Per-file info threshold for tokens/info.
tokenThresholds.warningnumber3000Per-file warning threshold for tokens/large.
tokenThresholds.errornumber8000Per-file error threshold for tokens/excessive.
tokenThresholds.aggregatenumber5000Cross-file total threshold for tokens/aggregate.
tokenThresholds.tierBreakdownnumber1000Always-loaded file threshold for tier-tokens/section-breakdown.
tokenThresholds.tierAggregatenumber4000Combined always-loaded threshold for tier-tokens/aggregate.
contextFilesstring[][]Extra glob patterns to scan alongside the built-in list.
excludestring[][]Globs of context files to drop from the scan entirely, matched against each file's project-relative path. Removes files rather than suppressing findings, so excluded files are also invisible to the cross-file checks.
mcpbooleanfalseEnable MCP config checks by default (same as --mcp).
mcpOnlybooleanfalseRun only MCP config checks, skip context-file checks (same as --mcp-only).
mcpGlobalbooleanfalseAlso scan user/global MCP configs (same as --mcp-global).
sessionbooleanfalseEnable session audit checks (cross-project consistency); same as --session.
sessionOnlybooleanfalseRun only session checks, skip context and MCP checks (same as --session-only).
skillsbooleanfalseEnable agent-skill checks (~/.claude/skills + ~/.claude/agents); same as --skills.
skillsOnlybooleanfalseRun only agent-skill checks, skip everything else (same as --skills-only).
hooksGlobalbooleanfalseAlso scan the user-global ~/.claude/settings.json in the dead-hook check (same as --hooks-global).

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]:

gitignore
# Blank lines and lines starting with # are skipped.paths                    # every paths finding, in every filetokens CLAUDE.md         # tokens findings in CLAUDE.md onlyredundancy .claude/**    # redundancy findings in files under .claude/
  • 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):

bash
npx -y @yawlabs/ctxlint@latest serve

With Claude Code

bash
claude mcp add ctxlint -- npx -y @yawlabs/ctxlint@latest serve

With .mcp.json (Claude Code project config, Cursor, Windsurf)

Create .mcp.json in your project root:

macOS / Linux / WSL:

json
{  "mcpServers": {    "ctxlint": {      "command": "npx",      "args": ["-y", "@yawlabs/ctxlint@latest", "serve"]    }  }}

Windows:

json
{  "mcpServers": {    "ctxlint": {      "command": "cmd",      "args": ["/c", "npx", "-y", "@yawlabs/ctxlint@latest", "serve"]    }  }}

Tip: This file is safe to commit — it contains no secrets.

With VS Code / GitHub Copilot

Add to .vscode/mcp.json:

json
{  "servers": {    "ctxlint": {      "command": "npx",      "args": ["-y", "@yawlabs/ctxlint@latest", "serve"]    }  }}

With Claude Desktop

Add to your Claude Desktop config (claude_desktop_config.json):

json
{  "mcpServers": {    "ctxlint": {      "command": "npx",      "args": ["-y", "@yawlabs/ctxlint@latest", "serve"]    }  }}

JSON Output

bash
npx @yawlabs/ctxlint@latest --format json

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.

SpecWhat it covers
AI Context File Linting Spec43 rules for validating context files (CLAUDE.md, .cursorrules, AGENTS.md, etc.) across 16 clients. Covers file formats, frontmatter schemas, path/command validation, staleness, token budgets, redundancy, and contradictions.
MCP Config Linting Spec29 rules for validating MCP server configs (.mcp.json, .cursor/mcp.json, .vscode/mcp.json, etc.) across 8 clients. Covers schema validation, hardcoded secrets, env var syntax, deprecated transports, and cross-file consistency.
Agent Session Linting Spec13 rules for auditing agent session data (history, memory) across 8 agents. Covers cross-project secret consistency, config drift, stale memory, and loop detection.
Agent Skill Linting Spec5 rules for auditing Claude Code skill (SKILL.md) and agent (.md) definitions under ~/.claude. Covers frontmatter presence, broken refs, trigger-phrase collisions, orphaned skills, and dead tool restrictions. (v1, experimental)

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]

来源:README.md,提交 bfc74b5

工具

7

ctxlint_audit

Audit AI agent context files (CLAUDE.md, AGENTS.md, etc.) in the project. Checks for stale references, invalid commands, redundant content, contradictions, frontmatter issues, and token waste. Scoped to context-file checks only; MCP-config and session-level checks are exposed as separate tools.

输入参数checksprojectPath

ctxlint_validate_path

Check if a file path referenced in a context file actually exists in the project. Returns the file status and suggests corrections if the path is invalid.

输入参数path必填projectPath

ctxlint_token_report

Get a token count breakdown for all context files in the project. Shows per-file and aggregate token usage, plus estimated waste from redundant content.

输入参数projectPath

ctxlint_fix

Run the linter with --fix mode to auto-correct broken file paths in context files using git history and fuzzy matching. Returns a summary of what was fixed. Pass dryRun: true to preview what would be fixed without writing any files.

输入参数checksdryRunprojectPath

ctxlint_mcp_audit

Lint MCP server configuration files in a project. Checks for schema errors, hardcoded secrets, deprecated transports, wrong env var syntax, URL issues, and cross-client inconsistencies.

输入参数checksprojectPathincludeGlobal

ctxlint_session_audit

Audit AI agent session data for cross-project consistency and session hazards. Checks for missing GitHub secrets, diverged config files and missing workflows across sibling repositories; stale, duplicate or overflowing memory entries; command loops; and, from Claude Code transcripts, shared temp paths, gates claimed clean after failing, edits piling up on the default branch, unresolvable commit SHAs in memory, and large whole-file Reads re-sent as context on later turns.

输入参数checksprojectPath

ctxlint_skill_audit

Audit agent skill and subagent definitions (~/.claude/skills/*/SKILL.md, ~/.claude/agents/*.md). Checks for frontmatter problems, broken file references, trigger collisions, orphaned skill directories, and dead tool restrictions.

输入参数checksprojectPath

版本历史

7
  1. v0.28.1最新Oct 31, 2026
  2. v0.28.0Oct 9, 2026
  3. v0.27.6Oct 7, 2026
  4. v0.27.5Oct 7, 2026
  5. v0.27.4Oct 6, 2026
  6. v0.27.3Sep 30, 2026
  7. v0.27.2Sep 16, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分