Skip to content

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

ContextLint

Lint, score, and compress your AI agent context files.

ContextLint scans CLAUDE.md, AGENTS.md, .cursorrules, Cursor rules, README.md, docs/**/*.md, and GitHub Copilot instructions to find duplicate, outdated, risky, and token-wasting context before Claude, Cursor, Codex, Gemini, or another AI coding agent reads it.

ContextLint demo

Status

Production-usable Rust CLI. Current focus: reliable local scanning, CI usage, and low-friction install.

Implemented:

  • contextlint scan
  • contextlint scan --json
  • contextlint scan --fail-under <score>
  • contextlint report --format markdown
  • contextlint report --format json
  • contextlint init
  • contextlint generate agents
  • contextlint completions <shell>
  • GitHub Action via uses: arsyadal/[email protected]
  • File discovery for common AI context files
  • Approximate token estimation
  • Duplicate instruction detection
  • Noisy section detection
  • Risky phrase detection
  • Outdated note detection
  • Missing backtick file reference detection
  • Missing command/script detection
  • Basic dependency/technology mismatch detection
  • Inline and config ignore support

Install

Via Homebrew:

brew tap arsyadal/tap
brew install contextlint

Via Cargo:

cargo install contextlint

Upgrade:

brew upgrade contextlint
# or
cargo install contextlint --force

Install from source

cargo install --path .

Usage

contextlint scan
contextlint scan --json
contextlint scan --path ./my-project --fail-under 70
contextlint report --format markdown --output contextlint-report.md
contextlint report --format json
contextlint init
contextlint completions bash > contextlint.bash
contextlint generate agents --output AGENTS.generated.md

Try demo fixture:

contextlint scan --path examples/fixtures/messy-context

Example output (abridged):

ContextLint v0.1.3

Project: examples/fixtures/messy-context

Files scanned: 6
✓ README.md (349 tokens)
✓ docs/noisy.md (5152 tokens)

Score: 0/100
Status: Very Noisy

Issues found:
[CRITICAL] Risky instruction contains 'drop table'. <!-- contextlint-ignore -->
[MEDIUM] Duplicate instruction found in 4 files.
[MEDIUM] Referenced command `npm run build` is not available.
[MEDIUM] Referenced path `docs/missing-architecture.md` does not exist. <!-- contextlint-ignore -->
[MEDIUM] Section 'Noisy Historical Context' is noisy/long.

More docs:

Landing site

The marketing site lives in site/ and is built with Next.js, shadcn-style components, Radix UI primitives, and Framer Motion.

cd site
npm install
npm run dev
npm run build

GitHub Action

name: ContextLint

on:
  pull_request:

jobs:
  contextlint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: arsyadal/[email protected]
        with:
          fail-under: "70"

Default scanned files

CLAUDE.md
AGENTS.md
.cursorrules
.cursor/rules/*
README.md
docs/**/*.md
.github/copilot-instructions.md

Config

Create config:

contextlint init

Example .contextlintrc.json:

{
  "include": ["CLAUDE.md", "AGENTS.md", ".cursorrules", "README.md", "docs/**/*.md"],
  "exclude": ["node_modules/**", "dist/**", "build/**", "docs/archive/**"],
  "scoreThreshold": 70,
  "tokenEstimator": "approximate",
  "ignore": ["risky-instruction:docs/archive/**"],
  "rules": {
    "duplicateInstruction": true,
    "outdatedArchitecture": true,
    "riskyInstruction": true,
    "noisySection": true
  }
}

Ignoring issues

Inline ignore:

<!-- contextlint-ignore-next-line -->
Ignore tests during refactor.

Ignore tests during refactor. <!-- contextlint-ignore -->

Config ignore supports rule IDs, path globs, and rule-id:path/glob/**:

{
  "ignore": [
    "duplicate-instruction",
    "docs/archive/**",
    "risky-instruction:docs/stale-context/**"
  ]
}

Scoring

ContextLint starts at 100 and subtracts issue penalties:

critical = -20
high     = -12
medium   = -6
low      = -2

Score bands:

90–100 = Excellent
75–89  = Good
60–74  = Needs Cleanup
40–59  = Risky
0–39   = Very Noisy

Development

cargo fmt --check
cargo check --locked
cargo clippy --locked -- -D warnings
cargo test --locked
cargo run -- scan

Product principle

The best AI context is not the longest context. It is the clearest, safest, and most relevant context.

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages