Part 11: Auto-Capture Hook (Stop Manually Writing Memory)
Description
*By Terp - [Terp AI Labs](https://x.com/OnlyTerp)* --- The vault system from Part 9 is powerful, but there's a gap: you have to manually write knowledge to vault files. In practice, after a long sessi
Installation
claude install-skill https://github.com/OnlyTerp/openclaw-optimization-guide README
Part 11: Auto-Capture Hook (Stop Manually Writing Memory)
*By Terp - [Terp AI Labs](https://x.com/OnlyTerp)*
The vault system from Part 9 is powerful, but there's a gap: you have to manually write knowledge to vault files. In practice, after a long session, you forget. Insights from debugging sessions, configuration discoveries, architectural decisions — they disappear when the context compacts or you reset.
**⚠️ This is NOT the same as OpenClaw's built-in `session-memory` hook.** The built-in hook just dumps raw conversation text to a dated markdown file. It does NOT extract knowledge — no decisions, no lessons, no claim-named files. If you enabled `session-memory` and thought you were done, you're not. You need THIS custom hook for real auto-capture. The built-in one is a session saver, not a knowledge extractor.
ByteRover (a community plugin on ClawHub) solves this with an `afterTurn` hook that curates every conversation turn. But it depends on an external `brv` binary that inherits your full environment and conversation content. We built the same thing natively using OpenClaw's hook system — no external binary, no trust issues, your own models.
How It Works
The auto-capture hook fires on three events:
- undefined
On each trigger it:
- undefined
Runs entirely async — fires and forgets. You never feel it.
Installation
1. Create the hook directory
mkdir -p ~/.openclaw/hooks/auto-capture
cd ~/.openclaw/hooks/auto-capture
git init # Codex requires a git repo
2. Copy the hook files
Copy [`hooks/auto-capture/HOOK.md`](./hooks/auto-capture/HOOK.md) and [`hooks/auto-capture/handler.ts`](./hooks/auto-capture/handler.ts) from this repo into `~/.openclaw/hooks/auto-capture/`.
Or clone this repo and symlink:
ln -s /path/to/openclaw-optimization-guide/hooks/auto-capture ~/.openclaw/hooks/auto-capture
3. Set environment variables
The handler reads config from environment variables. Set these before starting your gateway:
**Option A: Cerebras (free, recommended)**
# Get a free key at https://cloud.cerebras.ai/
export CEREBRAS_API_KEY="csk-your-key-here"
**Option B: Anthropic (if you're on Claude Max and don't want another provider)**
export AUTOCAPTURE_API_URL="https://api.anthropic.com/v1/messages"
export AUTOCAPTURE_API_KEY="sk-ant-your-key-here"
export AUTOCAPTURE_MODEL="claude-sonnet-4-20250514"
**Option C: Any OpenAI-compatible API** ```
Related Agents
Opencode
(60.8k ⭐) - The open source AI coding agent.
Data & AI community Gemini CLI
(90.5k ⭐) - An open-source AI agent that brings the power of Gemini directly into your terminal.
Data & AI community Chatgpt On Wechat
CowAgent是基于大模型的超级AI助理,能主动思考和任务规划、访问操作系统和外部资源、创造和执行Skills、拥有长期记忆并不断成长,比OpenClaw更轻量和便捷。同时支持微信、飞书、钉钉、企微、QQ、公众号、网页等接入,可选择OpenAI/Claude/Gemini/DeepSeek/ Qwen/GLM/Kimi/LinkAI,能处理文本、语音、图片和文件,可快速搭建个人AI助理和企业数字员工。
Data & AI community Claude Mem
(13.1k ⭐) - A Claude Code plugin that automatically captures everything Claude does during your coding sessions, compresses it with AI (using Claude's agent-sdk), and injects relevant context back...
Data & AI community Read research for Nyquist validation data
cat "$phase_dir"/*-RESEARCH.md 2>/dev/null node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" roadmap get-phase "$phase_number" ls "$phase_dir"/*-BRIEF.md 2>/dev/null
Data & AI community Multi Agent Review
| A sophisticated AI-powered code review system designed to provide comprehensive, multi-perspective a... | - | [wshobson/agents](https://github.com/wshobson/agents) |
Data & AI community