memory-context

A command-line memory search tool for finding relevant past learnings, analysis notes, and project documents. It searches by meaning as well as exact words.

In plain words
What is it for?
Use it to recall previous work, search analysis and project notes, and find solutions related to a natural-language question or code identifier.
Why use it?
It avoids repeating investigations or losing useful context between coding sessions. You can quickly check whether a problem or code pattern was handled before.

Skill for Claude CodeCodex

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 skills/d-o-hub/github-template-ai-agents/memory-context
Any agent
npx skills add d-o-hub/github-template-ai-agents --skill memory-context
Clone the repo
git clone --depth 1 https://github.com/d-o-hub/github-template-ai-agents

Made for: Claude Code, Codex.

Per session 86 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 771 The whole file, excluding the scripts and references it only reads on demand.
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.00086 $0.00771
Opus 5 $0.00043 $0.00385
Sonnet 5 $0.00017 $0.00154
Haiku 4.5 $0.00009 $0.00077

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

Security

Grade A, and why

memory-context 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/skills/memory-context/SKILL.md · 101 lines

How it starts

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

Memory Context

Retrieve semantically relevant past learnings, analysis outputs, and project knowledge using the csm (Chaotic Semantic Memory) CLI.

Prerequisites

cargo install chaotic_semantic_memory --features cli

When to Use

  • At session start to recall previous work
  • When facing a problem that might have been solved before
  • To retrieve specific findings from analysis/ or agents-docs/

Indexing (Run Once)

# Index lessons (lessons.jsonl stores lesson summary text in "title")
csm index-jsonl -F agents-docs/lessons.jsonl --field title --id-field id --tag-field tags

# Index analysis outputs and docs
csm index-dir --glob "analysis/**/*.md" --glob "agents-docs/*.md" --heading-level 2

Index stored in .git/memory-index/csm.db (per-clone, never committed).

Querying

# Natural language query (default: hybrid retrieval)
csm query "how to handle git worktree cleanup" --top-k 5

# Code identifier query (exact match optimized)
csm query "MAX_CONTEXT_TOKENS" --top-k 3 --output-format json

# Code-heavy query
csm query "get_user_by_id" --code-aware --top-k 5

Output Formats

  • --output-format table (default): human-readable
  • --output-format json: machine-parseable for agent consumption
  • --output-format quiet: IDs only

Token Budget

Use a hard post-query cap from .agents/config.sh:

source .agents/config.sh
csm query "how to handle git worktree cleanup" --top-k 8 --output-format table |
awk -v max_tokens="$MAX_CONTEXT_TOKENS" '
{
    for (i = 1; i <= NF; i++) {
        if (token_count < max_tokens) {
            printf "%s%s", $i, (token_count + 1 < max_tokens ? " " : "\n")
            token_count++
        } else {
            exit
        }
    }
}
'

This enforces an approximate token ceiling even if retrieval output is verbose.

See Also

  • learn — Extract learnings into AGENTS.md
  • delegate — Context retrieval and handoff

Rationalizations

Rationalization Reality
"I'll just search with grep instead" grep finds literal text; semantic retrieval surfaces related concepts and non-obvious connections.
"The index is probably out of date" A stale index is better than no index; re-index periodically rather than skipping retrieval entirely.

Read the full file on GitHub · 101 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 · 101 lines · 86 tokens per session scan A 301595863df2

Subscribe to this mod's changes

memory-context is a skill published in the GitHub repository d-o-hub/github-template-ai-agents (2 stars, last pushed 2d ago), licensed MIT. It adds 86 tokens to every session and 771 once invoked, about $0.0004 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.