feat: ctx-ignore setup + enforce in fs tools#36
Merged
Conversation
- Generated .contextignore / .claudeignore / .cursorignore via `ctx-ignore scan` (github.com/arniesaha/ctx-ignore) - Added `npm run ctx-ignore` script for regeneration - New src/tools/ignore.ts: walk-up loader + isIgnored/filterIgnored helpers, cached per root, with MAX_IGNORE_CONTEXT=false escape hatch - read_file returns an "(ignored)" stub instead of dumping huge files (node_modules, build artifacts, binaries) - list_files filters ignored entries and reports hidden count - Kept test files and package-lock.json OUT of the patched .gitignore (ctx-ignore's default patches those, but they belong in git) Part of the context-optimization series addressing yesterday's Claude subscription quota exhaustion. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.contextignore,.claudeignore,.cursorignorenpm run ctx-ignorefor regenerationread_file/list_files— so the agent stops accidentally slurpingnode_modules, build artifacts, or huge binary files into its own context windowMAX_IGNORE_CONTEXT=falseescape hatch for debuggingWhy
Part of the context-optimization series addressing yesterday's Claude subscription quota exhaustion. A single bot call to
read_file package-lock.jsonorlist_files node_modules/can dump tens of thousands of tokens into history that are re-sent on every subsequent tool iteration.Scan reported a 99.9% reduction in theoretical scan surface (69.7M → 62.8K tokens).
Kept
*.test.tsandpackage-lock.jsonout of the gitignore patch — tests document behavior and lockfiles belong in git; they're ignored only for AI-context purposes.Test plan
npm test— all 76 tests pass, 4 new ignore tests addednpm run build— cleanread_file package-lock.jsonreturns "(ignored by .contextignore)"list_files .shows filtered output with hidden count🤖 Generated with Claude Code