opencode-claude-memory AGENTS.md

Project instructions for an OpenCode plugin that stores and recalls persistent memory across coding sessions. OpenCode is a tool for working with code through an AI agent.

In plain words
What is it for?
Use them when developing or maintaining the plugin’s memory tools, file scanning, prompts, paths, and integration tests.
Why use it?
They explain the plugin’s structure and rules so changes do not break how memories are saved, searched, recalled, or removed.

Instructions file for CodexOpenCode

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 instructions/kuitos/opencode-claude-memory/agents-md
Clone the repo
git clone --depth 1 https://github.com/kuitos/opencode-claude-memory

Made for: Codex, OpenCode.

Per session 1,713 This file is loaded in full into every session.
When invoked 1,713 The same file — it is already loaded in full.
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.01713 $0.01713
Opus 5 $0.00856 $0.00856
Sonnet 5 $0.00343 $0.00343
Haiku 4.5 $0.00171 $0.00171

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

Security

Grade A, and why

opencode-claude-memory AGENTS.md 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.

AGENTS.md · 127 lines

How it starts

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

AGENTS.md

OpenCode plugin that replicates Claude Code's persistent memory system. TypeScript on Bun, consumed as raw .ts by OpenCode (no build step). Published to npm via semantic-release.

Structure

.
├── bin/opencode-memory  # Bash wrapper: shell hook install + post-session extraction + auto-dream consolidation
├── src/
│   ├── index.ts         # Plugin entry: MemoryPlugin export, 5 tools + system prompt hook
│   ├── memory.ts        # CRUD: save/delete/list/search/read + MEMORY.md index management + truncateEntrypoint
│   ├── memoryScan.ts    # Recursive memory directory scanner: MemoryHeader[], frontmatter parsing, manifest formatting
│   ├── paths.ts         # Path resolution + security: ~/.claude/projects/<hash>/memory/
│   ├── prompt.ts        # System prompt builder: type instructions + index + recalled content (aligned with Claude Code memoryTypes.ts)
│   └── recall.ts        # Smart recall: keyword scoring via scanMemoryFiles, mtime fallback, truncation, age warnings
├── test/
│   ├── integration.test.ts       # End-to-end lifecycle: save→list→search→read→recall→delete
│   ├── memory.test.ts            # Unit tests for memory.ts (truncateEntrypoint, CRUD, index)
│   ├── memoryScan.test.ts        # Unit tests for memoryScan.ts (scan, frontmatter, manifest)
│   ├── prompt.test.ts            # Unit tests for prompt.ts (buildMemorySystemPrompt)
│   ├── recall.test.ts            # Unit tests for recall.ts (scoring, recall, formatting)
│   ├── opencode-memory.test.ts   # Bash wrapper tests (TMPDIR normalization, log toggle)
│   └── github-actions-ci.test.ts # CI workflow smoke test
├── .releaserc           # semantic-release config
└── tsconfig.json        # moduleResolution: bundler, types: bun-types

Where to Look

Task File
Add/modify a memory tool src/index.ts — tool definitions in tool: section
Change memory file format src/memory.tsparseFrontmatter(), buildFrontmatter()
Fix path resolution or worktree sharing src/paths.tsgetMemoryDir(), findCanonicalGitRoot()
Modify what the agent sees about memory src/prompt.tsbuildMemorySystemPrompt()
Change which memories are auto-recalled src/recall.tsrecallRelevantMemories()
Scan memory directory / build manifest src/memoryScan.tsscanMemoryFiles(), formatMemoryManifest()
Fix post-session extraction bin/opencode-memory — bash wrapper
Fix shell hook install/uninstall bin/opencode-memoryinstall/uninstall subcommands

Read the full file on GitHub · 127 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 · 127 lines · 1,713 tokens per session scan A e4673923ad01

Subscribe to this mod's changes

opencode-claude-memory AGENTS.md is an instructions file published in the GitHub repository kuitos/opencode-claude-memory (53 stars, last pushed 2d ago), licensed MIT. It adds 1,713 tokens to every session, about $0.0086 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-30.