@yawlabs/ctxlint 0.2.2 → 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 +54 -17
- package/dist/index.js +706 -70
- package/dist/mcp/server.js +566 -47
- package/package.json +25 -11
package/README.md
CHANGED
|
@@ -21,34 +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/rules/*.mdc` | 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
|
-
| `CODEX.md` | OpenAI Codex CLI |
|
|
42
42
|
| `.aiderules` | Aider |
|
|
43
43
|
| `.aide/rules/*.md` | Aide / Codestory |
|
|
44
44
|
| `.amazonq/rules/*.md` | Amazon Q Developer |
|
|
45
|
-
| `.goose/instructions.md` | Goose by Block |
|
|
46
|
-
|
|
|
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 |
|
|
47
51
|
|
|
48
52
|
## Example Output
|
|
49
53
|
|
|
50
54
|
```
|
|
51
|
-
ctxlint v0.
|
|
55
|
+
ctxlint v0.3.0
|
|
52
56
|
|
|
53
57
|
Scanning /Users/you/my-app...
|
|
54
58
|
|
|
@@ -61,9 +65,10 @@ CLAUDE.md
|
|
|
61
65
|
→ Did you mean src/middleware/auth.ts? (renamed 14 days ago)
|
|
62
66
|
✗ Line 8: "pnpm test" — script "test" not found in package.json
|
|
63
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
|
|
64
69
|
ℹ Line 3: "Express" is in package.json dependencies — agent can infer this
|
|
65
70
|
|
|
66
|
-
Summary: 2 errors,
|
|
71
|
+
Summary: 2 errors, 2 warnings, 1 info
|
|
67
72
|
Token usage: 1,203 tokens per agent session
|
|
68
73
|
Estimated waste: ~55 tokens (redundant content)
|
|
69
74
|
```
|
|
@@ -78,12 +83,15 @@ Arguments:
|
|
|
78
83
|
|
|
79
84
|
Options:
|
|
80
85
|
--strict Exit code 1 on any warning or error (for CI)
|
|
81
|
-
--checks <list> Comma-separated: paths, commands, staleness, tokens, redundancy
|
|
86
|
+
--checks <list> Comma-separated: paths, commands, staleness, tokens, redundancy, contradictions, frontmatter
|
|
82
87
|
--ignore <list> Comma-separated checks to skip
|
|
83
88
|
--fix Auto-fix broken paths using git history and fuzzy matching
|
|
84
|
-
--format
|
|
89
|
+
--format <fmt> Output format: text, json, or sarif (default: text)
|
|
85
90
|
--tokens Show token breakdown per file
|
|
86
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)
|
|
87
95
|
-V, --version Output the version number
|
|
88
96
|
-h, --help Display help
|
|
89
97
|
|
|
@@ -100,6 +108,18 @@ Commands:
|
|
|
100
108
|
|
|
101
109
|
Exits with code 1 if any errors or warnings are found.
|
|
102
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
|
+
|
|
103
123
|
## Auto-fix
|
|
104
124
|
|
|
105
125
|
```bash
|
|
@@ -110,19 +130,33 @@ When a broken path was renamed in git or has a close match in the project, `--fi
|
|
|
110
130
|
|
|
111
131
|
## Pre-commit Hook
|
|
112
132
|
|
|
133
|
+
### Built-in
|
|
134
|
+
|
|
113
135
|
```bash
|
|
114
136
|
npx @yawlabs/ctxlint init
|
|
115
137
|
```
|
|
116
138
|
|
|
117
139
|
Sets up a git pre-commit hook that runs `ctxlint --strict` before each commit.
|
|
118
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
|
+
|
|
119
153
|
## Config File
|
|
120
154
|
|
|
121
155
|
Create a `.ctxlintrc` or `.ctxlintrc.json` in your project root:
|
|
122
156
|
|
|
123
157
|
```json
|
|
124
158
|
{
|
|
125
|
-
"checks": ["paths", "commands", "tokens"],
|
|
159
|
+
"checks": ["paths", "commands", "tokens", "contradictions", "frontmatter"],
|
|
126
160
|
"ignore": ["redundancy"],
|
|
127
161
|
"strict": true,
|
|
128
162
|
"tokenThresholds": {
|
|
@@ -130,11 +164,14 @@ Create a `.ctxlintrc` or `.ctxlintrc.json` in your project root:
|
|
|
130
164
|
"warning": 2000,
|
|
131
165
|
"error": 5000,
|
|
132
166
|
"aggregate": 4000
|
|
133
|
-
}
|
|
167
|
+
},
|
|
168
|
+
"contextFiles": ["CONVENTIONS.md", "docs/ai-rules.md"]
|
|
134
169
|
}
|
|
135
170
|
```
|
|
136
171
|
|
|
137
|
-
|
|
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.
|
|
138
175
|
|
|
139
176
|
## Use as MCP Server
|
|
140
177
|
|