Cursor · HooksPerfiles
Calidad frontend
Prettier y ESLint al editar, tipos y tests al terminar.
por Prompt Studio
hooksafterFileEditstop
Licencia: MITVer original
Contenido
Dónde va: .cursor/hooks.json
{
"version": 1,
"hooks": {
"afterFileEdit": [
{
"command": "bash -c 'f=$(jq -r .file_path); echo \"$f\" | grep -Eq -e \"[.](js|jsx|ts|tsx)\" && npx eslint --fix \"$f\" >/dev/null 2>&1; exit 0'"
},
{
"command": "bash -c 'f=$(jq -r .file_path); echo \"$f\" | grep -Eq -e \"[.](css|scss|less)\" && npx prettier --write \"$f\" >/dev/null 2>&1; exit 0'"
}
],
"stop": [
{
"command": "bash -c 'jq -e \".status == \\\"completed\\\"\" >/dev/null || { echo \"{}\"; exit 0; }; if npx tsc --noEmit >/tmp/cursor-hook-check.log 2>&1; then echo \"{}\"; else echo \"{\\\"followup_message\\\":\\\"Hay errores de TypeScript. Revisa /tmp/cursor-hook-check.log y corrígelo.\\\"}\"; fi'"
},
{
"command": "bash -c 'jq -e \".status == \\\"completed\\\"\" >/dev/null || { echo \"{}\"; exit 0; }; if npx vitest run >/tmp/cursor-hook-check.log 2>&1; then echo \"{}\"; else echo \"{\\\"followup_message\\\":\\\"Fallan tests de Vitest. Revisa /tmp/cursor-hook-check.log y corrígelo.\\\"}\"; fi'"
}
]
}
}
Más en Hooks
Bloquear comandos peligrosos
Detiene rm -rf, git push --force y similares antes de ejecutarse.
Proteger .env
Impide que el agente lea archivos con secretos.
Formatear al editar
Ejecuta Prettier en cada archivo que edita el agente.
Lint al terminar
Corre el linter cuando el agente termina su turno.
Aviso al terminar
Notificación de escritorio cuando el agente acaba (macOS).
Registro de comandos
Guarda cada comando del agente en .cursor/audit.log.