hook-development
Hooks für Claude Code-Automatisierung erstellen
Également disponible depuis: anthropics,davila7
Hooks ermöglichen ereignisgesteuerte Automatisierung in Claude Code-Plugins. Verwenden Sie Hooks zum Validieren von Tool-Aufrufen, Durchsetzen von Abschlussstandards, Laden von Projektkontext und Integrieren externer Tools in Workflows. Das Skill umfasst sowohl prompt-basierte Hooks für intelligente Entscheidungen als auch Befehlshooks für deterministische Checks.
Télécharger le ZIP du skill
Importer dans Claude
Allez dans Paramètres → Capacités → Skills → Importer un skill
Activez et commencez à utiliser
Tester
Utilisation de "hook-development". Create a hook that validates before Claude writes any files
Résultat attendu:
- Hook configuration for PreToolUse event
- Matcher: Write|Edit tools
- Type: prompt-based hook
- Validation checks: system paths, credentials, path traversal
- Output: permissionDecision (allow/deny/ask), systemMessage
Utilisation de "hook-development". Set up a hook that stops the agent if tests did not run
Résultat attendu:
- Hook configuration for Stop event
- Matcher: wildcard (all operations)
- Type: prompt-based hook
- Checks: test execution status, build results
- Output: decision (approve/block), reason, systemMessage
Utilisation de "hook-development". Create a SessionStart hook that loads project environment
Résultat attendu:
- Hook configuration for SessionStart event
- Type: command hook with bash script
- Action: detect project type, set environment variables
- Uses $CLAUDE_ENV_FILE for variable persistence
- Output: continue (true), systemMessage
Audit de sécurité
SûrOfficial Anthropic skill containing documentation and example scripts for Claude Code hook development. All files are educational content demonstrating validation patterns and safe scripting practices. No execution of external commands, network operations, or file system modifications during skill operation. Example scripts use safe bash practices including set -euo pipefail, proper variable quoting, and input validation.
Facteurs de risque
⚡ Contient des scripts (3)
Score de qualité
Ce que vous pouvez construire
Sicherheitsvalidierungs-Hooks erstellen
Hooks erstellen, die gefährliche Dateischreibvorgänge blockieren, Bash-Befehle validieren und Geheimnisse erkennen, bevor Operationen ausgeführt werden.
Abschlussstandards durchsetzen
Stop-Hooks einrichten, die erfordern, dass Tests ausgeführt werden und Builds erfolgreich sind, bevor der Agent Aufgaben abschließen darf.
Kontextladen automatisieren
SessionStart-Hooks konfigurieren, um Projekttyp zu erkennen, Umgebungsvariablen zu setzen und Konfiguration automatisch zu laden.
Essayez ces prompts
File path: $TOOL_INPUT.file_path. Check: not in system directories, not credentials, no path traversal. Return 'approve' or 'deny'.
Command: $TOOL_INPUT.command. Look for destructive operations, privilege escalation, or unauthorized network access. Return 'approve', 'ask', or 'deny'.
Review the transcript. Were tests run after code changes? Did the build succeed? Are all user questions answered? Return 'approve' or 'block' with reason.
Read the transcript at $TRANSCRIPT_PATH. Evaluate: test coverage, build status, code quality, question completion. Return detailed assessment.
Bonnes pratiques
- Prompt-basierte Hooks für komplexe Logik verwenden, die von LLM-Reasoning profitiert.
- Angemessene Timeouts setzen: 30 Sekunden für Prompt-Hooks, 60 Sekunden für Befehlshooks.
- Alle Eingaben in Befehlshooks validieren, um Injektionsschwachstellen zu verhindern.
Éviter
- Pfade hartcodieren statt ${CLAUDE_PLUGIN_ROOT} für Portabilität zu verwenden.
- Sich auf Hook-Ausführungsreihenfolge verlassen, da Hooks parallel laufen.
- Langlaufende Hooks erstellen, die timeouten und den Workflow blockieren.
Foire aux questions
Welche Hook-Typen unterstützt Claude Code?
Was ist der Unterschied zwischen Prompt- und Befehlshooks?
Können Hooks Status zwischen Ereignissen teilen?
Sind Hooks sicher in der Verwendung?
Warum wird mein Hook nicht ausgeführt?
Wann sollte ich Befehlshooks Prompt-Hooks vorziehen?
Détails du développeur
Auteur
anthropicsLicence
MIT
Dépôt
https://github.com/anthropics/claude-code/tree/main/plugins/plugin-dev/skills/hook-developmentRéf
main
Structure de fichiers