Cursor · HooksPerfiles
Perfil iOS
SwiftFormat, swift test y protección de firmas.
por Prompt Studio
hooksafterFileEditbeforeReadFilebeforeShellExecutionstop
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 \"[.]swift\" && swiftformat \"$f\" >/dev/null 2>&1; exit 0'"
}
],
"stop": [
{
"command": "bash -c 'jq -e \".status == \\\"completed\\\"\" >/dev/null || { echo \"{}\"; exit 0; }; if swift test >/tmp/cursor-hook-check.log 2>&1; then echo \"{}\"; else echo \"{\\\"followup_message\\\":\\\"Fallan tests de Swift. Revisa /tmp/cursor-hook-check.log y corrígelo.\\\"}\"; fi'"
}
],
"beforeReadFile": [
{
"command": "bash -c 'jq -r .file_path | grep -Eq -e \"[.](mobileprovision|p8|cer)$\" && echo \"{\\\"permission\\\":\\\"deny\\\",\\\"userMessage\\\":\\\"Archivo protegido: el agente no puede leer firmas de iOS\\\",\\\"agentMessage\\\":\\\"Archivo protegido: el agente no puede leer firmas de iOS\\\"}\" || echo \"{\\\"permission\\\":\\\"allow\\\"}\"'"
}
],
"beforeShellExecution": [
{
"command": "bash -c 'jq -r .command | grep -Eiq -e \"xcodebuild [^;&|]*(archive|-exportArchive)\" && echo \"{\\\"permission\\\":\\\"ask\\\",\\\"userMessage\\\":\\\"Confirma antes de archivar apps de iOS\\\",\\\"agentMessage\\\":\\\"Confirma antes de archivar apps de iOS\\\"}\" || 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.