Cursor · HooksFormato
Format with google-java-format
Formats Java every time the agent edits.
by Prompt Studio
hooksafterFileEdit
License: MITView original
Contents
Where it goes: .cursor/hooks.json
{
"version": 1,
"hooks": {
"afterFileEdit": [
{
"command": "bash -c 'f=$(jq -r .file_path); echo \"$f\" | grep -Eq -e \"[.]java\" && google-java-format -i \"$f\" >/dev/null 2>&1; exit 0'"
}
]
}
}
More in Hooks
Block dangerous commands
Stops rm -rf, git push --force and similar before they run.
Protect .env
Prevents the agent from reading files with secrets.
Format on edit
Runs Prettier on every file the agent edits.
Lint on stop
Runs the linter when the agent finishes its turn.
Notify when done
Desktop notification when the agent finishes (macOS).
Command log
Saves every agent command to .cursor/audit.log.