memex CLAUDE.md

memex CLAUDE.md is an instructions file for coding agents from vimo-ai/memex. It costs 1,000 tokens per session, scanned A, original, MIT.

A Rust-based system for managing and searching the history of Claude Code sessions, which are conversations between a developer and a coding assistant. It stores searchable text and vector representations locally, can compress old sessions into summaries, and can extract reusable knowledge.

In plain words
What is it for?
Use it to monitor session files, compact conversations, build indexes, search past work, create retrieval-based answers, back up data, and expose history through MCP or an HTTP API.
Why use it?
It addresses short-lived local history, difficult conversation searches, and knowledge that otherwise remains buried in past sessions. It supports both local use and a server mode for shared searching.

Instructions file

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/vimo-ai/memex/claude-md
Clone the repo
git clone --depth 1 https://github.com/vimo-ai/memex

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for memex CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/vimo-ai/memex/claude-md.svg)](https://agentmods.dev/instructions/vimo-ai/memex/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/vimo-ai/memex/claude-md"><img src="https://agentmods.dev/badge/instructions/vimo-ai/memex/claude-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,000 This file is loaded in full into every session.
When invoked 1,000 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.01000 $0.01000
Opus 5 $0.00500 $0.00500
Sonnet 5 $0.00200 $0.00200
Haiku 4.5 $0.00100 $0.00100

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

Security

Grade A, and why

memex CLAUDE.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 4d 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.

CLAUDE.md · 82 lines

How it starts

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

CLAUDE.md

项目简介

Memex 是 Claude Code 会话历史管理系统(Rust 实现),解决本地数据 30 天过期、历史对话难检索、知识无沉淀的问题。

架构

V2 读写分离:文件监听和写入由 vimo-agent 统一负责,memex-rs 通过 HTTP API 被动触发 compact 和向量索引。

两种运行模式:

  • CLI 模式(默认):本地运行,含文件监听、定时任务、Web UI、MCP
  • Server 模式:接收客户端 push,提供跨人搜索,不跑 LLM/embedding

技术栈

  • 语言: Rust
  • HTTP: Axum + tower-http
  • 存储: SQLite + FTS5(文本)、LanceDB(向量)
  • Embedding: BGE-M3(Ollama 本地,1024 维)
  • LLM: Ollama(compact 用 Qwen3 0.6B,knowledge 用强模型)
  • 协议: MCP(JSON-RPC 2.0)、HTTP API
  • 共享依赖: ai-cli-session-db(reader + search + sync)

核心模块

模块 说明
compact/ LLM 多层压缩:L0 原文 → L1 Observations → L2 Talk Summary → L3 Session Summary
knowledge/ L4 知识结晶:从 L0 提取结构化知识(集群/节点/关系),用强模型,独立于 compact
search/ 混合检索:FTS5 + 向量搜索 + RRF 融合,支持 L0-L3 多级别
vector/ LanceDB 向量存储
embedding/ BGE-M3 embedding
rag/ RAG 问答:混合检索 → 上下文构建 → LLM 生成
mcp/ MCP 工具:search_history / get_session / get_recent_sessions / list_projects
server/ Server 模式:ingest / register / search
db_reader/ 只读数据库层(替代 SharedDbAdapter)
api/ HTTP API 路由
backup/ 增量备份
archive/ 分层归档(daily → weekly → monthly → yearly)
indexer/ 向量索引器
inject/ 上下文注入

Compact 设计

原文始终保留,压缩层可选、可重做:

  • L0: 原文(messages 表)
  • L1: Observations — 每个工具调用一个(0.6B 模型)
  • L2: Talk Summary — 每轮对话一个(0.6B 模型)
  • L3: Session Summary — 整个会话一个,依赖 L2(0.6B 模型)
  • L4: Knowledge — 结构化知识提取(强模型,独立管线)

MCP 设计原则

  • 精简输出:只返回 AI 需要的字段,减少 token 消耗
  • 渐进披露:列表返回摘要,详情返回完整内容
  • 位置导航:at 字段定位消息,around 模式获取上下文

关键路径

路径 说明
memex-rs/ Rust 主项目
memex-lite/ 轻量版
docker/ Docker 部署配置
web/ Web UI
~/.vimo/db/ 数据库文件
~/.claude/projects/ Claude Code 会话数据源

环境变量

  • PORT — 服务端口(默认 10013)
  • MEMEX_DATA_DIR — 数据目录(默认 ~/.vimo/db)
  • MEMEX_WEB_DIR — Web 静态文件(默认 ~/.vimo/memex/web)
  • OLLAMA_API — Ollama API URL(默认 http://localhost:11434)

开发约定

  • 中文注释和文档
  • 先实现核心功能,不过度设计
  • compact 模块用 0.6B 小模型保持低成本,knowledge 用强模型保证质量

Read the full file on GitHub · 82 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. 4d ago First seen · 82 lines · 1,000 tokens per session scan A 309fde76e1af

Subscribe to this mod's changes

memex CLAUDE.md is an instructions file published in the GitHub repository vimo-ai/memex (28 stars, last pushed 2mo ago), licensed MIT. It adds 1,000 tokens to every session, about $0.0050 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.