Set up Git branching workflow (GitFlow, trunk-based)
✓Works with OpenClaudeYou are a Git workflow architect. The user wants to set up a complete Git branching strategy using either GitFlow or trunk-based development, including branch creation, protection rules, and merge workflows.
What to check first
- Run
git --versionto confirm Git is installed (2.0+) - Run
git config --listto check current user configuration (user.name, user.email must be set) - Check if your repository is initialized with
git rev-parse --git-dir
Steps
- Choose your strategy: GitFlow (feature/release/hotfix branches) or trunk-based (main + short-lived feature branches); GitFlow suits complex releases, trunk-based suits CI/CD
- Create main branches: run
git branch mainandgit branch develop(GitFlow) or just ensuremainexists (trunk-based) - Push base branches:
git push origin main develop(GitFlow) orgit push origin main(trunk-based) - Create feature branch from correct source:
git checkout -b feature/user-authfromdevelop(GitFlow) ormain(trunk-based) - Make commits with conventional format:
git commit -m "feat: add login form"using type prefixes (feat, fix, docs, refactor) - Push feature branch:
git push origin feature/user-authand create a pull request - Configure branch protection rules in GitHub/GitLab: require reviews (minimum 1), require status checks (CI/CD), dismiss stale reviews
- Merge via PR with strategy: create merge commit (GitFlow) or squash commits (trunk-based) using
git merge --no-fforgit merge --squash - Delete feature branch after merge:
git push origin --delete feature/user-authandgit branch -d feature/user-authlocally - For GitFlow releases: create
release/1.0.0fromdevelop, merge tomainwith tag, then back todevelop
Code
#!/bin/bash
# GitFlow workflow setup and automation
# 1. INITIALIZE REPOSITORY WITH GITFLOW
git flow init -d
# 2. CREATE AND SWITCH TO FEATURE BRANCH
git flow feature start user-authentication
# Equivalent: git checkout -b feature/user-authentication develop
# 3. MAKE CHANGES AND COMMIT
echo "New authentication logic" > auth.js
git add auth.js
git commit -m "feat: implement JWT-based authentication"
# 4. PUSH FEATURE BRANCH
git flow feature publish user-authentication
# Equivalent: git push origin feature/user-authentication
# 5. FINISH FEATURE (MERGE BACK TO DEVELOP)
git flow feature finish user-authentication
# Creates merge commit, deletes local branch, switches to develop
# 6. FOR RELEASE BRANCH (GitFlow release management)
git flow release start 1.2.0
# Update version numbers, changelog
echo "1.2.0" > VERSION
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Workflow Automation Skills
Other Claude Code skills in the same category — free to download.
Pre-Commit Hooks
Configure pre-commit hooks (Husky, lint-staged)
Auto Formatter
Set up auto-formatting (Prettier, ESLint)
Issue Template
Create GitHub issue and PR templates
Dependabot Setup
Configure Dependabot/Renovate for auto-updates
Release Workflow
Automate release workflow with changelogs
Code Owner Setup
Configure CODEOWNERS file
Branch Protection
Set up branch protection rules
Auto Labeler
Auto-label PRs based on changed files
Want a Workflow Automation skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.