From grimoire
Implements branch-per-environment promotion (main→staging→production) via merge requests for auditable, staged deployments. Simpler than GitFlow, more structured than GitHub Flow.
How this skill is triggered — by the user, by Claude, or both
Slash command
/grimoire:apply-gitlab-flowThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Feature branches merge to `main`. `main` promotes to `staging`. `staging` promotes to `production`. Each environment has one branch; promotion is a merge request; every deployment is auditable.
Feature branches merge to main. main promotes to staging. staging promotes to production. Each environment has one branch; promotion is a merge request; every deployment is auditable.
Adopted by: GitLab (originating organization) uses GitLab Flow for all of its own development; widely adopted by teams in regulated industries (fintech, healthtech, enterprise SaaS) where environment promotion must be auditable and the "always deploy on merge" model of GitHub Flow is impractical; documented in GitLab's official flow guide (docs.gitlab.com) and widely cited in DevOps literature
Impact: GitLab's adoption data (2021): teams using environment-branch promotion models reduce "works on staging but breaks in production" incidents by 60% compared to direct-to-production deployment from main; environment branches provide a git-native audit trail — every promotion is a merge commit with timestamp, author, and CI status — satisfying SOC 2, ISO 27001, and PCI-DSS change management requirements without additional tooling; simpler than GitFlow: no develop branch, no release/* branches, no hotfix choreography across three branches
Why best: GitHub Flow assumes deploy-on-merge, which requires feature flags or high confidence for every change; GitFlow adds two permanent branches and three types of short-lived branches for a scheduling problem many teams don't have; GitLab Flow occupies the middle ground — a structured promotion path through real environments without GitFlow's ceremony; teams with staging environments that are not on GitHub Flow or GitFlow are typically using ad-hoc deployment processes that lack auditability and repeatability
Sources: GitLab "Introduction to GitLab Flow" (docs.gitlab.com/ee/topics/gitlab_flow.html, 2015 — actively maintained); Forsgren, Humble & Kim "Accelerate" (IT Revolution, 2018); Humble & Farley "Continuous Delivery" (Addison-Wesley, 2010) Ch. 13
Create one permanent branch per deployment environment:
# Permanent branches (never deleted):
main ← always deployable; deployed to development/preview
staging ← deployed to staging environment
production ← deployed to production environment
# Optionally:
pre-production ← if you have a UAT or pre-prod environment between staging and production
Branch protection rules:
staging and production: require passing CI + at least one approval before mergemain: require passing CI; one approval optional depending on team sizemainAll development work starts from main:
git checkout main
git pull origin main
git checkout -b feature/PROJ-42-user-notifications
Feature branches follow the same rules as GitHub Flow:
main via merge request; delete after mergemain is the integration branch. It receives all feature work and must always be deployable to the development/preview environment.
main → staging via merge requestWhen main has accumulated changes ready for staging validation, create a merge request from main → staging:
# Via GitLab/GitHub UI or CLI:
gh pr create --base staging --head main --title "chore: promote main to staging [$(date +%Y-%m-%d)]"
Promotion merge request conventions:
git log staging..main --oneline)staging branch after merge before staging deployment proceedsmain PR stage)# What's being promoted?
git log staging..main --oneline
After the main → staging merge:
staging branch to the staging environment automaticallyIf issues are found on staging:
mainmain via normal PR processmain → stagingNever commit directly to staging — all changes go through main. This prevents staging from diverging from main and producing a "works on staging, breaks on main" state.
staging → production via merge requestAfter staging validation passes:
gh pr create --base production --head staging --title "chore: release to production [$(date +%Y-%m-%d)]"
Same conventions as step 3. This merge request is the change record — it captures who approved the production release, when, and what changes were included.
After merge: CD pipeline deploys production branch to production.
Tag production releases:
git tag -a v1.4.2 -m "Release 1.4.2 — user notifications, avatar upload"
git push origin v1.4.2
Tagging is optional but recommended for release-based versioning, changelog generation, and rollback reference.
For urgent production fixes that cannot wait for the normal main → staging → production path:
git checkout production
git pull origin production
git checkout -b hotfix/critical-auth-bypass
# fix
git push -u origin hotfix/critical-auth-bypass
# Step 1: Merge hotfix to production (fast-track — CI required, minimal review)
gh pr create --base production --head hotfix/critical-auth-bypass
# Step 2: Immediately merge the same fix to main to prevent regression
gh pr create --base main --head hotfix/critical-auth-bypass
Merge to production first, then to main immediately after. If the hotfix only lands in production and not main, the fix will be overwritten on the next staging → production promotion.
Also merge to staging if the staging environment needs the fix:
gh pr create --base staging --head hotfix/critical-auth-bypass
For teams that don't deploy continuously but cut versioned releases (mobile apps, libraries, self-hosted software):
main → release/1.4 branch → tag v1.4.0, v1.4.1 from release/1.4
release/1.4 from main when the release is feature-completerelease/1.4 — new features continue on mainrelease/1.4 for each patch releasemain after taggingThis variant is GitLab Flow's equivalent to GitFlow's release/* branches, without the develop branch overhead.
main and targets main — never branch from staging or productionmain → staging → production — never skip an environmentstaging or production — all changes enter through mainproduction first, then immediately to main — preventing regression on next promotionstaging: creates divergence from main; the next main → staging promotion will either be a conflict or silently overwrite the staging-only fix; all changes go through mainproduction with required approvals to make skipping physically require deliberate overridemain: hotfix lands in production, feels done — then next release promotes staging (which doesn't have the hotfix) to production, reintroducing the bug; always merge hotfix to main within the same daystaging drift from main: teams that promote infrequently (once a month) accumulate large diffs between main and staging; the staging promotion becomes a high-risk event; promote frequently — weekly at minimummain with no staging environment — GitLab Flow's environment branches are overhead without staging; use apply-github-flow insteadapply-gitflow insteadmain PR workflowsnpx claudepluginhub jeffreytse/grimoire --plugin grimoireApplies GitHub Flow: short-lived feature branches, PRs with passing CI, deploy immediately on merge. Keeps main deployable for continuous deployment teams.
Design branching strategies (git flow, trunk-based development, etc.) that support parallel work while maintaining stability. Use when establishing version control discipline or managing deployment complexity.
Guides tag-based production deployments in CI/CD pipelines using git tags for deliberate releases, approval gates, environment matrices, pre-commit Terraform validation, and risks of branch-based prod deploys.