Cursor · HooksPerfiles
Perfil Django
Black al editar, check y migraciones de Django al terminar.
por Prompt Studio
hooksafterFileEditbeforeShellExecutionstop
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 \"[.]py\" && black -q \"$f\" >/dev/null 2>&1; exit 0'"
}
],
"stop": [
{
"command": "bash -c 'jq -e \".status == \\\"completed\\\"\" >/dev/null || { echo \"{}\"; exit 0; }; if python manage.py check --fail-level WARNING >/tmp/cursor-hook-check.log 2>&1; then echo \"{}\"; else echo \"{\\\"followup_message\\\":\\\"El check de Django falla. Revisa /tmp/cursor-hook-check.log y corrígelo.\\\"}\"; fi'"
},
{
"command": "bash -c 'jq -e \".status == \\\"completed\\\"\" >/dev/null || { echo \"{}\"; exit 0; }; if python manage.py makemigrations --check --dry-run >/tmp/cursor-hook-check.log 2>&1; then echo \"{}\"; else echo \"{\\\"followup_message\\\":\\\"Faltan migraciones de Django. Revisa /tmp/cursor-hook-check.log y corrígelo.\\\"}\"; fi'"
}
],
"beforeShellExecution": [
{
"command": "bash -c 'jq -r .command | grep -Eiq -e \"manage[.]py (flush|reset_db)\" && echo \"{\\\"permission\\\":\\\"deny\\\",\\\"userMessage\\\":\\\"Bloqueado por hooks.json: no se permite vaciar la base de Django\\\",\\\"agentMessage\\\":\\\"Bloqueado por hooks.json: no se permite vaciar la base de Django\\\"}\" || echo \"{\\\"permission\\\":\\\"allow\\\"}\"'"
}
]
}
}
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.