sinapse-ai 7.1.0 → 7.3.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/.sinapse-ai/data/entity-registry.yaml +777 -881
- package/.sinapse-ai/data/registry-update-log.jsonl +2 -0
- package/.sinapse-ai/development/agents/sinapse-orqx.md +599 -443
- package/.sinapse-ai/install-manifest.yaml +6 -6
- package/bin/cli.js +116 -75
- package/package.json +2 -1
- package/packages/installer/src/wizard/i18n.js +2 -2
- package/packages/installer/src/wizard/index.js +14 -0
- package/packages/installer/src/wizard/questions.js +3 -3
- package/sinapse/agents/sinapse-orqx.md +32 -14
- package/squads/claude-code-mastery/CHANGELOG.md +22 -0
- package/squads/claude-code-mastery/README.md +146 -0
- package/squads/claude-code-mastery/agents/claude-mastery-chief.md +554 -0
- package/squads/claude-code-mastery/agents/config-engineer.md +865 -0
- package/squads/claude-code-mastery/agents/hooks-architect.md +1013 -0
- package/squads/claude-code-mastery/agents/mcp-integrator.md +791 -0
- package/squads/claude-code-mastery/agents/project-integrator.md +1196 -0
- package/squads/claude-code-mastery/agents/roadmap-sentinel.md +931 -0
- package/squads/claude-code-mastery/agents/skill-craftsman.md +1250 -0
- package/squads/claude-code-mastery/agents/swarm-orqx.md +1008 -0
- package/squads/claude-code-mastery/checklists/agent-team-readiness-checklist.md +88 -0
- package/squads/claude-code-mastery/checklists/brownfield-readiness-checklist.md +91 -0
- package/squads/claude-code-mastery/checklists/change-checklist.md +75 -0
- package/squads/claude-code-mastery/checklists/context-rot-checklist.md +114 -0
- package/squads/claude-code-mastery/checklists/integration-audit-checklist.md +104 -0
- package/squads/claude-code-mastery/checklists/multi-agent-review-checklist.md +77 -0
- package/squads/claude-code-mastery/checklists/pre-push-checklist.md +79 -0
- package/squads/claude-code-mastery/data/ci-cd-patterns.yaml +412 -0
- package/squads/claude-code-mastery/data/claude-code-quick-ref.yaml +314 -0
- package/squads/claude-code-mastery/data/hook-patterns.yaml +512 -0
- package/squads/claude-code-mastery/data/mcp-integration-catalog.yaml +323 -0
- package/squads/claude-code-mastery/data/project-type-signatures.yaml +335 -0
- package/squads/claude-code-mastery/scripts/validate-setup.js +163 -0
- package/squads/claude-code-mastery/squad.yaml +205 -0
- package/squads/claude-code-mastery/tasks/audit-integration.md +219 -0
- package/squads/claude-code-mastery/tasks/audit-settings.md +206 -0
- package/squads/claude-code-mastery/tasks/audit-setup.md +225 -0
- package/squads/claude-code-mastery/tasks/brownfield-setup.md +322 -0
- package/squads/claude-code-mastery/tasks/ci-cd-setup.md +335 -0
- package/squads/claude-code-mastery/tasks/claude-md-engineer.md +334 -0
- package/squads/claude-code-mastery/tasks/configure-claude-code.md +215 -0
- package/squads/claude-code-mastery/tasks/context-rot-audit.md +329 -0
- package/squads/claude-code-mastery/tasks/create-agent-definition.md +278 -0
- package/squads/claude-code-mastery/tasks/create-rules.md +206 -0
- package/squads/claude-code-mastery/tasks/create-team-topology.md +258 -0
- package/squads/claude-code-mastery/tasks/diagnose.md +166 -0
- package/squads/claude-code-mastery/tasks/enterprise-config.md +346 -0
- package/squads/claude-code-mastery/tasks/hook-designer.md +272 -0
- package/squads/claude-code-mastery/tasks/integrate-project.md +304 -0
- package/squads/claude-code-mastery/tasks/mcp-integration-plan.md +229 -0
- package/squads/claude-code-mastery/tasks/mcp-workflow.md +285 -0
- package/squads/claude-code-mastery/tasks/multi-project-setup.md +228 -0
- package/squads/claude-code-mastery/tasks/optimize-context.md +217 -0
- package/squads/claude-code-mastery/tasks/optimize-workflow.md +226 -0
- package/squads/claude-code-mastery/tasks/parallel-decomposition.md +293 -0
- package/squads/claude-code-mastery/tasks/permission-strategy.md +266 -0
- package/squads/claude-code-mastery/tasks/sandbox-setup.md +279 -0
- package/squads/claude-code-mastery/tasks/setup-repository.md +230 -0
- package/squads/claude-code-mastery/tasks/setup-wizard.md +236 -0
- package/squads/claude-code-mastery/tasks/worktree-strategy.md +320 -0
- package/squads/claude-code-mastery/templates/claude-md-fullstack.md +147 -0
- package/squads/claude-code-mastery/templates/claude-md-library.md +175 -0
- package/squads/claude-code-mastery/templates/claude-md-microservices.md +186 -0
- package/squads/claude-code-mastery/templates/claude-md-mobile.md +198 -0
- package/squads/claude-code-mastery/templates/claude-md-monorepo.md +139 -0
- package/squads/claude-code-mastery/templates/github-actions-claude-ci.yml +348 -0
- package/squads/claude-code-mastery/templates/github-actions-claude-review.yml +179 -0
- package/squads/claude-code-mastery/workflows/wf-audit-complete.yaml +140 -0
- package/squads/claude-code-mastery/workflows/wf-knowledge-update.yaml +165 -0
- package/squads/claude-code-mastery/workflows/wf-project-setup.yaml +192 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
# Task: Enterprise Configuration
|
|
2
|
+
|
|
3
|
+
**Task ID:** CCM-CONFIG-007
|
|
4
|
+
**Version:** 1.0.0
|
|
5
|
+
**Command:** `*enterprise-config`
|
|
6
|
+
**Orchestrator:** Sigil (config-engineer)
|
|
7
|
+
**Purpose:** Generate and deploy enterprise-grade Claude Code configuration using managed-settings.json for organizational policy enforcement, MDM integration, compliance rules, and standardized MCP server deployment across teams.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
+------------------+ +------------------+ +------------------+
|
|
15
|
+
| 1. Set Up | --> | 2. Configure | --> | 3. Set Up |
|
|
16
|
+
| managed- | | MDM/OS-Level | | managed- |
|
|
17
|
+
| settings.json | | Policies | | mcp.json |
|
|
18
|
+
+------------------+ +------------------+ +------------------+
|
|
19
|
+
| |
|
|
20
|
+
v v
|
|
21
|
+
+------------------+ +------------------+
|
|
22
|
+
| 4. Configure | --> | 5. Deploy |
|
|
23
|
+
| Compliance | | Across |
|
|
24
|
+
| Rules | | Organization |
|
|
25
|
+
+------------------+ +------------------+
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Inputs
|
|
31
|
+
|
|
32
|
+
| Field | Type | Source | Required | Validation |
|
|
33
|
+
|-------|------|--------|----------|------------|
|
|
34
|
+
| org_name | string | User parameter | Yes | Organization identifier |
|
|
35
|
+
| compliance | array | User parameter | No | Compliance frameworks: `soc2`, `hipaa`, `gdpr`, `pci`, `iso27001` |
|
|
36
|
+
| platform_targets | array | User parameter | No | `macos`, `linux`, `windows`, `wsl2` (default: all) |
|
|
37
|
+
| team_count | number | User parameter | No | Number of developers/teams using Claude Code |
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Preconditions
|
|
42
|
+
|
|
43
|
+
- Administrative access to deploy managed settings files
|
|
44
|
+
- Understanding of organizational security policies
|
|
45
|
+
- MDM system access (for macOS plist or Windows registry deployment)
|
|
46
|
+
- Knowledge of approved tools and MCP servers for the organization
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Execution Phases
|
|
51
|
+
|
|
52
|
+
### Phase 1: Set Up managed-settings.json
|
|
53
|
+
|
|
54
|
+
Create the managed settings file that cannot be overridden by user or project settings:
|
|
55
|
+
|
|
56
|
+
**Deployment locations (one per platform):**
|
|
57
|
+
|
|
58
|
+
| Platform | Path |
|
|
59
|
+
|----------|------|
|
|
60
|
+
| macOS | `/Library/Application Support/ClaudeCode/managed-settings.json` |
|
|
61
|
+
| Linux/WSL | `/etc/claude-code/managed-settings.json` |
|
|
62
|
+
| Windows | `C:\Program Files\ClaudeCode\managed-settings.json` |
|
|
63
|
+
|
|
64
|
+
**Base template:**
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"permissions": {
|
|
69
|
+
"deny": [
|
|
70
|
+
"Read(./.env)",
|
|
71
|
+
"Read(./.env.*)",
|
|
72
|
+
"Read(./secrets/**)",
|
|
73
|
+
"Read(./**/*.pem)",
|
|
74
|
+
"Read(./**/*.key)",
|
|
75
|
+
"Bash(rm -rf /)",
|
|
76
|
+
"Bash(curl * | bash)",
|
|
77
|
+
"Bash(wget * | bash)"
|
|
78
|
+
],
|
|
79
|
+
"defaultMode": "acceptEdits"
|
|
80
|
+
},
|
|
81
|
+
"disableBypassPermissionsMode": "disable",
|
|
82
|
+
"allowManagedPermissionRulesOnly": false,
|
|
83
|
+
"env": {
|
|
84
|
+
"CLAUDE_CODE_EFFORT_LEVEL": "high",
|
|
85
|
+
"CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "80"
|
|
86
|
+
},
|
|
87
|
+
"companyAnnouncements": [
|
|
88
|
+
"{org_name}: Use Claude Code responsibly. Report issues to #ai-tools."
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Managed-only policy keys:**
|
|
94
|
+
|
|
95
|
+
| Key | Type | Purpose | Recommendation |
|
|
96
|
+
|-----|------|---------|----------------|
|
|
97
|
+
| `disableBypassPermissionsMode` | `"disable"` | Prevent users from bypassing permissions | Always set in enterprise |
|
|
98
|
+
| `allowManagedPermissionRulesOnly` | boolean | Only managed deny/allow rules apply | `true` for regulated environments |
|
|
99
|
+
| `allowManagedHooksOnly` | boolean | Only managed hooks can execute | `true` for high-security |
|
|
100
|
+
| `allowManagedMcpServersOnly` | boolean | Only managed MCP servers allowed | `true` for compliance |
|
|
101
|
+
| `companyAnnouncements` | string[] | Messages shown to all users | Use for policies and reminders |
|
|
102
|
+
|
|
103
|
+
### Phase 2: Configure MDM/OS-Level Policies
|
|
104
|
+
|
|
105
|
+
For organizations using Mobile Device Management:
|
|
106
|
+
|
|
107
|
+
**macOS (plist):**
|
|
108
|
+
```xml
|
|
109
|
+
<!-- com.anthropic.claudecode.plist -->
|
|
110
|
+
<dict>
|
|
111
|
+
<key>disableBypassPermissionsMode</key>
|
|
112
|
+
<string>disable</string>
|
|
113
|
+
<key>permissions</key>
|
|
114
|
+
<dict>
|
|
115
|
+
<key>defaultMode</key>
|
|
116
|
+
<string>acceptEdits</string>
|
|
117
|
+
<key>deny</key>
|
|
118
|
+
<array>
|
|
119
|
+
<string>Read(./.env)</string>
|
|
120
|
+
<string>Read(./.env.*)</string>
|
|
121
|
+
<string>Read(./secrets/**)</string>
|
|
122
|
+
</array>
|
|
123
|
+
</dict>
|
|
124
|
+
</dict>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Windows (Registry):**
|
|
128
|
+
```
|
|
129
|
+
HKLM\SOFTWARE\Policies\ClaudeCode\
|
|
130
|
+
disableBypassPermissionsMode = "disable" (REG_SZ)
|
|
131
|
+
permissions\defaultMode = "acceptEdits" (REG_SZ)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Linux (file-based):**
|
|
135
|
+
Deploy `/etc/claude-code/managed-settings.json` via configuration management (Ansible, Chef, Puppet).
|
|
136
|
+
|
|
137
|
+
Provide platform-specific deployment scripts or configuration snippets.
|
|
138
|
+
|
|
139
|
+
### Phase 3: Set Up managed-mcp.json
|
|
140
|
+
|
|
141
|
+
Create the managed MCP configuration for standard organizational tools:
|
|
142
|
+
|
|
143
|
+
**Deployment locations:**
|
|
144
|
+
|
|
145
|
+
| Platform | Path |
|
|
146
|
+
|----------|------|
|
|
147
|
+
| macOS | `/Library/Application Support/ClaudeCode/managed-mcp.json` |
|
|
148
|
+
| Linux/WSL | `/etc/claude-code/managed-mcp.json` |
|
|
149
|
+
| Windows | `C:\Program Files\ClaudeCode\managed-mcp.json` |
|
|
150
|
+
|
|
151
|
+
**Template:**
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"mcpServers": {
|
|
156
|
+
"context7": {
|
|
157
|
+
"command": "npx",
|
|
158
|
+
"args": ["-y", "@context7/mcp-server"],
|
|
159
|
+
"env": {}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"allowedMcpServers": [
|
|
163
|
+
{ "serverName": "context7" },
|
|
164
|
+
{ "serverName": "playwright" }
|
|
165
|
+
],
|
|
166
|
+
"deniedMcpServers": [
|
|
167
|
+
{ "serverName": "filesystem" }
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Server allowlisting strategy:**
|
|
173
|
+
|
|
174
|
+
| Strategy | Setting | Use Case |
|
|
175
|
+
|----------|---------|----------|
|
|
176
|
+
| Open (default) | No restrictions | Trusted teams, experimental |
|
|
177
|
+
| Allowlist | `allowedMcpServers` array | Standard teams, moderate control |
|
|
178
|
+
| Managed-only | `allowManagedMcpServersOnly: true` | Regulated environments |
|
|
179
|
+
| Blocklist | `deniedMcpServers` array | Block specific known-risky servers |
|
|
180
|
+
|
|
181
|
+
### Phase 4: Configure Compliance Rules
|
|
182
|
+
|
|
183
|
+
For each compliance framework, add specific rules:
|
|
184
|
+
|
|
185
|
+
**SOC2:**
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"permissions": {
|
|
189
|
+
"deny": [
|
|
190
|
+
"Read(./**/*.pem)", "Read(./**/*.key)",
|
|
191
|
+
"Bash(curl * | bash)", "Bash(wget * | bash)"
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
"disableBypassPermissionsMode": "disable",
|
|
195
|
+
"sandbox": {
|
|
196
|
+
"network": { "allowManagedDomainsOnly": true }
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**HIPAA (healthcare data):**
|
|
202
|
+
```json
|
|
203
|
+
{
|
|
204
|
+
"permissions": {
|
|
205
|
+
"deny": [
|
|
206
|
+
"Read(./patient-data/**)", "Read(./phi/**)",
|
|
207
|
+
"WebFetch"
|
|
208
|
+
],
|
|
209
|
+
"defaultMode": "askAlways"
|
|
210
|
+
},
|
|
211
|
+
"allowManagedPermissionRulesOnly": true,
|
|
212
|
+
"allowManagedMcpServersOnly": true
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**GDPR (personal data):**
|
|
217
|
+
```json
|
|
218
|
+
{
|
|
219
|
+
"permissions": {
|
|
220
|
+
"deny": [
|
|
221
|
+
"Read(./user-data/**)", "Read(./pii/**)",
|
|
222
|
+
"Read(./**/personal/**)"
|
|
223
|
+
]
|
|
224
|
+
},
|
|
225
|
+
"companyAnnouncements": [
|
|
226
|
+
"GDPR: Do not paste personal data into Claude Code prompts."
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**PCI-DSS (payment data):**
|
|
232
|
+
```json
|
|
233
|
+
{
|
|
234
|
+
"permissions": {
|
|
235
|
+
"deny": [
|
|
236
|
+
"Read(./payment/**)", "Read(./**/*card*)",
|
|
237
|
+
"Read(./**/*billing*)"
|
|
238
|
+
],
|
|
239
|
+
"defaultMode": "askAlways"
|
|
240
|
+
},
|
|
241
|
+
"disableBypassPermissionsMode": "disable"
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Merge compliance rules with the base managed-settings.json.
|
|
246
|
+
|
|
247
|
+
### Phase 5: Deploy Across Organization
|
|
248
|
+
|
|
249
|
+
1. Generate deployment artifacts:
|
|
250
|
+
- `managed-settings.json` for each platform
|
|
251
|
+
- `managed-mcp.json` for each platform
|
|
252
|
+
- MDM profiles (plist for macOS, registry for Windows)
|
|
253
|
+
- Managed CLAUDE.md (optional, for org-wide instructions)
|
|
254
|
+
2. Create deployment documentation:
|
|
255
|
+
- Installation instructions per platform
|
|
256
|
+
- Verification commands to confirm deployment
|
|
257
|
+
- Rollback procedure
|
|
258
|
+
3. Provide verification checklist:
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
# Verify managed settings are loaded (run as user)
|
|
262
|
+
# Claude Code will show managed policy indicators in the UI
|
|
263
|
+
|
|
264
|
+
# Check managed file exists
|
|
265
|
+
# macOS:
|
|
266
|
+
ls -la "/Library/Application Support/ClaudeCode/managed-settings.json"
|
|
267
|
+
# Linux:
|
|
268
|
+
ls -la /etc/claude-code/managed-settings.json
|
|
269
|
+
# Windows:
|
|
270
|
+
dir "C:\Program Files\ClaudeCode\managed-settings.json"
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Output Format
|
|
276
|
+
|
|
277
|
+
```markdown
|
|
278
|
+
## Enterprise Configuration Package
|
|
279
|
+
|
|
280
|
+
**Organization:** {org_name}
|
|
281
|
+
**Compliance:** {frameworks}
|
|
282
|
+
**Platforms:** {targets}
|
|
283
|
+
**Teams:** {team_count}
|
|
284
|
+
|
|
285
|
+
### Generated Files
|
|
286
|
+
|
|
287
|
+
| File | Platform | Purpose | Deploy To |
|
|
288
|
+
|------|----------|---------|-----------|
|
|
289
|
+
| managed-settings.json | {platform} | Policy enforcement | {path} |
|
|
290
|
+
| managed-mcp.json | {platform} | Standard MCP servers | {path} |
|
|
291
|
+
| CLAUDE.md | All | Org-wide instructions | {path} |
|
|
292
|
+
| {mcp-profile} | macOS | MDM deployment | Jamf/Intune |
|
|
293
|
+
|
|
294
|
+
### Policy Summary
|
|
295
|
+
|
|
296
|
+
| Policy | Setting | Effect |
|
|
297
|
+
|--------|---------|--------|
|
|
298
|
+
| Bypass disabled | disableBypassPermissionsMode: disable | Users cannot skip permissions |
|
|
299
|
+
| Managed rules only | allowManagedPermissionRulesOnly: {val} | {effect} |
|
|
300
|
+
| Managed MCP only | allowManagedMcpServersOnly: {val} | {effect} |
|
|
301
|
+
| Network restriction | allowManagedDomainsOnly: {val} | {effect} |
|
|
302
|
+
|
|
303
|
+
### Deny Rules ({count} total)
|
|
304
|
+
|
|
305
|
+
{Numbered list of all deny rules with categories}
|
|
306
|
+
|
|
307
|
+
### Approved MCP Servers
|
|
308
|
+
|
|
309
|
+
| Server | Purpose | Status |
|
|
310
|
+
|--------|---------|--------|
|
|
311
|
+
| {name} | {purpose} | Allowed/Managed |
|
|
312
|
+
|
|
313
|
+
### Deployment Instructions
|
|
314
|
+
|
|
315
|
+
{Platform-specific deployment steps}
|
|
316
|
+
|
|
317
|
+
### Verification
|
|
318
|
+
|
|
319
|
+
{Commands to verify deployment on each platform}
|
|
320
|
+
|
|
321
|
+
### Rollback
|
|
322
|
+
|
|
323
|
+
{Steps to remove managed settings if needed}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## Veto Conditions
|
|
329
|
+
|
|
330
|
+
- **NEVER** generate enterprise configuration without `disableBypassPermissionsMode: "disable"`. This is the foundational enterprise security control.
|
|
331
|
+
- **NEVER** include real API keys, tokens, or credentials in managed configuration files. Use environment variable references.
|
|
332
|
+
- **NEVER** set `allowManagedPermissionRulesOnly: true` without also including comprehensive deny rules. This would leave the system unprotected.
|
|
333
|
+
- **NEVER** deploy managed-settings.json without providing a rollback procedure. Configuration errors at the managed level affect all users.
|
|
334
|
+
- **NEVER** omit compliance-specific rules when a compliance framework is specified. Partial compliance is worse than documented non-compliance.
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## Completion Criteria
|
|
339
|
+
|
|
340
|
+
- [ ] managed-settings.json generated with deny-first rules and enterprise policy keys
|
|
341
|
+
- [ ] MDM/OS-level deployment method documented for target platforms
|
|
342
|
+
- [ ] managed-mcp.json generated with approved server list
|
|
343
|
+
- [ ] Compliance rules integrated for all specified frameworks
|
|
344
|
+
- [ ] Deployment instructions created per platform
|
|
345
|
+
- [ ] Verification commands provided
|
|
346
|
+
- [ ] Rollback procedure documented
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# Task: Design Custom Hooks
|
|
2
|
+
|
|
3
|
+
**Task ID:** CCM-PI-006
|
|
4
|
+
**Version:** 1.0.0
|
|
5
|
+
**Command:** `*hook-designer`
|
|
6
|
+
**Agent:** Conduit (project-integrator)
|
|
7
|
+
**Purpose:** Design custom Claude Code hooks for a project by identifying automation needs, choosing appropriate hook types and events, designing hook logic, and producing implementation-ready specifications.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Automation Needs
|
|
15
|
+
|
|
|
16
|
+
v
|
|
17
|
+
+---------------------+
|
|
18
|
+
| 1. Identify Hook |
|
|
19
|
+
| Needs |
|
|
20
|
+
+---------------------+
|
|
21
|
+
|
|
|
22
|
+
v
|
|
23
|
+
+---------------------+
|
|
24
|
+
| 2. Choose Hook Type |
|
|
25
|
+
| & Category |
|
|
26
|
+
+---------------------+
|
|
27
|
+
|
|
|
28
|
+
v
|
|
29
|
+
+---------------------+
|
|
30
|
+
| 3. Select Events |
|
|
31
|
+
+---------------------+
|
|
32
|
+
|
|
|
33
|
+
v
|
|
34
|
+
+---------------------+
|
|
35
|
+
| 4. Design Hook Logic |
|
|
36
|
+
+---------------------+
|
|
37
|
+
|
|
|
38
|
+
v
|
|
39
|
+
+---------------------+
|
|
40
|
+
| 5. Implement & Test |
|
|
41
|
+
+---------------------+
|
|
42
|
+
|
|
|
43
|
+
v
|
|
44
|
+
+---------------------+
|
|
45
|
+
| 6. Integration |
|
|
46
|
+
| Verification |
|
|
47
|
+
+---------------------+
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Inputs
|
|
53
|
+
|
|
54
|
+
| Field | Type | Source | Required | Validation |
|
|
55
|
+
|-------|------|--------|----------|------------|
|
|
56
|
+
| hook_purpose | string | User | Yes | Description of what the hook should automate |
|
|
57
|
+
| trigger_event | string | User | No | Specific event if known (e.g., "PreToolUse", "Stop") |
|
|
58
|
+
| project_path | string | User or cwd | Yes | Project directory for context |
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Preconditions
|
|
63
|
+
|
|
64
|
+
- Claude Code installed and functional
|
|
65
|
+
- Understanding of the project's workflow and pain points
|
|
66
|
+
- `.claude/` directory exists (or will be created)
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Execution Phases
|
|
71
|
+
|
|
72
|
+
### Phase 1: Identify Hook Needs
|
|
73
|
+
|
|
74
|
+
Analyze the requested automation against hook capabilities:
|
|
75
|
+
|
|
76
|
+
1. **Categorize the need**:
|
|
77
|
+
- Security: blocking dangerous commands, validating inputs
|
|
78
|
+
- Automation: auto-formatting, auto-logging, state management
|
|
79
|
+
- Quality: linting on save, test on commit, review on complete
|
|
80
|
+
- Observability: timing, token tracking, cost monitoring
|
|
81
|
+
- Context management: compaction, memory updates, state persistence
|
|
82
|
+
|
|
83
|
+
2. **Validate hook-suitability**: some needs are better served by:
|
|
84
|
+
- Skills/commands (user-triggered, not event-triggered)
|
|
85
|
+
- Rules (static instructions, not runtime logic)
|
|
86
|
+
- CI/CD (post-merge, not during session)
|
|
87
|
+
|
|
88
|
+
If the need is not hook-suitable, recommend the appropriate alternative.
|
|
89
|
+
|
|
90
|
+
### Phase 2: Choose Hook Type and Category
|
|
91
|
+
|
|
92
|
+
Claude Code hooks operate in two transport modes:
|
|
93
|
+
|
|
94
|
+
| Transport | Language | Best For | Constraint |
|
|
95
|
+
|-----------|----------|----------|------------|
|
|
96
|
+
| command | Any (bash, node, python) | File operations, API calls, complex logic | Must exit within timeout |
|
|
97
|
+
| prompt | N/A (returns text) | Injecting context into conversation | Output added to assistant context |
|
|
98
|
+
|
|
99
|
+
**Hook categories by event:**
|
|
100
|
+
|
|
101
|
+
| Event | When Fires | Common Uses |
|
|
102
|
+
|-------|-----------|-------------|
|
|
103
|
+
| PreToolUse | Before any tool call | Block dangerous commands, validate inputs |
|
|
104
|
+
| PostToolUse | After tool completes | Log results, capture metrics, trigger follow-ups |
|
|
105
|
+
| Stop | Session ends normally | Save state, generate summary, update memory |
|
|
106
|
+
| SubagentStop | Subagent completes | Collect results, merge outputs |
|
|
107
|
+
| PreCompact | Before context compaction | Preserve critical state |
|
|
108
|
+
| Notification | User receives notification | Custom notification routing |
|
|
109
|
+
| UserPromptSubmit | User sends message | Input preprocessing, routing |
|
|
110
|
+
|
|
111
|
+
Select the appropriate event based on when the automation should trigger.
|
|
112
|
+
|
|
113
|
+
### Phase 3: Select Appropriate Events
|
|
114
|
+
|
|
115
|
+
For the identified need, determine:
|
|
116
|
+
|
|
117
|
+
1. **Primary event**: the main trigger for the hook
|
|
118
|
+
2. **Guard conditions**: when the hook should fire vs skip
|
|
119
|
+
- Tool name filter (for PreToolUse/PostToolUse)
|
|
120
|
+
- Session state checks
|
|
121
|
+
- File pattern matching
|
|
122
|
+
3. **Timeout**: maximum execution time (default 10s for command hooks)
|
|
123
|
+
4. **Error behavior**: what happens if the hook fails
|
|
124
|
+
- `continue`: session proceeds (recommended for non-critical hooks)
|
|
125
|
+
- `stop`: session halts (use only for security-critical hooks)
|
|
126
|
+
|
|
127
|
+
### Phase 4: Design Hook Logic
|
|
128
|
+
|
|
129
|
+
Design the hook implementation:
|
|
130
|
+
|
|
131
|
+
1. **Input contract**: what data the hook receives from Claude Code
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"tool_name": "Bash",
|
|
135
|
+
"tool_input": { "command": "rm -rf /tmp/test" },
|
|
136
|
+
"session_id": "abc123"
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
2. **Processing logic**: what the hook does with the input
|
|
141
|
+
- Parse input data
|
|
142
|
+
- Apply business logic (validation, transformation, logging)
|
|
143
|
+
- Produce output (block/allow, log entry, context injection)
|
|
144
|
+
|
|
145
|
+
3. **Output contract**: what the hook returns
|
|
146
|
+
- For PreToolUse: `{ "decision": "allow" }` or `{ "decision": "block", "reason": "..." }`
|
|
147
|
+
- For prompt hooks: plain text to inject into conversation
|
|
148
|
+
- For command hooks: exit code 0 (success) or non-zero (failure)
|
|
149
|
+
|
|
150
|
+
4. **Performance requirements**:
|
|
151
|
+
- Hook must complete within timeout
|
|
152
|
+
- No blocking I/O without timeouts
|
|
153
|
+
- Graceful degradation on failure
|
|
154
|
+
|
|
155
|
+
5. **State management** (if needed):
|
|
156
|
+
- Where to store state (file, environment variable)
|
|
157
|
+
- State format (JSON, YAML)
|
|
158
|
+
- Concurrency considerations
|
|
159
|
+
|
|
160
|
+
### Phase 5: Implement and Test
|
|
161
|
+
|
|
162
|
+
Create the hook implementation:
|
|
163
|
+
|
|
164
|
+
1. **Write the hook script** following the designed logic
|
|
165
|
+
- Use the language best suited to the task (Node.js for JSON, Bash for simple commands)
|
|
166
|
+
- Include error handling and timeout protection
|
|
167
|
+
- Add inline comments explaining the logic
|
|
168
|
+
|
|
169
|
+
2. **Register the hook** in settings.json:
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"hooks": {
|
|
173
|
+
"{EventName}": [
|
|
174
|
+
{
|
|
175
|
+
"type": "command",
|
|
176
|
+
"command": "node .claude/hooks/{hook-name}.js",
|
|
177
|
+
"timeout": 10000
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
3. **Test the hook**:
|
|
185
|
+
- Manual trigger with sample input
|
|
186
|
+
- Edge cases: missing fields, malformed input, timeout simulation
|
|
187
|
+
- Verify exit code and output format
|
|
188
|
+
|
|
189
|
+
### Phase 6: Integration Verification
|
|
190
|
+
|
|
191
|
+
Verify the hook works within the full Claude Code session:
|
|
192
|
+
|
|
193
|
+
1. Start a Claude Code session
|
|
194
|
+
2. Trigger the event that fires the hook
|
|
195
|
+
3. Verify the hook executed (check logs, output, or behavior)
|
|
196
|
+
4. Confirm no interference with other hooks or normal workflow
|
|
197
|
+
5. Check performance: hook completes well within timeout
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Output Format
|
|
202
|
+
|
|
203
|
+
```markdown
|
|
204
|
+
## Hook Design Specification
|
|
205
|
+
|
|
206
|
+
**Purpose:** {hook_purpose}
|
|
207
|
+
**Event:** {event_name}
|
|
208
|
+
**Type:** {command|prompt}
|
|
209
|
+
**Language:** {node|bash|python}
|
|
210
|
+
|
|
211
|
+
### Design
|
|
212
|
+
|
|
213
|
+
**Trigger:** {when the hook fires}
|
|
214
|
+
**Guard:** {conditions to skip execution}
|
|
215
|
+
**Timeout:** {N}ms
|
|
216
|
+
|
|
217
|
+
### Input/Output Contract
|
|
218
|
+
|
|
219
|
+
**Input:**
|
|
220
|
+
```json
|
|
221
|
+
{input_schema}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Output:**
|
|
225
|
+
```json
|
|
226
|
+
{output_schema}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Implementation
|
|
230
|
+
|
|
231
|
+
**File:** `.claude/hooks/{hook-name}.js`
|
|
232
|
+
**Registration:**
|
|
233
|
+
```json
|
|
234
|
+
{settings_json_snippet}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Test Plan
|
|
238
|
+
|
|
239
|
+
| Scenario | Input | Expected Output |
|
|
240
|
+
|----------|-------|-----------------|
|
|
241
|
+
| Normal case | {input} | {output} |
|
|
242
|
+
| Edge case | {input} | {output} |
|
|
243
|
+
| Error case | {input} | {output} |
|
|
244
|
+
|
|
245
|
+
### Performance
|
|
246
|
+
|
|
247
|
+
- Expected execution time: {N}ms
|
|
248
|
+
- Timeout configured: {N}ms
|
|
249
|
+
- Failure mode: {continue|stop}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Veto Conditions
|
|
255
|
+
|
|
256
|
+
- **NEVER** design hooks that block all tool use without escape hatch
|
|
257
|
+
- **NEVER** design hooks that send data to external services without user consent
|
|
258
|
+
- **NEVER** set hook timeout above 30 seconds (causes session lag)
|
|
259
|
+
- **NEVER** use `stop` error behavior for non-security hooks
|
|
260
|
+
- **NEVER** design hooks that modify source code -- hooks observe and gate, they do not author
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## Completion Criteria
|
|
265
|
+
|
|
266
|
+
- [ ] Hook need identified and validated as hook-suitable
|
|
267
|
+
- [ ] Hook type and event selected with rationale
|
|
268
|
+
- [ ] Input/output contract defined
|
|
269
|
+
- [ ] Hook logic designed with error handling
|
|
270
|
+
- [ ] Implementation created and registered in settings.json
|
|
271
|
+
- [ ] Test plan documented with at least 3 scenarios
|
|
272
|
+
- [ ] Integration verified in a real session
|