How Claude Code handles git commits and pull requests, including git safety protocols and best practices. Use when user asks about creating commits, making PRs, git workflows, or git safety.
Automates git commits and PR creation with built-in safety protocols. Creates commits only when explicitly requested, following repository conventions and avoiding destructive operations. Generates PRs with comprehensive summaries using GitHub CLI.
/plugin marketplace add reggiechan74/claude-plugins/plugin install claude-code-metaskill@claude-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Claude Code provides intelligent git workflow automation with built-in safety protocols. It can create commits, generate pull requests, and manage git operations while following best practices and security guidelines.
NEVER:
Avoid git commit --amend - ONLY use --amend when either:
Before amending:
git log -1 --format='%an %ae'Only create commits when the user explicitly requests them. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.
Step 1 - Gather Information (in parallel): Run these bash commands simultaneously:
git status - see all untracked filesgit diff - see both staged and unstaged changesgit log - see recent commit messages to follow the repository's commit message styleStep 2 - Analyze and Draft:
Step 3 - Execute Commit (sequentially): Add relevant untracked files to the staging area, then create the commit with a message ending with:
š¤ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Then run git status after the commit completes to verify success.
Step 4 - Handle Pre-commit Hooks: If the commit fails due to pre-commit hook changes, retry ONCE. If it succeeds but files were modified by the hook, verify it's safe to amend:
git log -1 --format='%an %ae'git status shows "Your branch is ahead"Always pass the commit message via HEREDOC for good formatting:
git commit -m "$(cat <<'EOF'
Commit message here.
š¤ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
Use the gh command via the Bash tool for ALL GitHub-related tasks including working with issues, pull requests, checks, and releases.
Step 1 - Understand Branch State (in parallel): Run these bash commands simultaneously:
git status - see all untracked filesgit diff - see both staged and unstaged changesgit log and git diff [base-branch]...HEAD - understand the full commit history from when the branch divergedStep 2 - Analyze All Commits: Analyze all changes that will be included in the pull request, making sure to look at all relevant commits (NOT just the latest commit, but ALL commits that will be included in the pull request).
Draft a pull request summary covering:
Step 3 - Create PR (in parallel if needed):
gh pr create with the format belowUse a HEREDOC to pass the body for correct formatting:
gh pr create --title "the pr title" --body "$(cat <<'EOF'
## Summary
<1-3 bullet points>
## Test plan
[Bulleted markdown checklist of TODOs for testing the pull request...]
š¤ Generated with [Claude Code](https://claude.com/claude-code)
EOF
)"
The gh command provides comprehensive GitHub integration:
View PR comments:
gh api repos/foo/bar/pulls/123/comments
Work with issues:
gh issue list
gh issue create --title "Bug report" --body "Description"
Check PR status:
gh pr status
gh pr view 123
Create employment contracts, offer letters, and HR policy documents following legal best practices. Use when drafting employment agreements, creating HR policies, or standardizing employment documentation.
Implement GDPR-compliant data handling with consent management, data subject rights, and privacy by design. Use when building systems that process EU personal data, implementing privacy controls, or conducting GDPR compliance reviews.