claude-code - 💡(How to fix) Fix [BUG] VS Code extension injects node_modules into system context, ignoring .claudeignore and files.exclude [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#49199Fetched 2026-04-17 08:48:05
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×5commented ×1

Error Message

Error Messages/Logs

Fix Action

Fix / Workaround

Workaround: deleting node_modules before starting Claude Code brings "System tools" back to a normal size. Starting Claude Code from inside the subdirectory instead of the workspace root also avoids the issue.

Code Example

Context is 1621% full
        Autocompact will trigger soon, which discards older messages. Use /compact
        now to control what gets kept.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

When Claude Code is started from a workspace root containing subdirectories with node_modules installed, the VS Code extension scans and injects those files as system tool context. "System tools" in /context shows 3.2m+ tokens (1600%+ of the 200k context window), making the session unusable from the start.

This happens even though node_modules is excluded via .claudeignore, files.exclude in .vscode/settings.json, and denyRead in .claude/settings.json.

What Should Happen?

node_modules directories should be excluded from workspace context scanning, consistent with the exclusions defined in .claudeignore, files.exclude, and permission settings.

Error Messages/Logs

⚠ Context is 1621% full
        Autocompact will trigger soon, which discards older messages. Use /compact
        now to control what gets kept.

Steps to Reproduce

  1. Open a workspace root in VS Code that contains subdirectories (e.g. a multi-repo workspace — the root itself is not a git repo)
  2. Run pnpm install (or npm install) in one of the subdirectories
  3. Start a new Claude Code session from the workspace root
  4. Run /context

Result: "System tools" shows 3.2m tokens (1616%) Expected: System tools shows a few thousand tokens

Workaround: deleting node_modules before starting Claude Code brings "System tools" back to a normal size. Starting Claude Code from inside the subdirectory instead of the workspace root also avoids the issue.

Claude Model

None

Is this a regression?

No, this never worked

Last Working Version

No response

Claude Code Version

2.1.92 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

.claudeignore at workspace root contains /node_modules/ .vscode/settings.json contains files.exclude: { "/node_modules": true } .claude/settings.json contains denyRead: ["/node_modules/"]

None of these prevent the injection. The issue appears to be that the VS Code extension performs its own workspace scan independently of these exclusion mechanisms.

extent analysis

TL;DR

The issue can be worked around by starting Claude Code from inside the subdirectory instead of the workspace root or by deleting node_modules before starting Claude Code.

Guidance

  • The problem seems to stem from the VS Code extension scanning the workspace independently of the defined exclusion mechanisms (.claudeignore, files.exclude, denyRead), leading to an excessive number of tokens being included in the "System tools" context.
  • To verify the issue, follow the provided steps to reproduce, which involve opening a workspace root in VS Code with subdirectories containing node_modules, running pnpm install or npm install, starting a new Claude Code session, and then running /context to observe the large number of tokens.
  • A potential mitigation could involve modifying the VS Code extension to respect the exclusion settings defined in .claudeignore, files.exclude, and denyRead, though this would require changes to the extension itself.
  • Another approach could be to automatically delete or ignore node_modules directories before starting Claude Code, though this might not be desirable in all scenarios.

Example

No specific code snippet is provided as the issue seems related to the interaction between the VS Code extension and the exclusion mechanisms rather than a specific code problem.

Notes

The issue does not appear to be a regression, and the provided version of Claude Code is 2.1.92. The problem is observed on Windows using WSL. The exclusion mechanisms in place (.claudeignore, files.exclude, denyRead) do not prevent the injection of node_modules into the context.

Recommendation

Apply the workaround of starting Claude Code from inside the subdirectory instead of the workspace root, as this avoids the issue without requiring modifications to the extension or deletion of node_modules. This approach allows for a functional workflow while the underlying issue is addressed.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING