Repository navigation
fix(hooks): return Cursor context from session start and the nudge - #16
Merged
Merged
Conversation
Cursor reads additional_context, and afterFileEdit has no output. session-start now inspects CURSOR_PROJECT_DIR, and the skill nudge moves to postToolUse for Write and StrReplace. The formatter stays on afterFileEdit. Co-authored-by: Cursor <cursoragent@cursor.com>
Review follow-up for the Cursor hooks. - validate.py: the parity self-test fixture keeps "version": 1, so the parity check is tested again; each self-test case must raise its own error, with a can-fail control. New rules: a script that prints additional_context may not sit on Cursor afterFileEdit, and every postToolUse entry needs a matcher. The fixture now exercises both Cursor events and parity in both directions. - session-start.sh stays silent under Cursor without CURSOR_PROJECT_DIR instead of inspecting the plugin install. - format-on-save.sh uses the same Cursor test as skill-nudge.sh (CURSOR_PLUGIN_ROOT or cursor_version) before joining a relative path. - skill-nudge.sh says "this file" for a Cursor Write, whose content can be the whole file, and no longer prints an error when its marker cannot be written. - hooks-test.sh: both reported Cursor edit shapes (StrReplace with path, Write with file_path and content), the once-per-conversation key, the relative-path join in both edit hooks, a Cursor terminal running Claude Code, and isolation from ambient CURSOR_* variables. - Docs: Cursor 3.9.8 is the first build that passes postToolUse context to the model; the edit tool names and keys are reported, not documented; Cursor's third-party import can run the hooks twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cursor plugin hooks were not delivering the Go standards line or the skill nudge. This PR fixes the Cursor wiring, and makes the validator and the hook tests hold it in place.
Hooks
session-start.sh: under Cursor (CURSOR_PLUGIN_ROOTset) it changes intoCURSOR_PROJECT_DIRand returns{"additional_context": …}naming/go-codingand the/go-*skills. WithoutCURSOR_PROJECT_DIRit stays silent instead of reading the plugin install. Claude Code still gets the plainload go-codingline.skill-nudge.sh: moves from CursorafterFileEdit, which documents no output, topostToolUsewith matcherWrite|StrReplace, and returnsadditional_contexttelling Cursor to read/<skill>.CURSOR_PLUGIN_ROOTor acursor_versionkey in the payload, checked before the Claude Code branch, because Cursor payloads also carryhook_event_name.conversation_idis Cursor's once-per-session key.Writeis reported as "this file", since itscontentcan be the whole file.TMPDIRcannot be written.format-on-save.shstays onafterFileEdit. Both edit hooks readfile_pathorpath, and use the same Cursor test to join a relative path toCURSOR_PROJECT_DIR.hooks/cursor-hooks.jsoncarries"version": 1and per-hook timeouts.Validator (
scripts/validate.py)hooks/cursor-hooks.jsonneeds"version": 1and may not use${CLAUDE_PLUGIN_ROOT}.PostToolUsescript may sit on CursorafterFileEditorpostToolUse, but a script that printsadditional_contextmay not sit onafterFileEdit.postToolUseentry needs a matcher.--selftestpasses a case only when that check's own error appears, and a can-fail control proves it. One check's error can no longer hide another check's regression. The fixture exercises both Cursor events and parity in both directions.Docs
docs/install.mdstates three Cursor facts:postToolUsecontext to the model.tool_inputkeys are reported, not documented.AGENTS.md,README.md,docs/testing.md,docs/authoring.mdandCHANGELOG.mddescribe the wiring.What Cursor documents, and what it doesn't
Documented in Cursor hooks:
"version": 1, andadditional_contextonsessionStartandpostToolUse;CURSOR_PLUGIN_ROOT, andCURSOR_PROJECT_DIRis always set;afterFileEditpasses an absolutefile_pathand lists no output.Delivery to the model: Cursor staff said
postToolUsecontext reaches the model from 3.9.8 (forum).Not documented: the edit tool's
tool_nameandtool_input. Two reports disagree:StrReplacewithpath(awslabs/aidlc-workflows#2873);Writewith{file_path, content}(pbakaus/impeccable#1069).The matcher and both scripts cover both shapes, and
hooks-test.shtests both.Test plan
python3 scripts/validate.pyandpython3 scripts/validate.py --selftest(15 cases plus the can-fail control)./scripts/hooks-test.sh(55 cases)claude plugin validate .andpython3 scripts/validate.py --check-links(76 of 76)--selftestfail. The real tree rejects three bad wirings: the nudge onafterFileEdit, the nudge on both events, andpostToolUsewithout a matcher._test.gofile nudges/go-testing(note thetool_namethe Hooks output shows);.gofile is reformatted.Made with Cursor
🤖 Generated with Claude Code