edwardzhang/sps-cli/git-workflow
Claude Code and agent skill by edwardzhang/sps-cli
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Workflow skill — git hygiene beyond commit-message style. Branching, rebasing, conflict resolution, recovering from mistakes. For commit-message format and PR sizing, see `coding-standards/references/commits-and-prs.md`.
Install
npx vskill@latest install edwardzhang/sps-cli/git-workflowSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as edwardzhang/sps-cli/git-workflow.
Git Workflow
Day-to-day git habits for keeping history useful and recovery cheap. For commit message style and PR sizing, load `coding-standards/references/commits-and-prs.md`.
When to load
- Starting a new feature branch
- Reviewing how to structure a series of commits
- Resolving a merge / rebase conflict
- Recovering from a "bad git operation"
- Onboarding to a repo with a specific workflow (trunk-based, GitFlow, etc.)
The posture
- Commits are communication. The history is read by your future self and your teammates. Make it readable.
- Small, logical, atomic commits. Each commit reverts cleanly. Each commit tells one story.
- Rebase your own branch; never shared branches. History rewriting on public branches breaks everyone.
- Never `--force` without `--force-with-lease`. The safer form checks no one else has pushed.
- Lost work is usually recoverable.
git reflogremembers. - When in doubt, stash or branch before experimenting. Cheap insurance.
Workflow patterns
Pick one per project and stick to it.
Trunk-based
Short-lived branches, merge to main at least daily. Best for CI-strong teams.
Pros: minimal merge pain, fast feedback, clear integration point. Cons: needs strong CI and feature flags to ship incomplete work safely.
Feature-branch + PR (pragmatic default)
Named branches per feature, merged via PR to main. Branches live days to a week.
Most teams. Rebase on main before merging to keep history linear.
GitFlow
develop, release/*, hotfix/* alongside main. Heavier; fits products with long support branches.
Use when you ship monthly / quarterly and have parallel release support. Overkill for most web apps.
Branch naming
Include a ticket id if your team tracks: fix/SEC-412-alg-none.
Rules:
- Lowercase + hyphens.
- No personal names (
alice/wip); one-off personal branches die without review. - No
feature/prefix — type is the prefix, andfeature/duplicates.
The commit loop
Good session flow:
git statusbefore starting — clean? any leftover changes?- Make a change; run tests.
git diff— review before staging.git add -p— stage in logical chunks, not everything blindly.git commit— one logical change, good message.- Repeat.
-p (patch) mode is underrated. It lets you split "one big edit" into several commits.
Rebase your own branch on main
Keeps a clean linear history and avoids dirty "Merge main into feature" commits.
Never rebase a branch others are working on — they'll have conflicts and lose commits.
Interactive rebase — clean up your history
Before opening a PR:
Opens an editor listing your commits. Actions:
| Action | Effect | |
|---|---|---|
pick | Keep as-is | |
reword | Change the commit message | |
edit | Stop to amend the commit | |
squash | Combine with the previous commit; edit message | |
fixup | Combine with previous; keep previous message | |
drop | Delete |
Use to squash WIP commits, fix typos in messages, reorder logically. Don't use on already-pushed-to-shared branches.
Handling conflicts
When rebase or merge hits a conflict:
Rules:
- Read both sides. Don't just pick one wholesale.
- Ensure tests pass after the resolution. A bad merge compiles but breaks behaviour.
- Commit the resolution as is. Don't mix in other changes.
rerere — reuse recorded resolutions
Turn on once, saves pain on repeated rebases:
Git remembers how you resolved a given conflict; applies it automatically next time the same conflict appears.
Force-push safely
Rebasing changes commit SHAs, requiring a force-push. Use --force-with-lease:
--force overwrites the remote without checking. If someone else pushed to your branch, you silently overwrite their work. --force-with-lease fails safely in that case.
Better alias:
Recovering lost work
Almost all "lost" git operations are recoverable via reflog.
If your last commit was broken and you ran git reset --hard:
Works for ~90 days by default. The golden rule: commit often. Committed work is almost never truly lost.
stash — quick save
Interrupting to switch branches?
Stash names help when you accumulate several. Don't let stashes pile up — they're not backup.
Cherry-pick
Copy a commit from another branch. Handy for:
- Backporting a fix to a release branch.
- Salvaging one commit from an abandoned branch.
Avoid using cherry-pick as a regular integration strategy; it creates duplicate work in the history.
Worktrees — parallel branches
One clone, multiple branches checked out in separate directories. Useful for long-running release branches, bisect, comparison.
bisect — find the commit that broke things
git bisect run ./test.sh automates it — git runs your script at each step.
.gitignore discipline
Keep it current. Default entries:
If a file was committed by accident, ignoring it doesn't remove it — use git rm --cached <file> + commit.
.gitattributes — normalize line endings
Avoid CRLF / LF chaos across Windows + Mac + Linux:
Commit it; once everyone has it, cross-OS diffs go quiet.
Git hooks — local enforcement
- pre-commit — run linter / formatter / tests before a commit is allowed.
- commit-msg — enforce commit message format.
- pre-push — run tests before push.
Use a hook manager (lefthook, husky, pre-commit) so hooks are in the repo, shared with the team.
Don't --no-verify your hooks. If a hook fails, fix the underlying issue.
Recovery cheat-sheet
| "I accidentally..." | Fix | |
|---|---|---|
| Committed to wrong branch | git reset --soft HEAD~1, switch branches, recommit | |
| Deleted a branch | git reflog → find SHA → git branch <name> <sha> | |
| Force-pushed over someone | Coordinate; git reflog on their machine can recover | |
| Committed a secret | Rotate the secret immediately; history rewrite is secondary | |
| Lost uncommitted changes | git reflog only helps if committed; stashes via git stash list | |
| Merged wrong branch | git reset --hard HEAD~1 (before push), or git revert (after push) | |
| Detached HEAD | git branch <newname> before switching away |
Forbidden patterns
git push --force(without--force-with-lease)--no-verifyto skip hooks because "they're annoying"- 20+
WIP/fixcommits pushed to main (squash them) - Long-lived feature branches (weeks+) without merging / rebasing
- Editing
.gitignorewithout committing the removals that.gitignorewas meant to catch - Rebasing a shared branch
- Committing secrets (even if planning to remove next commit)
git add -Awithout review- Keeping personal branches around in the remote for months
- Mixing rename + content change in one commit (hides the rename)
Pair with
- `coding-standards/references/commits-and-prs.md` — commit messages + PR sizing.
- `devops/references/ci-cd.md` — branch protection + CI triggers.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
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
- 3
- 7-day trend score
- 7
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/edwardzhang/sps-cli/git-workflow)