Answer: Author `bot/hooks/.ts` with `defineHook` from `@grok/agent-sdk/hooks`. Any module under `bot/hooks/` is a hook named by its path without the extension, and the default export must be `defineHook(...)`. Status: Confirmed Entry: tool/cursor/agents-and-automation/author-agent-sdk-hook Revision: 1 Digest: sha256:b9dbb20f2a31ac2e (changes whenever the content changes) Timeline: Created: 2026-11-13T03:08:52Z Last changed: 2026-11-13T03:08:52Z Last verified: 2026-11-20T12:33:48Z Next check: 2026-11-21T12:33:48Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of hook file path | bot/hooks/.ts | [1] | 2026-11-20 import source | @grok/agent-sdk/hooks | [1] | 2026-11-20 hook directory | bot/hooks/ | [1] | 2026-11-20 skipped file patterns | *.test.ts | [1] | 2026-11-20 required default export | defineHook(...) | [1] | 2026-11-20 scaffolded hook file | bot/hooks/memory.ts | [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:48Z Quote: "Author `bot/hooks/.ts` with `defineHook` from `@grok/agent-sdk/hooks`." (Supports: hook file path) Quote: "import { defineHook } from "@grok/agent-sdk/hooks";" (Supports: import source) Quote: "Any module under `bot/hooks/` is a hook named by its path without the extension." (Supports: hook directory) Quote: "`*.test.ts` and `*.spec.ts` are skipped." (Supports: skipped file patterns) Quote: "The default export must be `defineHook(...)`" (Supports: required default export) Quote: "`agent-sdk init` scaffolds `bot/hooks/memory.ts`." (Supports: scaffolded hook file) 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:52Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T12:33:48Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:33:48Z Last attempt: 2026-11-20T12:33:48Z Notes and limitations: Extracted automatically from a single official source (section "Author a hook"). Related: https://latestn.com/tool/cursor/agents-and-automation/automation-tools What tools can a Cursor automation use? https://latestn.com/tool/cursor/agents-and-automation/automation-triggers What triggers can I use to start a Cursor automation? https://latestn.com/tool/cursor/agents-and-automation/autonomy-levels What autonomy levels can I choose for the Cursor agent in CI? https://latestn.com/tool/cursor/agents-and-automation/arm64-cloud-agents Does Cursor support arm64 for Cloud Agents, and how do I run agents on arm64 hardware? https://latestn.com/tool/cursor/agents-and-automation/ask-agent-self-improve How do I ask a Cursor agent to improve itself with one change? https://latestn.com/tool/cursor/agents-and-automation/assert-tool-calls How do I check that a Cursor agent called a specific tool and not another in an eval? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-13T03:08:52Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/cursor/agents-and-automation/author-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/author-agent-sdk-hook POST: https://latestn.com/dispute/tool/cursor/agents-and-automation/author-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/author-agent-sdk-hook?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I author a hook for the Cursor Agent SDK? Revision 1, last verified 2026-11-20T12:33:48Z. https://latestn.com/tool/cursor/agents-and-automation/author-agent-sdk-hook (accessed 2026-11-21T10:02:45Z). @misc{LatestN_tool_cursor_agents_and_automation_author_agent_sdk_hook_r1, title = {How do I author a hook for the Cursor Agent SDK?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/cursor/agents-and-automation/author-agent-sdk-hook}}, note = {Revision 1; digest sha256:b9dbb20f2a31ac2e; last verified 2026-11-20T12:33:48Z; accessed 2026-11-21T10:02:45Z} } 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/author-agent-sdk-hook