Home
cd ../playbooks
Academic ResearchBeginner

Git Commit Workflow

Structured approach to git commits with quality checks, meaningful messages, and proper staging. Never commit broken code.

5 minutes
By communitySource
#git#commit#version-control#workflow#best-practices

Your git log reads 'fix', 'fix again', 'WIP', 'asdf', 'actually fix this time'. You commit everything at once, skip the build check, and untangling what changed three weeks ago requires forensic archaeology.

Who it's for: developers who want cleaner git history, teams establishing commit conventions, junior developers learning git best practices, open-source contributors following project commit standards, anyone whose git log is a stream of consciousness

Example

"Set up a structured commit workflow for our team" → Pre-commit quality gates (build check, lint, test), conventional commit message format with scope and type, staging review to catch accidental includes, and a checklist that prevents broken commits from ever landing

CLAUDE.md Template

New here? 3-minute setup guide → | Already set up? Copy the template below.

Or install from your terminal:
npx ccplaybooks add git-commit-workflow
# Git Commit Protocol

## Command
`/commit` — Run the commit workflow with quality checks

## Pre-Commit Checklist

Before staging anything:
- [ ] Build passes (`npm run build` or equivalent)
- [ ] Tests pass (`npm test` or equivalent)
- [ ] Lint passes (`npm run lint` or equivalent)
- [ ] No console.logs or debugger statements in production code

Get new playbooks like this one

One email a week with new Claude Code workflows. Free, like everything here.

No spam. Unsubscribe anytime.

README.md

What This Does

This playbook establishes a structured git commit workflow with quality gates. Before committing, verify the build passes, write meaningful commit messages, and ensure only intentional changes are staged.

Prerequisites

  • Claude Code installed and configured
  • A git repository Always review before committing:
git status                  # What's staged?
git diff --staged           # What exactly are the changes?

Exclude patterns:

  • .env files — Never commit
  • node_modules/ — In .gitignore
  • Build artifacts — Usually in .gitignore
  • Large binary files — Use LFS or exclude

Commit Message Format

<type>: <subject>

[optional body]

[optional footer]

Types

  • feat: New feature
  • fix: Bug fix
  • refactor: Code restructure (no behavior change)
  • docs: Documentation only
  • test: Adding/updating tests
  • style: Formatting (no code change)
  • chore: Maintenance (deps, build, etc.)

Subject Rules

  • Imperative mood: "Add feature" not "Added feature"
  • Under 50 characters
  • No period at end
  • Capitalize first letter

Body Rules (if needed)

  • Blank line after subject
  • Wrap at 72 characters
  • Explain "why" not "what" (code shows what)

Examples

Good:

feat: Add user authentication with JWT

Implemented login/logout with JWT tokens stored in httpOnly cookies.
Chose cookies over localStorage for XSS protection.

Closes #123

Bad:

updated some stuff

Commit Workflow

Step 1: Review Changes

git status
git diff

Step 2: Run Quality Checks

npm run build
npm test
npm run lint

Step 3: Stage Selectively

git add src/components/Auth.tsx
git add src/hooks/useAuth.ts

Step 4: Review Staged

git diff --staged

Step 5: Commit with Message

git commit -m "feat: Add JWT authentication"

Step 6: Verify

git log -1  # Check commit looks right

Common Mistakes

Mistake: Committing broken code Fix: Always run build/tests before committing

Mistake: Committing too much at once Fix: Small, focused commits (one logical change each)

Mistake: Vague commit messages Fix: Follow the format. Future you will thank present you.

Mistake: Committing secrets Fix: Use .gitignore, pre-commit hooks, and review diffs carefully

PR-Ready Commits

When preparing for a pull request:

  1. Each commit should be atomic (one logical change)
  2. Each commit should pass tests independently
  3. Consider squashing WIP commits before PR
  4. Rebase on main to avoid merge commits

Quality Score for Commits

Before committing, score against:

  • Build passes (+20)
  • Tests pass (+20)
  • Lint clean (+10)
  • Message follows format (+10)
  • Changes are focused (+10)
  • No accidental files (+10)
  • No secrets/debug code (+20)

Score 80+ to commit. Below 80, fix issues first.


## Step-by-Step Setup

### Step 1: Add to your CLAUDE.md

Add the commit protocol to your project's CLAUDE.md.

### Step 2: Test the workflow

Make a small change, then:

/commit


Claude should guide you through the full workflow.

## Example Usage

**User:**
> "/commit"

**Claude:**
> ## Commit Workflow
>
> ### Step 1: Review Changes
> ```bash
> $ git status
> Modified: src/components/Button.tsx
> Modified: src/styles/button.css
> Untracked: src/components/Button.test.tsx
> ```
>
> ### Step 2: Quality Checks
> - Build: ✓ Passed
> - Tests: ✓ 47/47 passing
> - Lint: ✓ No errors
>
> ### Step 3: Review Diff
> Changes look intentional:
> - Button.tsx: Added loading state prop
> - button.css: Loading spinner styles
> - Button.test.tsx: Test for loading state
>
> ### Step 4: Proposed Commit
> ```
> feat: Add loading state to Button component
>
> Added isLoading prop that shows a spinner and disables the button.
> Includes accessibility attributes (aria-busy, aria-disabled).
> ```
>
> **Quality Score: 90/100**
>
> Stage all 3 files and commit with this message?

**User:**
> "Yes, commit"

**Claude:**
> ```bash
> $ git add src/components/Button.tsx src/styles/button.css src/components/Button.test.tsx
> $ git commit -m "feat: Add loading state to Button component
>
> Added isLoading prop that shows a spinner and disables the button.
> Includes accessibility attributes (aria-busy, aria-disabled)."
>
> [main a1b2c3d] feat: Add loading state to Button component
>  3 files changed, 45 insertions(+), 2 deletions(-)
>  create mode 100644 src/components/Button.test.tsx
> ```
>
> Committed successfully.

## Tips

- **Small commits > big commits**: Easier to review, revert, and understand.
- **Don't commit WIP**: Use stash or a WIP branch instead.
- **Review your own diff**: Catch accidental changes before they're committed.
- **Use conventional commits**: The format enables auto-changelogs and semantic versioning.

## Troubleshooting

**Problem**: Accidentally committed a secret

**Solution**: Immediately: `git reset HEAD~1`, remove secret, re-commit. If pushed, rotate the secret immediately — it's compromised.

**Problem**: Commit is too big

**Solution**: For future commits, commit more frequently. For past commits, consider interactive rebase to split.

**Problem**: Commit message doesn't follow format

**Solution**: Use `git commit --amend` to fix the message (only before pushing).

$Related Playbooks

Academic Research

Idea Catalyst

Find cross-domain research inspiration by decomposing problems, searching other fields, and synthesizing transferable insights.

15 minutes
Intermediate
Academic Research

Interactive Research Interview

Use Claude as an interviewer to formalize vague ideas into concrete specifications. Transform 'I have this intuition...' into a clear research plan.

5 minutes
Beginner
Academic Research

LaTeX Conference Template Organizer

Turn a messy official conference LaTeX .zip into a clean, Overleaf-ready structure — main file cleanup that preserves the required document class and packages, section files split into text/, an anonymous-submission configuration example with a camera-ready restoration checklist, and an auto-generated README with page limits and compilation requirements pulled from the conference site.

5 minutes
Beginner
Academic Research

Iterative Build & Fix Loop

Run builds in a loop that automatically detects errors, fixes them, and re-runs until the build succeeds. Works with any build system: npm, cargo, go, make, gradle, and more.

10 minutes
Intermediate
Academic Research

Knowledge Base Builder

Build a structured knowledge base for your domain with notation registries, application databases, design principles, and anti-patterns.

20 minutes
Intermediate
Academic Research

Literature Review Synthesis

Systematically search, analyze, and synthesize research literature. Extract key findings, identify gaps, and produce structured literature reviews.

10 minutes
Intermediate
Academic Research

Manuscript Referee Review

Get a thorough pre-submission review with referee-style objections. Identify weaknesses before reviewers do, and strengthen your paper proactively.

10 minutes
Intermediate
Academic Research

ML Paper Writing for Top Conferences

Write publication-ready ML/AI papers for NeurIPS, ICML, ICLR, ACL, AAAI, and COLM — a non-negotiable citation-verification workflow against the ~40% hallucination rate in AI-generated references, a claim-ledger gate that stops unsupported claims from reaching manuscript prose, and sentence-level writing principles synthesized from named researchers (Nanda, Farquhar, Gopen & Swan, Lipton, Steinhardt, Perez) who've published extensively at top venues.

10 minutes
Advanced
Academic Research

ML Research Paper Pipeline: Design to Submission

An end-to-end pipeline for ML/AI research papers targeting NeurIPS, ICML, ICLR, ACL, AAAI, and COLM — experiment design tied to claims, incremental-safe execution with an experiment journal, negative-result handling, ensemble self-review with a meta-reviewer, and anonymization-safe submission prep.

15 minutes
Advanced
Academic Research

Multi-Agent Parallel Review

Run multiple specialized review agents in parallel — proofreader, code reviewer, security auditor, etc. Each agent focuses on one dimension with full attention.

15 minutes
Intermediate
Academic Research

Research Paper Structure Editor

Improve the structural clarity of ML/CV/NLP research papers before submission — a reverse-outlining check that maps every paragraph's topic sentence back to the section thesis, section-by-section guidance for Abstract through Conclusion, a five-dimension adversarial self-review, and a claim-evidence map that catches unsupported claims in the Abstract and Introduction before a reviewer does.

5 minutes
Intermediate
Academic Research

Paper Figures to PowerPoint

Extract all figures, tables, and equations from a research paper PDF and generate a polished PowerPoint deck automatically.

10 minutes
Intermediate

Browse all Academic Research playbooks →