git-checkpoint
它能做什么
这项技能使用 Git 提交作为智能体工作的安全网。适合希望智能体尝试大型重构,同时又不想冒丢失良好代码风险的开发者。
适用场景
- ✓当你即将对项目进行大型或有风险的改动时。
- ✓当你想进行跨多个文件的重构,并保留一个安全的起点时。
- ✓当某次改动让情况变糟,你想回到上一个良好状态的时候。
技能链接
https://github.com/agentscope-ai/agentscope-java/blob/main/agentscope-examples/agents/agentscope-codingagent/src/main/resources/workspace-templates/skills/git-checkpoint/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请保存当前代码的检查点,然后重构支付模块。如果出了问题,就回滚到检查点。”
每周 5 个新技能,1 分钟读完。
工作原理
这项技能会在有风险的工作之前创建一个检查点提交,并记录其 ID。如果改动出错,它会丢弃未提交的改动,或重置到检查点,然后尝试另一种方法。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Git Checkpoint and Rollback
You work in a git-backed sandbox. Use git as an undo/snapshot mechanism so you can take bold steps without fear of corrupting the working tree.
Checkpoint before risky work
Before a large refactor or anything you are unsure about, save the current good state:
git add -A && git commit -m "checkpoint: before <short description>" --no-verify
Record the commit hash (git rev-parse HEAD) so you can return to it.
Roll back on failure
If a change makes things worse and you cannot quickly fix it, revert rather than piling on more edits:
- Discard uncommitted changes to a file:
git checkout -- <file> - Discard ALL uncommitted changes:
git reset --hard HEAD - Return to a checkpoint:
git reset --hard <checkpoint-hash>
Then re-read the code and try a different approach.
Rules
- NEVER create
.bak/ backup files — git is your history. - Checkpoint commits are local scaffolding; squash or reset them before pushing the final PR branch so the published history stays clean.
常见问题
它会删除我未保存的工作吗?
只有在需要回滚时,才会丢弃未提交的改动,因此请先保存重要的工作。
它会生成备份文件吗?
不会。技能规定不创建备份文件,因为 Git 会保留历史。
检查点提交会怎样处理?
技能规定,在推送最终分支之前应先清理这些检查点提交。
详情
作者的原始描述
Use git as a safety net - create a checkpoint commit before risky or large changes and roll back cleanly if a change makes things worse. Use before multi-file refactors.
热度
- GitHub 星标
- 6.2k
- 排名
- #14388
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
agentscope-java
6.2k帮你的智能体用 Java 编写非阻塞的 AgentScope 代码,AgentScope 是基于 Project Reactor 的多智能体框架。
data-report
6.2k帮你的智能体把数据集汇总成报告,包括平均值、总数、范围和趋势,并保存为 Markdown 文件。
data-transform
6.2k帮你的智能体在 CSV 和 JSON 等格式之间转换数据文件,使数据可以在其他工具中使用。
git-changelog
6.2k帮你的智能体根据 Git 历史编写变更日志或发布说明,并按新功能、修复和其他改动分组。