agentleFS
alloevilalloevil/agents-with-receipts/.agents/skills/repo-mental-model/SKILL.md

repo-mental-model

Skill1 starsChanged 3 months agoMITView on GitHub

用 git 历史回答「这段代码为什么是这样」,并按 /how /why /teach /recall 四个问题给出结构化回答。查不到动机时如实说未知,不推测。用于调查陌生模块、可疑的兼容分支、被注释掉的代码,或改动前需要弄清缘由的场合。

The file

Files
SKILL.md

建心智模型:/how · /why · /teach · /recall

把一个陌生模块讲清楚,让改动建立在证据上。每条结论都要能指到证据(文件:行、提交号、PR 链接、官方文档);指不到的就写「未知」,不要给一个听起来合理的推测。

/how — 运行时

  • 按调用顺序列出「一次典型请求 / 一次典型任务」经过的函数,格式 src/pricing/calc.ts:42 → src/api/client.ts:118。
  • 指出哪一步做校验、哪一步做缓存、缓存失效的触发点在哪。
  • 列出改这个模块最容易踩的三个坑,每个坑给一个仓库里的真实例子(文件:行)。
  • 能跑就跑:起服务或跑最小相关测试,用观察到的行为校正你的叙述,把命令和输出贴出来。

/why — 动机

  • git log -S "<字符串>" -- <path>:找出使该字符串出现次数发生变化的提交(增或删)。
  • git log -L <start>,<end>:<file> 或 git log -L '/<函数名>/,/^}/:<file>:追踪行区间或函数的演进。
  • git blame -L <start>,<end> <file>:最后修改这些行的提交与作者。
  • 拿到提交号后读提交信息、关联 PR 讨论与 issue——动机通常只写在那里。
  • 结论写回仓库:代码旁一行注释指向提交或 PR,或写进 ADR。找不到就写「未知」。

/teach — 取舍

对每个候选方案给出三段:换来什么 / 牺牲什么(指名具体代价:延迟、运维面、测试方式) / 什么可观测条件下应当改选另一个。用仓库里已有的做法作对照(「仓库里谁已经在这么做,为什么它适合,为什么不适用于这里」)。说不出「什么会推翻它」的方案,标记为未检验。

/recall — 取回

  • 接着上次继续,而不是从零重开:claude -c(当前目录最近一次会话)、claude -r "<会话名>"(按 ID 或名字恢复);长会话先命名。
  • 更可靠的一条:把结论写进仓库文件(spec、ADR、代码旁注释)。会话历史在个人机器上,不随人走、不进版本控制。

输出格式

开头一行给结论:这段代码现在是什么、能不能改。然后四段:运行时 / 动机(提交号 + 链接,或 未知) / 取舍 / 取回(文件路径,或 无)。四段里的每一条都要带证据,没有证据的条目直接写「未知」。

边界

  • 这条 skill 只产出理解,不做改动;改不改由人决定。
  • 查不到动机时不要从代码风格倒推理由——编出来的理由比没有理由更贵。
  • squash 合并或 rebase 过的历史里,blame 只能指到最近一次改动,这时回到 PR 里找原始讨论。
  • 已熟悉的代码路径不要重复考古,只烧上下文。

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.