一键导入
git-workflow
Git workflow commands: commit, branch, pr, push, sync, review, fixup, update-pr, commit-push, clean-gone, status, merge. Use with command argument.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Git workflow commands: commit, branch, pr, push, sync, review, fixup, update-pr, commit-push, clean-gone, status, merge. Use with command argument.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Complete development workflow for Claude Code
4400+ curated code review prompts from leading open-source repositories
Complete development workflow for Codex
Evaluate session using OpenAI eval-skills framework (Outcome/Process/Style/Efficiency). Analyzes session transcript vs Claude Code config to score performance and generate improvement recommendations. Creates GitHub issue with rubric scores and actionable plan.
Git workflow commands: commit, branch, pr, push, sync, review, fixup, update-pr, commit-push, clean-gone, run-e2e. Use with command argument.
Professional code review skill for Claude Code. Automatically collects file changes and task status. Triggers when working directory has uncommitted changes, or reviews latest commit when clean. Triggers: code review, review, 代码审核, 代码审查, 检查代码
| name | git-workflow |
| description | Git workflow commands: commit, branch, pr, push, sync, review, fixup, update-pr, commit-push, clean-gone, status, merge. Use with command argument. |
| user-invocable | true |
| argument-hint | <command> [options] |
| allowed-tools | ["Bash","Read","Glob","Edit","Write","Task","Grep","AskUserQuestion"] |
Unified git workflow commands for commits, branches, PRs, and reviews.
Invoke with a command name as argument:
Skill({ skill: "git-workflow", args: "commit" })$git-workflow commit or /skills git-workflow commit| Command | Description |
|---|---|
commit | Create conventional commit with all changes staged |
branch | Create feature branch with naming convention |
pr | Create pull request with smart template |
push | Push commits to remote safely |
sync | Sync branch with main via merge or rebase |
review | Run comprehensive code review |
fixup | Fix PR review comments and CI failures |
update-pr | Update PR title and body from commits |
commit-push | Create conventional commit and push |
clean-gone | Remove local branches deleted from remote |
status | Full PR dashboard: CI, reviews, threads, mergeable |
merge | Merge PR after readiness check |
Create a conventional commit with all current changes staged.
In multi-agent and human-in-the-loop workflows, all changes should be committed unless they are clearly cruft. Do not be overly selective.
! git status --short
! git diff --stat
! git diff --cached --stat
! git log --oneline -5
git add -A (stage everything)type(scope): short description
- Bullet point explaining what changed
- Another bullet point if needed
| Type | When to Use |
|---|---|
feat | New feature |
fix | Bug fix |
refactor | Code restructuring without behavior change |
docs | Documentation only |
test | Adding or updating tests |
chore | Build, CI, dependencies |
perf | Performance improvement |
# Stage all changes
git add -A
# Check for sensitive files
git diff --cached --name-only | grep -E '\.(env|pem|key)$|credentials|secret'
# Commit with heredoc for multi-line
git commit -m "$(cat <<'EOF'
feat(auth): add login endpoint
- Added POST /api/auth/login
- Created AuthService with password verification
- Added unit tests for authentication flow
EOF
)"
# Single-line for trivial changes
git commit -m "fix(typo): correct spelling in README"
If sensitive files are staged, unstage them:
git reset HEAD <sensitive-file>
Then re-run the commit.
Banned:
Required:
type(scope): descriptiongit add -Atype(scope): description formatgit add -ACreate a new branch using worktrunk (wt switch), falling back to git if wt is unavailable.
! git branch --show-current
! command -v wt && wt status 2>/dev/null || echo "wt not available"
! git branch --list | head -10
description: Brief description (converted to kebab-case slug, max 30 chars)wt switch -c ${SLUG} --base mainwt unavailable: git fetch origin main && git checkout -b ${SLUG} origin/main# Using worktrunk (preferred)
wt switch -c user-authentication --base main
wt switch -c fix-balance-calc --base main
wt switch -c update-dependencies --base main
# Fallback (no worktrunk)
git fetch origin main
git checkout -b user-authentication origin/main
Convert description to kebab-case:
add-user-authenticationfix-null-pointer-in-loginBanned:
Required:
wt switch -c when availableCreate a pull request with smart template selection based on commit type.
! git branch --show-current
! git log origin/main..HEAD --oneline 2>/dev/null | head -10
! git diff --stat origin/main 2>/dev/null | tail -5
! git status --short
BRANCH=$(git branch --show-current)
[[ "$BRANCH" == "main" || "$BRANCH" == "master" ]] && echo "ERROR: Create feature branch first with wt switch -c <name> --base main (or /branch)"
If on main -> stop and instruct to use /branch first.
If uncommitted changes exist, use /commit workflow first.
Before pushing, sync with main to avoid conflicts:
Skill({ skill: "git-workflow", args: "sync --rebase" })
git push -u origin $(git branch --show-current)
Ask user for PR type:
Determine primary commit type from first commit:
PRIMARY_TYPE=$(git log origin/main..HEAD --format="%s" | head -1 | cut -d'(' -f1)
| Commit Type | Template Style |
|---|---|
feat | Feature template (summary, motivation, changes) |
refactor, docs, chore, test | Refactor template (what/why/impact) |
fix, other | Fix template (problem, solution, testing) |
Fill template with:
{{SUMMARY}} - Brief description from commits{{COMMITS}} - List of commits{{FILES_CHANGED}} - Files modified{{WHY}} - Motivation (extract from plan if exists)Include implementation plan if available:
PLAN_FILE=$(ls -t ~/.claude/plans/*.md 2>/dev/null | head -1)
[[ -n "$PLAN_FILE" ]] && PLAN_CONTENT=$(cat "$PLAN_FILE")
# Ready for review
gh pr create --title "type(scope): description" --body "$(cat <<'EOF'
## Summary
- Brief description of changes
## Changes
- List of changes made
## Test Plan
- [ ] Tests pass locally
- [ ] Manual testing completed
EOF
)"
# Draft PR
gh pr create --draft --title "..." --body "..."
gh pr merge $(gh pr view --json number -q '.number') --auto --squash
gh pr view --json url -q '.url'
Banned:
/branch firstRequired:
Push commits to remote with safety checks and auto-retry.
! git branch --show-current
! git status --short
! git log origin/$(git branch --show-current 2>/dev/null)..HEAD --oneline 2>/dev/null || echo "New branch or no upstream"
Before pushing, sync with main to avoid conflicts:
Skill({ skill: "git-workflow", args: "sync --rebase" })
This delegates to the sync command which handles fetch, rebase, conflict resolution, and push.
| Situation | Command | Why |
|---|---|---|
| New branch | git push -u origin branch | Sets upstream tracking |
| Normal commits | git push | Standard push |
| After rebase | git push --force-with-lease | Safer than --force |
| After amend | git push --force-with-lease | History rewritten |
BRANCH=$(git branch --show-current)
# Block protected branches
if [[ "$BRANCH" == "main" || "$BRANCH" == "master" ]]; then
echo "ERROR: Cannot push directly to $BRANCH"
exit 1
fi
# New branch (set upstream)
git push -u origin "$BRANCH"
# Existing branch (normal push)
git push
# After rebase (force with lease for safety)
git push --force-with-lease
If push is rejected because remote has new commits:
BRANCH=$(git branch --show-current)
if ! git push; then
git fetch origin "$BRANCH"
if [ -n "$(git log HEAD..origin/$BRANCH --oneline 2>/dev/null)" ]; then
echo "Remote has new commits. Rebasing..."
git rebase "origin/$BRANCH"
git push --force-with-lease
fi
fi
Banned:
git push --force (use --force-with-lease instead)Required:
-u flag for new branches--force-with-lease after rebase/amend-u flag for new branches--force-with-lease (not --force) if neededSync current branch with main (or specified base) using merge or rebase.
! git branch --show-current
! git fetch origin main 2>&1 | head -3
! git log --oneline HEAD..origin/main 2>/dev/null | head -5 || echo "Up to date or no origin/main"
! git status --short
base: Base branch to sync with (default: main)--rebase: Use rebase strategy without prompting (for automated sync before push)--merge: Use merge strategy without prompting--rebase or --merge flag if provided, otherwise ask user# Parse arguments
BASE="main"
STRATEGY=""
for arg in "$@"; do
case "$arg" in
--rebase) STRATEGY="rebase" ;;
--merge) STRATEGY="merge" ;;
*) BASE="$arg" ;;
esac
done
# Fetch latest
git fetch origin "$BASE"
# If no strategy flag provided, ask user (see Merge vs Rebase Decision below)
# If --rebase flag: use rebase
# If --merge flag: use merge
# MERGE (preserves history, creates merge commit)
git merge "origin/$BASE" --no-edit
# OR REBASE (linear history, rewrites commits)
git rebase "origin/$BASE"
# Push after merge
git push
# Push after rebase
git push --force-with-lease
| Aspect | Merge | Rebase |
|---|---|---|
| History | Preserves branches | Linear, clean |
| Commit | Creates merge commit | Rewrites commits |
| Push | Normal push | Force push required |
| Shared branch | Safe | Dangerous |
| Solo feature | OK | Preferred |
Use MERGE when:
Use REBASE when:
Conflict markers:
<<<<<<< HEAD
your changes
=======
incoming changes
>>>>>>> origin/main
Resolution options:
After resolving:
# For merge
git add <resolved-files>
git commit -m "merge: resolve conflicts with main"
# For rebase
git add <resolved-files>
git rebase --continue
# Abort merge in progress
git merge --abort
# Abort rebase in progress
git rebase --abort
# Reset to before sync
git reset --hard ORIG_HEAD
Banned:
git push --force (use --force-with-lease)Required:
--force-with-lease after rebaseExecute a comprehensive code review using specialized review agents.
! git branch --show-current
! git merge-base HEAD main 2>/dev/null || echo "main"
! git diff --name-only $(git merge-base HEAD main 2>/dev/null || echo "HEAD~1") HEAD 2>/dev/null | head -20
Spawn the code-reviewer agent to apply domain-specific checklists:
Task({
subagent_type: "build-mode:code-reviewer",
description: "Apply domain checklists",
prompt: `Review the following files for code quality:
Files: ${ARGUMENTS || "changed files on current branch"}
Apply relevant domain checklists:
- Frontend (React patterns, accessibility, data fetching)
- API (input validation, error responses, auth)
- Data layer (schemas, transactions, indexes)
- Testing (behavior focus, realistic data, coverage)
Report findings with priorities (P1: must fix, P2: should fix, P3: nice to have).`
})
Spawn the quality-reviewer agent for 3-pass quality analysis:
Task({
subagent_type: "build-mode:quality-reviewer",
description: "Review code quality",
prompt: `Review code quality for:
Files: ${ARGUMENTS || "changed files on current branch"}
3-pass review:
1. Style - naming, formatting, magic numbers
2. Patterns - DRY, single responsibility, abstraction level
3. Maintainability - change impact, dependencies, testability
Only report issues with 80%+ confidence. Distinguish must-fix from nice-to-have.`
})
Spawn the security-reviewer agent for security audit:
Task({
subagent_type: "build-mode:security-reviewer",
description: "Security audit",
prompt: `Security review for:
Files: ${ARGUMENTS || "changed files on current branch"}
Check against OWASP Top 10:
- Injection vulnerabilities (SQL, XSS, command)
- Authentication/authorization issues
- Cryptographic failures
- Security misconfigurations
- Hardcoded secrets
Report P0 (critical), P1 (high), P2 (medium) issues.`
})
Spawn the silent-failure-hunter agent to check error handling:
Task({
subagent_type: "build-mode:silent-failure-hunter",
description: "Check error handling",
prompt: `Hunt for silent failures in:
Files: ${ARGUMENTS || "changed files on current branch"}
Find:
- Empty catch blocks
- Silent returns on error
- Broad exception catching
- Missing error propagation
- Swallowed rejections
Classify: P0 (must fix), P1 (should fix), P2 (consider).`
})
After all reviews complete, aggregate findings:
## Review Summary
### Critical Issues (P0)
[List all P0 issues from all reviewers]
### High Priority (P1)
[List all P1 issues]
### Medium Priority (P2)
[List all P2 issues]
### Low Priority (P3)
[List all P3 issues]
### Verdict: [PASS / NEEDS FIXES]
- Pass: No P0 issues, P1 issues are minor
- Needs Fixes: Any P0 issues or multiple P1 issues
For targeted reviews, use arguments:
--security-only - Only security-reviewer--quality-only - Skip security and error handling--quick - Only code-reviewer with reduced scopeBanned:
Required:
Fix all unresolved PR review comments and CI failures with educational feedback.
! git branch --show-current
! git status --short
! gh pr view --json number,title,state,reviewDecision 2>/dev/null || echo "No PR found"
! gh pr checks 2>/dev/null | head -20 || echo "No checks"
# Get unresolved review threads (uses GraphQL API - reviewThreads field doesn't exist in gh pr view)
! {baseDir}/scripts/get-unresolved-threads.sh 2>/dev/null | head -30 || echo "No unresolved threads"
# Get PR issue comments (general comments like Codex/Gemini reviews, not inline threads)
! {baseDir}/scripts/get-issue-comments.sh --actionable 2>/dev/null | head -30 || echo "No issue comments"
Extract from the data above:
For each unresolved thread, issue comment, or CI failure:
Issue comments (like Codex or Gemini reviews) often contain:
Before pushing, verify locally:
bun run lint
bun run test
bun run ci # if available
Before pushing fixes, sync with main:
Skill({ skill: "git-workflow", args: "sync --rebase" })
Use single responsibility - delegate to commit-push:
Skill({ skill: "git-workflow", args: "commit-push fix: address PR review comments" })
Or manually:
git add -A
git commit -m "fix: address PR review comments"
git push --force-with-lease
For EACH unresolved thread, provide feedback using symbols:
Resolve thread via GraphQL:
# Get thread IDs from context (already fetched above) or fetch again
THREADS=$({baseDir}/scripts/get-unresolved-threads.sh)
THREAD_ID=$(echo "$THREADS" | jq -r '.id' | head -1)
# Resolve the thread
{baseDir}/scripts/resolve-thread.sh "$THREAD_ID"
Example feedback patterns:
[checkmark] Good catch! The null check was missing. Fixed in abc123.
[half-circle] Valid concern but useMemo is premature here since component rarely re-renders. Added comment explaining tradeoff.
[x] This pattern is intentional for TypeScript discriminated unions. The 'redundant' check enables type narrowing. Added clarifying comment.
{baseDir}/scripts/count-unresolved-threads.sh
Should return 0.
If CI fails after push:
gh pr checks --watchMax 3 CI retry iterations before escalating.
Banned:
Required:
Update an existing PR's title and body based on current commits.
! gh pr view --json number,title,baseRefName 2>/dev/null || echo "No PR found"
! git log origin/main..HEAD --oneline 2>/dev/null | head -10
! git diff --stat origin/main 2>/dev/null | tail -5
PR_NUM=$(gh pr view --json number -q '.number' 2>/dev/null)
[[ -z "$PR_NUM" ]] && echo "ERROR: No PR found for current branch"
If no PR found -> stop and instruct to use /pr first.
Fetch current PR body and identify preserved sections:
gh pr view --json body -q '.body'
Parse for preserved content:
# User description blockUse Full Regenerate mode if:
--regenerate flag is passed, OROtherwise use Incremental Update mode.
BASE=$(gh pr view --json baseRefName -q '.baseRefName')
git log origin/${BASE}..HEAD --pretty=format:"%s" | head -20
git diff --stat origin/${BASE}
type(scope): summary of changesFor Incremental Update:
## Commits with current commit list## Files Changed with current diff statFor Full Regenerate:
Include plan if available:
PLAN_FILE=$(ls -t ~/.claude/plans/*.md 2>/dev/null | head -1)
[[ -n "$PLAN_FILE" ]] && PLAN_CONTENT=$(cat "$PLAN_FILE")
gh pr edit $PR_NUM --title "type(scope): description"
gh pr edit $PR_NUM --body "$(cat <<'EOF'
[assembled body]
EOF
)"
gh pr view --json url -q '.url'
## Summary
- Brief description of changes
## Commits
- list of commits
## Files Changed
- diff stat
<details>
<summary>Implementation Plan</summary>
[Plan content if available]
</details>
Banned:
--regenerateRequired:
--regenerate or body is broken--regenerate)Create a conventional commit and push to remote. This command delegates to commit and push for single responsibility.
! git branch --show-current
! git status --short
! git log origin/$(git branch --show-current 2>/dev/null)..HEAD --oneline 2>/dev/null || echo "New branch"
Delegate to commit command:
Skill({ skill: "git-workflow", args: "commit $ARGUMENTS" })
This will:
git add -ADelegate to push command:
Skill({ skill: "git-workflow", args: "push" })
This will:
-u flag for new branchesIf delegation is not available, execute directly:
# Stage all changes
git add -A
# Commit
git commit -m "$(cat <<'EOF'
type(scope): description
- Change details
EOF
)"
# Push
BRANCH=$(git branch --show-current)
git push -u origin "$BRANCH" || git push
Banned:
--force instead of --force-with-leaseRequired:
Clean up local branches that have been deleted from the remote repository.
! git fetch --prune 2>&1 | head -5
! git branch -vv | grep ': gone]' | awk '{print $1}' || echo "No gone branches"
! git branch --list | wc -l
# Fetch and prune stale remote-tracking branches
git fetch --prune
# List branches with their tracking status
git branch -vv
# Find branches marked as [gone]
git branch -vv | grep ': gone]' | awk '{print $1}'
# Delete a gone branch
git branch -D <branch-name>
# Fetch and prune
git fetch --prune
# Get list of gone branches
GONE_BRANCHES=$(git branch -vv | grep ': gone]' | awk '{print $1}')
if [ -z "$GONE_BRANCHES" ]; then
echo "No branches to clean up"
exit 0
fi
echo "Branches to remove:"
echo "$GONE_BRANCHES"
# Remove each branch
for branch in $GONE_BRANCHES; do
if command -v wt &>/dev/null; then
echo "Removing via worktrunk: $branch"
wt remove "$branch" || git branch -D "$branch"
else
# Fallback: manual worktree + branch removal
WORKTREE=$(git worktree list | grep "$branch" | awk '{print $1}')
if [ -n "$WORKTREE" ]; then
echo "Removing worktree: $WORKTREE"
git worktree remove "$WORKTREE" --force
fi
echo "Deleting branch: $branch"
git branch -D "$branch"
fi
done
echo "Cleanup complete"
| Status | Meaning | Action |
|---|---|---|
[gone] | Remote branch deleted | Delete local branch |
[ahead X] | Local commits not pushed | Keep (warn user) |
[behind X] | Remote has new commits | Keep |
This command only deletes branches where:
[gone] by gitIt will NOT delete:
Banned:
Required:
Full PR dashboard showing CI checks, reviews, unresolved threads, and mergeable state.
! git branch --show-current
! gh pr view --json number,title,state 2>/dev/null || echo "No PR found"
--json: Output machine-readable JSON instead of human-readable textowner/repo#pr: Target a specific PR instead of the current branchDelegates to scripts/pr-status.sh:
{baseDir}/scripts/pr-status.sh [--json] [owner/repo#pr]
READY TO MERGE or BLOCKED with specific reasons| Code | Meaning |
|---|---|
0 | Ready to merge |
1 | Blocked (reasons listed) |
2 | No PR found |
Required:
Merge the current PR via GitHub squash merge, then print cleanup commands for the user.
! git branch --show-current
! gh pr view --json number,title,state 2>/dev/null || echo "No PR found"
! git worktree list --porcelain | head -3
scripts/pr-status.sh to verify readinessAskUserQuestion to ask if the user wants to continue anywaygh pr merge --squash --delete-branchgit worktree list --porcelain for the first (main) worktree# Step 1: Check readiness
if ! {baseDir}/scripts/pr-status.sh; then
echo "⚠ PR is not ready to merge."
# Use AskUserQuestion to ask whether to continue anyway
fi
# Step 2: Squash merge via GitHub
gh pr merge --squash --delete-branch
# Step 3: Get main worktree path
MAIN_WORKTREE=$(git worktree list --porcelain | head -1 | sed 's/^worktree //')
# Step 4: Get current worktree path
CURRENT_WORKTREE=$(pwd)
# Step 5: Print cleanup commands for the user
echo ""
echo "Run these commands to clean up:"
echo " cd $MAIN_WORKTREE"
echo " git worktree remove $CURRENT_WORKTREE"
echo " git pull"
The agent cannot remove the worktree it is running in — the folder removal will fail.
Instead, print the cleanup commands so the user can run them after the session.
Use AskUserQuestion (not plain text) when asking whether to proceed despite failed status check.
Banned:
wt merge (always use gh pr merge for remote squash)Required:
AskUserQuestion before continuinggh pr merge --squash --delete-branch