@cloudstreamsoftware/claude-tools 1.0.0 → 1.1.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/README.md +152 -37
- package/agents/INDEX.md +183 -0
- package/agents/architect.md +247 -0
- package/agents/build-error-resolver.md +555 -0
- package/agents/catalyst-deployer.md +132 -0
- package/agents/code-reviewer.md +121 -0
- package/agents/compliance-auditor.md +148 -0
- package/agents/creator-architect.md +395 -0
- package/agents/deluge-reviewer.md +98 -0
- package/agents/doc-updater.md +471 -0
- package/agents/e2e-runner.md +711 -0
- package/agents/planner.md +122 -0
- package/agents/refactor-cleaner.md +309 -0
- package/agents/security-reviewer.md +582 -0
- package/agents/tdd-guide.md +302 -0
- package/config/versions.json +63 -0
- package/dist/hooks/hooks.json +209 -0
- package/dist/index.js +47 -0
- package/dist/lib/asset-value.js +609 -0
- package/dist/lib/client-manager.js +300 -0
- package/dist/lib/command-matcher.js +242 -0
- package/dist/lib/cross-session-patterns.js +754 -0
- package/dist/lib/intent-classifier.js +1075 -0
- package/dist/lib/package-manager.js +374 -0
- package/dist/lib/recommendation-engine.js +597 -0
- package/dist/lib/session-memory.js +489 -0
- package/dist/lib/skill-effectiveness.js +486 -0
- package/dist/lib/skill-matcher.js +595 -0
- package/dist/lib/tutorial-metrics.js +242 -0
- package/dist/lib/tutorial-progress.js +209 -0
- package/dist/lib/tutorial-renderer.js +431 -0
- package/dist/lib/utils.js +380 -0
- package/dist/lib/verify-formatter.js +143 -0
- package/dist/lib/workflow-state.js +249 -0
- package/hooks/hooks.json +209 -0
- package/package.json +5 -1
- package/scripts/aggregate-sessions.js +290 -0
- package/scripts/branch-name-validator.js +291 -0
- package/scripts/build.js +101 -0
- package/scripts/commands/client-switch.js +231 -0
- package/scripts/deprecate-skill.js +610 -0
- package/scripts/diagnose.js +324 -0
- package/scripts/doc-freshness.js +168 -0
- package/scripts/generate-weekly-digest.js +393 -0
- package/scripts/health-check.js +270 -0
- package/scripts/hooks/credential-check.js +101 -0
- package/scripts/hooks/evaluate-session.js +81 -0
- package/scripts/hooks/pre-compact.js +66 -0
- package/scripts/hooks/prompt-analyzer.js +276 -0
- package/scripts/hooks/prompt-router.js +422 -0
- package/scripts/hooks/quality-gate-enforcer.js +371 -0
- package/scripts/hooks/session-end.js +156 -0
- package/scripts/hooks/session-start.js +195 -0
- package/scripts/hooks/skill-injector.js +333 -0
- package/scripts/hooks/suggest-compact.js +58 -0
- package/scripts/lib/asset-value.js +609 -0
- package/scripts/lib/client-manager.js +300 -0
- package/scripts/lib/command-matcher.js +242 -0
- package/scripts/lib/cross-session-patterns.js +754 -0
- package/scripts/lib/intent-classifier.js +1075 -0
- package/scripts/lib/package-manager.js +374 -0
- package/scripts/lib/recommendation-engine.js +597 -0
- package/scripts/lib/session-memory.js +489 -0
- package/scripts/lib/skill-effectiveness.js +486 -0
- package/scripts/lib/skill-matcher.js +595 -0
- package/scripts/lib/tutorial-metrics.js +242 -0
- package/scripts/lib/tutorial-progress.js +209 -0
- package/scripts/lib/tutorial-renderer.js +431 -0
- package/scripts/lib/utils.js +380 -0
- package/scripts/lib/verify-formatter.js +143 -0
- package/scripts/lib/workflow-state.js +249 -0
- package/scripts/onboard.js +363 -0
- package/scripts/quarterly-report.js +692 -0
- package/scripts/setup-package-manager.js +204 -0
- package/scripts/sync-upstream.js +391 -0
- package/scripts/test.js +108 -0
- package/scripts/tutorial-runner.js +351 -0
- package/scripts/validate-all.js +201 -0
- package/scripts/verifiers/agents.js +245 -0
- package/scripts/verifiers/config.js +186 -0
- package/scripts/verifiers/environment.js +123 -0
- package/scripts/verifiers/hooks.js +188 -0
- package/scripts/verifiers/index.js +38 -0
- package/scripts/verifiers/persistence.js +140 -0
- package/scripts/verifiers/plugin.js +215 -0
- package/scripts/verifiers/skills.js +209 -0
- package/scripts/verify-setup.js +164 -0
- package/skills/INDEX.md +157 -0
- package/skills/backend-patterns/SKILL.md +586 -0
- package/skills/backend-patterns/catalyst-patterns.md +128 -0
- package/skills/bigquery-patterns/SKILL.md +27 -0
- package/skills/bigquery-patterns/performance-optimization.md +518 -0
- package/skills/bigquery-patterns/query-patterns.md +372 -0
- package/skills/bigquery-patterns/schema-design.md +78 -0
- package/skills/cloudstream-project-template/SKILL.md +20 -0
- package/skills/cloudstream-project-template/structure.md +65 -0
- package/skills/coding-standards/SKILL.md +524 -0
- package/skills/coding-standards/deluge-standards.md +83 -0
- package/skills/compliance-patterns/SKILL.md +28 -0
- package/skills/compliance-patterns/hipaa/audit-requirements.md +251 -0
- package/skills/compliance-patterns/hipaa/baa-process.md +298 -0
- package/skills/compliance-patterns/hipaa/data-archival-strategy.md +387 -0
- package/skills/compliance-patterns/hipaa/phi-handling.md +52 -0
- package/skills/compliance-patterns/pci-dss/saq-a-requirements.md +307 -0
- package/skills/compliance-patterns/pci-dss/tokenization-patterns.md +382 -0
- package/skills/compliance-patterns/pci-dss/zoho-checkout-patterns.md +56 -0
- package/skills/compliance-patterns/soc2/access-controls.md +344 -0
- package/skills/compliance-patterns/soc2/audit-logging.md +458 -0
- package/skills/compliance-patterns/soc2/change-management.md +403 -0
- package/skills/compliance-patterns/soc2/deluge-execution-logging.md +407 -0
- package/skills/consultancy-workflows/SKILL.md +19 -0
- package/skills/consultancy-workflows/client-isolation.md +21 -0
- package/skills/consultancy-workflows/documentation-automation.md +454 -0
- package/skills/consultancy-workflows/handoff-procedures.md +257 -0
- package/skills/consultancy-workflows/knowledge-capture.md +513 -0
- package/skills/consultancy-workflows/time-tracking.md +26 -0
- package/skills/continuous-learning/SKILL.md +84 -0
- package/skills/continuous-learning/config.json +18 -0
- package/skills/continuous-learning/evaluate-session.sh +60 -0
- package/skills/continuous-learning-v2/SKILL.md +126 -0
- package/skills/continuous-learning-v2/config.json +61 -0
- package/skills/frontend-patterns/SKILL.md +635 -0
- package/skills/frontend-patterns/zoho-widget-patterns.md +103 -0
- package/skills/gcp-data-engineering/SKILL.md +36 -0
- package/skills/gcp-data-engineering/bigquery/performance-optimization.md +337 -0
- package/skills/gcp-data-engineering/dataflow/error-handling.md +496 -0
- package/skills/gcp-data-engineering/dataflow/pipeline-patterns.md +444 -0
- package/skills/gcp-data-engineering/dbt/model-organization.md +63 -0
- package/skills/gcp-data-engineering/dbt/testing-patterns.md +503 -0
- package/skills/gcp-data-engineering/medallion-architecture/bronze-layer.md +60 -0
- package/skills/gcp-data-engineering/medallion-architecture/gold-layer.md +311 -0
- package/skills/gcp-data-engineering/medallion-architecture/layer-transitions.md +517 -0
- package/skills/gcp-data-engineering/medallion-architecture/silver-layer.md +305 -0
- package/skills/gcp-data-engineering/zoho-to-gcp/data-extraction.md +543 -0
- package/skills/gcp-data-engineering/zoho-to-gcp/real-time-vs-batch.md +337 -0
- package/skills/security-review/SKILL.md +498 -0
- package/skills/security-review/compliance-checklist.md +53 -0
- package/skills/strategic-compact/SKILL.md +67 -0
- package/skills/tdd-workflow/SKILL.md +413 -0
- package/skills/tdd-workflow/zoho-testing.md +124 -0
- package/skills/tutorial/SKILL.md +249 -0
- package/skills/tutorial/docs/ACCESSIBILITY.md +169 -0
- package/skills/tutorial/lessons/00-philosophy-and-workflow.md +198 -0
- package/skills/tutorial/lessons/01-basics.md +81 -0
- package/skills/tutorial/lessons/02-training.md +86 -0
- package/skills/tutorial/lessons/03-commands.md +109 -0
- package/skills/tutorial/lessons/04-workflows.md +115 -0
- package/skills/tutorial/lessons/05-compliance.md +116 -0
- package/skills/tutorial/lessons/06-zoho.md +121 -0
- package/skills/tutorial/lessons/07-hooks-system.md +277 -0
- package/skills/tutorial/lessons/08-mcp-servers.md +316 -0
- package/skills/tutorial/lessons/09-client-management.md +215 -0
- package/skills/tutorial/lessons/10-testing-e2e.md +260 -0
- package/skills/tutorial/lessons/11-skills-deep-dive.md +272 -0
- package/skills/tutorial/lessons/12-rules-system.md +326 -0
- package/skills/tutorial/lessons/13-golden-standard-graduation.md +213 -0
- package/skills/tutorial/lessons/14-fork-setup-and-sync.md +312 -0
- package/skills/tutorial/lessons/15-living-examples-system.md +221 -0
- package/skills/tutorial/tracks/accelerated/README.md +134 -0
- package/skills/tutorial/tracks/accelerated/assessment/checkpoint-1.md +161 -0
- package/skills/tutorial/tracks/accelerated/assessment/checkpoint-2.md +175 -0
- package/skills/tutorial/tracks/accelerated/day-1-core-concepts.md +234 -0
- package/skills/tutorial/tracks/accelerated/day-2-essential-commands.md +270 -0
- package/skills/tutorial/tracks/accelerated/day-3-workflow-mastery.md +305 -0
- package/skills/tutorial/tracks/accelerated/day-4-compliance-zoho.md +304 -0
- package/skills/tutorial/tracks/accelerated/day-5-hooks-skills.md +344 -0
- package/skills/tutorial/tracks/accelerated/day-6-client-testing.md +386 -0
- package/skills/tutorial/tracks/accelerated/day-7-graduation.md +369 -0
- package/skills/zoho-patterns/CHANGELOG.md +108 -0
- package/skills/zoho-patterns/SKILL.md +446 -0
- package/skills/zoho-patterns/analytics/dashboard-patterns.md +352 -0
- package/skills/zoho-patterns/analytics/zoho-to-bigquery-pipeline.md +427 -0
- package/skills/zoho-patterns/catalyst/appsail-deployment.md +349 -0
- package/skills/zoho-patterns/catalyst/context-close-patterns.md +354 -0
- package/skills/zoho-patterns/catalyst/cron-batch-processing.md +374 -0
- package/skills/zoho-patterns/catalyst/function-patterns.md +439 -0
- package/skills/zoho-patterns/creator/form-design.md +304 -0
- package/skills/zoho-patterns/creator/publish-api-patterns.md +313 -0
- package/skills/zoho-patterns/creator/widget-integration.md +306 -0
- package/skills/zoho-patterns/creator/workflow-automation.md +253 -0
- package/skills/zoho-patterns/deluge/api-patterns.md +468 -0
- package/skills/zoho-patterns/deluge/batch-processing.md +403 -0
- package/skills/zoho-patterns/deluge/cross-app-integration.md +356 -0
- package/skills/zoho-patterns/deluge/error-handling.md +423 -0
- package/skills/zoho-patterns/deluge/syntax-reference.md +65 -0
- package/skills/zoho-patterns/integration/cors-proxy-architecture.md +426 -0
- package/skills/zoho-patterns/integration/crm-books-native-sync.md +277 -0
- package/skills/zoho-patterns/integration/oauth-token-management.md +461 -0
- package/skills/zoho-patterns/integration/zoho-flow-patterns.md +334 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# Lesson 7: Hooks System
|
|
2
|
+
|
|
3
|
+
Automate quality checks and enforce workflows before and after Claude Code actions.
|
|
4
|
+
|
|
5
|
+
## Concept
|
|
6
|
+
|
|
7
|
+
Hooks are scripts that run automatically at specific lifecycle events:
|
|
8
|
+
|
|
9
|
+
| Hook Type | When It Runs | Use Cases |
|
|
10
|
+
|-----------|--------------|-----------|
|
|
11
|
+
| **UserPromptSubmit** | When user sends a message | Real-time correction detection, intent analysis |
|
|
12
|
+
| **PreToolUse** | Before a tool executes | Block dangerous operations, validate inputs, credential scanning |
|
|
13
|
+
| **PostToolUse** | After a tool completes | Auto-format code, run type checks, warn about issues |
|
|
14
|
+
| **Stop** | When Claude response ends | Final validation before user sees result |
|
|
15
|
+
| **SessionStart** | When session begins | Load context, detect environment |
|
|
16
|
+
| **SessionEnd** | When session closes | Persist state, capture patterns |
|
|
17
|
+
| **PreCompact** | Before context compaction | Save important state before memory trim |
|
|
18
|
+
|
|
19
|
+
## Why This Matters
|
|
20
|
+
|
|
21
|
+
Without hooks, you must manually:
|
|
22
|
+
- Check for credentials before every edit
|
|
23
|
+
- Run Prettier after every file change
|
|
24
|
+
- Verify TypeScript after every `.ts` modification
|
|
25
|
+
- Remember to save session state
|
|
26
|
+
|
|
27
|
+
Hooks automate these guardrails, making quality enforcement invisible.
|
|
28
|
+
|
|
29
|
+
## Current Hooks in This System
|
|
30
|
+
|
|
31
|
+
The system includes these production hooks in `hooks/hooks.json`:
|
|
32
|
+
|
|
33
|
+
### UserPromptSubmit Hook (Real-Time Learning)
|
|
34
|
+
|
|
35
|
+
| Hook | What It Does | Trigger |
|
|
36
|
+
|------|--------------|---------|
|
|
37
|
+
| **Prompt Analyzer** | Detects corrections and learning opportunities in your messages | Every user message |
|
|
38
|
+
|
|
39
|
+
This hook powers the system's **real-time learning**. When you say things like "no, actually use X instead", the prompt analyzer:
|
|
40
|
+
1. Detects the correction pattern
|
|
41
|
+
2. Extracts what was wrong vs. what's right
|
|
42
|
+
3. Records it in session memory
|
|
43
|
+
4. After 2+ occurrences, it becomes a persistent learned pattern
|
|
44
|
+
|
|
45
|
+
### PreToolUse Hooks (Before Actions)
|
|
46
|
+
|
|
47
|
+
| Hook | What It Does | Trigger |
|
|
48
|
+
|------|--------------|---------|
|
|
49
|
+
| **Credential Check** | Scans for hardcoded Zoho/GCP credentials | Edit/Write operations |
|
|
50
|
+
| **Tmux Reminder** | Suggests tmux for long-running commands | npm install, docker, pytest, etc. |
|
|
51
|
+
| **Dev Server Block** | BLOCKS dev servers outside tmux | `npm run dev` and variants |
|
|
52
|
+
| **Git Push Review** | Reminds to review before push | `git push` commands |
|
|
53
|
+
| **Doc Blocker** | BLOCKS random .md file creation | Write to non-README .md files |
|
|
54
|
+
| **Suggest Compact** | Suggests context compaction at intervals | Edit/Write operations |
|
|
55
|
+
|
|
56
|
+
### PostToolUse Hooks (After Actions)
|
|
57
|
+
|
|
58
|
+
| Hook | What It Does | Trigger |
|
|
59
|
+
|------|--------------|---------|
|
|
60
|
+
| **PR Logger** | Logs PR URL and provides review command | After `gh pr create` |
|
|
61
|
+
| **Prettier Format** | Auto-formats JS/TS files | After editing .js/.jsx/.ts/.tsx |
|
|
62
|
+
| **TypeScript Check** | Runs `tsc --noEmit` and reports errors | After editing .ts/.tsx |
|
|
63
|
+
| **Console.log Warning** | Warns about console.log in code | After editing JS/TS files |
|
|
64
|
+
|
|
65
|
+
### Stop Hook (End of Response)
|
|
66
|
+
|
|
67
|
+
| Hook | What It Does | Trigger |
|
|
68
|
+
|------|--------------|---------|
|
|
69
|
+
| **Console.log Audit** | Checks all modified files for console.log | Every response |
|
|
70
|
+
|
|
71
|
+
### Session Hooks (Lifecycle)
|
|
72
|
+
|
|
73
|
+
| Hook | What It Does | Trigger |
|
|
74
|
+
|------|--------------|---------|
|
|
75
|
+
| **SessionStart** | Loads previous context, detects package manager | New session |
|
|
76
|
+
| **SessionEnd** | Persists session state | Session closes |
|
|
77
|
+
| **Evaluate Session** | Extracts reusable patterns from work | Session closes |
|
|
78
|
+
| **PreCompact** | Saves state before compaction | Before memory trim |
|
|
79
|
+
|
|
80
|
+
## Hook Configuration Format
|
|
81
|
+
|
|
82
|
+
Hooks are defined in `hooks/hooks.json` with this structure:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"hooks": {
|
|
87
|
+
"PreToolUse": [
|
|
88
|
+
{
|
|
89
|
+
"matcher": "tool == \"Edit\" || tool == \"Write\"",
|
|
90
|
+
"hooks": [
|
|
91
|
+
{
|
|
92
|
+
"type": "command",
|
|
93
|
+
"command": "node scripts/hooks/credential-check.js"
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
"description": "Scan for hardcoded credentials in edits"
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Matcher Syntax
|
|
104
|
+
|
|
105
|
+
Matchers are expressions that determine when a hook runs:
|
|
106
|
+
|
|
107
|
+
| Matcher | Meaning |
|
|
108
|
+
|---------|---------|
|
|
109
|
+
| `*` | Always run |
|
|
110
|
+
| `tool == "Edit"` | Only on Edit tool |
|
|
111
|
+
| `tool == "Bash" && tool_input.command matches "git push"` | Bash with specific command |
|
|
112
|
+
| `tool_input.file_path matches "\\.ts$"` | Files ending in .ts |
|
|
113
|
+
|
|
114
|
+
### Hook Types
|
|
115
|
+
|
|
116
|
+
| Type | Description |
|
|
117
|
+
|------|-------------|
|
|
118
|
+
| `command` | Run a shell command |
|
|
119
|
+
|
|
120
|
+
The command receives tool input via stdin (JSON) and outputs modified JSON via stdout.
|
|
121
|
+
|
|
122
|
+
## Exercise
|
|
123
|
+
|
|
124
|
+
### Exercise 7.1: Examine Hook Configuration
|
|
125
|
+
|
|
126
|
+
**Step 1**: View the hooks configuration:
|
|
127
|
+
```bash
|
|
128
|
+
cat hooks/hooks.json
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Step 2**: Count the hooks:
|
|
132
|
+
- How many PreToolUse hooks?
|
|
133
|
+
- How many PostToolUse hooks?
|
|
134
|
+
- What session hooks exist?
|
|
135
|
+
|
|
136
|
+
### Exercise 7.2: See a Hook in Action
|
|
137
|
+
|
|
138
|
+
**Step 1**: Create a test TypeScript file with an issue:
|
|
139
|
+
```typescript
|
|
140
|
+
// Create: test-hook.ts
|
|
141
|
+
const x = 1;
|
|
142
|
+
console.log(x);
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Step 2**: When you edit a TypeScript file, observe the PostToolUse hooks fire:
|
|
146
|
+
1. Prettier formats the file
|
|
147
|
+
2. TypeScript check runs
|
|
148
|
+
3. Console.log warning appears
|
|
149
|
+
|
|
150
|
+
**Step 3**: Notice how you didn't have to run these manually - hooks automated it.
|
|
151
|
+
|
|
152
|
+
### Exercise 7.3: Understanding Hook Scripts
|
|
153
|
+
|
|
154
|
+
**Step 1**: View a hook script:
|
|
155
|
+
```bash
|
|
156
|
+
cat scripts/hooks/credential-check.js
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**What to observe:**
|
|
160
|
+
- Scripts receive tool input via stdin (JSON)
|
|
161
|
+
- Scripts output modified JSON via stdout
|
|
162
|
+
- Scripts can `process.exit(1)` to BLOCK the operation
|
|
163
|
+
- Scripts log to stderr for user visibility
|
|
164
|
+
|
|
165
|
+
### Exercise 7.4: Blocking vs. Warning Hooks
|
|
166
|
+
|
|
167
|
+
Some hooks BLOCK operations (exit code 1), others just WARN:
|
|
168
|
+
|
|
169
|
+
| Hook | Behavior |
|
|
170
|
+
|------|----------|
|
|
171
|
+
| Credential Check | BLOCKS if secrets found |
|
|
172
|
+
| Dev Server Block | BLOCKS outside tmux |
|
|
173
|
+
| Doc Blocker | BLOCKS random .md files |
|
|
174
|
+
| Console.log Warning | WARNS but allows |
|
|
175
|
+
| Tmux Reminder | WARNS but allows |
|
|
176
|
+
|
|
177
|
+
## Verification
|
|
178
|
+
|
|
179
|
+
You've completed this exercise successfully if:
|
|
180
|
+
- [ ] You found `hooks/hooks.json` and understand its structure
|
|
181
|
+
- [ ] You know the 6 hook lifecycle events
|
|
182
|
+
- [ ] You saw hooks fire when editing a file
|
|
183
|
+
- [ ] You understand the difference between blocking and warning hooks
|
|
184
|
+
|
|
185
|
+
## Creating Custom Hooks
|
|
186
|
+
|
|
187
|
+
To add a custom hook:
|
|
188
|
+
|
|
189
|
+
**Step 1**: Create script in `scripts/hooks/your-hook.js`:
|
|
190
|
+
```javascript
|
|
191
|
+
#!/usr/bin/env node
|
|
192
|
+
let data = '';
|
|
193
|
+
process.stdin.on('data', chunk => data += chunk);
|
|
194
|
+
process.stdin.on('end', () => {
|
|
195
|
+
const input = JSON.parse(data);
|
|
196
|
+
|
|
197
|
+
// Your validation logic
|
|
198
|
+
if (somethingBad) {
|
|
199
|
+
console.error('[Hook] BLOCKED: Reason');
|
|
200
|
+
process.exit(1); // Block the operation
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Pass through the data
|
|
204
|
+
console.log(data);
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Step 2**: Add entry to `hooks/hooks.json`:
|
|
209
|
+
```json
|
|
210
|
+
{
|
|
211
|
+
"matcher": "tool == \"Bash\" && tool_input.command matches \"deploy\"",
|
|
212
|
+
"hooks": [
|
|
213
|
+
{
|
|
214
|
+
"type": "command",
|
|
215
|
+
"command": "node scripts/hooks/your-hook.js"
|
|
216
|
+
}
|
|
217
|
+
],
|
|
218
|
+
"description": "What this hook does"
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**Step 3**: Restart Claude Code session for hooks to load.
|
|
223
|
+
|
|
224
|
+
### Example: Block Commits on Friday Afternoons
|
|
225
|
+
|
|
226
|
+
```json
|
|
227
|
+
{
|
|
228
|
+
"matcher": "tool == \"Bash\" && tool_input.command matches \"git commit\"",
|
|
229
|
+
"hooks": [
|
|
230
|
+
{
|
|
231
|
+
"type": "command",
|
|
232
|
+
"command": "node -e \"const d=new Date();if(d.getDay()===5&&d.getHours()>=14){console.error('[Hook] BLOCKED: No commits after 2pm Friday!');process.exit(1)}\""
|
|
233
|
+
}
|
|
234
|
+
],
|
|
235
|
+
"description": "Prevent Friday afternoon commits (you'll thank yourself)"
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Key Takeaway
|
|
240
|
+
|
|
241
|
+
Hooks are invisible guardrails. They enforce quality standards without requiring manual intervention. The system includes 12+ production hooks that:
|
|
242
|
+
- Scan for secrets before edits
|
|
243
|
+
- Auto-format code after changes
|
|
244
|
+
- Catch TypeScript errors immediately
|
|
245
|
+
- Persist context across sessions
|
|
246
|
+
|
|
247
|
+
You don't run these manually - they just work.
|
|
248
|
+
|
|
249
|
+
## Hooks Quick Reference
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
BLOCKING HOOKS (exit 1):
|
|
253
|
+
- Credential check (secrets in code)
|
|
254
|
+
- Dev server block (outside tmux)
|
|
255
|
+
- Doc blocker (random .md files)
|
|
256
|
+
|
|
257
|
+
WARNING HOOKS (stderr only):
|
|
258
|
+
- Console.log warning
|
|
259
|
+
- Tmux reminder
|
|
260
|
+
- Git push review
|
|
261
|
+
|
|
262
|
+
LIFECYCLE HOOKS:
|
|
263
|
+
- SessionStart: Load context
|
|
264
|
+
- SessionEnd: Persist state
|
|
265
|
+
- PreCompact: Save before trim
|
|
266
|
+
- Stop: Final validation
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Next Steps
|
|
270
|
+
|
|
271
|
+
In Lesson 8, you'll learn about MCP Servers - external capabilities like memory persistence and live documentation lookup.
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
**Concepts learned**: Hook lifecycle events, PreToolUse/PostToolUse/Stop/Session hooks, blocking vs. warning
|
|
276
|
+
**Key file**: `hooks/hooks.json`
|
|
277
|
+
**Progress**: 8 of 15 lessons complete
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
# Lesson 8: MCP Servers
|
|
2
|
+
|
|
3
|
+
Model Context Protocol (MCP) servers extend Claude Code with external capabilities.
|
|
4
|
+
|
|
5
|
+
## Concept
|
|
6
|
+
|
|
7
|
+
MCPs are plugins that give Claude Code access to external systems:
|
|
8
|
+
|
|
9
|
+
| Tier | MCPs | Purpose |
|
|
10
|
+
|------|------|---------|
|
|
11
|
+
| **Core** | memory, sequential-thinking, context7 | Always active - essential functionality |
|
|
12
|
+
| **Per-Client** | zoho-analytics, zoho-books, gcloud, bigquery, dbt | Enabled based on client tech stack |
|
|
13
|
+
| **Optional** | magic, firecrawl, github, filesystem | Project-specific needs |
|
|
14
|
+
|
|
15
|
+
## Why This Matters
|
|
16
|
+
|
|
17
|
+
Without MCPs:
|
|
18
|
+
- Claude forgets everything between sessions
|
|
19
|
+
- You manually look up library documentation
|
|
20
|
+
- No direct access to GitHub, GCP, or Zoho APIs
|
|
21
|
+
- Limited to what Claude knows at training time
|
|
22
|
+
|
|
23
|
+
With MCPs:
|
|
24
|
+
- Memory persists across all sessions
|
|
25
|
+
- Up-to-date docs fetched on demand
|
|
26
|
+
- Direct API access to external systems
|
|
27
|
+
- Extended capabilities via plugins
|
|
28
|
+
|
|
29
|
+
## The 12 Available MCPs
|
|
30
|
+
|
|
31
|
+
### Core MCPs (Always Enabled)
|
|
32
|
+
|
|
33
|
+
These three MCPs are configured in `.mcp.json` by default:
|
|
34
|
+
|
|
35
|
+
#### 1. Memory MCP
|
|
36
|
+
|
|
37
|
+
Persists knowledge across sessions using a knowledge graph structure:
|
|
38
|
+
- **Entities**: Things (projects, decisions, patterns)
|
|
39
|
+
- **Relations**: Connections between entities
|
|
40
|
+
- **Observations**: Facts about entities
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"memory": {
|
|
45
|
+
"command": "npx",
|
|
46
|
+
"args": ["-y", "@modelcontextprotocol/server-memory"],
|
|
47
|
+
"env": {
|
|
48
|
+
"MEMORY_FILE_PATH": "~/.claude/memory/cloudstream-memory.json"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Use case**: "Remember that Client X prefers morning standups" persists across sessions.
|
|
55
|
+
|
|
56
|
+
#### 2. Sequential Thinking MCP
|
|
57
|
+
|
|
58
|
+
Enables multi-step reasoning for complex architecture decisions. Breaks down problems into logical steps before acting.
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"sequential-thinking": {
|
|
63
|
+
"command": "npx",
|
|
64
|
+
"args": ["-y", "@modelcontextprotocol/server-sequential-thinking"]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Use case**: Complex architecture decisions, compliance analysis, debugging sessions.
|
|
70
|
+
|
|
71
|
+
#### 3. Context7 MCP
|
|
72
|
+
|
|
73
|
+
Fetches live documentation for libraries. Never work with outdated API references.
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"context7": {
|
|
78
|
+
"command": "npx",
|
|
79
|
+
"args": ["-y", "@upstash/context7-mcp"]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Pro tip**: Add Zoho SDKs to Context7 at [context7.com/add-library](https://context7.com/add-library)
|
|
85
|
+
|
|
86
|
+
### Per-Client MCPs (Enable Based on Tech Stack)
|
|
87
|
+
|
|
88
|
+
These MCPs are documented in `mcp-configs/mcp-servers.json`:
|
|
89
|
+
|
|
90
|
+
#### 4. Zoho Analytics MCP (Docker)
|
|
91
|
+
|
|
92
|
+
Official Zoho Analytics integration for reporting and dashboards.
|
|
93
|
+
|
|
94
|
+
| Requirement | Value |
|
|
95
|
+
|-------------|-------|
|
|
96
|
+
| Runtime | Docker |
|
|
97
|
+
| Credentials | ZOHO_ANALYTICS_CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN, ORG_ID |
|
|
98
|
+
| Status | Beta |
|
|
99
|
+
|
|
100
|
+
#### 5. Zoho Books MCP (Python)
|
|
101
|
+
|
|
102
|
+
Accounting integrations for financial workflows.
|
|
103
|
+
|
|
104
|
+
| Requirement | Value |
|
|
105
|
+
|-------------|-------|
|
|
106
|
+
| Runtime | uvx (Python) |
|
|
107
|
+
| Credentials | ZOHO_CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN, ORGANIZATION_ID |
|
|
108
|
+
| Region | US/EU/IN/AU |
|
|
109
|
+
|
|
110
|
+
#### 6. Google Cloud MCP (Official Preview)
|
|
111
|
+
|
|
112
|
+
GCP resource management for cloud infrastructure projects.
|
|
113
|
+
|
|
114
|
+
| Requirement | Value |
|
|
115
|
+
|-------------|-------|
|
|
116
|
+
| Runtime | npx |
|
|
117
|
+
| Credentials | GOOGLE_APPLICATION_CREDENTIALS (service account key path) |
|
|
118
|
+
|
|
119
|
+
#### 7. BigQuery MCP
|
|
120
|
+
|
|
121
|
+
Read-only data warehouse queries for analytics projects.
|
|
122
|
+
|
|
123
|
+
| Requirement | Value |
|
|
124
|
+
|-------------|-------|
|
|
125
|
+
| Runtime | npx |
|
|
126
|
+
| Credentials | GOOGLE_APPLICATION_CREDENTIALS |
|
|
127
|
+
| Access | Read-only (secure) |
|
|
128
|
+
|
|
129
|
+
#### 8. dbt MCP (Official)
|
|
130
|
+
|
|
131
|
+
Data transformation workflows for medallion architecture (bronze/silver/gold layers).
|
|
132
|
+
|
|
133
|
+
| Requirement | Value |
|
|
134
|
+
|-------------|-------|
|
|
135
|
+
| Runtime | uvx (Python) |
|
|
136
|
+
| Credentials | DBT_HOST, DBT_TOKEN |
|
|
137
|
+
|
|
138
|
+
### Optional MCPs (Project-Specific)
|
|
139
|
+
|
|
140
|
+
#### 9. GitHub MCP
|
|
141
|
+
|
|
142
|
+
PR management, issue tracking, repository operations.
|
|
143
|
+
|
|
144
|
+
| Requirement | Value |
|
|
145
|
+
|-------------|-------|
|
|
146
|
+
| Runtime | npx |
|
|
147
|
+
| Credentials | GITHUB_PERSONAL_ACCESS_TOKEN |
|
|
148
|
+
|
|
149
|
+
#### 10. Filesystem MCP
|
|
150
|
+
|
|
151
|
+
Project file operations scoped to a specific directory.
|
|
152
|
+
|
|
153
|
+
| Requirement | Value |
|
|
154
|
+
|-------------|-------|
|
|
155
|
+
| Runtime | npx |
|
|
156
|
+
| Arg | Project directory path |
|
|
157
|
+
|
|
158
|
+
#### 11. Magic UI MCP
|
|
159
|
+
|
|
160
|
+
150+ animated React components for widget development.
|
|
161
|
+
|
|
162
|
+
| Requirement | Value |
|
|
163
|
+
|-------------|-------|
|
|
164
|
+
| Runtime | npx |
|
|
165
|
+
| Credentials | None |
|
|
166
|
+
|
|
167
|
+
#### 12. Firecrawl MCP
|
|
168
|
+
|
|
169
|
+
Web data extraction for consulting projects.
|
|
170
|
+
|
|
171
|
+
| Requirement | Value |
|
|
172
|
+
|-------------|-------|
|
|
173
|
+
| Runtime | npx |
|
|
174
|
+
| Credentials | FIRECRAWL_API_KEY |
|
|
175
|
+
|
|
176
|
+
## MCP Configuration
|
|
177
|
+
|
|
178
|
+
MCPs are configured in two places:
|
|
179
|
+
|
|
180
|
+
| File | Purpose |
|
|
181
|
+
|------|---------|
|
|
182
|
+
| `.mcp.json` | Active MCPs for current project |
|
|
183
|
+
| `mcp-configs/mcp-servers.json` | Full catalog with documentation |
|
|
184
|
+
|
|
185
|
+
### Adding an MCP to Your Project
|
|
186
|
+
|
|
187
|
+
**Step 1**: Find the MCP in the catalog:
|
|
188
|
+
```bash
|
|
189
|
+
cat mcp-configs/mcp-servers.json
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Step 2**: Copy the configuration to `.mcp.json`:
|
|
193
|
+
```json
|
|
194
|
+
{
|
|
195
|
+
"mcpServers": {
|
|
196
|
+
"github": {
|
|
197
|
+
"command": "npx",
|
|
198
|
+
"args": ["-y", "@modelcontextprotocol/server-github"],
|
|
199
|
+
"env": {
|
|
200
|
+
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here"
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Step 3**: Restart Claude Code session for MCPs to load.
|
|
208
|
+
|
|
209
|
+
## Exercise
|
|
210
|
+
|
|
211
|
+
### Exercise 8.1: Check Active MCPs
|
|
212
|
+
|
|
213
|
+
**Step 1**: View current MCP configuration:
|
|
214
|
+
```bash
|
|
215
|
+
cat .mcp.json
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Step 2**: You should see three MCPs: memory, sequential-thinking, context7.
|
|
219
|
+
|
|
220
|
+
### Exercise 8.2: View MCP Catalog
|
|
221
|
+
|
|
222
|
+
**Step 1**: View all available MCPs:
|
|
223
|
+
```bash
|
|
224
|
+
cat mcp-configs/mcp-servers.json
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
**Step 2**: Notice the different tiers:
|
|
228
|
+
- Core (always enabled)
|
|
229
|
+
- Per-client (based on tech stack)
|
|
230
|
+
- Optional (project-specific)
|
|
231
|
+
|
|
232
|
+
### Exercise 8.3: Verify Memory MCP
|
|
233
|
+
|
|
234
|
+
**Step 1**: Ask Claude to store something:
|
|
235
|
+
```
|
|
236
|
+
Remember that the preferred deployment day is Tuesday.
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Step 2**: In a NEW session, ask:
|
|
240
|
+
```
|
|
241
|
+
What's the preferred deployment day?
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
If memory is working, Claude will recall the preference.
|
|
245
|
+
|
|
246
|
+
### Exercise 8.4: Use Context7
|
|
247
|
+
|
|
248
|
+
**Step 1**: Ask for live documentation:
|
|
249
|
+
```
|
|
250
|
+
Using context7, show me the current React useState hook signature.
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**Step 2**: Notice that Context7 fetches live documentation, not training data.
|
|
254
|
+
|
|
255
|
+
## Troubleshooting
|
|
256
|
+
|
|
257
|
+
| Issue | Cause | Fix |
|
|
258
|
+
|-------|-------|-----|
|
|
259
|
+
| MCP won't start | Package not found | Run `npx -y @package/name` manually first |
|
|
260
|
+
| Auth errors | Invalid credentials | Check environment variables in .mcp.json |
|
|
261
|
+
| Docker MCPs fail | Docker not running | Start Docker Desktop |
|
|
262
|
+
| uvx MCPs fail | Python not installed | Install Python 3.10+ with pip |
|
|
263
|
+
| Memory not persisting | Invalid file path | Check MEMORY_FILE_PATH exists |
|
|
264
|
+
|
|
265
|
+
## Security Best Practices
|
|
266
|
+
|
|
267
|
+
1. **Never commit credentials** - Use environment variables, not hardcoded values
|
|
268
|
+
2. **Separate tokens per client** - Don't share credentials across clients
|
|
269
|
+
3. **Rotate GCP keys quarterly** - Service account best practice
|
|
270
|
+
4. **Minimum scopes** - Only request the API permissions you need
|
|
271
|
+
5. **Read-only where possible** - BigQuery is read-only for safety
|
|
272
|
+
|
|
273
|
+
## Verification
|
|
274
|
+
|
|
275
|
+
You've completed this exercise successfully if:
|
|
276
|
+
- [ ] You found `.mcp.json` and `mcp-configs/mcp-servers.json`
|
|
277
|
+
- [ ] You understand the 3 MCP tiers (Core, Per-Client, Optional)
|
|
278
|
+
- [ ] You know what each of the 12 MCPs does
|
|
279
|
+
- [ ] You tested memory persistence (or understand why it might not work if not configured)
|
|
280
|
+
|
|
281
|
+
## Key Takeaway
|
|
282
|
+
|
|
283
|
+
MCPs extend Claude Code's capabilities beyond text generation. The three core MCPs (memory, sequential-thinking, context7) should always be configured. Add per-client MCPs based on the tech stack.
|
|
284
|
+
|
|
285
|
+
## MCP Quick Reference
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
CORE (always enabled):
|
|
289
|
+
- memory: Knowledge graph persistence
|
|
290
|
+
- sequential-thinking: Complex reasoning
|
|
291
|
+
- context7: Live documentation
|
|
292
|
+
|
|
293
|
+
PER-CLIENT:
|
|
294
|
+
- zoho-analytics: Dashboards (Docker)
|
|
295
|
+
- zoho-books: Accounting (Python)
|
|
296
|
+
- gcloud: GCP resources
|
|
297
|
+
- bigquery: Data warehouse (read-only)
|
|
298
|
+
- dbt: Data transformation
|
|
299
|
+
|
|
300
|
+
OPTIONAL:
|
|
301
|
+
- github: PR/issue management
|
|
302
|
+
- filesystem: File operations
|
|
303
|
+
- magic: UI components
|
|
304
|
+
- firecrawl: Web extraction
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Next Steps
|
|
308
|
+
|
|
309
|
+
In Lesson 9, you'll learn about client management commands for multi-client context switching and handoff documentation.
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
**MCPs learned**: 12 MCPs across 3 tiers
|
|
314
|
+
**Key files**: `.mcp.json`, `mcp-configs/mcp-servers.json`
|
|
315
|
+
**Reference**: MCP-SETUP-GUIDE.md for detailed installation
|
|
316
|
+
**Progress**: 9 of 15 lessons complete
|