Concepts: the aide-memory mental model

aide-memory is a persistent memory layer for AI coding agents. It captures decisions, preferences, and technical context as you work, surfaces them when the agent is in the relevant area, and shares them with your teammates over git.

This page is the editor-agnostic mental model. For runtime UX inside a specific tool see Supported Editors; for config keys see Configuration; for the MCP tools and CLI commands see Reference.


Where aide-memory fits

Most coding agents already work with two kinds of context:

  • Editor-level rules (CLAUDE.md, .cursorrules) carry always-on guidance, project conventions, and reference info that should be available on every turn. They’re a single flat document, no scoping, no categorization.
  • Skills / sub-agents carry procedures the agent can invoke for specific tasks.

aide-memory adds a third surface: dynamic, scoped, categorized knowledge that grows with the code, captured automatically and recalled when the agent is in the relevant area. Rules cover always-on guidance; skills cover procedures; aide-memory covers what those don’t, the dynamic, area-specific decisions and preferences and team conventions that build up over time.

The three coexist. aide-memory doesn’t replace your CLAUDE.md or your skills. The mental model:

  • Rules file = “things every agent in this project should always know” (style, project layout, common pitfalls)
  • Skills = “procedures the agent can run for specific tasks”
  • aide-memory = “the body of decisions, preferences, technical facts, and corrections that grows with your codebase, scoped to where each one applies”

1. Memories

A memory is a single JSON file under .aide/memories/<layer>/. It captures one unit of knowledge (a decision, a preference, a fact, a rule) with a scope (the code area it applies to) and a layer (what kind of knowledge it is). Memories are human-readable, diffable, and syncable via git.

2. The four layers

Layers separate how the knowledge is used. Recall and injection are prioritized by layer, so the agent gets the most context-relevant entries first.

LayerWhat it capturesExample
preferencesAn individual contributor’s coding style or workflow”I write component files as Component/index.tsx + Component/Component.test.tsx, never co-located in the parent dir”
technicalFacts about the stack not obvious from code”Apollo client uses persisted query hashes; raw queries 404 in prod”
area_contextA decision or constraint specific to a code area”The billing module is event-sourced; new code appends events, never mutates balances directly”
guidelinesA team-wide or project-wide principle”Public API responses use {error: {code, message}} envelopes for any non-2xx status”

preferences further splits into personal/ (gitignored) and shared/ (committed). The other three layers are team-visible by default.

3. Scopes

Every memory can carry a scope, a glob pattern describing which code area it applies to. Scopes are relative to your project root. Examples:

  • src/auth/** matches the auth module across machines
  • packages/api/server/** matches a monorepo subpackage
  • (no scope) means project-wide; surfaces everywhere

Inheritance is the key property: a memory scoped to src/** surfaces for src/checkout/CartSummary.tsx. A memory scoped to src/checkout/** surfaces only inside checkout code. Scoping lets you attach context to specific areas without polluting recall in unrelated files.

How specific a scope must be to surface per-file vs SessionStart-only is tunable via recall.minScopeDepth (default 1, permissive). See Configuration for the visualization.

4. Hooks

Hooks are small scripts the editor runs at lifecycle points. aide-memory installs them at aide-memory init. They fire automatically so capture and recall happen without manual invocation.

HookFires whenWhat aide-memory does
SessionStartSession begins, resumes, or clearsInjects top preferences + guidelines + priority-always memories as session context
PreToolUseBefore file read, edit, search, or aide_* MCP callFirst read of a file with un-recalled scoped memories: prompts the agent to call aide_recall. After that, subsequent reads are silent or soft-nudged if some scoped memories haven’t been recalled yet. Tunable.
PostToolUseAfter aide_recall / aide_remember / aide_searchRecords what was recalled so re-reads of the same path don’t re-prompt for the IDs already in context
UserPromptSubmitUser sends a messageDetects correction patterns (“no, use X instead”) and prompts the agent to call aide_remember
StopAgent finishes a turnPeriodic reflection prompt (“anything worth remembering?”) on a tunable schedule (default ramps every 3 → every 5 → every 10 turns by session length)
PreCompactBefore context compactionClears session tracking so post-compact reads re-prompt cleanly

Not every editor supports every channel. See Supported Editors for what each adapter ships today and Hooks for the script-by-script breakdown.

5. MCP tools

aide-memory ships a local MCP server with seven tools. The agent calls them during conversation; you can run the equivalent CLI commands. See Reference for full details.

ToolPurpose
aide_recallRetrieve memories for a code area, ranked by layer and scope specificity
aide_rememberStore a new memory (layer + scope + what/why + tags)
aide_updateEdit an existing memory’s content, scope, or tags
aide_forgetPermanently delete a memory (no archive mode)
aide_searchKeyword and/or semantic search across all memories (modes: auto / keyword / semantic)
aide_memoriesList memories with layer, scope, contributor, tag filters
aide_importBulk-import from markdown bullet / numbered lists

6. Storage shape

.aide/
├── memories/
│   ├── preferences/
│   │   ├── personal/    # gitignored, private to you
│   │   └── shared/      # tracked, visible to team
│   ├── technical/
│   ├── area_context/
│   └── guidelines/
├── config.json          # local configuration with every public knob seeded
├── config-reference.md  # auto-generated key/default/description listing
└── cache/
    ├── memory.db        # SQLite cache (rebuildable, gitignored)
    └── recalled-paths-<sid>.txt  # session-scoped tracking

JSON files are the source of truth. SQLite is a rebuildable cache. Recall stats live only in the cache so per-machine usage data doesn’t end up in git.

7. Sync via git

Memories are files. Commit them, push them, pull them. A post-checkout git hook (installed at init) imports new or changed memory files into the local SQLite cache after git pull or branch switch. Conflicts resolve by updated_at timestamp; newer wins.

8. Recall strategy

When the agent calls aide_recall({paths: [...]}):

  1. Path-matched memories: scoped globs that cover the requested paths (with parent inheritance: querying src/ returns memories scoped under src/).
  2. Sort order: scope match first (scoped beats project-wide), then layer priority (area_context > technical > preferences > guidelines), then scope specificity (deeper scopes rank higher) and keyword relevance.
  3. Cap: recall.limit (default 20) per call; remaining IDs come back as missingIds on the next pre-read fire so the agent can call aide_recall({ids: [...]}) for the next batch.
  4. Layer-diversity rebalance: when results are below recall.layerDiversityMinLimit (default 5), under-represented layers swap up so each enabled layer is represented.

For conceptual searches (“where do we handle auth tokens?”), prefer aide_search over aide_recall since keyword (and optional semantic) search surfaces memories that path-scoping alone would miss.

9. What aide-memory does not do

  • No LLM calls of its own. The model in your editor does the reasoning.
  • No background distillation. Memories are what you (or the agent on your behalf) wrote. Call aide_update to change them.
  • No remote storage. Memory content stays on your disk. Anonymized usage counts ship to PostHog by default; disable with AIDE_TELEMETRY=off.

Further reading