commit-context
它能做什么
这项技能把一个文件、函数或行追溯到产生其当前提交的智能体会话。它只报告 git 和记忆查询实际返回的内容。
适用场景
- ✓当你询问某段代码为什么会出现在代码库中时。
- ✓当你想知道一项改动产生时智能体正在做什么时。
- ✓当你想了解代码中某个具体位置的背景时。
技能链接
https://github.com/rohitg00/agentmemory/blob/main/plugin/skills/commit-context/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“这段刷新令牌的代码为什么在这里?请把它追溯到编写它的那个会话。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会使用 git blame 找出你指定行所对应的提交,然后在记忆服务器中查找该提交。它会报告关联的会话和关键观察内容,如果提交早于会话关联功能,它会说明这一点。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
The user wants commit context for: $ARGUMENTS
Quick start
git blame -L 40,52 src/auth/refresh.ts # -> SHA 9a1b2c3d
memory_commit_lookup { "sha": "9a1b2c3d4e5f60718293a4b5c6d7e8f901234567" }
Expected output:
9a1b2c3 on main by dev: "rotate refresh tokens"
Linked session 7f3a9c2 "Auth refresh rework", 14 obs.
Why
Report only what git and the lookup return. When the lookup gives commit: null,
the commit predates session linking; do not invent intent.
Workflow
- Find the SHA:
git blame -L <start>,<end> <file>for a line range;git log -L :<function>:<file>for a function;git log -n 1 -- <file>for a bare path. - Look it up:
memory_commit_lookup { "sha": "<full-sha>" }. - Present the commit (sha, short sha, branch, author, message), the linked
session(s) (id, project, started/ended, observation count, summary), and the
importance >= 7 observations via
memory_recallwhen available.
Anti-patterns
WRONG: lookup returns { "commit": null }, you narrate "the agent was
refactoring auth" from the diff alone.
RIGHT: "This commit predates session linking, so there is no recorded agent
session. From git show: it changed token rotation in refresh.ts."
Checklist
- SHA came from git blame/log, not a guess.
commit: nullreported as "predates linking", no fabricated session.- Session details quote the lookup response verbatim.
- No intent claimed beyond what observations state.
See also
commit-history: list many agent-linked commits at once.recall: dig deeper into the linked session's observations.
Troubleshooting
See TROUBLESHOOTING.md if memory_commit_lookup is not available.
常见问题
如果没有关联会话怎么办?
技能会说明该提交早于会话关联功能,不会编造解释。
它使用 git 吗?
使用。它通过 git blame、git log 或文件历史找到提交。
它会猜测改动背后的意图吗?
不会。如果没有记录的会话,它只描述差异所显示的内容。
详情
作者的原始描述
Trace a file, function, or line back to the agent session that produced its current commit. Use when the user asks "why is this code here", "what was the agent doing when this changed", "who wrote this", or wants context on a specific location in the codebase.
repo: rohitg00/agentmemory
热度
- GitHub 星标
- 30k
- 排名
- #9345
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
agentmemory-agents
30k帮你的智能体把 agentmemory 记忆服务器连接到 Claude Code、Cursor 和 Codex 等编程工具。
agentmemory-architecture
30k解释 agentmemory 如何为编程智能体存储、搜索和管理记忆,从记录到回忆的整个过程。
agentmemory-config
30k帮你的智能体设置并检查 agentmemory 记忆服务器,包括端口、配置和功能开关。
agentmemory-hooks
30k帮你的智能体自动从编程会话中记录有用的笔记,而不需要你逐条手动保存。