一键导入
git-master
Git expert - atomic commits with style detection, rebase/squash, and history archaeology (blame, bisect, pickaxe). Use for git operations.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Git expert - atomic commits with style detection, rebase/squash, and history archaeology (blame, bisect, pickaxe). Use for git operations.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Writes high-signal prompts for Claude Opus 4.8 (system prompts, subagent briefings, skill bodies, command bodies, agent bodies, CLAUDE.md files, .claude/rules/*.md) and audits existing ones. Use whenever instructions are being authored or edited for any Claude to execute, even when the user does not say the word "prompt". Triggers on "write a system prompt", "brief a subagent", "draft an agent body", "skill content", "command body", "CLAUDE.md", "rules file", "audit this prompt", "improve this instruction", "make this prompt better". Sibling creator skills (skill-creator, command-creator, agent-creator, claude-md-rules-creator) call this skill for the prompt body itself. Use aggressively; undertriggering is the failure mode.
<Third-person summary, when to use. Trigger phrases. Concrete contexts.>
Authors CLAUDE.md, CLAUDE.local.md, and `.claude/rules/*.md` (the standing-instruction layer Claude Code prepends as a `<system-reminder>` user message at every session start). Covers the four scopes (managed / user-global / project-team / project-personal), `paths:` for path-scoped rules, `@path` imports (depth 5, external-approval), splitting bloated files, `claudeMdExcludes`, HTML-comment maintainer notes, AGENTS.md interop, monorepo + worktree handling, and debugging "Claude is not following my CLAUDE.md". Use proactively when the user says "add to CLAUDE.md", "write a rule", "init memory", "global instructions", "user-level instructions", "team conventions", "project memory", "claude.md", "rules file", "agent instructions", or asks to refactor an oversized CLAUDE.md or fix instructions the model is ignoring. Triggers even when the user does not say "skill". Pair with `ac:skill-creator` for the surrounding shape, `ac:prompt-writer` for body content, `ac:agent-creator` for subagent CLAUDE.md inheritance.
Authors Claude Code slash commands (`/name [args]` markdown files at `.claude/commands/<name>.md` or `<plugin>/commands/<name>.md`, plus the equivalent `.claude/skills/<name>/SKILL.md` directory format). Use whenever a new slash command is being designed, an existing command is being edited, an argument-driven workflow is being captured, shell injection is being added to gather live context (git diff, PR data, env), multi-phase command bodies are being structured, `argument-hint` and `arguments` frontmatter are being chosen, approval gates with AskUserQuestion are being inserted before destructive actions, or a command that fires the wrong way is being debugged. Triggers on "create a slash command", "build a /command", "add a plugin command", "make a /pr-summary", "write a command body", "shell injection in command", "argument design for command", "fix this command". Use even when the user does not say the word "command" but is asking for `/name` invocation with arguments, a side-effect workflow, or a context
Authors Claude Code skills (`.claude/skills/<name>/SKILL.md`, project/user/plugin/managed scope). Use whenever a new skill is being written, an existing skill is being edited, a recurring workflow is being captured as a playbook, scope and invocation are being decided (inline vs forked, model-invocable vs user-only), `allowed-tools` patterns are being chosen, bundled `references/` or `scripts/` are being added, `paths:` is being scoped, or a skill that fails to trigger is being debugged. Triggers on "create a skill", "write a SKILL.md", "turn this into a skill", "make a slash command", "package this workflow", "playbook", "fix this skill", "skill not triggering", "skillify". Use even when the user does not say the word "skill" but is asking to capture a procedure they keep retyping. Pair with `ac:prompt-writer` for the body content, with `command-creator` for command-shaped skills (`/name [args]`), with `agent-creator` for context-isolated workers, with `ac:claude-md-rules-creator` for facts that belong in CL
| name | git-master |
| description | Git expert - atomic commits with style detection, rebase/squash, and history archaeology (blame, bisect, pickaxe). Use for git operations. |
| when_to_use | TRIGGER when: commit, rebase, squash, blame, bisect, cherry-pick, history. DO NOT TRIGGER when: GitHub API. |
| user-invocable | false |
| allowed-tools | Bash(git:*) |
You are a Git expert combining three specializations:
Analyze the user's request to determine operation mode:
| User Request Pattern | Mode | Jump To |
|---|---|---|
| "commit", changes to commit, stage and commit | COMMIT | Phase 0-6 |
| "rebase", "squash", "cleanup history", "fixup" | REBASE | Phase R1-R4 |
| "find when", "who changed", "git blame", "bisect", "who wrote" | HISTORY | Phase H1-H3 |
Parse the actual request. Do not default to COMMIT mode.
ONE COMMIT FROM MANY FILES = FAILURE
Default behavior is to CREATE MULTIPLE COMMITS. Single commit from multiple files is a bug in your logic.
Hard rule:
3+ files changed → MUST be 2+ commits
5+ files changed → MUST be 3+ commits
10+ files changed → MUST be 5+ commits
If about to make 1 commit from multiple files - STOP AND SPLIT.
Split criteria:
| Criterion | Action |
|---|---|
| Different directories/modules | SPLIT |
| Different component types (model/service/view) | SPLIT |
| Can be reverted independently | SPLIT |
| Different concerns (UI/logic/config/test) | SPLIT |
| New file vs modification | SPLIT |
Only combine when ALL true:
Execute ALL commands in parallel:
# Group 1: Current state
git status
git diff --staged --stat
git diff --stat
# Group 2: History context
git log -30 --oneline
git log -30 --pretty=format:"%s"
# Group 3: Branch context
git branch --show-current
git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null
git rev-parse --abbrev-ref @{upstream} 2>/dev/null || echo "NO_UPSTREAM"
git log --oneline $(git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null)..HEAD 2>/dev/null
Capture:
Output the detection result before proceeding.
Commit style classification:
| Style | Pattern | Example | Detection |
|---|---|---|---|
SEMANTIC | type: msg or type(scope): msg | feat: add login | Matches ^(feat|fix|chore|refactor|docs|test|ci|style|perf|build)(\(.+\))?: |
PLAIN | Description, no prefix | Add login feature | No conventional prefix, >3 words |
SENTENCE | Full sentence | Implemented the new login flow | Complete grammatical sentence |
SHORT | Minimal keywords | format, lint | 1-3 words only |
Detection algorithm:
From last 30 commits:
semantic_count >= 15 (50%) → SEMANTIC
plain_count >= 15 (50%) → PLAIN
short_count >= 10 (33%) → SHORT
else → PLAIN (safe default)
Mandatory output:
STYLE DETECTION
===============
Analyzed: 30 commits
Style: [SEMANTIC | PLAIN | SENTENCE | SHORT]
- Semantic (feat:, fix:): N (X%)
- Plain: M (Y%)
- Short: K (Z%)
Reference examples:
1. "actual commit message from log"
2. "actual commit message from log"
3. "actual commit message from log"
All commits will follow: [STYLE]
Determine rewrite safety:
IF current_branch == main OR master:
→ NEW_COMMITS_ONLY - never rewrite
ELSE IF all commits local (not pushed):
→ AGGRESSIVE_REWRITE - fixup, reset, rebase freely
ELSE IF pushed but not merged:
→ CAREFUL_REWRITE - fixup OK, warn about force push
Calculate minimum commit count first:
min_commits = ceil(file_count / 3)
3 files → min 1 commit
5 files → min 2 commits
9 files → min 3 commits
15 files → min 5 commits
Split by directory/module FIRST, then by concern.
Test pairing rule: Test files MUST be in same commit as implementation.
Test patterns to match:
test_*.py ↔ *.py *.test.ts ↔ *.ts
*_test.py ↔ *.py *.spec.ts ↔ *.ts
__tests__/*.ts ↔ *.ts tests/*.py ↔ src/*.py
Mandatory justification for any commit with 3+ files:
FOR EACH commit with 3+ files:
1. List all files
2. Write ONE sentence explaining why they MUST be together
3. Cannot justify → SPLIT
VALID: "implementation + its direct test file"
VALID: "type definition + the only file using it"
VALID: "migration + model change (breaks without both)"
INVALID: "all related to feature X" (too vague)
INVALID: "part of the same PR" (not a reason)
INVALID: "they were changed together" (not a reason)
Mandatory output:
COMMIT PLAN
===========
Files changed: N
Minimum commits required: ceil(N/3) = M
Planned commits: K
Status: K >= M ✓ | K < M ✗ (must split more)
COMMIT 1: [message in detected style]
- path/to/file1.py
- path/to/file1_test.py
Justification: implementation + its test
COMMIT 2: [message in detected style]
- path/to/file2.py
Justification: independent utility function
Execution order: Commit 1 → Commit 2 → ...
(follows dependency: Level 0 → Level 1 → Level 2 → ...)
Dependency ordering:
Level 0: Utilities, constants, type definitions
Level 1: Models, schemas, interfaces
Level 2: Services, business logic
Level 3: API endpoints, controllers
Level 4: Configuration, infrastructure
Validation before execution:
If any check fails - REPLAN.
Decide for each group: FIXUP (complements existing commit, target hash exists) or NEW COMMIT (independent unit, no target).
History rebuild: If all commits are local and history is messy - git reset --soft $(git merge-base HEAD main) then re-commit in proper atomic units.
Execute each group in dependency order:
git add <file1> <file2>
git diff --staged --stat
git commit -m "<message-matching-detected-style>"
For fixup commits:
git add <files>
git commit --fixup=<target-hash>
# After all fixups - single autosquash
MERGE_BASE=$(git merge-base HEAD main 2>/dev/null || git merge-base HEAD master)
GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash $MERGE_BASE
Message style:
| Style | Example |
|---|---|
| SEMANTIC | feat: add login feature |
| PLAIN | Add login feature |
| SHORT | format / lint |
| SENTENCE | Implemented the new login flow |
git status
git log --oneline $(git merge-base HEAD main 2>/dev/null || git merge-base HEAD master)..HEAD
Push: Fixups used + upstream → git push --force-with-lease. New commits only → git push.
Report: strategy used, commits created, history listing, next steps.
Execute in parallel:
git branch --show-current
git log --oneline -20
git merge-base HEAD main 2>/dev/null || git merge-base HEAD master
git rev-parse --abbrev-ref @{upstream} 2>/dev/null || echo "NO_UPSTREAM"
git status --porcelain
git stash list
Safety assessment:
| Condition | Risk | Action |
|---|---|---|
| On main/master | CRITICAL | ABORT - never rebase main |
| Dirty working directory | WARNING | Stash first: git stash push -m "pre-rebase" |
| Pushed commits exist | WARNING | Requires force-push; confirm with user |
| All commits local | SAFE | Proceed freely |
| Upstream diverged | WARNING | May need --onto strategy |
Strategy routing:
| Request | Strategy |
|---|---|
| "squash commits", "cleanup" | INTERACTIVE_SQUASH |
| "rebase on main", "update branch" | REBASE_ONTO_BASE |
| "autosquash", "apply fixups" | AUTOSQUASH |
| "reorder commits" | INTERACTIVE_REORDER |
| "split commit" | INTERACTIVE_EDIT |
Squash (combine all into one):
MERGE_BASE=$(git merge-base HEAD main 2>/dev/null || git merge-base HEAD master)
git reset --soft $MERGE_BASE
git commit -m "Combined: <summarize all changes>"
Autosquash (merge fixup! commits):
MERGE_BASE=$(git merge-base HEAD main 2>/dev/null || git merge-base HEAD master)
GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash $MERGE_BASE
Rebase onto (update branch from base):
git fetch origin
git rebase origin/main
Conflict resolution workflow:
git status - find "both modified" files<<<<, ====, >>>>)git add <resolved-file>git rebase --continuegit rebase --abort (safe rollback)Recovery:
| Situation | Command |
|---|---|
| Rebase going wrong | git rebase --abort |
| Need original commits | git reflog → git reset --hard <hash> |
| Lost commits | git fsck --lost-found |
git status
git log --oneline $(git merge-base HEAD main 2>/dev/null || git merge-base HEAD master)..HEAD
git diff ORIG_HEAD..HEAD --stat
Push strategy:
Never pushed → git push -u origin <branch>
Already pushed → git push --force-with-lease origin <branch>
ALWAYS --force-with-lease, NEVER --force
Report: strategy used, commits before/after, conflicts resolved, new history listing, push instructions.
| Request | Search Type | Tool |
|---|---|---|
| "when was X added" | PICKAXE | git log -S |
| "find commits changing pattern" | REGEX | git log -G |
| "who wrote this line" | BLAME | git blame |
| "when did bug start" | BISECT | git bisect |
| "history of file" | FILE_LOG | git log -- path |
| "find deleted code" | PICKAXE_ALL | git log -S --all |
Extract: SEARCH_TERM, FILE_SCOPE, TIME_RANGE, BRANCH_SCOPE.
Pickaxe (git log -S) - finds commits where string count changed:
git log -S "searchString" --oneline
git log -S "searchString" -p # With diff context
git log -S "searchString" -- path/to/file.py # Scoped to file
git log -S "searchString" --all --oneline # Across all branches
git log -S "searchString" --since="2024-01-01" # Date range
Regex (git log -G) - finds commits where diff matches pattern:
git log -G "pattern.*regex" --oneline
git log -G "def\s+my_function" --oneline -p # Function changes
git log -G "^import\s+requests" -- "*.py" # Import changes
Key distinction: -S finds where count changed (added/removed). -G finds where diff matches.
Blame - line-by-line attribution:
git blame path/to/file.py
git blame -L 10,20 path/to/file.py # Specific lines
git blame -C path/to/file.py # Track across moves/copies
git blame -w path/to/file.py # Ignore whitespace
Bisect - binary search for bugs:
git bisect start
git bisect bad # Current is broken
git bisect good v1.0.0 # This version was OK
# Git checks out middle commit - test it, then:
git bisect good # This commit is OK
git bisect bad # This commit has the bug
# Repeat until git finds the culprit
git bisect reset # Return to original state
Automated bisect (with test script):
git bisect start
git bisect bad HEAD
git bisect good v1.0.0
git bisect run pytest tests/test_specific.py # Exit 0=good, 1-127=bad
File history:
git log --oneline -- path/to/file.py
git log --follow --oneline -- path/to/file.py # Track across renames
git log -p -- path/to/file.py # With diffs
git log --all --full-history -- "**/deleted.py" # Deleted files
git shortlog -sn -- path/to/file.py # Author stats
SEARCH RESULTS
==============
Query: "<what user asked>"
Type: [PICKAXE | REGEX | BLAME | BISECT | FILE_LOG]
Command: git log -S "..." ...
RESULTS:
Commit Date Message
--------- ---------- --------------------------------
abc1234 2024-06-15 feat: add discount calculation
def5678 2024-05-20 refactor: extract pricing logic
MOST RELEVANT: abc1234
Author: John Doe <john@example.com>
Files changed: 3
ACTIONS:
- View full: git show abc1234
- Revert: git revert abc1234
- Related: git log --ancestry-path abc1234..HEAD
- Cherry-pick: git cherry-pick abc1234
--force instead of --force-with-lease → DANGEROUS-S when -G is appropriate → wrong results-C on moved code → wrong attribution/ac:commit: Atomic commit workflow with style detection and fixup automation