bun run handles script execution without needing chmod. ### Building Your First TypeScript Hook The workflow is straightforward. You'll create a dedicated directory for your hooks, initialize a Bun project, and write a TypeScript script that demonstrates controlling the AI. 1. Initialize a Bun Project: Create a .cursor/hooks directory and initialize a new Bun project within it. This gives you a dedicated environment for your hook logic with TypeScript support out of the box. ~~~bash mkdir .cursor/hooks cd .cursor/hooks bun init ~~~ 2. Configure hooks.json: Update your .cursor/hooks.json to execute the TypeScript script using bun run. This command points to the entry file generated by Bun. ~~~json { "version": 1, "hooks": { "beforeSubmitPrompt": [ { "command": "bun run hooks/index.ts" } ] } } ~~~ 3. Handle Hook Output: Each hook type expects a specific JSON response structure. For beforeSubmitPrompt, you return an object with a continue property. Setting it to false blocks the AI from processing the prompt—a powerful demonstration of controlling the AI's behavior. ~~~typescript const output = { continue: false, }; console.log(JSON.stringify(output, null, 2)); ~~~ With this foundation in place, you can create sophisticated automations that integrate seamlessly with Cursor, all while working in a familiar TypeScript environment with full access to the Node.js ecosystem. ### Prompts Used ~~~markdown Do anything ~~~ ~~~markdown Please say hello ~~~https://egghead.io/lessons/level-up-cursor-hooks-with-type-script-and-bun~sqo8a