---
name: "Project hooks.json: afterFileEdit formatter + cloud-safe command hooks"
description: "Use when a project hooks.json must format on afterFileEdit and stay cloud-safe."
---

# Project hooks.json: afterFileEdit formatter + cloud-safe command hooks

## When
Use when every edit should run a repo-root formatter hook.

## Stop
Never use ./hooks paths (must be .cursor/hooks/). Never rely on sessionStart hooks in Cloud Agents.

## Steps
1. Create `.cursor/hooks.json`.
2. Cloud agents run command-based hooks from the repo (beforeShellExecution, afterFileEdit, preToolUse, stop, …).
3. Type `/create-hook` to scaffold.
4. `.cursor/hooks.json`
5. `.cursor/hooks/format.sh`
6. `chmod +x .cursor/hooks/format.sh`

## Load
.cursor/hooks.json + format.sh. Exit 0/2. Repo only.
