Answer: A hook definition is a plain object, so a unit test calls `hook.events["turn.completed"]` directly with an event and a stub `HookContext`. Discovery skips `*.test.ts`, so the test can live next to the hook. Status: Confirmed Entry: tool/cursor/agents-and-automation/test-agent-sdk-hook Revision: 1 Digest: sha256:e4d355692e6eb714 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:08:53Z Last changed: 2026-11-13T03:08:53Z Last verified: 2026-11-20T12:33:50Z Next check: 2026-11-21T12:33:50Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of Unit test method | hook.events["turn.completed"] | [1] | 2026-11-20 Test file pattern skipped by discovery | *.test.ts | [1] | 2026-11-20 Validate command | agent-sdk validate --dir . | [1] | 2026-11-20 Info command | agent-sdk info --dir . --json | [1] | 2026-11-20 Run command | agent-sdk run --dir . --message "…" | [1] | 2026-11-20 Sources: [1] Anysphere. "cursor.com/docs/agent-sdk/reference/hooks.md". https://cursor.com/docs/agent-sdk/reference/hooks.md Role: primary. Accessed: 2026-11-20T12:33:50Z Quote: "a unit test calls `hook.events["turn.completed"]` directly with an event and a stub `HookContext`" (Supports: Unit test method) Quote: "Discovery skips `*.test.ts`, so the test can live next to the hook." (Supports: Test file pattern skipped by discovery) Quote: "`agent-sdk validate --dir .`" (Supports: Validate command) Quote: "`agent-sdk info --dir . --json`" (Supports: Info command) Quote: "`agent-sdk run --dir . --message "…"`" (Supports: Run command) Snapshot SHA-256: 21175b6d0a63b3713459cedd568d20c541ba9e5d98dcdc76f54c2a57951ea6a0 (captured 2026-11-13T03:08:52Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-13T03:08:53Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T12:33:50Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:33:50Z Last attempt: 2026-11-20T12:33:50Z Notes and limitations: Extracted automatically from a single official source (section "Test a hook"). Related: https://latestn.com/tool/cursor/agents-and-automation/test-github-agent-with-replay How do I test a Cursor GitHub agent using replay? https://latestn.com/tool/cursor/agents-and-automation/tool-event-matchers How do I use tool and event matchers in Cursor Evals? https://latestn.com/tool/cursor/agents-and-automation/track-follow-up-reached-agent How do I track which follow-up reached the agent in a Cursor Agent SDK session? https://latestn.com/tool/cursor/agents-and-automation/start-stop-channel How do I start and stop a channel in Cursor's Agent SDK? https://latestn.com/tool/cursor/agents-and-automation/stream-and-resume-run How do I stream a Cursor cloud agent run and resume the stream if it disconnects? https://latestn.com/tool/cursor/agents-and-automation/subagent-ignored-directories What directories are ignored inside a Cursor subagent? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-13T03:08:53Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/cursor/agents-and-automation/test-agent-sdk-hook/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/cursor/agents-and-automation/test-agent-sdk-hook POST: https://latestn.com/dispute/tool/cursor/agents-and-automation/test-agent-sdk-hook with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/cursor/agents-and-automation/test-agent-sdk-hook?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I test a Cursor Agent SDK hook? Revision 1, last verified 2026-11-20T12:33:50Z. https://latestn.com/tool/cursor/agents-and-automation/test-agent-sdk-hook (accessed 2026-11-21T10:01:35Z). @misc{LatestN_tool_cursor_agents_and_automation_test_agent_sdk_hook_r1, title = {How do I test a Cursor Agent SDK hook?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/cursor/agents-and-automation/test-agent-sdk-hook}}, note = {Revision 1; digest sha256:e4d355692e6eb714; last verified 2026-11-20T12:33:50Z; accessed 2026-11-21T10:01:35Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/cursor/agents-and-automation/test-agent-sdk-hook