Topic-level automated memory management for Codex.
Inspired by hatawong/claude-recap
curl -fsSL https://raw.githubusercontent.com/WhiteCrow/codex-recap/main/install.sh | bash默认安装位置:
- 源码目录:
~/.local/share/codex-recap/src - 命令入口:
~/.local/bin/codex-recap
升级方式:重新执行同一条安装命令。
卸载方式:删除 ~/.local/share/codex-recap 和 ~/.local/bin/codex-recap。
- 在目标项目根目录执行一次:
codex-recap install-
正常启动 Codex。
-
在会话里直接输入:
topic: <topic-name>
# 示例:topic: setup-auth
topic: current
topic: list
topic: <topic-name>
topic: current
topic: list
topic: remember Do not auto-commit.
topic: remember-global Always prefer bun.
topic: rebuild
topic: off
- 以 topic 为单位组织记忆,而不是把整个 session 压成一份大摘要。
- 当用户明显切换任务时,自动归档旧 topic 并切到新 topic。
- 当当前 topic 有实质进展时,在最终回复前自动 checkpoint。
- 用 topic 粒度恢复上下文,更适合继续执行、检索和人工查看。
topic: off可以暂停自动化管理,直到再次显式设置 topic。
Codex 可以继续会话,但当任务切换、会话重开,或者长对话混入多个主题时,topic 级别的工作上下文仍然很容易漂散。没有结构化记忆管理时,同一个项目背景会被反复解释,进度埋在长 transcript 里,任务边界也会越来越模糊。
codex-recap 把 claude-recap 的核心思路适配到 Codex,具体依赖:
- 本地 Markdown memory
- 受控的
AGENTS.md自动化规则 - 基于 topic 的归档与恢复
- 基于 transcript 的重建,作为兜底恢复路径
- 比 session 级摘要更细,信息损失更少。
- 多任务切换时更容易恢复到正确上下文。
- 更适合 grep、人工阅读和继续执行。
- 归档和恢复都围绕具体任务,而不是混杂对话。
codex-recap install会向当前项目的AGENTS.md注入受控区块。- Codex 学会把
topic:前缀消息识别为控制命令。 topic: <topic-name>会映射到codex-recap topic set <topic-name>。- topic 切换时,旧 topic 会被归档成 Markdown。
topic checkpoint用于在最终回复前内部保存有意义的进展。rebuild会扫描最近匹配的 Codex transcript,在需要时重建 topic 上下文。
这个项目参考了 hatawong/claude-recap。
codex-recap 保留了 topic-based memory 的核心思路,但结合 Codex 的约束,采用 AGENTS.md 驱动的自动化,而不是 Claude 的 hook 集成方式。
默认存储在 ~/.codex-recap。如需覆盖,设置 MEMORY_HOME。
~/.codex-recap/
REMEMBER.md
projects/
{encoded-project-path}/
REMEMBER.md
{session-id}/
.topic_mode
.current_topic
.current_topic.json
01-setup-auth.md
02-fix-login-bug.md
- 仅支持 Codex。
- 不依赖 hooks,但也不具备 hook 级强制保证。
- v1 不提供 MCP server。
- 自动化是通过
AGENTS.md指令驱动的 best-effort 机制。
npm run check
npm test
npm run buildcurl -fsSL https://raw.githubusercontent.com/WhiteCrow/codex-recap/main/install.sh | bashDefault install locations:
- Source checkout:
~/.local/share/codex-recap/src - Command wrapper:
~/.local/bin/codex-recap
To upgrade, rerun the same install command.
To uninstall, remove ~/.local/share/codex-recap and ~/.local/bin/codex-recap.
- Run once at the root of the target project:
codex-recap install-
Start Codex normally.
-
Use these messages directly in the conversation:
topic: <topic-name>
# example: topic: setup-auth
topic: current
topic: list
topic: <topic-name>
topic: current
topic: list
topic: remember Do not auto-commit.
topic: remember-global Always prefer bun.
topic: rebuild
topic: off
- Organizes memory by topic instead of flattening an entire session into one summary.
- Archives the previous topic automatically when the user clearly switches tasks.
- Creates a checkpoint before the final reply when meaningful progress was made.
- Restores context at topic granularity, which is easier to continue, inspect, and grep.
- Lets you pause automation with
topic: offuntil a new topic is explicitly set.
Codex can continue a session, but topic-level working context is still easy to lose when tasks change, sessions restart, or a long thread drifts across multiple concerns. Without structured memory management, the same project context keeps getting re-explained, progress gets buried in long transcripts, and task boundaries blur.
codex-recap adapts the core idea behind claude-recap to Codex by using:
- local Markdown memory
- managed
AGENTS.mdautomation rules - topic-based archival and recovery
- transcript-backed rebuild as a fallback recovery path
- It preserves more task-specific detail than session-level summaries.
- It handles task switching more cleanly.
- It makes archived context easier to inspect and reuse.
- It keeps memory centered on concrete units of work rather than mixed conversations.
codex-recap installinjects a managed block into the current project'sAGENTS.md.- Codex learns to interpret
topic:-prefixed messages as control commands. topic: <topic-name>maps tocodex-recap topic set <topic-name>.- Topic switches archive the previous topic into Markdown.
topic checkpointis used internally to persist meaningful progress before final replies.rebuildscans the latest matching Codex transcript and reconstructs topic context when needed.
This project is inspired by hatawong/claude-recap.
codex-recap keeps the core idea of topic-based memory, but adapts it to Codex constraints with AGENTS.md-driven automation instead of Claude hook-based integration.
By default memory is stored in ~/.codex-recap. Override it with MEMORY_HOME if needed.
~/.codex-recap/
REMEMBER.md
projects/
{encoded-project-path}/
REMEMBER.md
{session-id}/
.topic_mode
.current_topic
.current_topic.json
01-setup-auth.md
02-fix-login-bug.md
- Codex-only.
- No hook dependency, but also no hook-level guarantees.
- No MCP server in v1.
- Automation is best-effort and instruction-driven through
AGENTS.md.
npm run check
npm test
npm run build