code-archaeology

code-archaeology is a skill for Claude Code, Codex from DuanZGit/D-Hub. It costs 142 tokens per session (965 once invoked), scanned A, original, MIT.

A Git-based code archaeology guide for understanding unfamiliar code and the reasons behind it. Git is a version-control system that records changes, authors, and commit messages over time.

In plain words
What is it for?
Use it before modifying legacy code, when joining an unfamiliar repository, during code review, or when investigating slow code or slow pull requests.
Why use it?
It replaces guesses about old code with evidence from file history, line ownership, issues, and pull requests. It also highlights confusing code without changing it automatically.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it before modifying legacy code, when joining an unfamiliar repository, during code review, or when investigating slow code or slow pull requests.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/duanzgit/d-hub/code-archaeology
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add DuanZGit/D-Hub --skill code-archaeology
Clone the repo
git clone --depth 1 https://github.com/DuanZGit/D-Hub

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for code-archaeology

README.md
[![agentmods](https://agentmods.dev/badge/skills/duanzgit/d-hub/code-archaeology/github.svg)](https://agentmods.dev/skills/duanzgit/d-hub/code-archaeology)
Your own site
<a href="https://agentmods.dev/skills/duanzgit/d-hub/code-archaeology"><img src="https://agentmods.dev/badge/skills/duanzgit/d-hub/code-archaeology/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for code-archaeology

Your own site · 80×15
<a href="https://agentmods.dev/skills/duanzgit/d-hub/code-archaeology"><img src="https://agentmods.dev/badge/skills/duanzgit/d-hub/code-archaeology.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 142 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 965 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00142 $0.00965
Opus 5.5 $0.00057 $0.00386
Sonnet 5.5 $0.00028 $0.00193
Haiku 4.5 $0.00014 $0.00097

Measured 10d ago against content hash 4cd616082a41, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

code-archaeology scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/code-archaeology/SKILL.md · 64 lines

What it actually says

code-archaeology

三件事,按需取用,不必全做。核心纪律:考古结论要有 commit 佐证,不许凭代码形状猜意图。

1. Git 历史考古——分清三类代码

改动前先跑(路径换成目标文件):

git log --follow --oneline -- <file> | head -30        # 文件级历史
git log -L <start>,<end>:<file> --oneline              # 函数级历史
git blame -L <start>,<end> -- <file>                    # 行级归属

对可疑代码段,找它诞生的 commit 读当时的 commit message 和关联 issue/PR:

  • 有意设计:有明确 commit message 说明取舍、关联 issue/PR、或后继 commit 反复围绕它演进 → 保留,改动前先理解约束("为什么"比"是什么"重要)。
  • 历史遗留:早期写的、后来没人动、无 message 说明、与现状脱节 → 标记候选清理项,报告给用户,不擅自删。
  • 失效问题:当初为修 bug/绕限制打的补丁,前提条件后来已消失 → 提出移除方案,注明依赖它的隐藏耦合,让用户拍板。

完成判据:每个"能不能动"的判断都有一句 commit 佐证(hash + 当时为什么写它)。

2. 新工程师视角——评认知成本

假设接手的是一个很强的新工程师,第一周要上手这段代码:

  • 通读主流程,标出让他皱眉的点:命名与行为不符、抽象过度(跳三层才到逻辑)、 职责不清(一个函数干三件事)、重复模式没收敛、魔法数字/隐式约定。
  • 每个痛点给出具体简化方案(改成什么、删什么),按「认知成本 ÷ 改动风险」排序, 高成本低风险的排前面。
  • 只提方案不动手,除非用户明确要求重构。

3. 近期 PR 复盘——找最慢环节

用户要"分析最近的 PR / 为什么迭代慢"时:

git log --since="30 days ago" --merges --oneline | head -20   # 时间窗自己调
gh pr list --state merged --limit 30 --json number,title,createdAt,mergedAt
  • 用 createdAt→mergedAt 算各 PR 停留时长,排出最慢的 3-5 个。
  • 逐个看卡在哪:review 等待轮次、CI 失败重跑、改动面太大拆不动、返工重做。
  • 输出:最慢环节排序 + 每项一个可执行改进(如"改小 PR 粒度""CI 分层快慢道"), 不写泛泛的"加强沟通"。

触发边界

  • 用户只要"解释这段代码"(不涉及能不能动/历史)→ 直接答,不用本技能。
  • 改动本身 → 回到 ponytail(最懒可行方案);考古只是动手前的侦察。
  • 产物要落盘时按 D-Hub 惯例写 docs/,不额外建目录。
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 64 lines · 142 tokens per session scan A 4cd616082a41

Subscribe to this mod's changes

code-archaeology is a skill published in the GitHub repository DuanZGit/D-Hub (0 stars, last pushed 2d ago), licensed MIT. It adds 142 tokens to every session and 965 once invoked, about $0.0006 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-20.

Related

code-archaeology compared with skills from other repositories

code-archaeology next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
code-archaeologyDuanZGit/D-HubSkill02d agoMITA142Claude Code, Codex
engineer-bot-getting-startedmakecindy/cindySkill11ktodayApache-2.0A44Claude Code, Codex
githubdiillson/chatcliSkill947d agoApache-2.0A78Claude Code
azure-reposMicrosoftDocs/Agent-SkillsSkill82422d agoCC-BY-4.0A113Claude Code
pr-comment-resolvergvkhosla/compound-engineering-piSkill532mo agoMITA30Claude Code, Codex
git-github-workflowKroMiose/nekro-agentSkill1.2k1mo agononeA101Claude Code
guardianseaworld008/Commonly-used-high-value-skillsSkill75yesterdayMITA35Claude Code, Codex