Documentation: - Add commands/README.md documenting all slash commands - Add skills/README.md documenting skill structure and patterns - Add .claude-plugin/marketplace.json for local dev testing Hooks: - Add PreCompact hook to remind about context preservation - Update hooks/README.md with new hook GCal improvements: - Add scripts/next_event.py for single event lookup - Update SKILL.md with simplified format and allowed-tools: Read 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
75 lines
1.6 KiB
Markdown
75 lines
1.6 KiB
Markdown
# Hooks
|
|
|
|
Event handlers that run automatically during Claude Code sessions.
|
|
|
|
## Active Hooks
|
|
|
|
| Event | Script | Purpose |
|
|
|-------|--------|---------|
|
|
| `SessionStart` | `scripts/session-start.sh` | Load context, check for pending items |
|
|
| `PreCompact` | `scripts/pre-compact.sh` | Remind to preserve context before compaction |
|
|
|
|
## Hook Events
|
|
|
|
| Event | When It Fires |
|
|
|-------|---------------|
|
|
| `SessionStart` | When Claude Code session begins |
|
|
| `SessionEnd` | When session ends |
|
|
| `PreToolUse` | Before a tool is used |
|
|
| `PostToolUse` | After a tool is used |
|
|
| `UserPromptSubmit` | When user submits a prompt |
|
|
| `PreCompact` | Before context compaction |
|
|
| `Notification` | When notification is sent |
|
|
|
|
## Configuration
|
|
|
|
Hooks are defined in `hooks.json`:
|
|
|
|
```json
|
|
{
|
|
"hooks": {
|
|
"SessionStart": [
|
|
{
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "~/.claude/hooks/scripts/session-start.sh"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
```
|
|
|
|
## Adding Hooks
|
|
|
|
1. Create script in `scripts/`
|
|
2. Make executable: `chmod +x scripts/your-hook.sh`
|
|
3. Add to `hooks.json`
|
|
4. Restart Claude Code
|
|
|
|
## Script Output
|
|
|
|
- Stdout is injected into session as context
|
|
- Use format: `HookName:Callback hook success: Success`
|
|
- Additional context: `HookName hook additional context: <message>`
|
|
|
|
## Matchers (for Tool Hooks)
|
|
|
|
```json
|
|
{
|
|
"matcher": "Write|Edit",
|
|
"hooks": [...]
|
|
}
|
|
```
|
|
|
|
Matches tool names with regex pattern.
|
|
|
|
## Tips
|
|
|
|
- Keep hooks fast (<1s) to avoid delays
|
|
- Use `set -euo pipefail` for safety
|
|
- Output useful context, not noise
|
|
- Test hooks manually before adding
|