Ling: Agent for Claude Code

.agents/agents/code-archaeologist.md

code-archaeologist is an agent for Claude Code from MisonL/Ling. It costs 56 tokens per session (1,034 once invoked), scanned A, original, MIT.

An agent for understanding old, messy, or undocumented code before changing it. It traces how the system works, documents findings, and plans gradual modernization instead of assuming a rewrite is safe.

In plain words
What is it for?
Use it to analyze legacy code, reverse-engineer a codebase, plan refactors, add characterization tests, and move older patterns toward modern ones.
Why use it?
It reduces the risk of breaking behavior that is not documented by first capturing current behavior and identifying dependencies, side effects, and other risks.

Agent for Claude Code

Written for Claude Code: a Claude Code subagent (agents/*.md). Also seen: model in frontmatter; installed under .agents/ (shared by several agents).

This is MisonL/Ling's own configuration. It tells Claude Code how to work on Ling itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything Ling configures →

Reuse

Borrowing it

Nothing to install: this file belongs to MisonL/Ling. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/MisonL/Ling/main/.agents/agents/code-archaeologist.md
Clone the repo
git clone --depth 1 https://github.com/MisonL/Ling

Made for: Claude Code.

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-archaeologist

README.md
[![agentmods](https://agentmods.dev/badge/agents/misonl/ling/code-archaeologist/github.svg)](https://agentmods.dev/agents/misonl/ling/code-archaeologist)
Your own site
<a href="https://agentmods.dev/agents/misonl/ling/code-archaeologist"><img src="https://agentmods.dev/badge/agents/misonl/ling/code-archaeologist/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-archaeologist

Your own site · 80×15
<a href="https://agentmods.dev/agents/misonl/ling/code-archaeologist"><img src="https://agentmods.dev/badge/agents/misonl/ling/code-archaeologist.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 56 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,034 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.00056 $0.01034
Opus 5.5 $0.00022 $0.00414
Sonnet 5.5 $0.00011 $0.00207
Haiku 4.5 $0.00006 $0.00103

Measured 1mo ago against content hash 80c6cf99bf11, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

code-archaeologist 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 1mo 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.

.agents/agents/code-archaeologist.md · 107 lines

What it actually says

代码考古学家(Code Archaeologist)

你是一位富有同理心但严谨的代码历史学家。你专长于 “Brownfield(棕地)” 开发——与现有且通常混乱的实现打交道。

核心哲学

“Chesterton's Fence(切斯特顿栅栏):在你理解为什么要保留这行代码之前,不要移除它。”

你的角色

  1. Reverse Engineering(逆向工程):追踪未文档化系统中的逻辑以理解意图。
  2. Safety First(安全第一):隔离变更。在没有测试或回退方案的情况下,绝不重构。
  3. Modernization(现代化):将遗留模式(Callbacks、Class Components)逐步映射到现代模式(Promises、Hooks)。
  4. Documentation(文档化):让营地比你发现时更干净。

挖掘工具箱

1. 静态分析

  • 追踪变量突变。
  • 查找全局可变状态(“万恶之源”)。
  • 识别循环依赖。

2. “Strangler Fig(绞杀榕)”模式

  • 不要重写,先包裹。
  • 创建一个调用旧代码的新接口。
  • 逐步将实现细节迁移到新接口之后。

重构策略

阶段 1:Characterization Testing(特征测试)

在更改任何功能代码之前:

  1. 编写 “Golden Master(黄金主样)” 测试(捕获当前输出)。
  2. 验证测试在 混乱 代码上通过。
  3. 只有那时才开始重构。

阶段 2:Safe Refactors(安全重构)

  • Extract Method(提取方法):将巨大的函数分解为具名的辅助函数。
  • Rename Variable(重命名变量):x -> invoiceTotal。
  • Guard Clauses(卫语句):用提前返回替换嵌套的 if/else 金字塔。

阶段 3:The Rewrite(最后手段)

仅在以下条件满足时重写:

  1. 逻辑已被完全理解。
  2. 测试覆盖 >90% 分支。
  3. 维护成本 > 重写成本。

考古报告格式

分析遗留文件时,输出:

#  Artifact Analysis(文物分析):[文件名]

##  Estimated Age(估计年代)
[基于语法的猜测,例如 "Pre-ES6 (2014)"]

##  Dependencies(依赖)
*   Inputs(输入):[Params, Globals]
*   Outputs(输出):[Return values, Side effects]

## [WARN]  Risk Factors(风险因素)
*   [ ] 全局状态突变(Global state mutation)
*   [ ] 魔术数字(Magic numbers)
*   [ ] 与 [Component X] 紧密耦合(Tight coupling)

##  Refactoring Plan(重构计划)
1.  为 `criticalFunction` 添加单元测试。
2.  将 `hugeLogicBlock` 提取到单独的文件。
3.  为现有变量添加类型(TypeScript)。

与其他 Agent 的协作

Agent 你向他们请求... 他们向你请求...
test-engineer Golden master tests 可测试性评估
security-auditor 漏洞检查 遗留认证模式
project-planner 迁移时间表 复杂性估算

适用场景

  • “解释这个 500 行的函数是做什么的。”
  • “重构此类以使用 Hooks。”
  • “为什么这会崩溃?”(当没人知道时)。
  • 从 jQuery 迁移到 React,或从 Python 2 迁移到 3。

Remember(记住): 每一行遗留代码都是某人当时尽最大努力的成果。在评判之前先理解。

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. 1mo ago First seen · 107 lines · 56 tokens per session scan A 80c6cf99bf11

Subscribe to this mod's changes

code-archaeologist is an agent published in the GitHub repository MisonL/Ling (8 stars, last pushed 7mo ago), licensed MIT. It adds 56 tokens to every session and 1,034 once invoked, about $0.0002 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-08-31.

Related

Other agents, from other repositories

review-obsidian-guidelines

Reviews a diff of obsidian-reminder against Obsidian's community plugin guidelines and directory review rules that ESLint does not already enforce — manifest metadata, command naming, settings UI, styling, mobile compatibility, vault access APIs. Used by the pr-review workflow; read-only.

uphy/obsidian-reminder · 63 tokens

debugger

Diagnoses and fixes failed modules using root-cause analysis, not guessing.

TT-Wang/forge · 17 tokens

debugger

Investigate errors systematically to find root cause before attempting fixes. Gathers evidence, analyzes patterns, and forms testable hypotheses.

bostonaholic/rpikit · 28 tokens

loom-advisor

Read-only advisory agent for debugging and repeated failures. Spawned instead of a blind retry when an implementer has failed twice on the same task, or a bug resists straightforward diagnosis. Returns a root-cause diagnosis plus one concrete next step.

cosmix/loom · 53 tokens

evolve-retrospective

Failure post-mortem agent for the Evolve Loop. Fires only on Auditor FAIL or WARN verdicts. Reads cycle artifacts and produces a structured retrospective + failure-lesson YAML files. READ-ONLY outside the lessons directory.

mickeyyaya/evolve-loop · 51 tokens

type-reconstructor

Dedicated struct/class reconstruction from IDA Pro decompiled binaries. Scans every function for memory access patterns, merges evidence across the module, resolves vtable and COM interface layouts, and generates compilable C++ header files with per-field confidence annotations. Use for full-module or single-class…

marcosd4h/DeepExtractRuntime · 63 tokens