Simplify Cursor Hooks Configuration with JSON Schema

Editing raw JSON for your hooks configuration is tedious and error-prone. You have to remember exact hook names, required properties, and valid values—all without any guidance from your editor. There's a simple solution that transforms this experience completely.

This lesson shows you how to add a single configuration block to your user settings that enables IntelliSense for all your hooks.json files. You'll get autocomplete suggestions, inline documentation, validation warnings, and hover hints—making hook configuration fast, reliable, and pleasant.

The Solution: json.schemas

By adding the following snippet to your user settings.json, you instruct Cursor (and VS Code) to download and apply a schema to any file named hooks.json within a .cursor directory.

This configuration enables several key features:

  • Autocomplete: Get suggestions for valid hook names like beforeReadFile or beforeSubmitPrompt.
  • Validation: See warnings for missing required properties (like command) or incorrect data types.
  • IntelliSense: Hover over properties to see descriptions and expected values.

This small setup transforms hook configuration from tedious and error-prone to fast and reliable across all your projects.

How it Works

  1. Open User Settings (JSON): Use the command palette to open your global settings.json file.
  2. Add the Schema Configuration: Paste the provided JSON block into your settings. This enables schema downloading and creates the file association.
  3. Start Using IntelliSense: Open any .cursor/hooks.json file and start typing—autocomplete suggestions will appear immediately.

The schema used here is based on Cursor's documentation and hosted on unpkg. If Cursor releases an official schema in the future, you can simply update the URL.

{ "json.schemaDownload.enable": true, "json.schemas": [ { "fileMatch": [ ".cursor/hooks.json" ], "url": "https://unpkg.com/cursor-hooks/schema/hooks.schema.json" } ] }
Advanced Cursor Hooks
Lesson 2 of 8

Advanced Cursor Hooks

Learn to build type-safe Cursor hooks with TypeScript & Bun. Automate AI-assisted coding, enforce standards, and streamline your development workflow.

Share with a coworker

Transcript

[00:00] Now a major convenience to set up is a schema file for your Hooks.json so you can get autocomplete, IntelliSense, and warnings and such as you're configuring your hooks. Now we can do this by opening our user.json settings. So this will apply to every project. And then if you just scroll down to the bottom I'll give you this code which you can copy and paste where the keys are to enable schema download to true and then to file match any .cursor.hooks.json file to this schema. Now this schema when we open it is one I put together by referencing the cursor docs around hooks since they haven't published an official one yet.

[00:38] And I assume once they publish an official one you'll just want to delete this block here. But for now you can see how the schema marks version and hooks as required and lists all of the available hooks that can be called. And the hooks arrays all have items with hook definitions which have commands on them. So in our JSON file we'll be able to add a hook like before submit prompt. We'll be able to get auto-complete.

[01:04] You'll see missing property command because these objects require a command, and it just makes it infinitely easier to configure these files however you need.