Skip to content

[BUG] System prompt wastes >10k tokens on large git repos that cannot be disabled #8245

@verbraucher

Description

@verbraucher

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?

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 .git folder, 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 .git is in permissions.deny, no git data should be loaded
  • System prompt should be ~3k tokens, not 23k+ tokens
  • OR a --no-git or 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

  1. Clone any large repository with 10000+ commits
  2. Add to .claude/settings.json:
   {"permissions": {"deny": ["Read(./.git/**)", "Read(./.git)"]}}
  1. Start Claude Code: claude
  2. Run /context command
  3. Note "System prompt" size (will be >20k tokens)
  4. Exit Claude, rename: mv .git .git.bak
  5. Start Claude Code again: claude
  6. Run /context command
  7. Compare system prompt (now ~3k tokens)
  8. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corebugSomething isn't workinghas reproHas detailed reproduction stepsmemoryplatform:linuxIssue specifically occurs on Linux

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions