git-workflow-and-versioning

OWNER/REPO · updated May 7, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/addyosmani/agent-skills --skill git-workflow-and-versioning
0 commentsdiscussion
summary

Structures git workflow practices for making code changes, committing, branching, and resolving conflicts.

skill.md
name
git-workflow-and-versioning
description
Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, or when you need to organize work across multiple parallel streams.

Git Workflow and Versioning

Overview

Git is your safety net. Treat commits as save points, branches as sandboxes, and history as documentation. With AI agents generating code at high speed, disciplined version control is the mechanism that keeps changes manageable, reviewable, and reversible.

When to Use

Always. Every code change flows through git.

Core Principles

Trunk-Based Development (Recommended)

Keep main always deployable. Work in short-lived feature branches that merge back within 1-3 days. Long-lived development branches are hidden costs — they diverge, create merge conflicts, and delay integration. DORA research consistently shows trunk-based development correlates with high-performing engineering teams.

main ──●──●──●──●──●──●──●──●──●──  (always deployable)
        ╲      ╱  ╲    ╱
         ●──●─╱    ●──╱    ← short-lived feature branches (1-3 days)

This is the recommended default. Teams using gitflow or long-lived branches can adapt the principles (atomic commits, small changes, descriptive messages) to their branching model — the commit discipline matters more than the specific branching strategy.

  • Dev branches are costs. Every day a branch lives, it accumulates merge risk.
  • Release branches are acceptable. When you need to stabilize a release while main moves forward.
  • Feature flags > long branches. Prefer deploying incomplete work behind flags rather than keeping it on a branch for weeks.

1. Commit Early, Commit Often

Each successful increment gets its own commit. Don't accumulate large uncommitted changes.

Work pattern:
  Implement slice → Test → Verify → Commit → Next slice

Not this:
  Implement everything → Hope it works → Giant commit

Commits are save points. If the next change breaks something, you can revert to the last known-good state instantly.

2. Atomic Commits

Each commit does one logical thing:

# Good: Each commit is self-contained
git log --oneline
a1b2c3d Add task creation endpoint with validation
d4e5f6g Add task creation form component
h7i8j9k Connect form to API and add loading state
m1n2o3p Add task creation tests (unit + integration)

# Bad: Everything mixed together
git log --oneline
x1y2z3a Add task feature, fix sidebar, update deps, refactor utils

3. Descriptive Messages

Commit messages explain the why, not just the what:

# Good: Explains intent
feat: add email validation to registration endpoint

Prevents invalid email formats from reaching the database.
Uses Zod schema validation at the route handler level,
consistent with existing validation patterns in auth.ts.

# Bad: Describes what's obvious from the diff
update auth.ts

Format:

<type>: <short description>

<optional body explaining why, not what>

Types:

  • feat — New feature
  • fix — Bug fix
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests
  • docs — Documentation only
  • chore — Tooling, dependencies, config

4. Keep Concerns Separate

Don't combine formatting changes with behavior changes. Don't combine refactors with features. Each type of change should be a separate commit — and ideally a separate PR:

# Good: Separate concerns
git commit -m "refactor: extract validation logic to shared utility"
git commit -m "feat: add phone number validation to registration"

# Bad: Mixed concerns
git commit -m "refactor validation and add phone number field"

Separate refactoring from feature work. A refactoring change and a feature change are two different changes — submit them separately. This makes each change easier to review, revert, and understand in history. Small cleanups (renaming a variable) can be included in a feature commit at reviewer discretion.

5. Size Your Changes

Target ~100 lines per commit/PR. Changes over ~1000 lines should be split. See the splitting strategies in code-review-and-quality for how to break down large changes.

~100 lines  → Easy to review, easy to revert
~300 lines  → Acceptable for a single logical change
~1000 lines → Split into smaller changes

Branching Strategy

Feature Branches

main (always deployable)
  │
  ├── feature/task-creation    ← One feature per branch
  ├── feature/user-settings    ← Parallel work
  └── fix/duplicate-tasks      ← Bug fixes
  • Branch from main (or the team's default branch)
  • Keep branches short-lived (merge within 1-3 days) — long-lived branches are hidden costs
  • Delete branches after merge
  • Prefer feature flags over long-lived branches for incomplete features

Branch Naming

feature/<short-description>   → feature/task-creation
fix/<short-description>       → fix/duplicate-tasks
chore/<short-description>     → chore/update-deps
refactor/<short-description>  → refactor/auth-module

Working with Worktrees

For parallel AI agent work, use git worktrees to run multiple branches simultaneously:

# Create a worktree for a feature branch
git worktree add ../project-feature-a feature/task-creation
git worktree add ../project-feature-b feature/user-settings

# Each worktree is a separate directory with its own branch
# Agents can work in parallel without interfering
ls ../
  project/              ← main branch
  project-feature-a/    ← task-creation branch
  project-feature-b/    ← user-settings branch

# When done, merge and clean up
git worktree remove ../project-feature-a

Benefits:

  • Multiple agents can work on different features simultaneously
  • No branch switching needed (each directory has its own branch)
  • If one experiment fails, delete the worktree — nothing is lost
  • Changes are isolated until explicitly merged

The Save Point Pattern

Agent starts work
    │
    ├── Makes a change
    │   ├── Test passes? → Commit → Continue
    │   └── Test fails? → Revert to last commit → Investigate
    │
    ├── Makes another change
    │   ├── Test passes? → Commit → Continue
    │   └── Test fails? → Revert to last commit → Investigate
    │
    └── Feature complete → All commits form a clean history

This pattern means you never lose more than one increment of work. If an agent goes off the rails, git reset --hard HEAD takes you back to the last successful state.

Change Summaries

After any modification, provide a structured summary. This makes review easier, documents scope discipline, and surfaces unintended changes:

CHANGES MADE:
- src/routes/tasks.ts: Added validation middleware to POST endpoint
- src/lib/validation.ts: Added TaskCreateSchema using Zod

THINGS I DIDN'T TOUCH (intentionally):
- src/routes/auth.ts: Has similar validation gap but out of scope
- src/middleware/error.ts: Error format could be improved (separate task)

POTENTIAL CONCERNS:
- The Zod schema is strict — rejects extra fields. Confirm this is desired.
- Added zod as a dependency (72KB gzipped) — already in package.json

This pattern catches wrong assumptions early and gives reviewers a clear map of the change. The "DIDN'T TOUCH" section is especially important — it shows you exercised scope discipline and didn't go on an unsolicited renovation.

Pre-Commit Hygiene

Before every commit:

# 1. Check what you're about to commit
git diff --staged

# 2. Ensure no secrets
git diff --staged | grep -i "password\|secret\|api_key\|token"

# 3. Run tests
npm test

# 4. Run linting
npm run lint

# 5. Run type checking
npx tsc --noEmit

Automate this with git hooks:

// package.json (using lint-staged + husky)
{
  "lint-staged": {
    "*.{ts,tsx}": ["eslint --fix", "prettier --write"],
    "*.{json,md}": ["prettier --write"]
  }
}

Handling Generated Files

  • Commit generated files only if the project expects them (e.g., package-lock.json, Prisma migrations)
  • Don't commit build output (dist/, .next/), environment files (.env), or IDE config (.vscode/settings.json unless shared)
  • Have a .gitignore that covers: node_modules/, dist/, .env, .env.local, *.pem

Using Git for Debugging

# Find which commit introduced a bug
git bisect start
git bisect bad HEAD
git bisect good <known-good-commit>
# Git checkouts midpoints; run your test at each to narrow down

# View what changed recently
git log --oneline -20
git diff HEAD~5..HEAD -- src/

# Find who last changed a specific line
git blame src/services/task.ts

# Search commit messages for a keyword
git log --grep="validation" --oneline

Common Rationalizations

RationalizationReality
"I'll commit when the feature is done"One giant commit is impossible to review, debug, or revert. Commit each slice.
"The message doesn't matter"Messages are documentation. Future you (and future agents) will need to understand what changed and why.
"I'll squash it all later"Squashing destroys the development narrative. Prefer clean incremental commits from the start.
"Branches add overhead"Short-lived branches are free and prevent conflicting work from colliding. Long-lived branches are the problem — merge within 1-3 days.
"I'll split this change later"Large changes are harder to review, riskier to deploy, and harder to revert. Split before submitting, not after.
"I don't need a .gitignore"Until .env with production secrets gets committed. Set it up immediately.

Red Flags

  • Large uncommitted changes accumulating
  • Commit messages like "fix", "update", "misc"
  • Formatting changes mixed with behavior changes
  • No .gitignore in the project
  • Committing node_modules/, .env, or build artifacts
  • Long-lived branches that diverge significantly from main
  • Force-pushing to shared branches

Verification

For every commit:

  • Commit does one logical thing
  • Message explains the why, follows type conventions
  • Tests pass before committing
  • No secrets in the diff
  • No formatting-only changes mixed with behavior changes
  • .gitignore covers standard exclusions
how to use git-workflow-and-versioning

How to use git-workflow-and-versioning on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add git-workflow-and-versioning
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/addyosmani/agent-skills --skill git-workflow-and-versioning

The skills CLI fetches git-workflow-and-versioning from GitHub repository OWNER/REPO and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/git-workflow-and-versioning

Reload or restart Cursor to activate git-workflow-and-versioning. Access the skill through slash commands (e.g., /git-workflow-and-versioning) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

Accelerate Code Development

Use skill to generate boilerplate code, refactor legacy code, and write tests faster

Example

Generate React component with TypeScript types, styled-components, and comprehensive test suite in minutes

Reduce development time by 40-60% for repetitive coding tasks

Code Review Automation

Systematically review code for bugs, security issues, and style violations

Example

Analyze pull requests for common anti-patterns, suggest performance improvements, flag security vulnerabilities

Catch 70%+ of code issues before human review, improve code quality

Debug Complex Issues

Trace errors through stack traces and identify root causes faster

Example

Analyze error logs, suggest probable causes, recommend fixes with code examples

Cut debugging time by 30-50%, especially for unfamiliar codebases

Learn New Technologies

Get explanations, examples, and best practices for unfamiliar frameworks

Example

Understand Next.js app router, learn Rust ownership, grasp Kubernetes concepts with practical examples

Accelerate learning curve by 2-3x, reduce onboarding time for new tech stacks

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client with skill installation support
  • Basic understanding of programming concepts and version control (Git)
  • Code editor or IDE for testing generated code (VS Code, JetBrains, etc.)
  • Test environment separate from production for validating skill outputs

Time Estimate

15-30 minutes to install and see first useful output

Installation Steps

  1. 1.Install the skill using provided installation command
  2. 2.Verify skill is loaded in Claude Desktop (check ~/.claude/skills directory)
  3. 3.Test skill with simple prompt: 'Help me review this code snippet'
  4. 4.Gradually increase complexity: code generation → refactoring → architecture advice
  5. 5.Review all generated code before committing to repository
  6. 6.Iterate on prompts to improve output quality and relevance
  7. 7.Share effective prompts with team for consistency

Common Pitfalls

  • Blindly trusting generated code without testing—always run tests and manual review
  • Not providing enough context about your project structure and coding standards
  • Expecting perfection on first generation—iteration and refinement are normal
  • Sharing proprietary code or API keys in prompts—maintain confidentiality
  • Over-relying on skill for critical security or business logic code
  • Skipping documentation of why AI-generated code was chosen over alternatives

Best Practices

✓ Do

  • +Always review and test AI-generated code before merging
  • +Provide clear context: language, framework, coding standards, constraints
  • +Use for boilerplate, tests, docs—areas where mistakes are easily caught
  • +Iterate on prompts: start broad, refine with specific requirements
  • +Combine AI suggestions with human judgment and domain expertise
  • +Document successful prompt patterns for team reuse
  • +Keep version control so you can rollback if needed
  • +Use skill for learning and exploration, not production-critical features initially

✗ Don't

  • Don't commit AI code without thorough testing and review
  • Don't expose sensitive code, credentials, or proprietary algorithms
  • Don't use for security-critical code (auth, crypto, payments) without expert review
  • Don't skip peer review process just because AI generated it
  • Don't assume code follows your team's conventions—verify
  • Don't let junior developers skip learning fundamentals by relying solely on AI
  • Don't ignore compiler warnings or test failures in generated code

💡 Pro Tips

  • Describe desired patterns explicitly: 'Use async/await, avoid callbacks'
  • Ask for alternatives: 'Show 3 approaches to solve this, with tradeoffs'
  • Request explanations: 'Explain why this approach is better than X'
  • Use skill for 70% generation + 30% manual refinement for best results
  • Build a prompt library for common patterns (API endpoints, components, tests)
  • Pair program with AI: describe problem → review solution → iterate → refine

When to Use This

✓ Use When

Use coding skills for boilerplate generation, code reviews, refactoring legacy code, writing tests, learning new frameworks, and debugging non-critical issues. Best for repetitive tasks where errors are easy to catch.

✗ Avoid When

Avoid for production security features (auth, encryption, payment processing), complex business logic requiring deep domain knowledge, performance-critical algorithms, or when learning fundamentals is more valuable than speed.

Learning Path

  1. 1Start with simple tasks: generate functions, write tests, explain code
  2. 2Progress to code review: analyze PRs, suggest improvements
  3. 3Advanced: architectural decisions, refactoring strategies, performance optimization
  4. 4Expert: use for exploring new paradigms, researching best practices, mentoring juniors

Integration

  • VS Code
  • JetBrains IDEs
  • Cursor
  • GitHub Copilot
  • Git workflows

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.657 reviews
  • Tariq Rao· Dec 28, 2024

    I recommend git-workflow-and-versioning for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Li Verma· Dec 24, 2024

    git-workflow-and-versioning is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Nikhil Brown· Dec 24, 2024

    git-workflow-and-versioning has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Kaira Robinson· Dec 20, 2024

    Solid pick for teams standardizing on skills: git-workflow-and-versioning is focused, and the summary matches what you get after install.

  • Kaira Garcia· Dec 8, 2024

    Keeps context tight: git-workflow-and-versioning is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Ganesh Mohane· Dec 4, 2024

    Solid pick for teams standardizing on skills: git-workflow-and-versioning is focused, and the summary matches what you get after install.

  • Rahul Santra· Nov 23, 2024

    We added git-workflow-and-versioning from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Li Bansal· Nov 19, 2024

    git-workflow-and-versioning reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Tariq Singh· Nov 15, 2024

    git-workflow-and-versioning fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Aditi Johnson· Nov 11, 2024

    We added git-workflow-and-versioning from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

showing 1-10 of 57

1 / 6