pekral/cursor-rules/git-workflow
Claude Code and agent skill by pekral/cursor-rules
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Use when choosing a Git branching strategy or handling merge vs rebase, conflicts, stashing, undoing mistakes, and release tagging — complementing the commit/PR conventions in the git rules.
Install
npx vskill@latest install pekral/cursor-rules/git-workflowSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as pekral/cursor-rules/git-workflow.
Constraints
- Commit, PR, and merge conventions live in
@rules/git/general.mdc— Englishtype(scope)commits, lowercase, no trailing period, no push tomain, small focused commits,Closes #issue linking, English PR titles, rebase-and-merge,ghCLI. This skill does NOT restate them. - Branch cleanup is owned by
@skills/cleanup-local-branches/SKILL.md. Defer to it; do not duplicate. - PR merging is owned by
@skills/merge-github-pr/SKILL.md. Defer to it; do not duplicate. - This skill covers only the complementary gaps below.
Use when
- Choosing or changing a branching strategy.
- Deciding merge vs rebase for a specific situation.
- Resolving a merge conflict.
- Stashing work in progress.
- Undoing a mistake (bad commit, wrong reset, accidental change).
- Cutting a release and tagging a version.
Branching strategies
GitHub Flow (simple, recommended for most)
main is always deployable. Branch from main, open a PR, merge after review and green CI, deploy. Best for SaaS and web apps with continuous deployment.
Trunk-based (high-velocity)
Everyone integrates into main via very short-lived branches (1–2 days). Incomplete work hides behind feature flags. CI must pass before merge. Needs strong CI/CD and discipline.
GitFlow (release-cycle driven)
main holds production code, develop is the integration branch, with release/* and hotfix/* branches. Heavyweight; only worth it for scheduled, regulated releases.
| Strategy | Team size | Release cadence | Best for | |
|---|---|---|---|---|
| GitHub Flow | any | continuous | SaaS, web apps, startups | |
| Trunk-based | 5+ experienced | multiple/day | high-velocity teams using feature flags | |
| GitFlow | 10+ | scheduled | enterprise, regulated industries |
Default to GitHub Flow unless the team has a concrete reason for another model. It aligns with the rebase-and-merge + short-focused-branches conventions in @rules/git/general.mdc.
Merge vs rebase mechanics
Merge (preserves history)
Use when preserving exact history matters or several people worked on the branch.
Rebase (linear history)
Use to update your local branch with the latest main before opening or refreshing a PR. Keeps history linear.
Always --force-with-lease, never plain --force.
Pull policy: sync a side branch before pulling it
@rules/git/general.mdc Pull Policy requires every non-default branch to be rebased onto the latest default branch so it always carries the newest default-branch history. The default branch is main on some repos and master on others — resolve it instead of hardcoding origin/main (which does not exist on a master-default repo and makes the command fail). Order matters: take the branch's own remote first, then rebase the default branch in, then force-push — do not pull again afterwards.
If the rebase changed composer.lock (the default branch updated dependencies), reinstall before continuing so the installed packages match the new lockfile:
The default branch itself is exempt — pull it directly with git pull. Read-only review skills are exempt too: they git pull only to read the diff and never rebase.
Verify a rewritten range commit by commit
@rules/git/general.mdc Git Rules (Every commit is green) requires every commit in the branch to pass the project's gate on its own, so that each one cherry-picks onto the default branch and deploys without errors. A rebase, squash, split, or reorder replays every commit onto a new base, so a green tip proves nothing about the commits underneath it — a conflict resolved in the wrong commit or a dependency that moved leaves an intermediate commit red while HEAD builds fine.
The `--exec` command must not modify the working tree. Pass the checking half of the gate (composer check), never the fix-and-check composer build: its @fix step rewrites tracked files, and an exec that exits 0 but leaves the tree dirty stops the rebase with execution succeeded … but left changes to the index and/or the working tree. That is a git plumbing error, not a verdict — the operator loses the signal about which commit is actually red. Run the fixers before you start the replay, not inside it.
--exec runs the gate after each replayed commit and stops at the first failure:
Repair the failing commit in place — never git rebase --skip past it and never append a repair commit at the tip: a repair at the tip leaves the broken commit permanently unshippable and re-creates the scattered-concern violation the reshape was meant to fix. When a commit cannot be made green alone, fold it into the commit it depends on (git rebase -i, mark it fixup) instead of publishing a red step.
Use git rebase --exec 'vendor/bin/pest tests' (or whatever faster subset the project actually defines — check composer.json scripts rather than assuming a composer test exists) while iterating, but run the full gate once before the force-push. A command that is not defined exits non-zero, and a non-zero exec stops the replay at the first commit — reporting a red history on a green range.
Never rebase shared/public history
Do NOT rebase a branch that has been pushed and that others may have based work on, nor any protected branch (main, develop), nor already-merged history. Rebase rewrites commits and breaks everyone downstream. For published branches, fix forward with git revert instead.
Conflict resolution
Prevention: keep branches small and short-lived, rebase onto main frequently, and coordinate before touching shared files. After resolving, re-run the project checks (see below) before continuing.
Stash workflow
Undoing mistakes
Rule: reset --hard and --amend rewrite history — safe only on unpushed, local-only commits. Once pushed and shared, undo with revert.
Semantic versioning and release tagging
MAJOR.MINOR.PATCH: MAJOR for breaking changes, MINOR for backward-compatible features, PATCH for backward-compatible fixes.
Conventional type(scope) subjects from @rules/git/general.mdc make this changelog range readable.
Laravel .gitignore essentials
Never commit .env, the vendor/ or node_modules/ trees, the Vite build output in /public/build, or generated keys.
Hooks
If you wire a pre-commit or pre-push hook, run the project's own checks (the composer build / Composer scripts and the Pest suite), not ad-hoc tooling. The hook should fail the commit on any error, mirroring CI.
Defer to
@rules/git/general.mdc— commit, PR, and merge conventions.@skills/cleanup-local-branches/SKILL.md— deleting stale local branches.@skills/merge-github-pr/SKILL.md— merging a ready PR.
Done when
- A branching strategy is chosen with a stated reason.
- Merge vs rebase is applied correctly and no shared/public history was rebased.
- A non-default branch was synced (own remote pulled, then the resolved default branch rebased in, then force-pushed — never hardcoding
origin/main), andcomposer installwas re-run whenever that rebase changedcomposer.lock. - Every commit of a rewritten range was verified green with
git rebase --exec, and any failing commit was repaired in place rather than by a repair commit at the tip. - Conflicts are resolved with markers removed and project checks re-run.
- Any undo used the right tool for whether the commit was pushed.
- Releases are tagged with annotated semver tags pushed to origin.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/git-workflow/SKILL.md
Popularity
- Repository stars
- 9
- Repository forks
- 1
- 7-day trend score
- 12
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/pekral/cursor-rules/git-workflow)