ctx-memory: Instructions file for Claude Code

AGENTS.md

ctx-memory AGENTS.md is an instructions file for Claude Code, Codex, OpenCode from GhadiSaab/ctx-memory. It costs 2,237 tokens per session, scanned A, original, MIT.

Repository instructions for ctx-memory, a local memory system for coding agents. It stores project history in SQLite with vector search and writes project memory to AGENTS.md so agents can use it in later sessions.

In plain words
What is it for?
Use it when working on ctx-memory or changing its architecture, hooks, wrappers, memory pipeline, or agent integrations. It also records known issues and project-specific conventions.
Why use it?
It reduces the need to repeat past work, decisions, errors, and conventions when starting a new coding session. It also documents how memory is collected and injected for different agents.

Instructions file for Claude CodeCodexOpenCode

Written for Claude Code and Codex and OpenCode: PostToolUse hook event, but also the file is AGENTS.md. Also seen: mentions CLAUDE.md; mentions subagents; mentions Claude Code.

This is GhadiSaab/ctx-memory's own configuration. It tells Claude Code, Codex and OpenCode how to work on ctx-memory itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything ctx-memory configures →

Not installable: its command points at a path on the author’s own machine, so it runs nowhere else. The line is /home/ghadi/perso/Project12.

Reuse

Borrowing it

Nothing to install: this file belongs to GhadiSaab/ctx-memory. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/GhadiSaab/ctx-memory/main/AGENTS.md
Clone the repo
git clone --depth 1 https://github.com/GhadiSaab/ctx-memory

Made for: Claude Code, Codex, OpenCode.

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

README.md
[![agentmods](https://agentmods.dev/badge/instructions/ghadisaab/ctx-memory/agents-md/github.svg)](https://agentmods.dev/instructions/ghadisaab/ctx-memory/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/ghadisaab/ctx-memory/agents-md"><img src="https://agentmods.dev/badge/instructions/ghadisaab/ctx-memory/agents-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for ctx-memory AGENTS.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/ghadisaab/ctx-memory/agents-md"><img src="https://agentmods.dev/badge/instructions/ghadisaab/ctx-memory/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 2,237 This file is loaded in full into every session.
When invoked 2,237 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.02237 $0.02237
Opus 5.5 $0.00895 $0.00895
Sonnet 5.5 $0.00447 $0.00447
Haiku 4.5 $0.00224 $0.00224

Measured 2mo ago against content hash 19c3ba7d76b0, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

ctx-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 2mo 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 · 89 lines

How it starts

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

Project Memory (from previous sessions)

Project Memory

Architecture

  • Persistent memory layer for LLM coding agents (Claude Code, Codex, Gemini, OpenCode) backed by SQLite + sqlite-vec, exposed via MCP
  • Three-layer pipeline: Layer 1 (pure message/event processing) → Layer 2 (digest ≤500 tokens) → Layer 3 (project memory markdown merge)
  • Shell wrapper intercepts tool binaries, spawns MCP sidecar (Claude/OpenCode only), runs pipeline on session end
  • Claude: hooks fire live (PostToolUse) + JSONL reader seeds messages post-session
  • Codex: post-hoc only — reads ~/.codex/state_5.sqlite + rollout JSONL after session ends
  • OpenCode: MCP sidecar + AGENTS.md injection at startup
  • AGENTS.md used for context injection for Codex and OpenCode (written before spawning tool)
  • Non-interactive subcommands (update, mcp, login, etc.) bypass wrapper entirely via execFileSync
  • You want OpenClaw (from Discord) to be able to act directly on your local files instead of only replying with paste-ready output. I’m checking your local OpenClaw/GSD setup to see exactly which permission boundary is blocking that and what to change safely.
  • I successfully applied the config-side changes, but openclaw approvals set failed because its CLI syntax is different than expected. I’m switching to directly updating ~/.openclaw/exec-approvals.json, then I’ll verify and restart gateway.
  • Now I have the full picture. Here are all the problems:

  • Problems Found

  • 1. Project12 sessions go to wrong project ("ghadi")

  • Root cause: /home/ghadi is a git repo (has .git/). When you run claude from /home/ghadi/perso/Project12, git rev-parse --show-toplevel walks up and returns /home/ghadi — so the wrapper resolves it to the ghadi project instead of creating a Project12 project.
  • Fix needed in src/wrapper/project.ts: If gitRoot is a parent of cwd (not the same or a direct project root), fall back to using cwd itself.
  • 2. Architecture/decisions never saved in digests

  • Root cause: decisions in Layer 1 only come from:
    • "confirmation" pattern matches with extractedDecision
    • Messages typed as "decision"
  • When Claude announces architecture, it's just an assistant message — Layer 1 never classifies it as a "decision". So decisions: [] always, nothing reaches Layer 3's architecture section.
  • Fix needed: Layer 1 needs to extract decisions from assistant messages that match architecture/decision patterns (e.g. "I'll use...", "The architecture is...", "decided to...").
  • 3. llm-memory projects list didn't show Project12

  • Root cause: Same as #1 — Project12 was never registered. Its sessions went to the ghadi project.
  • 4. No messages captured (0 messages_raw despite JSONL existing)

  • Root cause: The JSONL reader runs at session end and finds the file by mtime >= sessionStartMs. But the current session's JSONL file is still open/being written, so the mtime check may race. Also, 0 messages in DB means seedBuffers with messages never ran (no messages seeded from JSONL).

  • Want me to fix these now? The priority order I'd suggest:
    1. Fix #1 (git root leaking to parent) — affects project isolation completely
    1. Fix #2 (decisions extraction) — affects architecture/memory quality
    1. Fix #4 (messages not seeded) — investigate why JSONL reader returns nothing for recent sessions
  • Now fix tryConfirmation in patterns.ts to extract a meaningful decision sentence instead of dumping the whole assistan…
  • "I'm using" still matches "using " in ARCH_SIGNALS. And "React 19 instead of 18" matches "react". Both are still appeari…
  • Clean! But "I'm using Subagent-Driven Development to build KubeQuest task by task" is in Architecture because it matches…
  • The real fix is to change the entrypoint guard to use import.meta.url instead of VITEST, but actually looking at th…
  • The fix: check if argv[1] ends with wrapper/index.js (the only valid case to run main()), rather than checking fo…

Read the full file on GitHub · 89 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. 2mo ago First seen · 89 lines · 2,237 tokens per session scan A 19c3ba7d76b0

Subscribe to this mod's changes

ctx-memory AGENTS.md is an instructions file published in the GitHub repository GhadiSaab/ctx-memory (1 stars, last pushed 4mo ago), licensed MIT. It adds 2,237 tokens to every session, about $0.0089 per session on Opus 5.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-31.

Related

ctx-memory AGENTS.md compared with instructions from other repositories

ctx-memory AGENTS.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
ctx-memory AGENTS.mdGhadiSaab/ctx-memoryInstructions file14mo agoMITA2,237Claude Code, Codex, OpenCode
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143kyesterdayMITA7,461Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file149kyesterdayMITA4,680Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA5,516GitHub Copilot
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA3,093GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file274k2d agoMITA4,313Codex, OpenCode