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.
npx agentmods add instructions/ghadisaab/ctx-memory/agents-mdgit clone --depth 1 https://github.com/GhadiSaab/ctx-memoryWhat 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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.02237 | $0.02237 |
| Opus 5 | $0.01118 | $0.01118 |
| Sonnet 5 | $0.00447 | $0.00447 |
| Haiku 4.5 | $0.00224 | $0.00224 |
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 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.
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 setfailed 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/ghadiis a git repo (has.git/). When you runclaudefrom/home/ghadi/perso/Project12,git rev-parse --show-toplevelwalks up and returns/home/ghadi— so the wrapper resolves it to theghadiproject instead of creating aProject12project. - Fix needed in
src/wrapper/project.ts: IfgitRootis a parent ofcwd(not the same or a direct project root), fall back to usingcwditself. -
2. Architecture/decisions never saved in digests
- Root cause:
decisionsin Layer 1 only come from: -
- "confirmation" pattern matches with
extractedDecision
- "confirmation" pattern matches with
-
- Messages typed as
"decision"
- Messages typed as
- When Claude announces architecture, it's just an
assistantmessage — Layer 1 never classifies it as a "decision". Sodecisions: []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 listdidn't show Project12 - Root cause: Same as #1 — Project12 was never registered. Its sessions went to the
ghadiproject. -
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
seedBufferswith messages never ran (no messages seeded from JSONL).
- Want me to fix these now? The priority order I'd suggest:
-
- Fix #1 (git root leaking to parent) — affects project isolation completely
-
- Fix #2 (decisions extraction) — affects architecture/memory quality
-
- Fix #4 (messages not seeded) — investigate why JSONL reader returns nothing for recent sessions
- Now fix
tryConfirmationin 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.urlinstead ofVITEST, but actually looking at th… - The fix: check if
argv[1]ends withwrapper/index.js(the only valid case to runmain()), rather than checking fo…
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.
- 2d ago First seen · 89 lines · 2,237 tokens per session scan A 19c3ba7d76b0
ctx-memory AGENTS.md is an instructions file published in the GitHub repository GhadiSaab/ctx-memory (0 stars, last pushed 2mo ago), licensed MIT. It adds 2,237 tokens to every session, about $0.0112 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-31.
Other instructions, from other repositories
vscode buildNext.instructions.md
Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).
spec-kit AGENTS.md
AGENTS.md instructions for github/spec-kit, covering agents.md, about spec kit and specify, quickstart — add a new integration in 5 steps, integration architecture and integrationmanifest — file tracking.
codex AGENTS.md
AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.
langchain AGENTS.md
AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.
vscode oss-third-party-notices.instructions.md
Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).
next.js AGENTS.md
Instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.