memory-audit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Memory audit — the surgical one-file pass

内存审计——单文件精准处理

This is the cap-trip response, not the daily ritual.
/memory-kit:close-session
runs every session and captures; this runs when the hot cache has actually outgrown itself and something must LEAVE it. Keeping them separate is the point: a daily ritual that also has to do surgery becomes a ritual people skip.
Always pause for approval before writing. The user talks; you write — including here.
这是超限响应操作,而非日常例行任务。
/memory-kit:close-session
会在每个会话结束时运行并捕获内容;而本操作仅在热缓存实际超出容量、必须移除部分内容时才执行。将两者区分开是关键:如果日常例行任务还要执行清理操作,人们会跳过这个例行任务。
在写入前务必暂停等待审批。用户确认后再执行写入操作——此处也不例外。

Inputs

输入项

  • .claude/memory/MEMORY.md
    — read in full.
  • knowledge/concepts/*.md
    — filenames + first 5 lines, for duplicate detection (the directory may not exist yet; the first move creates it).
  • context/handoffs/
    — to confirm a session narrative already lives there → drop, not move.
  • .claude/memory/MEMORY.md
    —— 完整读取。
  • knowledge/concepts/*.md
    —— 文件名+前5行内容,用于重复检测(该目录可能尚未存在;首次移动操作会创建它)。
  • context/handoffs/
    —— 确认会话记录已存在于此→直接删除,而非移动。

Step 1 — classify every section

步骤1 —— 对每个章节进行分类

Scan by
## 
heading. For each, count lines and mark exactly one action:
MarkWhen
move (create)
a settled pattern (confirmed on 3+ distinct dates) with >25 lines of reference detail
move (merge)
same, but a concept article on the topic already exists
drop
a per-session chronicle — it already lives in a handoff; distil at most one settled line
update in-place
stale: names a deleted file, a closed ticket, a superseded decision
simplify
true and useful, but three times longer than it needs to be
keep
earns its lines
## 
标题扫描。对每个章节,统计行数并标记唯一操作:
标记适用场景
move (create)
已定型模式(在3个以上不同日期确认)且包含超过25行参考细节
move (merge)
同上,但该主题的概念文章已存在
drop
单会话记录——已存在于交接目录中;最多提炼1行定型内容
update in-place
过期内容:提及已删除的文件、已关闭的工单、已被取代的决策
simplify
内容真实有用,但篇幅是所需的三倍
keep
篇幅合理且有留存价值

Step 2 — the move plan (a table, never prose)

步骤2 —— 移动计划(仅用表格,禁止 prose)

#SectionLinesActionTargetReason
1Nmove / merge / drop / simplify / keep
knowledge/concepts/<slug>.md
or —
Close the table with: estimated line savings, and the projected line/byte count afterwards against the caps (180 lines / 32 KB / 3000 chars per line).
序号章节行数操作目标位置原因
1Nmove / merge / drop / simplify / keep
knowledge/concepts/<slug>.md
或 —
表格末尾需添加:预估行数节省量,以及操作后预计的行数/字节数与上限(180行 / 32 KB / 每行3000字符)的对比。

Step 3 — PAUSE

步骤3 —— 暂停

Print the plan and ask for approval. Wait for an explicit yes or edits. No writes before that.
打印计划并请求审批。等待明确的同意或修改意见。审批前不得执行任何写入操作。

Step 4 — execute the approved moves, atomically

步骤4 —— 以原子方式执行已批准的移动操作

  • move (create): write
    knowledge/concepts/<slug>.md
    with frontmatter matching
    knowledge/index.md
    's spec, then add its one-line entry to that index in the same pass.
  • move (merge): append under a
    ### From MEMORY.md (YYYY-MM-DD)
    header — never duplicate a section that already says the same thing.
  • in MEMORY.md: replace the moved section with a one-line pointer plus a one-line teaser. A move without a pointer orphans the content — that is the failure this audit exists to prevent.
  • drop: delete; keep at most one distilled line.
  • move (create):按照
    knowledge/index.md
    的规范写入带前置元数据(frontmatter)的
    knowledge/concepts/<slug>.md
    ,并在同一操作中向该索引添加一行条目。
  • move (merge):在
    ### From MEMORY.md (YYYY-MM-DD)
    标题下追加内容——绝不重复已存在的相同章节。
  • 在MEMORY.md中:将被移动的章节替换为一行指向目标的链接加一行内容提要。如果移动后没有链接,内容会变成孤立状态——这正是本次审计要避免的失败情况。
  • drop:删除该章节;最多保留1行提炼后的内容。

Step 5 — the header, then the report

步骤5 —— 更新头部,生成报告

Replace the MEMORY.md current-state header (≤3 lines, dated). Report before/after line and byte counts, every file touched, and save declined candidates to
context/handoffs/memory-audit-deferred-YYYY-MM-DD.md
so the next audit starts from them.
替换MEMORY.md的当前状态头部(≤3行,带日期)。报告操作前后的行数和字节数、所有被修改的文件,并将未通过的候选内容保存到
context/handoffs/memory-audit-deferred-YYYY-MM-DD.md
,以便下次审计从这些内容开始。

Refuse when

拒绝执行的情况

  • No cap is tripped AND no settled-pattern candidate exists → say "no audit needed" and stop. A SINGLE tripped cap is reason enough to proceed (one 3000-char line qualifies).
  • The user declines the plan → save it next to the handoffs and stop.
  • 未触发超限且无定型模式候选对象→回复“无需审计”并停止操作。只要有一项超限就足以执行(比如一行达到3000字符)。
  • 用户拒绝计划→将计划保存到交接目录旁并停止操作。

Anti-patterns

反模式

  • Writing anything before the approval.
  • Creating a new concept when a keyword grep matches an existing one — merge bias broken.
  • Promoting a session CHRONICLE into a knowledge article. Concepts hold settled patterns; narrative belongs to handoffs, and the action for it here is
    drop
    .
  • Burying the plan in prose. The table is what makes it reviewable in ten seconds.
  • 审批前执行任何写入操作。
  • 当关键词搜索匹配到现有概念时仍创建新的概念文章——违反合并优先原则。
  • 将会话记录(CHRONICLE)升级为知识文章。概念文章用于存放定型模式;记录内容属于交接目录,此处对应的操作是
    drop
  • 用 prose 描述计划。表格是让计划能在10秒内完成审核的关键。