[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

  1. Have a .gitignore with a directory listed (e.g., Future Modules/)
  2. Ask Claude Code to create a file in that directory
  3. Claude creates the file, then suggests "Want me to commit and push?"
  4. User must manually catch and ask "is that gitignored?" -- only then does Claude check

Current Behavior

  • Claude suggests git add + git commit for 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:

  1. Run git check-ignore <file> or check .gitignore patterns for target files
  2. Warn the user if the file is gitignored
  3. 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

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗