Learning CenterClaude CodeGit Workflow with Claude Code
Intermediate6 min read

Git Workflow with Claude Code

Let Claude manage commits, branches, and PRs while you focus on outcomes.

Claude Code as Your Git Partner

Claude Code has full git capabilities: status, diff, commit, branch, push, PR creation. It can handle the entire commit workflow while you focus on the feature.

Conventional Commits

Always use conventional commit format:

feat: add user avatar upload to profile page
fix: resolve race condition in session refresh
refactor: extract auth logic into dedicated hook
chore: upgrade Next.js 15 → 16

Claude will suggest commit messages in this format. Review them before accepting — commit messages are documentation.

Branch Naming Convention

For tracked work, use the project ticket format:

cc-113-learning-center
feat/user-avatars
fix/session-race-condition

The Safe Git Workflow

Ask Claude to:

  1. Run git status to review all changes
  2. Run git diff to inspect diffs before staging
  3. Stage specific files (never git add . blindly)
  4. Commit with a descriptive message
  5. Push and create a PR if ready

What Claude Should Never Do

  • git push --force on main/master (never)
  • git reset --hard without explicit approval
  • git commit --no-verify (bypasses hooks)
  • Commit .env or secrets files

Configure these as PreToolUse hooks to enforce at the system level, not just as instructions.

PR Workflow

When creating PRs, Claude should:

  1. Review the full commit history (not just the latest commit)
  2. Run git diff main...HEAD to see all changes
  3. Write a comprehensive PR summary with test plan
  4. Check for PR templates in .github/

The PR title and body are the permanent record of your work — invest in them.

Loading…