Skip to main content
skill CX Codex

git-workflow · bagelhole — Claude Code skill: branches, PRs, releases

A skill that lays out branching strategies, pull request flow and release management so a team settles on one set of Git rules.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add BagelHole/DevOps-Security-Agent-Skills --skill git-workflow -a claude-code
Open on GitHub

What git-workflow does

Three branching models come with commands for each step: trunk-based development for short-lived branches, GitHub Flow for web apps, and GitFlow for versioned products on scheduled releases. You get the checkout, rebase, merge and cleanup lines rather than a description of them.

Commit conventions follow Conventional Commits, with types like feat, fix, docs and refactor, plus a message template wired up through git config --global commit.template ~/.gitmessage. The rest covers a pull request template, branch protection for main written as YAML, a .github/CODEOWNERS example, and hooks: a shell pre-commit script, Husky and lint-staged config in package.json, and commitlint setup.

You need Git installed, a host such as GitHub, GitLab or Bitbucket, and basic Git knowledge. The sample pre-commit hook calls npm run lint and npm run test:unit, so it fails on the first commit in a project without those scripts — worth checking package.json before copying it over.

What it helps with

  • pick a branching model that fits your release cadence
  • protect main and require reviews before merge
  • enforce one commit message format across the team
  • write a pull request template with a checklist
  • add a pre-commit hook that runs lint and tests

Example prompts for the agent

  • Set up GitFlow for a project with scheduled releases
  • Write a pre-commit hook that runs lint and unit tests
  • Draft branch protection rules for main and a CODEOWNERS file

How to install git-workflow

1Skills CLI (Vercel)

npx skills add BagelHole/DevOps-Security-Agent-Skills --skill git-workflow -a claude-code

2Manually: put the files in place

~/.claude/skills/git-workflow/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/git-workflow/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about git-workflow

How do I install git-workflow in Claude?

Run npx skills add BagelHole/DevOps-Security-Agent-Skills --skill git-workflow -a claude-code. The skill lands at ~/.claude/skills/git-workflow/SKILL.md.

What does git-workflow do?

It covers branching strategies, pull request workflow and release management. The point is agreeing on Git rules as a team.

Which branching strategies does it cover?

Trunk-based development, GitHub Flow and GitFlow. Each one comes with the commands to run.

Source text

SKILL.md · MIT
---
name: git-workflow
description: Implement Git branching strategies, PR workflows, and release management patterns. Configure GitFlow, trunk-based development, or GitHub Flow for team collaboration. Use when establishing version control workflows or improving development team collaboration.
license: MIT
metadata:
  author: devops-skills
  version: "1.0"
---

# Git Workflow

Implement effective branching strategies and pull request workflows for team collaboration.

## When to Use This Skill

Use this skill when:
- Establishing team Git workflows
- Implementing branching strategies
- Configuring pull request processes
- Setting up release management
- Improving code review practices

## Prerequisites

- Git installed
- Repository hosting (GitHub, GitLab, Bitbucket)
- Basic Git knowledge

## Branching Strategies

### Trunk-Based Development

Best for: Continuous deployment, small teams, mature CI/CD

```
main ─────●─────●─────●─────●─────●─────●─────●
          │     │     │     │     │     │
          └─●   └─●   └─●   └─●   └─●   └─●
         feature branches (short-lived)
```

```bash
# Create short-lived feature branch
git checkout main
git pull origin main
git checkout -b feature/add-login

# Work and commit frequently
git add .
git commit -m "feat: add login form"

# Keep branch updated
git fetch origin
git rebase origin/main

# Merge quickly (same day ideally)
git checkout main
git pull origin main
git merge feature/add-login
git push origin main
git branch -d feature/add-login
```

### GitHub Flow

Best for: Continuous delivery, web applications

```
main ─────●─────●───────────●─────────────●─────●
          │           ↑           ↑       ↑
          └───●───●───┘           │       │
              feature/login       │       │
                                  │       │
          └───●───●───●───●───────┘       │
              feature/dashboard           │
                                          │
          └───●─────────────────────────┘
              hotfix/security-patch
```

```bash
# Create feature branch from main
git checkout main
git pull origin main
git checkout -b feature/user-dashboard

# Push and create PR
git push -u origin feature/user-dashboard

# After review, merge via PR (squash recommended)
# Delete branch after merge
```

### GitFlow

Best for: Scheduled releases, versioned products

```
main     ────────●────────────────●──────────────●
                 ↑                ↑              ↑
release  ────────┼────●───●──────┼──────────────┼
                 │    │   │      │              │
develop  ───●────●────┼───●──●───●───●───●───●──┼
            │         │      │       │   │      │
feature  ───┴─────────┘      │       │   │      │
                             │       │   │      │
hotfix   ────────────────────┴───────┼───┼──────┘
                                     │   │
feature  ────────────────────────────┴───┘
```

```bash
# Initialize GitFlow
git flow init

# Start feature
git flow feature start user-auth

# Finish feature (merges to develop)
git flow feature finish user-auth

# Start release
git flow release start 1.0.0

# Finish release (merges to main and develop)
git flow release finish 1.0.0

# Hotfix
git flow hotfix start security-fix
git flow hotfix finish security-fix
```

## Commit Conventions

### Conventional Commits

```
<type>(<scope>): <description>

[optional body]

[optional footer(s)]
```

Types:
- `feat`: New feature
- `fix`: Bug fix
- `docs`: Documentation
- `style`: Formatting
- `refactor`: Code restructuring
- `test`: Adding tests
- `chore`: Maintenance

Examples:
```bash
git commit -m "feat(auth): add OAuth2 login support"
git commit -m "fix(api): handle null response from payment service"
git commit -m "docs: update API documentation for v2 endpoints"
git commit -m "refactor(db): optimize user query performance"

# Breaking change
git commit -m "feat(api)!: change response format for user endpoint

BREAKING CHANGE: The user endpoint now returns an object instead of array"
```

### Commit Message Template

```bash
# Create template file ~/.gitmessage
# Subject line (50 chars max)

# Body (72 chars per line max)
# - What changed
# - Why it changed
# - Any side effects

# Footer
# Fixes #123
# Co-authored-by: Name <email>

# Configure Git to use template
git config --global commit.template ~/.gitmessage
```

## Pull Request Workflow

### PR Template

```markdown
<!-- .github/pull_request_template.md -->
## Description
Brief description of changes

## Type of Change
- [ ] Bug fix (non-breaking change)
- [ ] New feature (non-breaking change)
- [ ] Breaking change
- [ ] Documentation update

## Testing
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed

## Checklist
- [ ] Code follows project style guidelines
- [ ] Self-review performed
- [ ] Documentation updated
- [ ] No new warnings introduced

## Related Issues
Closes #

## Screenshots (if applicable)
```

### Branch Protection Rules

```yaml
# GitHub branch protection
branch_protection:
  branch: main
  required_pull_request_reviews:
    required_approving_review_count: 1
    dismiss_stale_reviews: true
    require_code_owner_reviews: true
  required_status_checks:
    strict: true
    contexts:
      - "ci/tests"
      - "ci/lint"
  restrictions:
    users: []
    teams: ["maintainers"]
  enforce_admins: true
  required_linear_history: true
  allow_force_pushes: false
  allow_deletions: false
```

### Code Owners

```
# .github/CODEOWNERS

# Default owners
* @team-leads

# Frontend code
/src/frontend/ @frontend-team
*.tsx @frontend-team
*.css @frontend-team

# Backend code
/src/api/ @backend-team
/src/services/ @backend-team

# Infrastructure
/terraform/ @platform-team
/k8s/ @platform-team
Dockerfile @platform-team

# Documentation
/docs/ @tech-writers
*.md @tech-writers
```

## Git Hooks

### Pre-commit Hook

```bash
#!/bin/sh
# .git/hooks/pre-commit

# Run linting
npm run lint
if [ $? -ne 0 ]; then
  echo "Linting failed. Fix errors before committing."
  exit 1
fi

# Run tests
npm run test:unit
if [ $? -ne 0 ]; then
  echo "Tests failed. Fix tests before committing."
  exit 1
fi

# Check for debug statements
if grep -r "console.log\|debugger\|binding.pry" --include="*.js" --include="*.ts" --include="*.rb" src/; then
  echo "Remove debug statements before committing."
  exit 1
fi
```

### Using Husky

```json
// package.json
{
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged",
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  },
  "lint-staged": {
    "*.{js,ts,tsx}": ["eslint --fix", "prettier --write"],
    "*.{css,scss}": ["prettier --write"]
  }
}
```

### Commitlint Configuration

```javascript
// commitlint.config.js
module.exports = {
  extends: ['@commitlint/config-conventional'],
  rules: {
    'type-enum': [
      2,
      'always',
      ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore', 'revert']
    ],
    'subject-max-length': [2, 'always', 72],
    'body-max-line-length': [2, 'always', 100]
  }
};
```

## Release Workflow

### Automated Release with Tags

```bash
# Create annotated tag
git tag -a v1.0.0 -m "Release version 1.0.0"

# Push tag
git push origin v1.0.0

# Create release from tag (GitHub CLI)
gh release create v1.0.0 \
  --title "Release 1.0.0" \
  --notes "Release notes here" \
  --target main
```

### Changelog Generation

```bash
# Using conventional-changelog
npx conventional-changelog -p angular -i CHANGELOG.md -s

# Using git-cliff
git cliff -o CHANGELOG.md
```

## Common Git Operations

### Rebase vs Merge

```bash
# Rebase (clean history)
git checkout feature/my-feature
git rebase main
git push --force-with-lease

# Merge (preserve history)
git checkout main
git merge feature/my-feature

# Squash merge (single commit)
git merge --squash feature/my-feature
git commit -m "feat: add feature X"
```

### Cherry Pick

```bash
# Apply specific commit to current branch
git cherry-pick abc123

# Cherry pick range
git cherry-pick abc123..def456

# Cherry pick without committing
git cherry-pick -n abc123
```

### Interactive Rebase

```bash
# Clean up last 3 commits
git rebase -i HEAD~3

# In editor:
# pick abc123 First commit
# squash def456 Second commit
# reword ghi789 Third commit
```

## Common Issues

### Issue: Merge Conflicts
**Problem**: Conflicts when merging branches
**Solution**: Rebase frequently, communicate with team, use smaller PRs

### Issue: Diverged Branches
**Problem**: Local branch far behind remote
**Solution**: `git pull --rebase` or `git fetch && git rebase origin/main`

### Issue: Accidental Commit to Wrong Branch
**Problem**: Committed to main instead of feature
**Solution**: `git reset HEAD~1`, checkout correct branch, recommit

## Best Practices

- Keep branches short-lived (< 1 week)
- Write meaningful commit messages
- Use PR templates consistently
- Require code reviews
- Protect main/master branch
- Automate checks with CI
- Squash merge for clean history
- Delete branches after merge

## Related Skills

- [semantic-versioning](../semantic-versioning/) - Version management
- [github-actions](../../ci-cd/github-actions/) - CI/CD automation
- [feature-flags](../feature-flags/) - Feature management

© devops-skills · MIT · BagelHole/DevOps-Security-Agent-Skills

Similar skills

All skills for Git and GitHub →

git-workflow by other authors comes first.

git-workflow affaan-m A skill that hands your agent Git conventions: which branching strategy to pick, how to word commits, and when rebase beats merge. CX Codex +1 5,000installs git-workflow agno-team A skill that enforces best practices for commits, branch names, and pull requests. Includes commit message validation, branch naming templates, and PR checklist structure — useful if your team has git standards. CX Codex +1 665installs git-workflow ruvnet A skill that walks branches, conflicts and the pull request lifecycle, with a diff-risk score before every merge. CX Codex +1 743installs git-workflow Galaxy-Dawn Enforces Git standards: Conventional Commits, branch naming, no-ff merge flows, and conflict resolution. Useful for teams needing consistent version control habits. CX Codex +1 374installs git-workflow jezweb Guides Git work for pull requests, merged-branch cleanup, conflict resolution, and monorepo release tags in Claude Code. CX Codex +1 1,200installs conventional-git samber Enforces Conventional Commits v1.0.0 rules for branch names and commit messages. Useful for parseable git history and automated changelogs on GitHub and GitLab. CX Codex +1 4,600installs git-workflow-strategy aj-geddes A skill that helps your agent pick a branching model and walk a feature, release or hotfix through the right steps. Useful when the team has no shared branch rules. CX Codex +1 482installs antfu-create-pr Anthony Fu Turns the current branch into a reviewable GitHub pull request: Conventional Commits title, evidence-based body, before/after screenshots for UI changes. CX Codex +1 485installs github-workflow-automation sickn33 A skill that hands the agent patterns for GitHub work: AI-assisted PR review, issue triage, Actions workflows, CI/CD hooks, rebases and cherry-picks. CX Codex +1 1,500installs babysitting-pr spencerpauly Monitors an open pull request for CI failures, review comments, and merge conflicts, then fixes issues locally and pushes updates. CX Codex +1 427installs git-commit fvadicamo A skill that writes git commits in Conventional Commits format with a type, a required scope and a short subject. Useful when the agent commits on your behalf. CX Codex +1 319installs

From the same set129

prompt-injection-defense Defends LLM applications against direct and indirect prompt injection attacks. It is designed for securing RAG pipelines and agentic tool-calling workflows. CX Codex +1 372installs kustomize Customizes Kubernetes manifests declaratively without templating. Helps structure base configurations and environment overlays across dev and production. CX Codex +1 370installs disaster-recovery A skill for disaster recovery planning: RTO and RPO targets, replication strategies, failover drills. Useful when you need a continuity plan on paper. CX Codex +1 367installs kubernetes-hardening Generates hardened Kubernetes manifests with strict security contexts, network policies, and RBAC rules. Useful when preparing workloads for security compliance. CX Codex +1 366installs cis-benchmarks Audits systems against CIS benchmarks and helps remediate security violations. Useful for applying hardening baselines to Linux servers or Kubernetes nodes. CX Codex +1 366installs waf-setup A skill that deploys and tunes a web application firewall: AWS WAF, Cloudflare and ModSecurity rules against OWASP Top 10 attacks. CX Codex +1 366installs gdpr-compliance A skill that walks you through consent management, data subject rights and privacy by design when your project handles personal data of EU and EEA residents. CX Codex +1 365installs threat-modeling Analyzes system architecture using the STRIDE methodology, maps trust boundaries, and defines security mitigations. CX Codex +1 355installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor