This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
A persistent memory system for coding agents — Claude Code and OpenAI Codex. Provides persistent memory across coding sessions via plain markdown files, with optional semantic search powered by qmd.
┌──────────────┐
│ src/core.ts │ ← all logic (paths, truncation, scratchpad,
│ │ context builder, qmd, tool functions)
└──────┬───────┘
│
┌────┴─────────────────┐
▼ ▼
┌──────────┐ ┌──────────────┐
│ src/ │ │ skills/ │
│ cli.ts │ │ ├─ claude-code/SKILL.md
│ │ │ └─ codex/SKILL.md
└──────────┘ └──────────────┘
CLI binary instruction files
`agent-memory` that invoke CLI
src/core.ts: All shared logic — paths, truncation, scratchpad, context builder, qmd integration, and standalone tool functions (memoryWrite,memoryRead,scratchpadAction,memorySearch)src/cli.ts: CLI entry point —agent-memorybinary with subcommandsskills/: SKILL.md files for Claude Code and Codex that invoke the CLI
# Build the CLI binary
bun run build:cli
# Run unit tests (no LLM, no qmd)
bun test test/unit.test.ts
bun test test/cli.test.ts
# Install skills for Claude Code / Codex
bash scripts/install-skills.sh- Core + CLI:
src/core.tscontains all logic;src/cli.tsimports from it - Configurable paths:
AGENT_MEMORY_DIRenv var or--dirflag overrides the memory directory (default:~/.agent-memory/) - Context injection: Builds memory context (scratchpad > today > search > MEMORY.md > yesterday) for injection into system prompts
- qmd integration: Optional, detected at runtime. Core tools work without it, only
memory_searchand selective injection require qmd - After every write: Debounced (500ms)
qmd updateruns fire-and-forget in the background - Scratchpad items: Stored as markdown checklists with HTML comment metadata (
<!-- timestamp [sessionId] -->)
| Level | File | Requirements | What it tests |
|---|---|---|---|
| Unit | test/unit.test.ts |
None | Utilities, scratchpad parsing, context builder, qmd helpers, tool functions |
| CLI | test/cli.test.ts |
None | CLI commands via core.ts imports + subprocess tests |