MemoryLayer
  • How it works
  • Arena
  • Benchmarks
  • Registry
  • Pricing
  • Docs
Log inGet started free
  • 01Arena
  • 02Benchmarks
  • 03Registry
  • 04Pricing
  • 05Docs
Log inGet started free

Docs

Docs home

Getting started

  • Quickstart
  • Claude Code
    1. Setup
    2. What setup adds
    3. Hooks
    4. CLAUDE.md rules
    5. Active namespace
  • Cursor

Learn

  • How memory works
  • Search & recall
  • Shared across agents
  • Grounded facts

Reference

  • MCP tools
  • Agent rules
  • Bookmarks
  • Registry & CLI

Help

  • FAQ
← QuickstartCursor →
Docs home

Getting started

  • Quickstart
  • Claude Code
    1. Setup
    2. What setup adds
    3. Hooks
    4. CLAUDE.md rules
    5. Active namespace
  • Cursor

Learn

  • How memory works
  • Search & recall
  • Shared across agents
  • Grounded facts

Reference

  • MCP tools
  • Agent rules
  • Bookmarks
  • Registry & CLI

Help

  • FAQ

Docs/Getting started

IDE Integration

Claude Code

One command, and Claude Code checks memory before it acts and saves what it learns — without you asking.

Setup

Terminalfrom your project
memorylayer namespace set <project-name>   # optional, keeps this project's memories apartmemorylayer setup --ide claude --yes

Safe to re-run: it updates its own marked block and leaves the rest of your CLAUDE.md alone. Undo it all with memorylayer setup --remove --ide claude --yes.

What setup adds

  • MCP server

    Lets Claude Code start MemoryLayer. Nothing else works without it.

    ~/.claude.json
  • Hooks13 scripts · 16 events

    Run on their own at set moments in a session.

    ~/.claude/hooks/~/.claude/settings.jsonWhat each hook does ↓
  • Rules

    Always-on instructions Claude reads every session.

    ~/.claude/CLAUDE.mdRead an excerpt ↓
  • Skill

    A /memorylayer reference card; the project copy wins.

    ~/.claude/skills/memorylayer/.claude/skills/memorylayer/

Hooks

A hook is a script Claude Code runs by itself at a set moment, the way a linter runs on save. Tap one to see what it does.

  1. When a session starts

    • SessionStartSets the namespace and loads the skill
      • Resolves the namespace from ~/.memorylayer/namespaces.json and exports MEMORYLAYER_NAMESPACE, so every Bash command sees it
      • Names the session after the project folder and watches package.json, go.mod, Cargo.toml and friends
      • Reloads the /memorylayer skill and reports whether the code index is up to date
      ~/.claude/hooks/memorylayer_session_start.js
    • CwdChangedFollows you into another project
      • Re-resolves the namespace for the new directory and updates MEMORYLAYER_NAMESPACE
      ~/.claude/hooks/memorylayer_cwd_changed.js
  2. Every prompt

    • UserPromptSubmitPuts memory in front of Claude before it answers
      • First turn: loads your rule, constraint and guide memories from every namespace, as content rather than a reminder
      • Every turn: tells Claude to recall from the project namespace and which tool fits the question
      • Ingest guard: skips re-indexing when the git commit hasn't changed
      ~/.claude/hooks/memorylayer_user_prompt_submit.js
  3. Around every tool call

    • PreToolUseMemory first, then filescan block
      • The first Read, Grep, Glob or Bash of a turn is denied until recall() or code() has run
      • The retry is always allowed, so a turn can't get stuck when memory has nothing
      • Before Edit or Write it asks for code(impact) and a check for known errors
      ~/.claude/hooks/memorylayer_pre_tool_use.js
    • PostToolUseLifts the gate and nudges good habits
      • After recall or code: marks memory as consulted, which opens the PreToolUse gate for the turn
      • After edits: reminds Claude to track errors as one memory each, open → fixed
      ~/.claude/hooks/memorylayer_post_tool_use.js · memorylayer_mark_used.js
    • PostToolUseFailureTurns a failed tool call into an error memory
      • Checks whether the error is already known, opens [error][open] if not, and closes it as [error][fixed] once solved
      ~/.claude/hooks/memorylayer_post_tool_use_failure.js
  4. When Claude finishes a reply

    • StopCheck the claims, save the learnings
      • Reminds Claude to run verify() on facts it just stated and to save anything new
      • Fires at most once per turn, so short replies don't get nagged
      • StopFailure fires every time — each failure is worth an error memory
      ~/.claude/hooks/memorylayer_stop.js
  5. When the context fills up

    • PreCompact · PostCompactSave before the trim, reload after
      • Before: asks Claude to write down decisions and open errors — nothing else survives the trim
      • After: loads priority memories straight back in, because the reminder to recall was trimmed too
      ~/.claude/hooks/memorylayer_compact.js
  6. Subagents and tasks

    • SubagentStart · SubagentStopSeed the helper, keep what it found
      • Start: gives the subagent the memories that match its task, since it begins with none of the conversation
      • Stop: asks Claude to keep any fix, pattern or decision the subagent surfaced
      ~/.claude/hooks/memorylayer_subagent.js
    • TaskCreated · TaskCompletedRecall past attempts, save the outcome
      • Seeds the task with matching memories, then saves the result and closes related error memories
      ~/.claude/hooks/memorylayer_task.js
    • TeammateIdleCheap upkeep while an agent waits
      • Suggests consolidate({ action: "ripple" }) or an explore pass — optional, skipped when there's nothing open
      ~/.claude/hooks/memorylayer_teammate_idle.js
  7. When the session ends

    • SessionEndThe closing checklist
      • Runs in the background so exit isn't delayed: save guides, close errors, record the index, run consolidate()
      ~/.claude/hooks/memorylayer_session_end.js

Every hook reads or writes one store~/.memorylayer/memories.db

CLAUDE.md rules

An excerpt of the managed block — the full text is on Agent rules.

~/.claude/CLAUDE.mdexcerpt
## Error lifecycle- Hit error → recall(tags=["error"], query="<error>") — check if known- New error → remember({ tags: ["error","open"], priority: 7 })- Fix found → update SAME memory → tags: ["error","fixed","solution"] ## Before any Edit/Write1. code(impact, symbolName, depth=2) — callers, callees, test files2. recall(tags=["error"], query="<symbol>") — known issues ## Ingest rules- git SHA unchanged (hook tells you) → SKIP ingest entirely- Repo >500 files → ASK USER first, suggest sub-directory

Which namespace is active

MemoryLayer walks up from the current directory and uses the closest match in ~/.memorylayer/namespaces.json.

Terminal
memorylayer namespace get    # what's active herememorylayer namespace list   # every folder → namespace mapping
← PreviousQuickstartNext →Cursor

Something missing or wrong? Email support@memorylayer.in or open an issue.