[Feature Request] Auto-check .gitignore before suggesting git add/commit
Status Closed — duplicate
Maintainer reply None cached
Activity 3 comments · opened Mar 25, 2026 · closed Mar 29, 2026
Problem
Claude Code suggests committing gitignored files without checking .gitignore first. Even with explicit CLAUDE.md rules ("NEVER commit gitignored files -- check .gitignore when unsure"), Claude still proposes "Want me to commit and push?" for files in gitignored directories.
Steps to Reproduce
- Have a
.gitignorewith a directory listed (e.g.,Future Modules/) - Ask Claude Code to create a file in that directory
- Claude creates the file, then suggests "Want me to commit and push?"
- User must manually catch and ask "is that gitignored?" -- only then does Claude check
Current Behavior
- Claude suggests
git add+git commitfor gitignored files - Relies on user or CLAUDE.md instructions to prevent the error
- No automated validation before suggesting commit
Expected Behavior
Before suggesting git add or git commit, Claude Code should:
- Run
git check-ignore <file>or check .gitignore patterns for target files - Warn the user if the file is gitignored
- Skip gitignored files from commit suggestions automatically
Why This Matters
Prevents accidental commits of:
- Private configuration files (API keys, credentials)
- Local caches and database files
- User-generated logs and temporary data
- Planning/spec documents marked as local-only
Environment
- Claude Code: VS Code extension (latest)
- OS: Windows 11 Pro
- Model: Claude Opus 4.6
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗