description: >- Initialize ai-dump: create work-logs, copy example configs, update .git/info/exclude, run hook tests. Supports project-level and system-level (~/.claude / ~/.cursor) installation.
One-time local setup for Claude/Cursor hooks in this repo.
Before doing anything else, ask the user:
"Do you want to install hooks at the project level (everything stays in this repo — only affects this project) or at the system level (hooks live in
~/.claude/and~/.cursor/and apply to every project on this machine)?"
Wait for their answer, then follow the matching option below.
Set up this repository for local Claude/Cursor hook usage.
Follow this exact flow:
-
First, inspect the repo and confirm these paths:
.claude/config.json.example.cursor/config.json.example.claude/hooks/__tests__.cursor/hooks/__tests__(optional).git/(optional, only if this is a git repo)
-
Do the setup work:
- Create
work-logs/in the repository root if it does not already exist. - If
.claude/config.jsondoes not exist and.claude/config.json.exampleexists, copy the example file to.claude/config.json. - If
.cursor/config.jsondoes not exist and.cursor/config.json.exampleexists, copy the example file to.cursor/config.json. - Never overwrite an existing
config.jsonwithout asking. - If this repo has a
.git/directory:- Ensure
.git/info/exists. - Ensure
.git/info/excludecontains these exact lines, adding only missing ones:work-logs/.claude/config.json.cursor/config.json
- Ensure
- Create
-
Run tests:
- If
.claude/hooks/__tests__exists, run:node --test .claude/hooks/__tests__ - If
.cursor/hooks/__tests__exists, also run:node --test .cursor/hooks/__tests__ - If Node is missing, stop and explain that Node is required.
- If
-
When finished, give a concise summary that includes:
- Whether config files were created
- Whether
work-logs/was created - Whether
.git/info/excludewas updated - Whether tests passed
-
End with these smoke-test instructions:
- Run one short task in Claude Code
- Run one short task in Cursor
- Trigger a permission request once
- Confirm logs appear under
work-logs/ - Confirm Claude notifications behave as expected
Rules for Option A:
- Do not use npm.
- Do not install dependencies.
- Do not use sudo.
- Do not touch files outside this repository, except
.git/info/excludeinside this repository. - Prefer exact, minimal edits.
- If a required example config file is missing, report it clearly.
- If this is not a git repo, skip exclude-file setup and say so.
Copies hooks to ~/.claude/hooks/ and ~/.cursor/hooks/ so they work across every project on this machine. Work-logs stay in each project's root (written by the hooks at runtime using the current working directory).
Follow this exact flow:
- Check that
nodeis on the PATH. If not, stop and tell the user Node.js is required. - Confirm these source files exist in the repo:
.claude/hooks/session-start.js,.claude/hooks/session-end.js,.claude/hooks/notify-stop.js,.claude/hooks/notify-failure.js,.claude/hooks/notify-permission.js. Report any that are missing and stop if any are absent.
- Create
~/.claude/hooks/if it does not exist. - Copy every
.jsfile from.claude/hooks/(excluding the__tests__subdirectory) to~/.claude/hooks/, overwriting existing files.
- If
~/.claude/settings.jsondoes not exist, create it with exactly this content:
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "node \"$HOME/.claude/hooks/session-start.js\""
}
]
}
],
"SessionEnd": [
{
"hooks": [
{
"type": "command",
"command": "node \"$HOME/.claude/hooks/session-end.js\"",
"timeout": 30
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "node \"$HOME/.claude/hooks/notify-stop.js\""
}
]
}
],
"StopFailure": [
{
"hooks": [
{
"type": "command",
"command": "node \"$HOME/.claude/hooks/notify-failure.js\""
}
]
}
],
"PermissionRequest": [
{
"hooks": [
{
"type": "command",
"command": "node \"$HOME/.claude/hooks/notify-permission.js\""
}
]
}
]
}
}- If
~/.claude/settings.jsonalready exists and already has ahookskey, do not overwrite it. Instead, read the file and check whether each of the five hook entries above is already present. Add only the missing entries under their respective event keys, preserving any existing content.
- If
.claude/config.json.exampleexists in the repo and~/.claude/config.jsondoes not exist, copy the example file to~/.claude/config.json. - If
~/.claude/config.jsonalready exists, leave it unchanged.
- Create
~/.cursor/hooks/if it does not exist. - Copy every
.jsfile from.cursor/hooks/to~/.cursor/hooks/, overwriting existing files.
- If
~/.cursor/hooks.jsondoes not exist, create it with exactly this content:
{
"version": 1,
"hooks": {
"sessionStart": [{ "command": "$HOME/.cursor/hooks/session-start.js" }],
"afterAgentResponse": [{ "command": "$HOME/.cursor/hooks/capture-summary.js" }],
"sessionEnd": [{ "command": "$HOME/.cursor/hooks/session-end.js", "timeout": 30 }]
}
}- If
~/.cursor/hooks.jsonalready exists and already has ahookskey, do not overwrite it. Read the file and add only the missing entries under their respective event keys, preserving any existing content. - If
.cursor/config.json.exampleexists and~/.cursor/config.jsondoes not, copy the example to~/.cursor/config.json.
- Create
work-logs/in this repository root if it does not already exist. - If this is a git repo, ensure
.git/info/excludecontainswork-logs/(adding it if missing). - Do NOT add
.claude/config.jsonor.cursor/config.jsonto the project exclude — those are now system-level files.
If .claude/settings.json exists in this repo and contains a hooks key (the project-level wiring), warn the user that leaving it in place will cause every hook to fire twice (once from the project settings, once from the system settings). Ask whether they want to remove the hooks key from .claude/settings.json or delete the file entirely. Act on their answer.
- If
.claude/hooks/__tests__exists, run:node --test .claude/hooks/__tests__ - Report pass or failure.
Give a concise summary that includes:
- Which hook files were copied to
~/.claude/hooks/and~/.cursor/hooks/ - Whether
~/.claude/settings.jsonwas created or merged - Whether
~/.claude/config.jsonwas created or skipped - Whether
~/.cursor/hooks.jsonwas created or merged - Whether
~/.cursor/config.jsonwas created or skipped - Whether
work-logs/was created - Whether tests passed
- Any duplicate-hooks warning issued
End with this note:
Both
~/.claude/settings.jsonand~/.cursor/hooks.jsonapply globally — no per-project hook wiring needed. For each new project, just creatework-logs/and you're done.
Rules for Option B:
- Do not use sudo.
- Do not overwrite
~/.claude/settings.jsonwholesale if it has existing content — merge carefully. - Do not overwrite
~/.claude/config.jsonif it already exists. - Only touch files inside this repository and inside
~/.claude/and~/.cursor/. - If Node is missing, stop immediately.