跳到正文
Skillpedia
通用编程6.2k · #14388

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/agentscope-ai/agentscope-java/blob/main/agentscope-examples/agents/agentscope-codingagent/src/main/resources/workspace-templates/skills/git-checkpoint/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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.

repo: agentscope-ai/agentscope-java

热度

GitHub 星标
6.2k
排名
#14388
许可证
Apache-2.0
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能