commit-archaeologist
它能做什么
这项技能通过查阅项目的本地 git 历史,解释一段代码背后的原因。适合在修改自己并未编写的代码之前,需要了解背景的人。
适用场景
- ✓你询问某个函数或某段代码为什么存在的时候。
- ✓你想知道某段代码是谁编写的,以及之后有哪些改动的时候。
- ✓你计划重写代码,需要先了解其历史的时候。
技能链接
https://github.com/Shubhamsaboo/awesome-llm-apps/blob/main/agent_skills/commit-archaeologist/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“这个函数为什么存在?请在 git 历史中查找并解释,然后我再做修改。”
每周 5 个新技能,1 分钟读完。
工作原理
它通过本地 git 提交追踪文件或代码行,找到引入这些代码的提交以及之后的修改,并阅读提交信息以寻找意图的线索。所有操作都在你的电脑上完成。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Commit Archaeologist
git blame names the last person to touch a line. This skill reconstructs the
reason the line exists. It traces a file or current line range through local git
history, identifies its origin and later edits, finds files that repeatedly
changed beside it, and extracts intent clues from commit messages.
Everything runs locally. No network calls, API keys, or repository writes.
When to use
- The user asks why a block, function, or file exists
- The user wants to know who introduced code and what changed afterward
- A rewrite or refactor needs historical constraints and change risks
- A workaround, temporary branch, or surprising design choice needs context
When not to use
- The user only wants raw blame output or a commit list
- The task is to squash, delete, or rewrite git history
- The repository is remote and has not been cloned locally
- The question is about project-wide architecture rather than one file or region
Gather the target
Get the repository path and tracked file path. Use a line range when the user names a current block or function. If either path is missing, ask only for the missing value. Do not scan sibling repositories.
Paths should be relative to the repository and use forward slashes. Line ranges
use inclusive current line numbers such as 40-72.
Run the dig
From this skill directory:
python3 scripts/archaeologist.py /path/to/repo src/cache.py --lines 40-72 --json
For the complete history of a file, omit --lines:
python3 scripts/archaeologist.py /path/to/repo src/cache.py --json
The script is read-only. With a range it uses git line-log; without one it uses file history with rename following. It also reads current authorship with blame. If it rejects a path or range, report that error and ask for a corrected target.
Before interpreting the JSON, read
references/reading-git-history.md. Its confidence rules prevent blame
ownership, correlation, and commit-message hints from becoming false certainty.
Read the JSON
region: normalized repository, current and historical paths, mode, range, and co-change thresholdintroduced_by: oldest commit in the selected historytimeline: commits ordered oldest to newest, with category, changed files, and detected renamesco_changed: files present beside the target in enough selected commitsauthors: current blamed lines and historical commit counts, kept separateintent_signals: issue references, reverts, workarounds, temporary markers, and unfinished-work markers found in commit messages
An empty signal list means the messages do not say why. It does not mean the change had no reason.
Write the report
Turn the JSON into a short "why this code exists" report:
- Bottom line. One or two sentences with the most likely explanation and a confidence label: high, medium, or low.
- Origin. Introducing hash, date, author, subject, and the neighboring files that make the initial purpose clearer.
- Timeline. Oldest to newest. Group mechanical edits when they do not change the story, but preserve reverts, fixes, and workarounds.
- Companion files. Explain repeated co-changes as a coupling clue. Do not
treat a one-off file in
changed_filesas a dependency. - Intent evidence. Quote short commit subjects or signal words. Label any conclusion beyond those facts as an inference.
- Change risk. Name the constraints, companion files, and unresolved temporary choices worth checking before an edit.
Keep hashes short in prose, but preserve enough characters to identify them. Do not dump the full JSON unless the user asks.
Evidence rules
- Current blame ownership is not proof of original authorship.
- The oldest selected commit is the region's introduction, not always the file's first commit.
- Repeated co-change suggests coupling; it does not prove a dependency.
- Commit categories are message heuristics, not verified issue types.
- "Temporary" and "workaround" are strong intent clues, but only the message author or linked discussion can confirm whether the constraint still applies.
- If the history is thin or messages are vague, say "the history shows" and "likely" instead of inventing a design rationale.
Follow-ups
End by offering one relevant follow-up, such as:
- "Want me to assess whether this looks deliberate or accidental?"
- "Want me to map what could break if this region changes?"
For a delibe
常见问题
它会把我的代码发送到别处吗?
不会。它完全在本地运行,不进行网络调用,也不会写入代码仓库。
它需要我提供什么?
代码仓库的位置、文件路径,以及可选的相关代码行范围。
它能重写或删除 git 历史吗?
不能。重写或删除历史不在这项技能的范围之内。
详情
作者的原始描述
Reconstructs why code exists from local git history, including the introducing commit, later changes, current authors, repeated companion files, and likely intent. Use when the user asks "why does this code exist", "who wrote this function and why", or to "explain the history of this function" before a rewrite, refactor, or risky edit. Runs entirely locally.
热度
- GitHub 星标
- 144k
- 排名
- #674
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/22
评论
- …
同一仓库的更多技能
advisor-orchestrator-worker
144k帮你的智能体把非常庞大的任务分配给一组 AI 模型,由较强的模型负责规划和检查,较便宜的模型负责执行。
dependency-doctor
144k帮你的智能体检查 requirements.txt、pyproject.toml 或 package.json 文件中常见的依赖问题,并提出小而便于审阅的修复建议。
first-reader
144k帮你的智能体模拟真实读者的阅读体验来测试草稿,指出读者可能在哪里失去兴趣,以及他们会记住什么。
project-graveyard
144k帮你的智能体扫描电脑上未完成的业余项目,解释每个项目停滞的原因,并挑选出值得完成的那一个。