[Feature Request] Add repository-level setting to disable automatic Git context loading
Problem
Claude Code automatically loads Git information (git status, commit history from .git/logs/HEAD, etc.) at the start of every session. While this is helpful for active development projects, it can be unnecessary for certain types of repositories.
Observed Token Consumption
In a repository with 73 commit entries in .git/logs/HEAD:
- Commit history alone: ~4,000 tokens (~55 tokens per entry)
- Additional Git metadata: ~14,000 tokens
- Total Git context: ~18,000 tokens per session
For personal repositories like note-taking systems where Git operations are infrequent, this context is rarely used but consumes tokens in every session.
Scaling Impact
The token cost scales with repository history:
- Small repos (10-20 commits): ~3,000-5,000 tokens
- Medium repos (50-100 commits): ~10,000-20,000 tokens
- Large repos (200+ commits): ~25,000+ tokens
Proposed Solution
Add a repository-level setting in .claude/settings.local.json to control Git context loading:
{
"git": {
"autoLoadContext": false
}
}
Or more granular control:
{
"git": {
"includeStatus": true, // git status (minimal cost)
"includeHistory": false, // .git/logs/HEAD
"maxHistoryEntries": 5 // limit history entries if included
}
}
Benefits
- Token efficiency: Significant savings for repos where Git context is rarely needed
- Faster session startup: Less context to process
- Repository-specific configuration: Enable/disable per repository based on workflow
- Backward compatible: Default behavior remains unchanged (all context loaded)
Use Cases
Repos that benefit from disabled Git context:
- Personal note-taking/memo systems
- Documentation-only repositories
- Single-developer projects with minimal Git operations
- Knowledge bases where commits are infrequent
Repos that should keep Git context:
- Team development projects
- Active feature development with frequent commits/PRs
- Projects requiring Git workflow awareness
Current Workaround
We implemented a workaround that reduces .git/logs/HEAD to 2 entries after each commit:
tail -2 .git/logs/HEAD > /tmp/HEAD.new && mv /tmp/HEAD.new .git/logs/HEAD
Result: Saves ~4,000 tokens (commit history portion only)
Limitation: The remaining ~14,000 tokens of Git metadata are still loaded
This demonstrates the need for a proper configuration option.
Related Issues
- #1104 (addressed indexing performance, but not context loading control)
Implementation Notes
- This is a repository-level setting (
.claude/settings.local.json), not global - Only affects automatic context loading at session start
- Git commands (
git status,git commit, etc.) would still work normally when explicitly invoked - Suggestion: Load Git context on-demand when Git-related keywords are detected in user input
Thank you for considering this feature request!
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗