Add Cursor hooks examples - #40
Conversation
- Add sample hook configuration for prompt, shell, file edit, and stop events - Include audit logging, model/repo blocking, sensitive prompt guard, and skill follow-up hooks - Document setup, customization, dependencies, and security-tool extension points
- Link the new hooks examples from the top-level README - Summarize the audit, sensitive prompt guard, and skill follow-up examples - Preserve existing SDK documentation links
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 4 potential issues.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
Reviewed by Cursor Bugbot for commit d667fb3. Configure here.
| local model="$1" | ||
| local repo="$2" | ||
|
|
||
| printf '{"continue":false,"user_message":"%s model is not allowed to be used on %s"}\n' "$model" "$repo" |
There was a problem hiding this comment.
Deny response breaks JSON escaping
Medium Severity · Logic Bug
The deny function uses printf with unescaped %s placeholders to construct the user_message in its JSON output. If blocked model or repo names contain characters like " or %, or newlines, the resulting JSON will be invalid, breaking the expected response contract.
Reviewed by Cursor Bugbot for commit d667fb3. Configure here.
| function changedFiles() { | ||
| const tracked = gitLines(["diff", "--name-only", "HEAD"]); | ||
| const untracked = gitLines(["ls-files", "--others", "--exclude-standard"]); | ||
| return [...new Set([...tracked, ...untracked])].sort(); |
There was a problem hiding this comment.
Stop hook uses unrelated git diff
Medium Severity · Logic Bug
changedFiles uses git diff --name-only HEAD plus all untracked files, so skill follow-ups can fire for pre-existing local edits the agent never touched, not just files changed during the run.
Reviewed by Cursor Bugbot for commit d667fb3. Configure here.
| printf '%s' "$payload" \ | ||
| | tr '\n' ' ' \ | ||
| | sed -nE 's/.*"model"[[:space:]]*:[[:space:]]*"([^"]*)".*/\1/p' | ||
| } |
There was a problem hiding this comment.
Regex model parse is spoofable
Medium Severity · Logic Bug
model_from_payload pulls model with sed over the entire stdin blob instead of parsing JSON, so a model substring inside prompt (or other fields) can be mistaken for the real selection and drive allow/deny incorrectly.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d667fb3. Configure here.
- Run blocking prompt guards before audit logging - Keep sensitive prompt previews out of logs when prompts are blocked - Preserve existing hook matchers, timeouts, and fail-closed settings


💻 Change Type
🔀 Description of Change
Add a guided Cursor Hooks examples folder with sample project hook configuration and scripts for audit logging, sensitive prompt guarding, model/repo prompt blocking, and skill update follow-ups. The top-level README now links to the hooks examples so they are discoverable from the cookbook index.
📝 Additional Information
Validation run:
jq empty hooks/.cursor/hooks.jsonbash -n hooks/.cursor/hooks/audit-log.sh hooks/.cursor/hooks/block-models-by-repo-origin.sh hooks/.cursor/hooks/sensitive-prompt-guard.shnode --check hooks/.cursor/hooks/update-skills-on-stop.mjssensitive-prompt-guard.shallow/block payload checksNo root build or unit test suite was present for these documentation/example changes.
Note
Low Risk
Documentation and sample hook scripts only; no application or production runtime changes.
Overview
Adds a Cursor Hooks cookbook section and a new
hooks/example you can copy into projects: sample.cursor/hooks.jsonplus scripts for audit logging, blocking sensitive prompts, optional model/repo prompt blocking, and astophook that nudges skill doc updates when mapped paths change.The root README now links to
hooks/so the examples sit alongside Cloud Agents and SDK entries.hooks/README.mddocuments layout, how to merge config, and customization (blocklists, patterns,SKILL_MAPPINGS, log env vars).Reviewed by Cursor Bugbot for commit 36fde23. Bugbot is set up for automated code reviews on this repo. Configure here.