tangcent/ai-cookbook/git-workflow
Claude Code and agent skill by tangcent/ai-cookbook
- community
Checking that the SKILL.md file is still in the repository.
Manage day-to-day Git workflow with safe branch creation, conventional commits, rebasing, pushing, MR creation, active-branch sync, and integration-branch consolidation. Use when the user asks to create branches, commit, push, sync feature/fix branches, rebuild dev branches, or open merge requests.
Install
npx vskill@latest install tangcent/ai-cookbook/git-workflowSKILL.md
Git Workflow
Core Rules
- Always sync remotes first:
``bash git fetch --all --prune ``
- Always detect default branch dynamically (fallback
main, thenmaster):
``bash default_branch="$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')" [ -z "$default_branch" ] && default_branch="$(git branch -r --list 'origin/main' | head -n1 | sed 's@^ *origin/@@')" [ -z "$default_branch" ] && default_branch=master ``
- Ask for confirmation before destructive operations:
git push --force-with-leasegit reset --hard- deleting branches/tags
- Never use plain
--force; use--force-with-lease. - Prefer
origin/<default-branch>as rebase target.
Branch and Commit Conventions
- Branch prefixes:
feature/<name>fix/<name>hotfix/<name>release/<name>chore/<name>- Commit prefixes:
feat:,fix:,perf:,refactor:,docs:,test:,chore:,release:
Bundled Helpers
Use these scripts from this skill directory:
scripts/detect-active-branches.sh [--base <branch>] [--window <n>]scripts/generate-mr-url.sh [source-branch] [target-branch]
generate-mr-url.sh supports generic GitLab remotes (not only git.tec-do.com).
Workflow A: Create Branch
- Ensure repo is up to date:
``bash git fetch --all --prune ``
- Pick base branch:
- default:
origin/<default-branch> - use user-provided base if specified
- Normalize branch name:
- If no prefix, infer one from intent (
feature,fix,chore,release,hotfix) - Convert spaces/underscores to
-
- Create and checkout:
``bash git checkout -b <prefix>/<slug> origin/<base-branch> ``
- If user asks to publish branch, push:
``bash git push -u origin <branch> ``
- Show MR URL:
``bash bash scripts/generate-mr-url.sh <branch> <default-branch> ``
Workflow B: Commit, Push, and MR
1. Branch safety decision
- Detect current branch:
``bash current_branch="$(git branch --show-current)" ``
- If current branch is protected/integration (
main,master,develop,dev,staging) or user requested new branch:
- create a new branch from
origin/<default-branch>and continue there.
- If current branch is feature/fix style, verify it is not stale:
``bash git cherry "origin/$default_branch" HEAD ``
- If all commits are already upstream (only
-lines), treat as stale and create a fresh branch.
2. Rebase onto latest default branch
- Stash if worktree is dirty:
``bash git stash push -u -m "git-workflow-auto-stash" ``
- Rebase:
``bash git rebase "origin/$default_branch" ``
- If conflicts occur, ask user to resolve and continue:
``bash git rebase --continue ``
- Restore stash if created:
``bash git stash pop ``
3. Stage and commit
- Review status:
``bash git status --short ``
- If user did not ask for partial staging, stage all:
``bash git add -A ``
- Propose conventional commit title based on diff intent.
- Ask for confirmation/edits on commit message.
- Commit:
``bash git commit -m "<type>: <summary>" ``
4. Push
- If rebase happened, default to:
``bash git push --force-with-lease origin <current-branch> `` Ask for confirmation first.
- Otherwise:
``bash git push -u origin <current-branch> ``
- Always print MR URL:
``bash bash scripts/generate-mr-url.sh <current-branch> <default-branch> ``
5. Create MR when requested
If user explicitly requested MR creation:
- Prefer
glab mr createwhen authenticated. - Build title/body from commits:
``bash git log "origin/$default_branch"..HEAD --pretty=format:'- %s' --reverse ``
- Create MR:
``bash glab mr create \ --target-branch "$default_branch" \ --source-branch "$(git branch --show-current)" \ --title "<title>" \ --description "<description>" ``
- If
glabis unavailable, return URL fromgenerate-mr-url.sh.
Workflow C: Sync Active Feature/Fix Branches
- Save current branch:
``bash origin_branch="$(git branch --show-current)" ``
- Detect candidates:
``bash bash scripts/detect-active-branches.sh --base "$default_branch" ``
- Show candidate list and ask user which branches to sync.
- For each selected branch:
git checkout <branch>git rebase "origin/$default_branch"- Resolve conflicts with user if needed
- confirm then
git push --force-with-lease origin <branch> - print MR URL via helper script
- Return to original branch.
Workflow D: Consolidate Integration Branch
Use for requests like "rebuild dev from active features".
- Ask for target integration branch (default
dev). - Detect active branches using helper script.
- Ask user to confirm branch list and base feature branch.
- Rebase each feature branch on
origin/<default-branch>first. - Checkout target branch and hard reset to base feature branch:
``bash git checkout <target-branch> git reset --hard <base-feature-branch> `` Ask confirmation before reset.
- Merge remaining feature branches one by one:
``bash git merge --no-ff <feature-branch> ``
- Ask before push, then push and provide MR URL.
Autonomy Principle
Make reasonable defaults automatically (prefix selection, staging, commit type, target branch). Ask only when:
- action is destructive
- user intent is ambiguous
- required information cannot be inferred
Security
- Security scanPassed, 90 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
- 7-day trend score
- 0
Not refreshed yet.
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/tangcent/ai-cookbook/git-workflow)