Skip to content

feat: ctx-ignore setup + enforce in fs tools#36

Merged
arniesaha merged 1 commit intomainfrom
feat/ctx-ignore-setup
Apr 23, 2026
Merged

feat: ctx-ignore setup + enforce in fs tools#36
arniesaha merged 1 commit intomainfrom
feat/ctx-ignore-setup

Conversation

@arniesaha
Copy link
Copy Markdown
Owner

Summary

  • Installed and ran ctx-ignore to generate .contextignore, .claudeignore, .cursorignore
  • Added npm run ctx-ignore for regeneration
  • Wired ignore enforcement into the bot's own read_file / list_files — so the agent stops accidentally slurping node_modules, build artifacts, or huge binary files into its own context window
  • MAX_IGNORE_CONTEXT=false escape hatch for debugging

Why

Part of the context-optimization series addressing yesterday's Claude subscription quota exhaustion. A single bot call to read_file package-lock.json or list_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.ts and package-lock.json out 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 added
  • npm run build — clean
  • Manual: bot read_file package-lock.json returns "(ignored by .contextignore)"
  • Manual: bot list_files . shows filtered output with hidden count

🤖 Generated with Claude Code

- 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>
@arniesaha arniesaha merged commit 2cfc39c into main Apr 23, 2026
1 check passed
@arniesaha arniesaha deleted the feat/ctx-ignore-setup branch April 23, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant