@yeongjaeyou/claude-code-config 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/code-review-handler.md +203 -0
- package/.claude/agents/issue-resolver.md +123 -0
- package/.claude/agents/python-pro.md +7 -2
- package/.claude/agents/web-researcher.md +5 -1
- package/.claude/commands/ask-deepwiki.md +46 -11
- package/.claude/commands/gh/auto-review-loop.md +201 -0
- package/.claude/commands/gh/create-issue-label.md +4 -0
- package/.claude/commands/gh/decompose-issue.md +24 -2
- package/.claude/commands/gh/post-merge.md +52 -10
- package/.claude/commands/gh/resolve-and-review.md +69 -0
- package/.claude/commands/gh/resolve-issue.md +3 -0
- package/.claude/commands/tm/convert-prd.md +4 -0
- package/.claude/commands/tm/post-merge.md +7 -1
- package/.claude/commands/tm/resolve-issue.md +4 -0
- package/.claude/commands/tm/sync-to-github.md +4 -0
- package/.claude/settings.json +15 -0
- package/.claude/skills/claude-md-generator/SKILL.md +130 -0
- package/.claude/skills/claude-md-generator/references/examples.md +261 -0
- package/.claude/skills/claude-md-generator/references/templates.md +156 -0
- package/.claude/skills/hook-creator/SKILL.md +88 -0
- package/.claude/skills/hook-creator/references/examples.md +339 -0
- package/.claude/skills/hook-creator/references/hook-events.md +193 -0
- package/.claude/skills/skill-creator/SKILL.md +160 -13
- package/.claude/skills/skill-creator/references/output-patterns.md +82 -0
- package/.claude/skills/skill-creator/references/workflows.md +28 -0
- package/.claude/skills/skill-creator/scripts/package_skill.py +10 -10
- package/.claude/skills/skill-creator/scripts/quick_validate.py +45 -15
- package/.claude/skills/slash-command-creator/SKILL.md +108 -0
- package/.claude/skills/slash-command-creator/references/examples.md +161 -0
- package/.claude/skills/slash-command-creator/references/frontmatter.md +74 -0
- package/.claude/skills/slash-command-creator/scripts/init_command.py +221 -0
- package/.claude/skills/subagent-creator/SKILL.md +127 -0
- package/.claude/skills/subagent-creator/assets/subagent-template.md +31 -0
- package/.claude/skills/subagent-creator/references/available-tools.md +63 -0
- package/.claude/skills/subagent-creator/references/examples.md +213 -0
- package/.claude/skills/youtube-collector/README.md +107 -0
- package/.claude/skills/youtube-collector/SKILL.md +158 -0
- package/.claude/skills/youtube-collector/references/data-schema.md +110 -0
- package/.claude/skills/youtube-collector/scripts/collect_videos.py +304 -0
- package/.claude/skills/youtube-collector/scripts/fetch_transcript.py +138 -0
- package/.claude/skills/youtube-collector/scripts/fetch_videos.py +229 -0
- package/.claude/skills/youtube-collector/scripts/register_channel.py +247 -0
- package/.claude/skills/youtube-collector/scripts/setup_api_key.py +151 -0
- package/package.json +1 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Templates
|
|
2
|
+
|
|
3
|
+
## Root CLAUDE.md Template
|
|
4
|
+
|
|
5
|
+
```markdown
|
|
6
|
+
# CLAUDE.md
|
|
7
|
+
|
|
8
|
+
## Project Context
|
|
9
|
+
|
|
10
|
+
[1-2 line business goal + tech stack summary]
|
|
11
|
+
|
|
12
|
+
## Operational Commands
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# [Package manager commands]
|
|
16
|
+
[install command]
|
|
17
|
+
[run command]
|
|
18
|
+
[test command]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Golden Rules
|
|
22
|
+
|
|
23
|
+
### Immutable
|
|
24
|
+
|
|
25
|
+
- [Non-negotiable security/architecture constraints]
|
|
26
|
+
- [Critical patterns that must never be violated]
|
|
27
|
+
|
|
28
|
+
### Do's
|
|
29
|
+
|
|
30
|
+
- [Clear positive actions]
|
|
31
|
+
- [Required patterns]
|
|
32
|
+
|
|
33
|
+
### Don'ts
|
|
34
|
+
|
|
35
|
+
- [Clear prohibitions]
|
|
36
|
+
- [Anti-patterns to avoid]
|
|
37
|
+
|
|
38
|
+
## Modular Rules
|
|
39
|
+
|
|
40
|
+
See @.claude/rules/[module].md for [description]
|
|
41
|
+
See @.claude/rules/[module].md for [description]
|
|
42
|
+
|
|
43
|
+
## [Project-Specific Sections]
|
|
44
|
+
|
|
45
|
+
[Data locations, submission tracking, deployment info, etc.]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Rules File Template (General)
|
|
49
|
+
|
|
50
|
+
```markdown
|
|
51
|
+
---
|
|
52
|
+
paths: [glob pattern, optional]
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
# [Module] Rules
|
|
56
|
+
|
|
57
|
+
## Role
|
|
58
|
+
|
|
59
|
+
[What this module does, 1-2 lines]
|
|
60
|
+
|
|
61
|
+
## Dependencies
|
|
62
|
+
|
|
63
|
+
- [Key external libraries]
|
|
64
|
+
- [Internal module dependencies]
|
|
65
|
+
|
|
66
|
+
## Patterns
|
|
67
|
+
|
|
68
|
+
- [Common code patterns]
|
|
69
|
+
- [File naming conventions]
|
|
70
|
+
- [Directory structure expectations]
|
|
71
|
+
|
|
72
|
+
## Do's
|
|
73
|
+
|
|
74
|
+
- [Module-specific positive actions]
|
|
75
|
+
- [Required patterns for this area]
|
|
76
|
+
|
|
77
|
+
### Don'ts
|
|
78
|
+
|
|
79
|
+
- [Module-specific prohibitions]
|
|
80
|
+
- [Common mistakes to avoid]
|
|
81
|
+
|
|
82
|
+
## Testing
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
[Module-specific test commands]
|
|
86
|
+
```
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Rules File Template (Path-Specific)
|
|
90
|
+
|
|
91
|
+
```markdown
|
|
92
|
+
---
|
|
93
|
+
paths: src/api/**/*.ts, src/api/**/*.tsx
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
# API Development Rules
|
|
97
|
+
|
|
98
|
+
## Role
|
|
99
|
+
|
|
100
|
+
Handle all backend API routes and server-side logic.
|
|
101
|
+
|
|
102
|
+
## Patterns
|
|
103
|
+
|
|
104
|
+
- All endpoints follow REST conventions
|
|
105
|
+
- Use standard error response format
|
|
106
|
+
- Include input validation on all routes
|
|
107
|
+
|
|
108
|
+
## Do's
|
|
109
|
+
|
|
110
|
+
- Validate all incoming data
|
|
111
|
+
- Return consistent error structures
|
|
112
|
+
- Log meaningful error context
|
|
113
|
+
|
|
114
|
+
## Don'ts
|
|
115
|
+
|
|
116
|
+
- Expose internal error details to clients
|
|
117
|
+
- Skip authentication checks
|
|
118
|
+
- Use raw SQL without parameterization
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Restructured Root Template
|
|
122
|
+
|
|
123
|
+
When converting a large CLAUDE.md to modular structure:
|
|
124
|
+
|
|
125
|
+
```markdown
|
|
126
|
+
# CLAUDE.md
|
|
127
|
+
|
|
128
|
+
## Project Context
|
|
129
|
+
|
|
130
|
+
[Keep existing overview, condensed to 2-3 lines]
|
|
131
|
+
|
|
132
|
+
## Operational Commands
|
|
133
|
+
|
|
134
|
+
[Keep essential commands only]
|
|
135
|
+
|
|
136
|
+
## Golden Rules
|
|
137
|
+
|
|
138
|
+
### Immutable
|
|
139
|
+
|
|
140
|
+
[Extract from existing, keep only critical rules]
|
|
141
|
+
|
|
142
|
+
### Do's / Don'ts
|
|
143
|
+
|
|
144
|
+
[Keep top 5-7 most important rules here]
|
|
145
|
+
|
|
146
|
+
## Modular Rules
|
|
147
|
+
|
|
148
|
+
Architecture and core pipeline: @.claude/rules/architecture.md
|
|
149
|
+
Data processing and caching: @.claude/rules/data.md
|
|
150
|
+
Model and inference: @.claude/rules/inference.md
|
|
151
|
+
[Add more as needed based on existing sections]
|
|
152
|
+
|
|
153
|
+
## [Keep minimal project-specific sections]
|
|
154
|
+
|
|
155
|
+
[Submission tracking, data locations - things that change rarely]
|
|
156
|
+
```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hook-creator
|
|
3
|
+
description: Create and configure Claude Code hooks for customizing agent behavior. Use when the user wants to (1) create a new hook, (2) configure automatic formatting, logging, or notifications, (3) add file protection or custom permissions, (4) set up pre/post tool execution actions, or (5) asks about hook events like PreToolUse, PostToolUse, Notification, etc.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Hook Creator
|
|
7
|
+
|
|
8
|
+
Create Claude Code hooks that execute shell commands at specific lifecycle events.
|
|
9
|
+
|
|
10
|
+
## Hook Creation Workflow
|
|
11
|
+
|
|
12
|
+
1. **Identify the use case** - Determine what the hook should accomplish
|
|
13
|
+
2. **Select the appropriate event** - Choose from available hook events (see references/hook-events.md)
|
|
14
|
+
3. **Design the hook command** - Write shell command that processes JSON input from stdin
|
|
15
|
+
4. **Configure the matcher** - Set tool/event filter (use `*` for all, or specific tool names like `Bash`, `Edit|Write`)
|
|
16
|
+
5. **Choose storage location** - User settings (`~/.claude/settings.json`) or project (`.claude/settings.json`)
|
|
17
|
+
6. **Test the hook** - Verify behavior with a simple test case
|
|
18
|
+
|
|
19
|
+
## Hook Configuration Structure
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"hooks": {
|
|
24
|
+
"<EventName>": [
|
|
25
|
+
{
|
|
26
|
+
"matcher": "<ToolPattern>",
|
|
27
|
+
"hooks": [
|
|
28
|
+
{
|
|
29
|
+
"type": "command",
|
|
30
|
+
"command": "<shell-command>"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Common Patterns
|
|
40
|
+
|
|
41
|
+
### Reading Input Data
|
|
42
|
+
|
|
43
|
+
Hooks receive JSON via stdin. Use `jq` to extract fields:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Extract tool input field
|
|
47
|
+
jq -r '.tool_input.file_path'
|
|
48
|
+
|
|
49
|
+
# Extract with fallback
|
|
50
|
+
jq -r '.tool_input.description // "No description"'
|
|
51
|
+
|
|
52
|
+
# Conditional processing
|
|
53
|
+
jq -r 'if .tool_input.file_path then .tool_input.file_path else empty end'
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Exit Codes for PreToolUse
|
|
57
|
+
|
|
58
|
+
- `0` - Allow the tool to proceed
|
|
59
|
+
- `2` - Block the tool and provide feedback to Claude
|
|
60
|
+
|
|
61
|
+
### Matcher Patterns
|
|
62
|
+
|
|
63
|
+
- `*` - Match all tools
|
|
64
|
+
- `Bash` - Match only Bash tool
|
|
65
|
+
- `Edit|Write` - Match Edit or Write tools
|
|
66
|
+
- `Read` - Match Read tool
|
|
67
|
+
|
|
68
|
+
## Quick Examples
|
|
69
|
+
|
|
70
|
+
**Log all bash commands:**
|
|
71
|
+
```bash
|
|
72
|
+
jq -r '"\(.tool_input.command)"' >> ~/.claude/bash-log.txt
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Auto-format TypeScript after edit:**
|
|
76
|
+
```bash
|
|
77
|
+
jq -r '.tool_input.file_path' | { read f; [[ "$f" == *.ts ]] && npx prettier --write "$f"; }
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Block edits to .env files:**
|
|
81
|
+
```bash
|
|
82
|
+
python3 -c "import json,sys; p=json.load(sys.stdin).get('tool_input',{}).get('file_path',''); sys.exit(2 if '.env' in p else 0)"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Resources
|
|
86
|
+
|
|
87
|
+
- **Hook Events Reference**: See `references/hook-events.md` for detailed event documentation with input/output schemas
|
|
88
|
+
- **Example Configurations**: See `references/examples.md` for complete, tested hook configurations
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# Hook Examples
|
|
2
|
+
|
|
3
|
+
Complete, tested hook configurations for common use cases.
|
|
4
|
+
|
|
5
|
+
## Logging Hooks
|
|
6
|
+
|
|
7
|
+
### Log All Bash Commands
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"hooks": {
|
|
12
|
+
"PreToolUse": [
|
|
13
|
+
{
|
|
14
|
+
"matcher": "Bash",
|
|
15
|
+
"hooks": [
|
|
16
|
+
{
|
|
17
|
+
"type": "command",
|
|
18
|
+
"command": "jq -r '\"\\(.tool_input.command) - \\(.tool_input.description // \"No description\")\"' >> ~/.claude/bash-command-log.txt"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Log All File Edits
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"hooks": {
|
|
32
|
+
"PostToolUse": [
|
|
33
|
+
{
|
|
34
|
+
"matcher": "Edit|Write",
|
|
35
|
+
"hooks": [
|
|
36
|
+
{
|
|
37
|
+
"type": "command",
|
|
38
|
+
"command": "jq -r '\"[\\(now | strftime(\"%Y-%m-%d %H:%M:%S\"))] \\(.tool_name): \\(.tool_input.file_path)\"' >> ~/.claude/edit-log.txt"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Auto-Formatting Hooks
|
|
48
|
+
|
|
49
|
+
### Format TypeScript Files
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"hooks": {
|
|
54
|
+
"PostToolUse": [
|
|
55
|
+
{
|
|
56
|
+
"matcher": "Edit|Write",
|
|
57
|
+
"hooks": [
|
|
58
|
+
{
|
|
59
|
+
"type": "command",
|
|
60
|
+
"command": "jq -r '.tool_input.file_path' | { read file_path; if echo \"$file_path\" | grep -q '\\.tsx\\?$'; then npx prettier --write \"$file_path\" 2>/dev/null; fi; }"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Format Python Files with Black
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"hooks": {
|
|
74
|
+
"PostToolUse": [
|
|
75
|
+
{
|
|
76
|
+
"matcher": "Edit|Write",
|
|
77
|
+
"hooks": [
|
|
78
|
+
{
|
|
79
|
+
"type": "command",
|
|
80
|
+
"command": "jq -r '.tool_input.file_path' | { read f; [[ \"$f\" == *.py ]] && black \"$f\" 2>/dev/null; }"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Format Go Files
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"hooks": {
|
|
94
|
+
"PostToolUse": [
|
|
95
|
+
{
|
|
96
|
+
"matcher": "Edit|Write",
|
|
97
|
+
"hooks": [
|
|
98
|
+
{
|
|
99
|
+
"type": "command",
|
|
100
|
+
"command": "jq -r '.tool_input.file_path' | { read f; [[ \"$f\" == *.go ]] && gofmt -w \"$f\"; }"
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## File Protection Hooks
|
|
110
|
+
|
|
111
|
+
### Block Edits to Sensitive Files
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"hooks": {
|
|
116
|
+
"PreToolUse": [
|
|
117
|
+
{
|
|
118
|
+
"matcher": "Edit|Write",
|
|
119
|
+
"hooks": [
|
|
120
|
+
{
|
|
121
|
+
"type": "command",
|
|
122
|
+
"command": "python3 -c \"import json, sys; data=json.load(sys.stdin); path=data.get('tool_input',{}).get('file_path',''); blocked=['.env', 'package-lock.json', '.git/', 'secrets']; sys.exit(2 if any(p in path for p in blocked) else 0)\""
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Block Modifications to Production Directory
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"hooks": {
|
|
136
|
+
"PreToolUse": [
|
|
137
|
+
{
|
|
138
|
+
"matcher": "Edit|Write|Bash",
|
|
139
|
+
"hooks": [
|
|
140
|
+
{
|
|
141
|
+
"type": "command",
|
|
142
|
+
"command": "jq -r '.tool_input | .file_path // .command // \"\"' | grep -q '/prod/' && echo 'BLOCKED: Cannot modify production files' && exit 2 || exit 0"
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Notification Hooks
|
|
152
|
+
|
|
153
|
+
### macOS Desktop Notification
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"hooks": {
|
|
158
|
+
"Notification": [
|
|
159
|
+
{
|
|
160
|
+
"matcher": "",
|
|
161
|
+
"hooks": [
|
|
162
|
+
{
|
|
163
|
+
"type": "command",
|
|
164
|
+
"command": "jq -r '.message' | xargs -I{} osascript -e 'display notification \"{}\" with title \"Claude Code\"'"
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Linux Desktop Notification
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"hooks": {
|
|
178
|
+
"Notification": [
|
|
179
|
+
{
|
|
180
|
+
"matcher": "",
|
|
181
|
+
"hooks": [
|
|
182
|
+
{
|
|
183
|
+
"type": "command",
|
|
184
|
+
"command": "jq -r '.message' | xargs -I{} notify-send 'Claude Code' '{}'"
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Sound Notification (macOS)
|
|
194
|
+
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"hooks": {
|
|
198
|
+
"Notification": [
|
|
199
|
+
{
|
|
200
|
+
"matcher": "",
|
|
201
|
+
"hooks": [
|
|
202
|
+
{
|
|
203
|
+
"type": "command",
|
|
204
|
+
"command": "afplay /System/Library/Sounds/Glass.aiff"
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Validation Hooks
|
|
214
|
+
|
|
215
|
+
### Validate JSON Before Write
|
|
216
|
+
|
|
217
|
+
```json
|
|
218
|
+
{
|
|
219
|
+
"hooks": {
|
|
220
|
+
"PreToolUse": [
|
|
221
|
+
{
|
|
222
|
+
"matcher": "Write",
|
|
223
|
+
"hooks": [
|
|
224
|
+
{
|
|
225
|
+
"type": "command",
|
|
226
|
+
"command": "jq -e '.tool_input | select(.file_path | endswith(\".json\")) | .content' | jq . > /dev/null 2>&1 || { echo 'Invalid JSON content'; exit 2; }"
|
|
227
|
+
}
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
]
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Lint TypeScript Before Commit
|
|
236
|
+
|
|
237
|
+
```json
|
|
238
|
+
{
|
|
239
|
+
"hooks": {
|
|
240
|
+
"PreToolUse": [
|
|
241
|
+
{
|
|
242
|
+
"matcher": "Bash",
|
|
243
|
+
"hooks": [
|
|
244
|
+
{
|
|
245
|
+
"type": "command",
|
|
246
|
+
"command": "jq -r '.tool_input.command' | grep -q 'git commit' && npx eslint . --max-warnings 0 || exit 0"
|
|
247
|
+
}
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Session Hooks
|
|
256
|
+
|
|
257
|
+
### Initialize Environment on Session Start
|
|
258
|
+
|
|
259
|
+
```json
|
|
260
|
+
{
|
|
261
|
+
"hooks": {
|
|
262
|
+
"SessionStart": [
|
|
263
|
+
{
|
|
264
|
+
"matcher": "",
|
|
265
|
+
"hooks": [
|
|
266
|
+
{
|
|
267
|
+
"type": "command",
|
|
268
|
+
"command": "[ -f .claude-env ] && source .claude-env"
|
|
269
|
+
}
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Cleanup on Session End
|
|
278
|
+
|
|
279
|
+
```json
|
|
280
|
+
{
|
|
281
|
+
"hooks": {
|
|
282
|
+
"SessionEnd": [
|
|
283
|
+
{
|
|
284
|
+
"matcher": "",
|
|
285
|
+
"hooks": [
|
|
286
|
+
{
|
|
287
|
+
"type": "command",
|
|
288
|
+
"command": "rm -f /tmp/claude-session-* 2>/dev/null; exit 0"
|
|
289
|
+
}
|
|
290
|
+
]
|
|
291
|
+
}
|
|
292
|
+
]
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Multiple Hooks Example
|
|
298
|
+
|
|
299
|
+
Combine multiple hooks in one configuration:
|
|
300
|
+
|
|
301
|
+
```json
|
|
302
|
+
{
|
|
303
|
+
"hooks": {
|
|
304
|
+
"PreToolUse": [
|
|
305
|
+
{
|
|
306
|
+
"matcher": "Edit|Write",
|
|
307
|
+
"hooks": [
|
|
308
|
+
{
|
|
309
|
+
"type": "command",
|
|
310
|
+
"command": "python3 -c \"import json,sys; p=json.load(sys.stdin).get('tool_input',{}).get('file_path',''); sys.exit(2 if '.env' in p else 0)\""
|
|
311
|
+
}
|
|
312
|
+
]
|
|
313
|
+
}
|
|
314
|
+
],
|
|
315
|
+
"PostToolUse": [
|
|
316
|
+
{
|
|
317
|
+
"matcher": "Edit|Write",
|
|
318
|
+
"hooks": [
|
|
319
|
+
{
|
|
320
|
+
"type": "command",
|
|
321
|
+
"command": "jq -r '.tool_input.file_path' | { read f; [[ \"$f\" == *.ts ]] && npx prettier --write \"$f\" 2>/dev/null; exit 0; }"
|
|
322
|
+
}
|
|
323
|
+
]
|
|
324
|
+
}
|
|
325
|
+
],
|
|
326
|
+
"Notification": [
|
|
327
|
+
{
|
|
328
|
+
"matcher": "",
|
|
329
|
+
"hooks": [
|
|
330
|
+
{
|
|
331
|
+
"type": "command",
|
|
332
|
+
"command": "afplay /System/Library/Sounds/Glass.aiff"
|
|
333
|
+
}
|
|
334
|
+
]
|
|
335
|
+
}
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
```
|