Git Commit Discipline Prompt for AI Coding Agents
A user shared a prompt rule to enforce git commit discipline in AI coding agents like Claude Code. - The rule requires that every task that changes files must end with a git commit before the final response. - It instructs the agent to inspect git status, treat pre-existing changes as user-owned, review diffs, run verification, and stage only relevant files. - Commits must have concise descriptive messages on main, report the commit hash, and not push, amend, or rewrite history unless asked. - Read-only tasks do not create empty commits.
Key insights
Explicit Git Commit Rules Reduce Risk and Improve Traceability in AI-Assisted Development
The shared prompt addresses a common pain point: AI coding agents making changes without proper version control. By mandating a commit after every file-changing task, with careful staging and verification, the rule ensures that changes are trackable and reversible. It also prevents the agent from bundling unrelated changes or pushing to remote repositories without permission, reducing the risk of accidentally corrupting shared codebases.