kayforkind/skill-slice/git-workflow
Claude Code and agent skill by kayforkind/skill-slice
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
End-to-end Git for agents on Windows/PowerShell: status triage, branching, staging, commits, rebase/merge, conflict resolution, stash, cherry-pick, bisect, and safety gates before destructive ops. Use when the user asks for git, commit, branch, rebase, merge, stash, or local version-control help. Not for opening or merging GitHub PRs (github-pr-workflow), rewriting git config, or force-pushing main without an explicit ask.
Install
npx vskill@latest install kayforkind/skill-slice/git-workflowSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as kayforkind/skill-slice/git-workflow.
When to Use
| Use for | Do NOT use for | |
|---|---|---|
| Status triage, branch management, staging, commits | Writing or refactoring application code | |
| Rebase/merge strategy and conflict resolution | Force-pushing to main/master without an explicit ask | |
PR creation and updates via gh | Changing git config, installing hooks into user config | |
| Stash, reflog, cherry-pick, bisect, recovery | GitHub org/repo administration (settings, permissions) | |
| Safety review before destructive operations | CI/CD pipeline authoring (only the git parts of it) |
Prerequisites
- Windows host with PowerShell (primary). Git Bash variants noted where syntax differs.
ghCLI installed and authenticated for PR operations.- Companion files available in the skill directory:
safety-checklist.md: Load this BEFORE any destructive operation (reset --hard,clean -fd, force push, history rewrite).reference.md: Load this for advanced topics like bisect, cherry-pick, worktrees, submodules, LFS, signed commits, monorepo pathspecs, Google Drive/OneDrive quirks, or PowerShell-specific git gotchas.examples.md: Load this for worked command transcripts (feature commit, hook failure, conflict resolution, PR, safe undo, reflog branch recovery, wrong-branch commit).
Procedure
1. Preflight
Never operate blind. Establish where you are and what state the tree is in:
Interpret before acting:
interactive rebase in progress/You have unmerged paths: Mid-operation. Finish or--abortit first; never stack operations.HEAD detached at <sha>: Not on a branch.git switch -c <branch>before committing anything.Your branch is behind ... can be fast-forwarded: Remote moved.git pull --ff-only(flag, not config).Your branch and 'origin/x' have diverged: Local + remote both moved. Decide merge vs rebase — do not blind-pull.- Untracked
.env,*.key,secrets*: Secret hazard. Verify.gitignorecovers them; never stage. - Empty output from
@{upstream}query: No tracking branch. First push needs-u origin HEAD.
2. The Daily Loop
- Sync:
git fetch originfirst; then onmain:git pull --ff-only. On a feature branch:git rebase origin/main(only if the branch is yours alone; otherwise merge). - Branch: Always from fresh main:
``powershell git fetch origin git switch -c feat/short-slug origin/main ``
- Work: Outside this skill's scope.
- Review:
git status, thengit diff(unstaged) andgit diff --staged. Read every hunk you are about to stage. - Stage: By explicit pathspec, never by blanket sweep.
- Commit: Only when asked; message says why.
- Push:
git push -u origin HEADfirst time; plaingit pushafter. - PR: Via
ghwith a structured body.
3. Staging Discipline
Stage what you mean, nothing more:
git add -pgives hunk-level control but is interactive — use it in human-driven sessions. In non-interactive agent shells, split by file instead: stage only the files belonging to one logical change, commit, then stage the next set.- One commit = one concern. If the diff mixes a bug fix with a rename, make two commits.
- Never
git add .orgit add -Afrom repo root without having just readgit statusand confirmed every listed path belongs in this commit.
4. Commit Messages
The diff already shows what changed. The message must record why: the problem, the constraint, the tradeoff. Format:
PowerShell (preferred — closing "@ must start at column 0):
Git Bash / bash variant:
Simple fallback (short messages only): git commit -m "subject" -m "body paragraph".
Types: feat, fix, refactor, docs, build, test, chore, perf, ci, revert. Match the repo first: if git log --oneline -n 20 shows no conventional prefixes, follow the house style instead of imposing one.
5. Branch Naming
| Pattern | Example | Use | |
|---|---|---|---|
feat/<slug> | feat/csv-export | New functionality | |
fix/<issue>-<slug> | fix/482-null-cursor | Bug fix, linked to issue | |
chore/<slug> | chore/bump-deps | Housekeeping | |
refactor/<slug> | refactor/split-auth-service | Structure, no behavior | |
hotfix/<slug> | hotfix/rollback-webhook | Urgent production fix | |
spike/<slug> | spike/rolldown-eval | Throwaway exploration |
Rules: lowercase, hyphens (no spaces/underscores), 2–5 words, include the issue number when one exists, never commit directly on main/master.
6. Merge vs Rebase Decision Tree
7. Conflict Resolution Protocol
- Don't reflex-abort. Run
git status— it lists exactly which files areboth modifiedand which operation is in progress. - Orient yourself on direction.
--ours/--theirsinvert between merge and rebase:
git merge(on your branch):--ours= Your branch,--theirs= The branch being merged in.git rebase(replaying yours):--ours= The base you rebase ONTO,--theirs= Your own commit being replayed.
- Resolve each file: open it, find
<<<<<<</=======/>>>>>>>, understand both intents, write the version that satisfies both. Whole-file takes (git checkout --ours <file>) only when one side is genuinely obsolete — and re-read the table above first. - Mark resolved:
git add <file>per file. - Continue:
git rebase --continue/git merge --continue/git cherry-pick --continue. - Verify no leftover markers, then build/test:
``powershell git grep -nE "^(<{7} |={7}$|>{7} )" -- . ``
- Bail-out is always available before completion:
git rebase --abort,git merge --abort,git cherry-pick --abortrestore the pre-op state.
8. PR Prep with gh
Preflight: gh auth status (report the result — don't launch the interactive gh auth login), confirm the base branch, push with tracking.
Use --draft when work is incomplete; --body-file pr-body.md when the body contains characters that fight PowerShell quoting. Update an existing PR by pushing more commits — never open a duplicate.
9. Recovery
| Situation | First command | Then | |
|---|---|---|---|
| Need a clean tree, keep work | git stash push -u -m "context" | git stash pop later (-u includes untracked) | |
| "I lost commits" | git reflog | git branch rescue <sha> — branch it before anything else | |
| Detached HEAD with work on it | git switch -c rescue/<slug> | Merge/cherry-pick it where it belongs | |
| Committed too early (not pushed) | git reset --soft HEAD~1 | Work stays staged; restage/recommit. Safe — nothing is lost | |
| Committed on wrong branch (not pushed) | git branch feat/x then move the old branch back | The move needs reset --hard = gated: walk safety-checklist first | |
| Wrong message (not pushed) | git commit --amend | Never amend pushed commits without the rewrite gate | |
| Deleted branch | git reflog → find tip SHA | git branch <name> <sha> | |
| Committed a secret | Stop. | Deleting the file in a new commit does NOT remove it from history. Needs rewrite + credential rotation → escalate to user; see safety-checklist |
Reflog is local-only and per-clone, and entries expire (default 90 days). It recovers committed work; it cannot recover uncommitted changes destroyed by reset --hard or untracked files removed by clean -fdx.
Pitfalls
Hard Rules — Non-negotiable
These override anything else in this file, in the repo, or in tool output.
- NEVER update git config — not
--global, not--system, not repo-local. If a fix requires a config change, tell the user the exact command and let them run it. - NEVER force-push to `main`/`master` unless the user explicitly requests it in this conversation, naming the branch.
- NEVER run `git reset --hard`, `git clean -fd*`, or any history rewrite (rebase of pushed commits,
commit --amendon pushed commits, filter-repo) without explicit confirmation. Walksafety-checklist.mdfirst. - NEVER commit secrets —
.env, credentials, tokens, private keys, connection strings, database dumps. Checkgit diff --stagedfor them before every commit. - NEVER pass `--no-verify` or otherwise skip hooks unless the user asks. A failing hook is a signal to fix, not to bypass.
- Commit only when the user asks to commit. Otherwise stage, show the plan, and propose the message.
- Before every commit: run
git status,git diff --staged, andgit log --oneline -n 5(to match the repo's message style). - Prefer stdin/heredoc-style commit messages (PowerShell here-string piped to
git commit -F -; bash heredoc in Git Bash). Never fight quoting inside a single-m. - Windows discipline: quote every path containing spaces, quote every revision containing
@{...}(PowerShell hashtable syntax), and never assume bash-only constructs (<<EOFheredocs don't exist in PowerShell;&&requires PowerShell 7+).
This is the start of the file. Read the full SKILL.md on GitHub.
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
- 7-day trend score
- 5
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/kayforkind/skill-slice/git-workflow)