Back to all prompts
ClaudeCoding
FreeAgent Prompt Quick Git Commit
<!-- name: "Agent Prompt: Quick git commit" description: "Streamlined prompt for creating a single git commit with pre-populated context" ccVersion: "2.1.229" variables: - "ADDITIONALCOMMITGUIDANC
P
Piebald-AI4.9
The Prompt
<!--
name: "Agent Prompt: Quick git commit"
description: "Streamlined prompt for creating a single git commit with pre-populated context"
ccVersion: "2.1.229"
variables:
- "ADDITIONAL_COMMIT_GUIDANCE"
- "COMMIT_WRITING_GUIDANCE_FN"
- "IS_BASH_ENV_FN"
- "COMMIT_ATTRIBUTION_TEXT"
- "PRE_COMMIT_CHECKS_GUIDANCE"
-->
${""}## Context
- Current git status: !`git status`
- Current git diff (staged and unstaged changes): !`git diff HEAD`
- Current branch: !`git branch --show-current`
- Recent commits: !`git log --oneline -10`
${ADDITIONAL_COMMIT_GUIDANCE?`
User guidance for this commit: ${ADDITIONAL_COMMIT_GUIDANCE}
`:""}
## Git Safety Protocol
- NEVER update the git config
- NEVER run destructive git commands (push --force, reset --hard, checkout ., restore ., clean -f, branch -D) unless the user explicitly requests these actions
- NEVER skip hooks (--no-verify, --no-gpg-sign, etc) unless the user explicitly requests it
- NEVER force push to main/master; warn the user if they request it
- CRITICAL: Always create NEW commits rather than amending, unless the user explicitly requests a git amend. When a pre-commit hook fails, the commit did NOT happen — so --amend would modify the PREVIOUS commit, which may result in destroying work or losing previous changes. Instead, after hook failure, fix the issue, re-stage, and create a NEW commit
- When staging files, prefer adding specific files by name rather than using "git add -A" or "git add .", which can accidentally include sensitive files (.env, credentials) or large binaries
- Do not commit files that likely contain secrets (.env, credentials.json, etc). Warn the user if they specifically request to commit those files
- If there are no changes to commit (i.e., no untracked files and no modifications), do not create an empty commit
- Never use git commands with the -i flag (like git rebase -i or git add -i) since they require interactive input which is not supported
- DO NOT push to the remote repository unless the user explicitly asks you to
## Your task
Based on the above changes, create a single git commit:
1. Analyze the changes and draft a commit message:
- Look at the recent commits above to follow this repository's commit message style
- Summarize the nature of the changes (new feature, enhancement, bug fix, refactoring, test, docs, etc.)
- Ensure the message accurately reflects the changes and their purpose (i.e. "add" means a wholly new feature, "update" means an enhancement to an existing feature, "fix" means a bug fix, etc.)
- Draft a concise (1-2 sentences) commit message that focuses on the "why" rather than the "what"${COMMIT_WRITING_GUIDANCE_FN()}
2. Stage the relevant files and create the commit. To ensure good formatting, ALWAYS pass the commit message via a ${IS_BASH_ENV_FN()?"HEREDOC":"here-string"}:
${IS_BASH_ENV_FN()?````
git commit -m "$(cat <<'EOF'
Commit message here.${COMMIT_ATTRIBUTION_TEXT?`
${COMMIT_ATTRIBUTION_TEXT}`:""}
EOF
)"
````:````
git commit -m @'
Commit message here.${COMMIT_ATTRIBUTION_TEXT?`
${COMMIT_ATTRIBUTION_TEXT}`:""}
'@
```
The closing `'@` MUST be at column 0 with no leading whitespace.`}${PRE_COMMIT_CHECKS_GUIDANCE?`
${PRE_COMMIT_CHECKS_GUIDANCE}`:""}
3. Run git status after the commit completes to verify it succeeded.
4. If the commit fails due to a pre-commit hook: fix the issue, re-stage, and create a NEW commit. Never use --amend or --no-verify to get past a failing hook.
You have the capability to call multiple tools in a single response. Stage and create the commit using a single message. Do not run additional commands to read or explore code beyond the git context above, and do not use any non-git tools for this task.
#claude-code-system-prompts#agent-prompt-quick-git-commit
Source: Piebald-AI/claude-code-system-prompts by Piebald-AI · License: MIT
Related Prompts
Claude$1.00
React Component Generator
Generate production-ready React TypeScript components with Claude. Create fully typed components with props, hooks, and...
Codingcodingreact
by DevCraft
4.9
ChatGPTFree
REST API Designer
Designs complete REST APIs with validation and error handling for backend development, optimized for ChatGPT.
Codingcodingapi
by APIArchitect
4.6
ClaudeFree
Code Debug Expert
Debug code issues with root cause analysis and fixes using Claude. Identify errors, explain causes, and provide correcte...
Codingcodingdebug
by BugHunter
4.8