Skip to Content
Prism Context Engine v1.2.0 - the CLI works locally with no account. See the Quick Start.
Hooks and IDE Setup

Hooks and IDE Setup

Prism checks every write your agent makes and sends corrections back to the agent. This page explains how the hook behaves and how to wire it per agent.

How the hook works

prism init installs a hook that runs this command:

npx @prism-engine/cli check --hook --format claude-code

The agent sends a tool event as JSON on stdin. prism check --hook finds the nearest .prism/rules.json (walking up from the target file), checks the content, and responds:

  • Clean — exit 0, the write proceeds.
  • Blocking violation — a correction message on stderr and exit 2. The agent reads the correction and fixes the file.

For Claude Code, prism init wires three hook events:

EventMatcherWhat happens
PreToolUseWrite|Edit|MultiEditThe proposed content is reconstructed and checked. A block exits 2 and halts the write before it lands
PostToolUseWrite|EditThe written file is re-checked from disk as a safety net
Stop—Files changed in the session are checked; a block exits 2 and the session cannot end until they are fixed

The hook command is identical for all three events; it dispatches on the event name in the payload.

Fails open by design

Enforcement never breaks your workflow. The hook exits 0 (no blocking) when:

  • No .prism/rules.json is found
  • The rules file is invalid JSON or fails validation
  • A file cannot be read
  • The engine errors out
  • The event payload is malformed or the tool shape is unknown

Hook errors are printed to stderr ([prism] check skipped: ...) and recorded in .prism/activity.log.

Kill switch

Disable all hook enforcement for a session:

export PRISM_DISABLE=1

The hook exits immediately without checking. Unset it to re-enable.

Per-agent wiring

Claude Code

Wired automatically by prism init into .claude/settings.json (PreToolUse + PostToolUse + Stop). Existing entries are merged, never overwritten. If the existing settings file is invalid JSON, it is left untouched and the hook snippets are printed for manual paste.

Cursor

prism init writes a --format cursor hook into .cursor/hooks.json as an afterFileEdit command (config verified against Cursor’s public docs; end-to-end firing inside Cursor is unverified). Cursor can also auto-map .claude/settings.json hooks when third-party skill mapping is enabled — do not run both, or you get duplicate corrections.

{ "version": 1, "hooks": { "afterFileEdit": [ { "command": "npx @prism-engine/cli check --hook --format cursor" } ] } }

Antigravity

prism init writes a --format antigravity PostToolUse handler into .agents/hooks.json (config verified against the Antigravity 2.0 docs; in-agent firing unverified):

{ "prism-pass": { "PostToolUse": [ { "hooks": [{ "type": "command", "command": "npx @prism-engine/cli check --hook --format antigravity" }] } ] } }

Claude Desktop

Claude Desktop has no hooks system. It gets MCP only (advisory rules through the assistant).

MCP setup for other editors

prism ide-setup auto-detects Cursor, Windsurf, VS Code, and Claude Desktop, asks before touching each, and writes the MCP server config:

{ "mcpServers": { "prism": { "command": "npx", "args": ["@prism-engine/cli", "serve"], "env": { "PRISM_TOKEN": "<your token>" } } } }

Config files it writes:

EditorFile
Cursor~/.cursor/mcp.json
Windsurf~/.windsurf/mcp.json
Claude Desktop~/Library/Application Support/Claude/claude_desktop_config.json
VS CodeUser settings.json (prism.token); install the Prism extension from the marketplace for full support

prism ide-setup asks for prism login first (or set PRISM_TOKEN). Restart your IDE after setup. Run prism doctor to verify.

Per-editor guides

Troubleshooting hooks

SymptomCause
Nothing enforces.prism/rules.json missing or invalid — the hook fails open. Run prism check <file> to see the error
Enforcement stoppedPRISM_DISABLE=1 is set
Duplicate correctionsBoth the Cursor hook and the mapped Claude hooks are active — remove one
check skipped: no .prism/rules.json foundThe rules file is not in the checked file’s directory tree

More in Troubleshooting.

Last updated on
Prism Context EnginePrism Context Engine

A rules layer for AI coding agents. Prism checks every write against your team's rules and sends corrections back to the agent.

Documentation

Product

Start a Project

Install the CLI and run `prism init`. No account needed.

GET_STARTED ↗
© 2026 Syntaxure Labs.DTI: VL1927082895984