@yawlabs/ctxlint 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -17
- package/dist/index.js +730 -97
- package/dist/mcp/server.js +662 -63
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -21,29 +21,38 @@ npx @yawlabs/ctxlint
|
|
|
21
21
|
| Check | What it finds |
|
|
22
22
|
|-------|--------------|
|
|
23
23
|
| **Broken paths** | File references in context that don't exist in your project |
|
|
24
|
-
| **Wrong commands** | Build/test commands that don't match your package.json scripts |
|
|
24
|
+
| **Wrong commands** | Build/test commands that don't match your package.json scripts or Makefile targets |
|
|
25
25
|
| **Stale context** | Context files not updated after recent code changes |
|
|
26
26
|
| **Token waste** | How much context window your files consume per session |
|
|
27
27
|
| **Redundancy** | Content the agent can already infer (e.g. "We use React" when react is in package.json) |
|
|
28
|
+
| **Contradictions** | Conflicting directives across context files (e.g. "use Jest" in one, "use Vitest" in another) |
|
|
29
|
+
| **Frontmatter** | Invalid or missing YAML frontmatter in Cursor .mdc, Copilot instructions, and Windsurf rules |
|
|
28
30
|
|
|
29
31
|
## Supported Context Files
|
|
30
32
|
|
|
31
33
|
| File | Tool |
|
|
32
34
|
|------|------|
|
|
33
|
-
| `CLAUDE.md`, `CLAUDE.local.md` | Claude Code |
|
|
34
|
-
| `AGENTS.md` | Multi-agent |
|
|
35
|
-
| `.cursorrules`, `.cursor/rules/*.md` | Cursor |
|
|
36
|
-
|
|
|
35
|
+
| `CLAUDE.md`, `CLAUDE.local.md`, `.claude/rules/*.md` | Claude Code |
|
|
36
|
+
| `AGENTS.md`, `AGENT.md`, `AGENTS.override.md` | AAIF / Multi-agent standard |
|
|
37
|
+
| `.cursorrules`, `.cursor/rules/*.md`, `.cursor/rules/*.mdc`, `.cursor/rules/*/RULE.md` | Cursor |
|
|
38
|
+
| `.github/copilot-instructions.md`, `.github/instructions/*.md`, `.github/git-commit-instructions.md` | GitHub Copilot |
|
|
37
39
|
| `.windsurfrules`, `.windsurf/rules/*.md` | Windsurf |
|
|
38
|
-
| `GEMINI.md` | Gemini |
|
|
39
|
-
| `JULES.md` | Jules |
|
|
40
|
+
| `GEMINI.md` | Gemini CLI |
|
|
40
41
|
| `.clinerules` | Cline |
|
|
41
|
-
| `
|
|
42
|
+
| `.aiderules` | Aider |
|
|
43
|
+
| `.aide/rules/*.md` | Aide / Codestory |
|
|
44
|
+
| `.amazonq/rules/*.md` | Amazon Q Developer |
|
|
45
|
+
| `.goose/instructions.md`, `.goosehints` | Goose by Block |
|
|
46
|
+
| `.junie/guidelines.md`, `.junie/AGENTS.md` | JetBrains Junie |
|
|
47
|
+
| `.aiassistant/rules/*.md` | JetBrains AI Assistant |
|
|
48
|
+
| `.continuerules`, `.continue/rules/*.md` | Continue |
|
|
49
|
+
| `.rules` | Zed |
|
|
50
|
+
| `replit.md` | Replit |
|
|
42
51
|
|
|
43
52
|
## Example Output
|
|
44
53
|
|
|
45
54
|
```
|
|
46
|
-
ctxlint v0.
|
|
55
|
+
ctxlint v0.3.0
|
|
47
56
|
|
|
48
57
|
Scanning /Users/you/my-app...
|
|
49
58
|
|
|
@@ -56,9 +65,10 @@ CLAUDE.md
|
|
|
56
65
|
→ Did you mean src/middleware/auth.ts? (renamed 14 days ago)
|
|
57
66
|
✗ Line 8: "pnpm test" — script "test" not found in package.json
|
|
58
67
|
⚠ Last updated 47 days ago. src/routes/ has 8 commits since.
|
|
68
|
+
⚠ testing framework conflict: "Vitest" in CLAUDE.md vs "Jest" in AGENTS.md
|
|
59
69
|
ℹ Line 3: "Express" is in package.json dependencies — agent can infer this
|
|
60
70
|
|
|
61
|
-
Summary: 2 errors,
|
|
71
|
+
Summary: 2 errors, 2 warnings, 1 info
|
|
62
72
|
Token usage: 1,203 tokens per agent session
|
|
63
73
|
Estimated waste: ~55 tokens (redundant content)
|
|
64
74
|
```
|
|
@@ -73,12 +83,15 @@ Arguments:
|
|
|
73
83
|
|
|
74
84
|
Options:
|
|
75
85
|
--strict Exit code 1 on any warning or error (for CI)
|
|
76
|
-
--checks <list> Comma-separated: paths, commands, staleness, tokens, redundancy
|
|
86
|
+
--checks <list> Comma-separated: paths, commands, staleness, tokens, redundancy, contradictions, frontmatter
|
|
77
87
|
--ignore <list> Comma-separated checks to skip
|
|
78
88
|
--fix Auto-fix broken paths using git history and fuzzy matching
|
|
79
|
-
--format
|
|
89
|
+
--format <fmt> Output format: text, json, or sarif (default: text)
|
|
80
90
|
--tokens Show token breakdown per file
|
|
81
91
|
--verbose Show passing checks too
|
|
92
|
+
--quiet Suppress all output (exit code only, for scripts)
|
|
93
|
+
--config <path> Path to config file (default: .ctxlintrc in project root)
|
|
94
|
+
--depth <n> Max subdirectory depth to scan (default: 2)
|
|
82
95
|
-V, --version Output the version number
|
|
83
96
|
-h, --help Display help
|
|
84
97
|
|
|
@@ -95,6 +108,18 @@ Commands:
|
|
|
95
108
|
|
|
96
109
|
Exits with code 1 if any errors or warnings are found.
|
|
97
110
|
|
|
111
|
+
### SARIF Output (GitHub Code Scanning)
|
|
112
|
+
|
|
113
|
+
```yaml
|
|
114
|
+
- name: Lint context files
|
|
115
|
+
run: npx @yawlabs/ctxlint --format sarif > ctxlint.sarif
|
|
116
|
+
|
|
117
|
+
- name: Upload SARIF
|
|
118
|
+
uses: github/codeql-action/upload-sarif@v3
|
|
119
|
+
with:
|
|
120
|
+
sarif_file: ctxlint.sarif
|
|
121
|
+
```
|
|
122
|
+
|
|
98
123
|
## Auto-fix
|
|
99
124
|
|
|
100
125
|
```bash
|
|
@@ -105,19 +130,33 @@ When a broken path was renamed in git or has a close match in the project, `--fi
|
|
|
105
130
|
|
|
106
131
|
## Pre-commit Hook
|
|
107
132
|
|
|
133
|
+
### Built-in
|
|
134
|
+
|
|
108
135
|
```bash
|
|
109
136
|
npx @yawlabs/ctxlint init
|
|
110
137
|
```
|
|
111
138
|
|
|
112
139
|
Sets up a git pre-commit hook that runs `ctxlint --strict` before each commit.
|
|
113
140
|
|
|
141
|
+
### pre-commit framework
|
|
142
|
+
|
|
143
|
+
Add to your `.pre-commit-config.yaml`:
|
|
144
|
+
|
|
145
|
+
```yaml
|
|
146
|
+
repos:
|
|
147
|
+
- repo: https://github.com/yawlabs/ctxlint
|
|
148
|
+
rev: v0.3.0
|
|
149
|
+
hooks:
|
|
150
|
+
- id: ctxlint
|
|
151
|
+
```
|
|
152
|
+
|
|
114
153
|
## Config File
|
|
115
154
|
|
|
116
155
|
Create a `.ctxlintrc` or `.ctxlintrc.json` in your project root:
|
|
117
156
|
|
|
118
157
|
```json
|
|
119
158
|
{
|
|
120
|
-
"checks": ["paths", "commands", "tokens"],
|
|
159
|
+
"checks": ["paths", "commands", "tokens", "contradictions", "frontmatter"],
|
|
121
160
|
"ignore": ["redundancy"],
|
|
122
161
|
"strict": true,
|
|
123
162
|
"tokenThresholds": {
|
|
@@ -125,19 +164,22 @@ Create a `.ctxlintrc` or `.ctxlintrc.json` in your project root:
|
|
|
125
164
|
"warning": 2000,
|
|
126
165
|
"error": 5000,
|
|
127
166
|
"aggregate": 4000
|
|
128
|
-
}
|
|
167
|
+
},
|
|
168
|
+
"contextFiles": ["CONVENTIONS.md", "docs/ai-rules.md"]
|
|
129
169
|
}
|
|
130
170
|
```
|
|
131
171
|
|
|
132
|
-
|
|
172
|
+
The `contextFiles` array adds custom file patterns to scan alongside the built-in list. Useful for project-specific context files like `CONVENTIONS.md`.
|
|
173
|
+
|
|
174
|
+
CLI flags override config file settings. Use `--config <path>` to load a config from a custom location.
|
|
133
175
|
|
|
134
176
|
## Use as MCP Server
|
|
135
177
|
|
|
136
|
-
ctxlint ships with an MCP server that exposes
|
|
178
|
+
ctxlint ships with an MCP server that exposes four tools (`ctxlint_audit`, `ctxlint_validate_path`, `ctxlint_token_report`, `ctxlint_fix`):
|
|
137
179
|
|
|
138
180
|
```bash
|
|
139
181
|
# Claude Code
|
|
140
|
-
claude mcp add ctxlint -- node node_modules/ctxlint/dist/mcp/server.js
|
|
182
|
+
claude mcp add ctxlint -- node node_modules/@yawlabs/ctxlint/dist/mcp/server.js
|
|
141
183
|
|
|
142
184
|
# Or run from source
|
|
143
185
|
claude mcp add ctxlint -- node /path/to/ctxlint/dist/mcp/server.js
|