Claude Code and Cursor hooks
awe can give Claude Code and Cursor your memory. Small hooks run when a session starts, before each prompt, and when the session ends. They bring in what awe knows about you and your work, and send what you did back to awe so it is remembered. This page is for people who use those tools and for developers who want to add their own hooks.
For Codex, Gemini CLI and other agents, see codex-integration.md. To give an editor awe’s tools as well as its memory, see mcp-host.md.
What the installer sets up
The installer writes hook settings inside the awe folder:
.claude/settings.jsonfor Claude Code.cursor/hooks.jsonfor Cursor
These are project settings. They work when you open the awe folder itself in Claude Code or Cursor. Your other projects are not covered until you run the step below.
Use your memory in every project
From the awe folder:
./awe-core mem setup --global
This adds awe’s three hooks to ~/.claude/settings.json, so they run in every Claude Code session on this computer. It sets up Claude Code only: not Cursor, Codex or Gemini CLI (see Cursor and codex-integration.md).
Your own permissions, hooks and settings in that file are kept. Before it changes a file that already exists, it saves a copy beside it named settings.json.before-awe-<date>-<time>. Running it again changes nothing. A file that is not valid JSON is left untouched, and the command says so.
Other forms:
./awe-core mem setup
./awe-core mem setup --vscode
- With no option, it adds the hooks to
.claude/settings.jsonin the folder you run it from, the same way. Use this to cover one project. --vscodealso installs the Claude Code extension for VS Code.
To undo, remove the awe entries from the settings file.
What each hook does
| When | Claude Code event | What runs | What it does |
|---|---|---|---|
| A session starts | SessionStart |
./awe-hook-bin ensure, then ./awe-hook-bin context |
Makes sure awe’s background service is running, then prints your operating notes and pinned memory. Claude Code adds that to the session |
| Before each prompt | UserPromptSubmit |
./awe-hook-bin sock prompt |
Sends the prompt to awe, which looks up memories that fit it and prints them. Claude Code adds them to the turn |
| The session ends | SessionEnd |
./awe-hook-bin sock flush |
Tells awe to read the session and keep what is worth remembering. Runs in the background |
awe-hook-bin is a small program in the awe folder. It talks to awe’s background service and never opens the databases itself. It finds the awe folder from the folder it is run in, then the AWE_PROJECT_PATH environment variable, then the folder the program itself is in (following a link, so a link to it on your PATH works). The hooks mem setup writes start with a cd into the awe folder all the same.
If awe is not running, the per-prompt hook returns nothing and your session carries on.
The hooks by hand
This is what mem setup writes, with /path/to/awe standing for your awe folder:
{
"hooks": {
"SessionStart": [
{ "hooks": [ { "type": "command",
"command": "cd \"/path/to/awe\" && ./awe-hook-bin ensure && ./awe-hook-bin context 2>/dev/null",
"timeout": 15 } ] }
],
"UserPromptSubmit": [
{ "hooks": [ { "type": "command",
"command": "cd \"/path/to/awe\" && ./awe-hook-bin sock prompt 2>/dev/null",
"timeout": 15 } ] }
],
"SessionEnd": [
{ "hooks": [ { "type": "command",
"command": "cd \"/path/to/awe\" && ./awe-hook-bin sock flush 2>/dev/null",
"async": true, "timeout": 120 } ] }
]
}
}
The generated commands also check that the folder and the program still exist. If you move or rename the awe folder, the hook prints a line on its error output that tells you to run mem setup again, and lets the session continue.
Cursor
Cursor reads .cursor/hooks.json. The awe folder’s copy uses three events:
| Cursor event | What runs | What it does |
|---|---|---|
sessionStart |
./awe-hook-bin cursor-session |
Prints the same starting context as JSON ({"additional_context": "..."}), the form Cursor expects |
beforeSubmitPrompt |
./awe-hook-bin sock prompt |
Sends the prompt to awe. awe writes the matching memories to .awe/workspace/.cursor_context.json |
stop |
./awe-hook-bin sock flush |
Tells awe to keep what is worth remembering |
A Cursor rule in the awe folder (.cursor/rules/read-context.mdc) tells the agent to read that context file at the start of a turn.
mem setup does not write Cursor’s settings. To use the hooks in another project, copy .cursor/hooks.json and .cursor/rules/read-context.mdc from the awe folder into that project. The hook commands find the awe folder through the AWE_PROJECT_PATH environment variable, so set it to your awe folder’s path.
The Claude Code plugin
integrations/claude-code-plugin/ in the awe folder is a Claude Code plugin that bundles the same three hooks with awe’s memory tools over MCP (the memory profile, with saving allowed) and two skills. It finds your awe folder through AWE_HOME, AWE_PROJECT_PATH, a parent of the working folder, or ~/awe. Its README.md has the install steps.
awe-hook-bin commands
| Command | What it does |
|---|---|
ensure |
Start awe’s background service if it is not running |
context |
Print the starting context as text |
startup |
ensure and context in one step |
cursor-session |
The starting context as JSON for Cursor |
codex-session, gemini-session, aider-session, oi-session, zed-session, continue-session, jetbrains-session |
The starting context for other tools, see codex-integration.md |
sock prompt |
Read a hook’s JSON from standard input (it must have a prompt field), send it to awe, print matching memories |
sock flush |
Ask awe to process the session |
Try it from the awe folder:
echo '{"prompt":"what did we decide about the launch date?"}' | ./awe-hook-bin sock prompt
./awe-hook-bin context
Two environment variables change its behavior: AWE_HOOK_SUPPRESS=1 makes every command do nothing, and AWE_HOOK_SKIP_ENSURE=1 skips starting the background service.
Rules files
Claude Code, Cursor, Gemini CLI and GitHub Copilot each read a rules file from a project (CLAUDE.md, .cursorrules, .cursor/rules/awe-policy.mdc, GEMINI.md, .github/copilot-instructions.md). In the awe folder these are generated from one source, templates/rules/, so they say the same thing:
./awe-core rules render
./awe-core rules render --check
./awe-core rules render --host cursor --stdout
renderwrites every rules file.--checkwrites nothing and exits with code 2 if a file no longer matches its source.--host <name>handles one file.--stdoutprints instead of writing.
Edit the files in templates/rules/, then render. Edits made directly to a generated file are overwritten.
Hooks around awe’s own tool calls
This is a separate feature with a similar name. You can make awe run a shell command of yours before or after it calls a tool.
./awe-core hook add log-tools PostToolUse "cat >> ~/awe-tool-calls.log"
./awe-core hook add guard-shell PreToolUse "/path/to/check.sh" --matcher-type server_name --matcher-value awe-script-executor --config '{"timeout":5,"blocking":true}'
./awe-core hook list
./awe-core hook list --event PreToolUse
./awe-core hook test 1
./awe-core hook disable 1
./awe-core hook enable 1
./awe-core hook remove 1
- The three values after
addare the hook’s name, the event (PreToolUseorPostToolUse) and the command. --matcher-typeistool_name,server_name,file_pathor*, and--matcher-valueis what to match. Without a matcher the hook runs for every tool call.--priorityorders hooks. Lower runs first.--configtakes JSON.timeoutis in seconds (default 5). With"blocking": true, a hook that fails or times out stops the tool call.
The command receives JSON on standard input with the event name, server name, tool name and arguments (and the result, for PostToolUse). To stop a tool call from a PreToolUse hook, print JSON such as {"blocked": true, "reason": "not allowed"}.
The same hooks can be managed through the core API (/api/hooks).
Troubleshooting
- Nothing is added to my sessions: check that the settings file exists (
.claude/settings.jsonin the project, or~/.claude/settings.json), and run./awe-hook-bin contextfrom the awe folder to see that it prints. - It worked, then stopped: the awe folder was probably moved or renamed. Run
./awe-core mem setup --globalagain from the new location. - Memories never match my prompt: awe may not be running. Run
./start-awe.sh. - My Claude Code settings changed:
mem setupsaved the file as it was before, beside it, assettings.json.before-awe-<date>-<time>. mem setupsays the file was left untouched: the settings file is not valid JSON (a comment or a trailing comma is enough). Fix it, then runmem setupagain.
Related
- codex-integration.md: Codex, Gemini CLI, aider and other coding agents
- mcp-host.md: attach an editor to awe’s tools and memory over MCP
- memory-follows-you.md: how memory reaches your other AI tools
- awe-memory.md: what awe remembers