memory

A command for saving or reading short memories as Markdown key-value files in a local directory. The instructions are primarily written in Chinese.

In plain words
What is it for?
Adding or retrieving named memories, inferring a category for each one, and recording dates or times when a memory includes them.
Why use it?
It provides a direct backup method for keeping reminders, decisions, and notes available across interactions without a database service.

Command

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.

agentmods
npx agentmods add commands/jasonhnd/life_os/memory
Clone the repo
git clone --depth 1 https://github.com/jasonhnd/life_OS
Per session 28 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 999 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00028 $0.00999
Opus 5 $0.00014 $0.00500
Sonnet 5 $0.00006 $0.00200
Haiku 4.5 $0.00003 $0.00100

Measured 2d ago against content hash 1fda00f5d9df, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

memory 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 2d 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.

docs/history/v1.10-command-surfaces/scripts/commands/memory.md · 88 lines

How it starts

The opening of the file, as written. The whole thing — 88 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/memory · 即时记忆 (v1.8.0 pivot)

v1.8.0 pivot 注解:之前调用 python -m tools.memory,但 tools/memory.py 在 v1.8.0 pivot 中被删除。v1.8.6/DR-10 后 Memory KV 改为 Markdown 文件。Memory 现在是一个扁平 KV 目录 (~/.claude/lifeos-memory/<key>.md),ROUTER 直接用 Write/Read tool 读写,没有 python 中间层。

Backup mode: 主要路径是 ROUTER 用 inline trigger rules 匹配 "记一下/提醒我/TODO/覚えて" 等关键词后自动 emit。这个命令是给"我想精确控制 key/value 格式"的备份。详见 hosts/CLAUDE.md → Auto-Trigger Rules → Memory auto-emit。

User invoked: /memory $ARGUMENTS

数据结构

每条 memory 是 ~/.claude/lifeos-memory/<key>.md

---
key: "<key>"
value: "<text>"
role: "礼/户/刑/工/吏/兵"
created: "<ISO8601>"
trigger_time: "<optional ISO8601 if value contains date/time>"
---

Key 推荐格式:reminder:<context> / decision:<topic> / note:<context>

你要做的

emit <key>=<value>

  1. 解析 keyvalue

  2. 推断 role:决策→刑、人际/学习/品牌→礼、财务→户、健康/数字基建→工、关系经营/团队→吏、项目执行→兵

  3. 如果 value 含日期/时间 → 提取为 trigger_time 字段

  4. 用 Write 工具创建 ~/.claude/lifeos-memory/<sanitized-key>.md(key 中的 : 改为 __/ 改为 _

  5. 报告:

    📚 已入档案柜
      · key: <key>
      · role: <role>
      · trigger time: <if any>
      · 24h 后未完成会出现在状态行
    

read

  1. Glob ~/.claude/lifeos-memory/*.md
  2. 对每个文件 Read 内容
  3. created 倒序列出
  4. 格式:
    📚 当前 memory({N} 条)
    - <key> · <role> · <value 前 60 字>... · <created 相对时间>
    - ...
    

remove <key>

  1. Resolve sanitized path
  2. Bash: rm ~/.claude/lifeos-memory/<sanitized-key>.md
  3. 报告 "🗑️ 已删除 "

path

显示 ~/.claude/lifeos-memory/ 路径,ls -1 列出当前所有 key。

退朝时自动整理

退朝(archiver 流程)时,archiver 的 knowledge-extractor 会读 ~/.claude/lifeos-memory/ 评估哪些 memory 值得提升为 wiki/,哪些过期可删。本命令本身不参与晋升逻辑。

三层记忆分工

时长 位置 例子
即时(<48h) ~/.claude/lifeos-memory/<key>.md 临时提醒、临时决策
中期(week) wiki/<topic>.md archiver 退朝时写
长期(年) SOUL.md 价值观、维度

Anti-pattern

  • 不要把长 narrative 塞进 memory — 长内容应该写到 wiki/
  • 不要尝试调用已删除的 tools/memory.py(v1.8.0 pivot 删了)—— 直接 Write 文件
  • 不要在 key 里用 /: 之外的奇怪字符(保持文件名安全)

Read the full file on GitHub · 88 lines

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. 2d ago First seen · 88 lines · 28 tokens per session scan A 1fda00f5d9df

Subscribe to this mod's changes

memory is a command published in the GitHub repository jasonhnd/life_OS (5 stars, last pushed 25d ago), licensed Apache-2.0. It adds 28 tokens to every session and 999 once invoked, about $0.0001 per session on Opus 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.