shreyam1008-git Skill 技能
覆盖提交、合并、冲突、回归调查、丢失恢复的全场景 Git 排错 Skill
技能简介
shreyam1008-git 是 shreyam1008 为 Claude、Codex、Claude Code 编写的一款"全场景 Git 排错与历史管理"Skill,覆盖日常提交、合并策略、回归调查、丢失提交恢复四大高频痛点。它把 selective staging、Conventional Commits 消息起草、git status/diff/log/blame/bisect 的用法、reflog 恢复路径、冲突解决流程、branch protection 与签名提交等最佳实践封装成可重复调用的提示模板,特别适合处理"代码丢了找不回来""冲突 merge 后跑不起来""不知道哪个 commit 引入 bug"这三类棘手场景。Quality Score 78、审计完整、风险仅声明外部命令,安全可靠。
核心能力
- 引导选择性暂存(selective staging),把混杂的暂存区内容拆分为多个语义清晰的 atomic commit,并起草 Conventional Commits 消息。
- 解释 feature branch 工作流、merge commit 选择、rebase 与 squash 的取舍,特别强调"私有历史可 rebase、共享历史必须 merge"的原则。
- 推荐 status / diff / log / blame / bisect 五件套用于历史排查:bisect 用于定位"哪个 commit 引入 bug",blame 用于追溯行级作者,log 用于审计。
- 给出 restore / amend / revert / reset / stash / reflog 六大恢复操作的适用场景与风险等级,避免误用
git reset --hard丢失工作。 - 引导冲突解决流程:先看意图、再做局部合并、跑 build/test、必要时启用 rerere 复用历史冲突解法。
- 推荐 branch protection、signed commit、annotated tag、secret 扫描等仓库安全实践。
安装配置
- 通过
npx skillstore add shreyam1008/git一行命令完成安装,依赖本机 Git ≥2.30 与可访问的终端权限。 - 安装前建议启用
git config --global rerere.enabled true,让 Skill 推荐的冲突复现机制生效。 - 推荐在仓库根目录的
.gitignore与分支保护规则中明确禁止 force push 到主分支,Skill 的"私有历史 rebase"才能真正落地。 - 若团队使用 GitHub,可配合 protected branch + required signed commits 一起启用,最大化 Skill 的安全保障。
使用步骤
- 第一步:执行
Inspect my repository status and diffs. Summarize staged and unstaged changes without modifying files or history.,让 Skill 先盘点当前工作区状态。 - 第二步:执行
Review my changes and propose separate logical commits with Conventional Commits messages. Wait for approval before staging or committing.,让它拆分 atomic commit。 - 第三步:合并冲突时执行
Inspect conflicts between [feature branch] and [target branch]. Propose resolutions that preserve intended behavior and identify tests before continuing integration.,按"意图优先 + 测试保障"流程解决。 - 第四步:定位丢失提交执行
Inspect status, log, and reflog to locate [lost change]. Explain recovery options and risks; request approval before any reset or history rewrite.,reflog 是恢复 commit 的最后一道防线。 - 第五步:完成集成后跑一遍
git log --graph --oneline --all验证历史结构,必要时给主分支打 annotated tag。
适用场景
- 长期维护的开源项目:需要规范提交粒度、保留可 bisect 的线性历史。
- 多人协作的 feature branch 团队:高频合并冲突,需要标准化的冲突解决流程。
- 紧急回滚 / 故障排查:用 bisect 定位引入 bug 的 commit,用 revert 安全撤销线上变更。
- 不小心
git reset --hard或git push --force后找回丢失提交:通过 reflog + fsck 抢救。 - 金融、政企等强合规场景:要求签名提交、审计追溯、branch protection 全开。
适用人群
- 中高级开发者与 Tech Lead,需要为团队建立 Git 协作规范。
- SRE / 运维工程师:在生产事故中通过 bisect 定位代码缺陷。
- DevRel / 开源维护者:希望保留可读的历史便于贡献者理解演进。
- 任何被
git rebase/git reset/ 冲突 merge 反复折磨过的开发者。
工作原理
Skill 内置一套"安全 Git 操作决策框架",核心是把每个命令按"是否修改历史、是否影响共享分支、是否可逆"做三维分类。对 destructive 命令(reset --hard、force-push、amend 已推送 commit)一律先要求 reflog 备份、再要求用户显式授权。对冲突解决引入"意图检查 → build → test → rerere"四步流程,避免盲目 accept 对方代码。Bisect 工具自动化基于"已知坏 feature 倒退 N 步→二分→测试→标记"算法,配合 Skill 提供的 prompt 让 AI 辅助阅读 diff 上下文。所有操作前都会先 inspect status/diff,避免直接写历史。审计已确认无 prompt injection 或恶意执行风险。
官方链接
- Skill 详情页:https://skillstore.io/skills/shreyam1008-git
- Manifest:https://skillstore.io/api/skills/shreyam1008-git/manifest
- 源仓库:https://github.com/shreyam1008/shre-skills/tree/ba9787f41c2fe1be1062eeb6322bc339a1026383/skills/git
- 安装命令:
npx skillstore add shreyam1008/git
评论与建议
登录 后参与评论或提建议