DocsGetting started
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
memorylayer namespace set <project-name> # optional, keeps this project's memories apartmemorylayer setup --ide cursor --yesCommit .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.jsonHooks8 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.
When a session starts
sessionStartSets the namespace for the session- Exports
MEMORYLAYER_NAMESPACEto every later hook - Spots
.domainfiles indomains/or.claude/domains/and suggests loading them
.cursor/hooks/memorylayer_session_start.js- Exports
Every prompt
beforeSubmitPromptPuts memory in front of Cursor before it answers- Loads your
rule,constraintandguidememories 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- Loads your
Around every tool call
preToolUseMemory first, then filescan block- The first Read, Grep, Glob or Shell of a turn is denied until
recallorcodehas run - The retry is always allowed, so a turn can't get stuck when memory has nothing
.cursor/hooks/memorylayer_pre_tool_use.js- The first Read, Grep, Glob or Shell of a turn is denied until
postToolUseLifts the gate and nudges good habits- After
recallorcode: 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- After
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- One memory per error,
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- Asks Cursor to write things down and run
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()andverify()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.
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"Something missing or wrong? Email support@memorylayer.in or open an issue.