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
  • Cursor
    1. Setup
    2. What setup adds
    3. Hooks
    4. Differences
    5. Cursor rules

Learn

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

Reference

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

Help

  • FAQ
← Claude CodeHow memory works →
Docs home

Getting started

  • Quickstart
  • Claude Code
  • Cursor
    1. Setup
    2. What setup adds
    3. Hooks
    4. Differences
    5. Cursor rules

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

Cursor

One command, and Cursor checks memory before it reads files. The hooks live in your repo, so teammates and cloud agents get them too.

Setup

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

Commit .cursor/hooks.json and .cursor/hooks/ — cloud agents load hooks from the repo (Cursor hooks docs). Safe to re-run; it also clears old user-level entries so nothing fires twice. Undo with memorylayer setup --remove --ide cursor --yes.

What setup adds

  • MCP server

    Global, so every project can start MemoryLayer.

    ~/.cursor/mcp.json
  • Hooks8 scripts · 9 events

    In the repo, registered in hooks.json.

    .cursor/hooks/.cursor/hooks.jsonWhat each hook does ↓
  • Rules

    Applied to every chat (alwaysApply).

    .cursor/rules/memorylayer.mdcRead an excerpt ↓
  • Skill

    A /memorylayer reference card; the project copy wins.

    ~/.agents/skills/memorylayer/.cursor/skills/memorylayer/

Hooks

A hook is a script Cursor runs by itself at a set moment. Tap one to see what it does.

  1. When a session starts

    • sessionStartSets the namespace for the session
      • Exports MEMORYLAYER_NAMESPACE to every later hook
      • Spots .domain files in domains/ or .claude/domains/ and suggests loading them
      .cursor/hooks/memorylayer_session_start.js
  2. Every prompt

    • beforeSubmitPromptPuts memory in front of Cursor before it answers
      • Loads your rule, constraint and guide memories on every turn — Cursor has no PostCompact to reload them
      • Ingest guard: skips re-indexing when the git commit hasn't changed
      • Suggests the right tool for the question, and resets the per-turn gate
      .cursor/hooks/memorylayer_before_submit_prompt.js
  3. Around every tool call

    • preToolUseMemory first, then filescan block
      • The first Read, Grep, Glob or Shell 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
      .cursor/hooks/memorylayer_pre_tool_use.js
    • postToolUseLifts the gate and nudges good habits
      • After recall or code: opens the preToolUse gate for the rest of the turn
      • After edits and direct reads: error-tracking and recall-first reminders
      .cursor/hooks/memorylayer_post_tool_use.js · memorylayer_mark_used.js
    • postToolUseFailureTurns a failed tool call into an error memory
      • One memory per error, [error][open] → [error][fixed]
      .cursor/hooks/memorylayer_post_tool_use_failure.js
  4. When the context fills up

    • preCompactSave before the trim
      • Asks Cursor to write things down and run consolidate({ action: "ripple" }); the next prompt reloads priorities
      .cursor/hooks/memorylayer_pre_compact.js
  5. Subagents

    • subagentStart · subagentStopSeed the helper, keep what it found
      • Start: gives the subagent the memories that match its task (never blocks the spawn)
      • Stop: reminds Cursor to remember() and verify() what it found
      .cursor/hooks/memorylayer_subagent.js

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

Where Cursor differs from Claude Code

  • No PostCompact — so priority memories reload on every prompt instead.
  • No Stop reminder — Cursor's stop hook can only start a new agent loop, so it's left out.
  • No SessionEnd checklist — the rules and preCompact prompt consolidation instead.

Cursor rules

An excerpt — the full text is on Agent rules.

.cursor/rules/memorylayer.mdcexcerpt
Core operating cycle — use these every session:THINK  → recall({ query, explore: true })LEARN  → remember({ content, namespace })VERIFY → verify({ text: "<claims>", domain? })SLEEP  → consolidate({ action: "ripple", namespace }) Before reading files:recall({ query, namespace }) FIRSTOnly Read if recall returns answer_kind="empty"
← PreviousClaude CodeNext →How memory works

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