Skip to content

Exclude node_modules and similar from project context to reduce token usage #187

Open
@Xayan

Description

Bug Description

It appears that claude receives a lot of unnecessary information about project structure in its system prompt right now, hiking up token usage. Directories like node_modules should be excluded.

Environment Info

  • Platform: macos
  • Terminal: vscode
  • Version: 0.2.19
  • Feedback ID: 26f7d9a8-d2bc-4d1b-8aea-8ec934cf1894

"Debugging" process

> With the exception of file CLAUDE.md, what kind of information, metadata, or tools do you have available right now, without looking anything up specifically?

⏺ I have access to:

  1. Directory structure snapshot (first 1000 files)
  2. Git status showing modified/added files
  3. Recent git commits
  4. Basic environment info (working directory, platform, date)

  This appears to be a VS Code extension project called "Roo Code" with TypeScript source files, various
  configuration files, and a webview UI component.

> > 1. Directory structure snapshot (first 1000 files)

  Please tell me it doesn't include node_modules

⏺ It does include node_modules. The directory structure snapshot shows many node module packages and their files, which makes up a significant portion of the 1000 files shown.

Suggested changes

  1. I think these directories could be ignored by default :
[
  "node_modules",
  "__pycache__",
  "env",
  "venv",
  "target/dependency",
  "build/dependencies",
  "dist",
  "out",
  "bundle",
  "vendor",
  "tmp",
  "temp",
  "deps",
  "pkg",
  "Pods",
]

I've been using this list in my custom build of Roo Code and it reduced the prompt by ~1/4 - but consider that there was limit of 100 files, with 1000 files here it will be so much more.

  1. Would be nice if this was configurable, globally and per-project.

  2. Limit max depth - I suggest 3 for the initial context.

  3. Consider adding additional metadata, like file size or number of lines.

Example

With these changes implemented, here's what the output of this command could look like. Much better, I believe.

## Current Project Structure (max depth: 3)

1.08GB Roo-Code/
├── 10TB yourmom.jar
├── 20.6kB CHANGELOG.md
├── 11.3kB LICENSE
├── 8.19kB README.md
├── 8.19kB assets/
│   ├── 4.1kB docs/
│   │   └── 133B demo.gif
│   └── 4.1kB icons/
│       └── 2.14kB rocket.png
├── 254kB audio/
│   ├── 88.2kB celebration.wav
│   ├── 26.5kB notification.wav
│   └── 132kB progress_loop.wav
├── 6.53MB bin/
│   └── 6.25MB roo-cline-3.7.5.vsix
├── 8.19kB cline_docs/
│   └── 5.47kB settings.md
├── 1.07kB ellipsis.yaml
├── 564B flake.lock
├── 646B flake.nix
├── 1.5kB jest.config.js
├── 2.14kB keyboard-shortcuts-plan.md
├── 585B knip.json
├── 579kB package-lock.json
├── 10.5kB package.json
├── 2.41MB src/
│   ├── 69.6kB __mocks__/
│   │   ├── 16.4kB @modelcontextprotocol/
│   │   ├── 454B McpHub.ts
│   │   ├── 250B default-shell.js
│   │   ├── 136B delay.js
│   │   ├── 8.19kB fs/
│   │   ├── 198B get-folder-size.js
│   │   ├── 183B globby.js
│   │   ├── 344B jest.setup.ts
│   │   ├── 95B os-name.js
│   │   ├── 430B p-wait-for.js
│   │   ├── 463B serialize-error.js
│   │   ├── 160B strip-ansi.js
│   │   └── 1.64kB vscode.js
│   ├── 20.5kB activate/
│   │   ├── 669B handleUri.ts
│   │   ├── 222B index.ts
│   │   ├── 2.43kB registerCodeActions.ts
│   │   ├── 3.52kB registerCommands.ts
│   │   └── 2.44kB registerTerminalActions.ts
│   ├── 336kB api/
│   │   ├── 2.31kB index.ts
│   │   ├── 238kB providers/
│   │   └── 94.2kB transform/
│   ├── 1.21MB core/
│   │   ├── 136kB Cline.ts
│   │   ├── 3.11kB CodeActionProvider.ts
│   │   ├── 6.34kB EditorUtils.ts
│   │   ├── 57.3kB __tests__/
│   │   ├── 12.3kB assistant-message/
│   │   ├── 73.7kB config/
│   │   ├── 160kB diff/
│   │   ├── 16.4kB mentions/
│   │   ├── 580B mode-validator.ts
│   │   ├── 565kB prompts/
│   │   ├── 16.4kB sliding-window/
│   │   └── 152kB webview/
│   ├── 12.3kB exports/
│   │   ├── 1.95kB README.md
│   │   ├── 1.25kB cline.d.ts
│   │   └── 1.97kB index.ts
│   ├── 3.85kB extension.ts
│   ├── 217kB integrations/
│   │   ├── 4.1kB diagnostics/
│   │   ├── 36.9kB editor/
│   │   ├── 28.7kB misc/
│   │   ├── 45.1kB terminal/
│   │   ├── 86kB theme/
│   │   └── 16.4kB workspace/
│   ├── 238kB services/
│   │   ├── 16.4kB browser/
│   │   ├── 77.8kB checkpoints/
│   │   ├── 8.19kB glob/
│   │   ├── 49.2kB mcp/
│   │   ├── 8.19kB ripgrep/
│   │   └── 77.8kB tree-sitter/
│   ├── 147kB shared/
│   │   ├── 6.12kB ExtensionMessage.ts
│   │   ├── 182B HistoryItem.ts
│   │   ├── 3.4kB WebviewMessage.ts
│   │   ├── 36.9kB __tests__/
│   │   ├── 22.1kB api.ts
│   │   ├── 873B array.ts
│   │   ├── 588B checkExistApiConfig.ts
│   │   ├── 2.21kB combineApiRequests.ts
│   │   ├── 2.71kB combineCommandSequences.ts
│   │   ├── 4.01kB context-mentions.ts
│   │   ├── 2.81kB experiments.ts
│   │   ├── 3.11kB getApiMetrics.ts
│   │   ├── 327B globalFileNames.ts
│   │   ├── 1.95kB globalState.ts
│   │   ├── 1.09kB mcp.ts
│   │   ├── 11kB modes.ts
│   │   ├── 6.09kB support-prompt.ts
│   │   ├── 2.18kB tool-groups.ts
│   │   └── 302B vsCodeSelectorUtils.ts
│   ├── 28.7kB test/
│   │   ├── 4.18kB VSCODE_INTEGRATION_TESTS.md
│   │   ├── 647B runTest.ts
│   │   └── 16.4kB suite/
│   └── 131kB utils/
│       ├── 45.1kB __tests__/
│       ├── 1.02kB cost.ts
│       ├── 1.45kB fs.ts
│       ├── 4.28kB git.ts
│       ├── 41kB logging/
│       ├── 4.33kB path.ts
│       ├── 6.73kB shell.ts
│       ├── 924B single-completion-handler.ts
│       ├── 1.5kB sound.ts
│       └── 2.46kB xml-matcher.ts
├── 471B tsconfig.integration.json
├── 715B tsconfig.json
└── 463MB webview-ui/
    ├── 389B components.json
    ├── 295B index.html
    ├── 1.41kB jest.config.cjs
    ├── 705kB package-lock.json
    ├── 2.68kB package.json
    ├── 0B public/
    ├── 954kB src/
    │   ├── 2.86kB App.tsx
    │   ├── 16.4kB __mocks__/
    │   ├── 8.19kB __tests__/
    │   ├── 745kB components/
    │   ├── 16.4kB context/
    │   ├── 10.4kB index.css
    │   ├── 285B index.tsx
    │   ├── 4.1kB lib/
    │   ├── 7.93kB preflight.css
    │   ├── 668B setupTests.ts
    │   ├── 41kB stories/
    │   ├── 86kB utils/
    │   └── 38B vite-env.d.ts
    ├── 545B tsconfig.json
    └── 822B vite.config.ts

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions