[BUG] System prompt wastes >10k tokens on large git repos that cannot be disabled
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Problem
Claude Code automatically loads git repository information into the system prompt. In large repos/monorepos, this consumes >20k tokens that cannot be disabled.
Evidence
Using /context command shows:
- With .git: System prompt 23.7k tokens
- Without .git: System prompt 3.1k tokens
- Impact: ~20k tokens wasted
Current Behavior
Setting permissions.deny has no effect:
json
{
"permissions": {
"deny": ["Read(./.git/**)", "Read(./.git)", "Write(./.git/**)", "Write(./.git)"]
}
}
The git context is loaded during initialization, before permission rules are evaluated.
Why This Matters
- Performance: Slower startup, unnecessary API calls
- Context: 10%+ of available context consumed before any work
-
Workaround: Must rename
.gitfolder, breaking git workflow
What Should Happen?
Claude Code should respect permissions.deny rules BEFORE loading git context, or provide a configuration option to disable git loading entirely.
Expected behavior:
- When
.gitis in permissions.deny, no git data should be loaded - System prompt should be ~3k tokens, not 23k+ tokens
- OR a
--no-gitor sth. else flag should be available to skip git detection
Error Messages/Logs
No errors - silent token consumption in system prompt.
See /context output screenshots showing 20k+ token difference.
Steps to Reproduce
- Clone any large repository with 10000+ commits
- Add to
.claude/settings.json:
{"permissions": {"deny": ["Read(./.git/**)", "Read(./.git)"]}}
- Start Claude Code: claude
- Run /context command
- Note "System prompt" size (will be >20k tokens)
- Exit Claude, rename: mv .git .git.bak
- Start Claude Code again: claude
- Run /context command
- Compare system prompt (now ~3k tokens)
- Difference = wasted git context tokens
Claude Model
Sonnet (default)
Claude Code Version
1.0.127
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
WSL (Windows Subsystem for Linux)
Additional Information
Related Issues
- #1104 - Closed incorrectly, deny patterns don't prevent git loading
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/1104
- https://github.com/anthropics/claude-code/issues/7781
- https://github.com/anthropics/claude-code/issues/1857
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and 👍 the existing issue instead
- To prevent auto-closure, add a comment or 👎 this comment
🤖 Generated with Claude Code
+1
+1
The same problem here: It add me more then 10k tokens in prompt.
While I don't have this specific issue. I wish there was an option to disable this behavior.
When I ask Claude Code to review recent code changes based on a diff I find it having the commit messages in its context gives it a bias to confirm what the git messages is claiming the changes are doing rather then just looking at the code.
I just wasted 10% of my weekly context usage because of this behavior (loading gitStatus in context, by default, without any ability to turn it off).
Claude has accidentally produced a large git commit message (2000 lines long), which was being loaded in every single chat.
Please make it possible to disable this behavior 🙏 Loading the git status is not necessary for most tasks!
Workaround:
cp ~/npm-global/bin/claude ~/npm-global/bin/claude.bak
vim ~/npm-global/bin/claude
:%s/CQ("git"/CQ("true git"/g
:wq