memory-patterns

A guide to managing an agent's context and memory, including the current conversation, persistent project notes, past events, and stored knowledge. Context is the information the agent can use while working.

In plain words
What is it for?
Use it when designing project notes, long-term memory, conversation summaries, or knowledge retrieval. It covers files such as CLAUDE.md or AGENTS.md, context compaction, and different memory types.
Why use it?
It addresses the problem of agents forgetting decisions or losing useful details when conversations become long or end. It describes ways to record and retrieve important project information.

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/apexiq/skillsmith/memory_patterns
Any agent
npx skills add ApexIQ/skillsmith --skill memory_patterns
Clone the repo
git clone --depth 1 https://github.com/ApexIQ/skillsmith

Made for: Claude Code, Codex.

Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 696 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.00032 $0.00696
Opus 5 $0.00016 $0.00348
Sonnet 5 $0.00006 $0.00139
Haiku 4.5 $0.00003 $0.00070

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

Security

Grade A, and why

memory-patterns 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.

.agent/skills/memory_patterns/SKILL.md · 108 lines

How it starts

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

🧠 Memory Patterns

Philosophy: Agents are stateless by default. Good memory design makes them context-aware and consistent.

The Problem

LLMs have finite context windows and no built-in memory across sessions. Without proper patterns:

  • Agents forget past decisions
  • Context overflow causes quality degradation
  • Token costs increase unnecessarily

Memory Types

Type Description Implementation
Short-term Current conversation context Prompt + recent messages
Long-term Persistent across sessions Files, databases, vector stores
Episodic Specific past experiences Indexed conversation logs
Semantic Facts and knowledge RAG with embeddings

Patterns

1. Structured Note-Taking (CLAUDE.md / AGENTS.md)

Store important context in project files:

# CLAUDE.md

## Key Decisions
- Using SQLModel for ORM (decided 2024-01-15)
- API versioning via URL path (/v1/, /v2/)

## Gotchas
- `email_id` is string (Gmail format), not integer

When to use: Project-specific knowledge, conventions, past decisions.

2. Context Compaction

Summarize long conversations to preserve tokens:

Original: [3000 tokens of back-and-forth]
Compacted: "User requested auth system. Decided on JWT + refresh tokens. 
           Implemented /login and /refresh endpoints. Tests passing."

When to use: Long-running tasks, before context window fills.

3. Hierarchical Memory (Sub-agent Pattern)

Delegate tasks to sub-agents with focused context:

Main Agent (high-level context)
├── Code Agent (code-only context)
├── Test Agent (test files context)
└── Doc Agent (documentation context)

When to use: Large codebases, parallel tasks, complex workflows.

4. File System as Memory

Use files to persist information beyond context:

.agents/
├── decisions/         # ADRs and key decisions
├── notes/             # Temporary working notes
└── context/           # Current task context

Read the full file on GitHub · 108 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 · 108 lines · 32 tokens per session scan A 53d3adaa004d

Subscribe to this mod's changes

memory-patterns is a skill published in the GitHub repository ApexIQ/skillsmith (5 stars, last pushed 5mo ago), licensed MIT. It adds 32 tokens to every session and 696 once invoked, about $0.0002 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.