cmp-standards 2.0.1 → 2.6.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 +633 -541
- package/dist/cli/index.js +239 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/dashboard/server.d.ts.map +1 -1
- package/dist/dashboard/server.js +203 -39
- package/dist/dashboard/server.js.map +1 -1
- package/dist/db/cloud.d.ts +174 -0
- package/dist/db/cloud.d.ts.map +1 -0
- package/dist/db/cloud.js +241 -0
- package/dist/db/cloud.js.map +1 -0
- package/dist/db/drizzle-client.d.ts +3 -3
- package/dist/db/drizzle-client.d.ts.map +1 -1
- package/dist/db/drizzle-client.js +57 -58
- package/dist/db/drizzle-client.js.map +1 -1
- package/dist/db/errors.d.ts +76 -0
- package/dist/db/errors.d.ts.map +1 -0
- package/dist/db/errors.js +135 -0
- package/dist/db/errors.js.map +1 -0
- package/dist/db/turso-client.d.ts +178 -0
- package/dist/db/turso-client.d.ts.map +1 -0
- package/dist/db/turso-client.js +455 -0
- package/dist/db/turso-client.js.map +1 -0
- package/dist/db/upstash-client.d.ts +161 -0
- package/dist/db/upstash-client.d.ts.map +1 -0
- package/dist/db/upstash-client.js +325 -0
- package/dist/db/upstash-client.js.map +1 -0
- package/dist/eslint/rules/no-async-useeffect.js +6 -6
- package/dist/hooks/cloud-post-tool-use.d.ts +30 -0
- package/dist/hooks/cloud-post-tool-use.d.ts.map +1 -0
- package/dist/hooks/cloud-post-tool-use.js +116 -0
- package/dist/hooks/cloud-post-tool-use.js.map +1 -0
- package/dist/hooks/cloud-pre-tool-use.d.ts +19 -0
- package/dist/hooks/cloud-pre-tool-use.d.ts.map +1 -0
- package/dist/hooks/cloud-pre-tool-use.js +149 -0
- package/dist/hooks/cloud-pre-tool-use.js.map +1 -0
- package/dist/hooks/cloud-session-start.d.ts +32 -0
- package/dist/hooks/cloud-session-start.d.ts.map +1 -0
- package/dist/hooks/cloud-session-start.js +257 -0
- package/dist/hooks/cloud-session-start.js.map +1 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/memory-checkpoint.d.ts.map +1 -1
- package/dist/hooks/memory-checkpoint.js +12 -20
- package/dist/hooks/memory-checkpoint.js.map +1 -1
- package/dist/hooks/pre-tool-use.d.ts +2 -8
- package/dist/hooks/pre-tool-use.d.ts.map +1 -1
- package/dist/hooks/pre-tool-use.js +7 -106
- package/dist/hooks/pre-tool-use.js.map +1 -1
- package/dist/hooks/session-start.d.ts +2 -1
- package/dist/hooks/session-start.d.ts.map +1 -1
- package/dist/hooks/session-start.js +111 -77
- package/dist/hooks/session-start.js.map +1 -1
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +225 -2
- package/dist/mcp/server.js.map +1 -1
- package/dist/schema/plans.d.ts +194 -0
- package/dist/schema/plans.d.ts.map +1 -0
- package/dist/schema/plans.js +180 -0
- package/dist/schema/plans.js.map +1 -0
- package/dist/schema/tracking.d.ts +644 -0
- package/dist/schema/tracking.d.ts.map +1 -0
- package/dist/schema/tracking.js +204 -0
- package/dist/schema/tracking.js.map +1 -0
- package/dist/services/ContextGenerator.d.ts +16 -0
- package/dist/services/ContextGenerator.d.ts.map +1 -0
- package/dist/services/ContextGenerator.js +62 -0
- package/dist/services/ContextGenerator.js.map +1 -0
- package/dist/services/PlanManager.d.ts +99 -0
- package/dist/services/PlanManager.d.ts.map +1 -0
- package/dist/services/PlanManager.js +372 -0
- package/dist/services/PlanManager.js.map +1 -0
- package/dist/services/ProjectScaffold.d.ts.map +1 -1
- package/dist/services/ProjectScaffold.js +109 -81
- package/dist/services/ProjectScaffold.js.map +1 -1
- package/dist/services/TaskTracker.d.ts +1 -1
- package/dist/services/TaskTracker.d.ts.map +1 -1
- package/dist/services/TaskTracker.js +4 -8
- package/dist/services/TaskTracker.js.map +1 -1
- package/dist/services/WorkPlanManager.d.ts +1 -1
- package/dist/services/WorkPlanManager.d.ts.map +1 -1
- package/dist/services/WorkPlanManager.js +8 -14
- package/dist/services/WorkPlanManager.js.map +1 -1
- package/dist/services/auto-inject.d.ts +1 -0
- package/dist/services/auto-inject.d.ts.map +1 -1
- package/dist/services/auto-inject.js +12 -17
- package/dist/services/auto-inject.js.map +1 -1
- package/dist/services/context-injector.d.ts +105 -0
- package/dist/services/context-injector.d.ts.map +1 -0
- package/dist/services/context-injector.js +357 -0
- package/dist/services/context-injector.js.map +1 -0
- package/dist/services/cross-project-sync.d.ts +2 -0
- package/dist/services/cross-project-sync.d.ts.map +1 -1
- package/dist/services/cross-project-sync.js +26 -21
- package/dist/services/cross-project-sync.js.map +1 -1
- package/dist/services/index.d.ts +15 -15
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +18 -20
- package/dist/services/index.js.map +1 -1
- package/dist/services/memory-consolidation.d.ts.map +1 -1
- package/dist/services/memory-consolidation.js +30 -27
- package/dist/services/memory-consolidation.js.map +1 -1
- package/dist/services/memory-router.d.ts +98 -0
- package/dist/services/memory-router.d.ts.map +1 -0
- package/dist/services/memory-router.js +373 -0
- package/dist/services/memory-router.js.map +1 -0
- package/dist/services/pattern-tracker.d.ts +93 -0
- package/dist/services/pattern-tracker.d.ts.map +1 -0
- package/dist/services/pattern-tracker.js +347 -0
- package/dist/services/pattern-tracker.js.map +1 -0
- package/dist/services/semantic-search.d.ts +33 -35
- package/dist/services/semantic-search.d.ts.map +1 -1
- package/dist/services/semantic-search.js +207 -165
- package/dist/services/semantic-search.js.map +1 -1
- package/dist/utils/env-loader.d.ts +41 -0
- package/dist/utils/env-loader.d.ts.map +1 -0
- package/dist/utils/env-loader.js +78 -0
- package/dist/utils/env-loader.js.map +1 -0
- package/dist/utils/git.d.ts +52 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +267 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/paths.d.ts +39 -5
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +88 -7
- package/dist/utils/paths.js.map +1 -1
- package/package.json +100 -94
- package/standards/README.md +50 -0
- package/standards/experts/expert-routing.md +215 -0
- package/standards/general/code-quality.md +86 -0
- package/standards/general/memory-usage.md +205 -0
- package/standards/general/sync-workflow.md +235 -0
- package/standards/general/workflow.md +82 -0
- package/standards/hooks/mandatory-tracking.md +446 -0
- package/standards/infrastructure/cloud-database.md +287 -0
- package/standards/mcp/server-design.md +243 -0
- package/standards/mcp/tool-patterns.md +354 -0
- package/standards/skills/skill-structure.md +286 -0
- package/standards/skills/workflow-design.md +323 -0
- package/standards/tools/tool-design.md +297 -0
- package/templates/agents/architecture-expert.md +61 -61
- package/templates/agents/database-expert.md +62 -62
- package/templates/agents/documentation-expert.md +57 -57
- package/templates/agents/memory-expert.md +88 -88
- package/templates/agents/performance-expert.md +61 -61
- package/templates/agents/security-expert.md +59 -59
- package/templates/agents/ux-expert.md +63 -63
- package/templates/agents/worker.md +75 -75
- package/templates/ai-skills/SKILL_TEMPLATE.md +55 -55
- package/templates/claude-settings.json +72 -0
- package/templates/commands/experts.md +138 -138
- package/templates/hooks/README.md +158 -158
- package/templates/hooks/project.config.json.template +77 -77
- package/templates/hooks/settings.local.json.template +57 -57
- package/templates/memory-config.json +56 -82
- package/templates/memory-config.schema.json +212 -212
- package/templates/settings.json +58 -58
- package/templates/skills/continue.md +205 -0
- package/templates/workflows/business-improvement.md +264 -264
- package/templates/workflows/expert-review.md +153 -153
- package/templates/workflows/internal-app.md +245 -245
- package/templates/workflows/sync-docs.md +187 -187
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
## /experts - AI Code Review System
|
|
2
|
-
|
|
3
|
-
> **Purpose**: Multi-expert code review with consensus voting
|
|
4
|
-
> **Usage**: `/experts [files or task description]`
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Overview
|
|
9
|
-
|
|
10
|
-
The `/experts` command launches a panel of AI experts to review your code:
|
|
11
|
-
|
|
12
|
-
1. **Security Expert** - SQL injection, auth, input validation
|
|
13
|
-
2. **Performance Expert** - Waterfalls, N+1, lazy loading
|
|
14
|
-
3. **Architecture Expert** - Types, modules, SOLID principles
|
|
15
|
-
4. **UX Expert** - Accessibility, mobile-first, design tokens
|
|
16
|
-
5. **Database Expert** - Schema, migrations, queries
|
|
17
|
-
6. **Memory Expert** - Pattern detection, auto-improvement
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Usage Examples
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
# Review specific file
|
|
25
|
-
/experts src/components/UserForm.tsx
|
|
26
|
-
|
|
27
|
-
# Review directory
|
|
28
|
-
/experts src/server/api/routers/
|
|
29
|
-
|
|
30
|
-
# Review with context
|
|
31
|
-
/experts "Review the new authentication flow"
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
## How It Works
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
1. ANALYZE CODE
|
|
40
|
-
• Detect criticality (CRITICAL vs NORMAL)
|
|
41
|
-
• Select relevant experts
|
|
42
|
-
|
|
43
|
-
2. PARALLEL REVIEW (30-45 seconds)
|
|
44
|
-
• Each expert reviews independently
|
|
45
|
-
• Generates vote and findings
|
|
46
|
-
|
|
47
|
-
3. CONSENSUS VOTING
|
|
48
|
-
• CRITICAL: Unanimity required (0 REJECT)
|
|
49
|
-
• NORMAL: Majority required (3/5 APPROVE)
|
|
50
|
-
|
|
51
|
-
4. RESULT
|
|
52
|
-
• APPROVED → Verification runs
|
|
53
|
-
• REJECTED → Detailed feedback provided
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## Criticality Detection
|
|
59
|
-
|
|
60
|
-
Code is **CRITICAL** if it involves:
|
|
61
|
-
- Authentication/Authorization
|
|
62
|
-
- Financial operations
|
|
63
|
-
- Database schema changes
|
|
64
|
-
- External payment integrations
|
|
65
|
-
|
|
66
|
-
Critical code requires **unanimous approval** (no REJECT votes).
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
## Expert Responsibilities
|
|
71
|
-
|
|
72
|
-
| Expert | Checks | Rejects On |
|
|
73
|
-
|--------|--------|------------|
|
|
74
|
-
| Security | SQL injection, auth, validation | Any security hole |
|
|
75
|
-
| Performance | N+1, waterfalls, bundle size | Critical perf issues |
|
|
76
|
-
| Architecture | Types, modules, SOLID | Type violations |
|
|
77
|
-
| UX | A11y, mobile, tokens | Missing accessibility |
|
|
78
|
-
| Database | Schema, migrations | Data loss risk |
|
|
79
|
-
| Memory | Patterns | Never (ABSTAIN) |
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
## Output Example
|
|
84
|
-
|
|
85
|
-
```
|
|
86
|
-
## Expert Review
|
|
87
|
-
Files: 1
|
|
88
|
-
Criticality: NORMAL
|
|
89
|
-
Experts: Security, Performance, Architecture, UX (4)
|
|
90
|
-
|
|
91
|
-
[30 seconds - parallel review]
|
|
92
|
-
|
|
93
|
-
✅ APPROVED (4/4)
|
|
94
|
-
Security: ✓ APPROVE
|
|
95
|
-
Performance: ✓ APPROVE
|
|
96
|
-
Architecture: ✓ APPROVE
|
|
97
|
-
UX: ✓ APPROVE
|
|
98
|
-
|
|
99
|
-
Running verification...
|
|
100
|
-
✓ typecheck passed
|
|
101
|
-
✓ lint passed
|
|
102
|
-
|
|
103
|
-
All checks passed! ✅
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
---
|
|
107
|
-
|
|
108
|
-
## When to Use
|
|
109
|
-
|
|
110
|
-
✅ **Use /experts for:**
|
|
111
|
-
- Critical changes (auth, payments, schema)
|
|
112
|
-
- Before submitting PRs
|
|
113
|
-
- Large refactors
|
|
114
|
-
- Learning (get feedback)
|
|
115
|
-
|
|
116
|
-
❌ **Don't use for:**
|
|
117
|
-
- WIP code
|
|
118
|
-
- Trivial changes (typos)
|
|
119
|
-
- Generated code
|
|
120
|
-
|
|
121
|
-
---
|
|
122
|
-
|
|
123
|
-
## Advanced Options
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
# Review specific experts only
|
|
127
|
-
/experts src/file.ts --only security,architecture
|
|
128
|
-
|
|
129
|
-
# Verbose output (show reasoning)
|
|
130
|
-
/experts src/file.ts --verbose
|
|
131
|
-
|
|
132
|
-
# Dry run (no auto-improvements)
|
|
133
|
-
/experts src/file.ts --dry-run
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
*Part of cmp-memory-system - MetaNautical Group*
|
|
1
|
+
## /experts - AI Code Review System
|
|
2
|
+
|
|
3
|
+
> **Purpose**: Multi-expert code review with consensus voting
|
|
4
|
+
> **Usage**: `/experts [files or task description]`
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
The `/experts` command launches a panel of AI experts to review your code:
|
|
11
|
+
|
|
12
|
+
1. **Security Expert** - SQL injection, auth, input validation
|
|
13
|
+
2. **Performance Expert** - Waterfalls, N+1, lazy loading
|
|
14
|
+
3. **Architecture Expert** - Types, modules, SOLID principles
|
|
15
|
+
4. **UX Expert** - Accessibility, mobile-first, design tokens
|
|
16
|
+
5. **Database Expert** - Schema, migrations, queries
|
|
17
|
+
6. **Memory Expert** - Pattern detection, auto-improvement
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Usage Examples
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Review specific file
|
|
25
|
+
/experts src/components/UserForm.tsx
|
|
26
|
+
|
|
27
|
+
# Review directory
|
|
28
|
+
/experts src/server/api/routers/
|
|
29
|
+
|
|
30
|
+
# Review with context
|
|
31
|
+
/experts "Review the new authentication flow"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## How It Works
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
1. ANALYZE CODE
|
|
40
|
+
• Detect criticality (CRITICAL vs NORMAL)
|
|
41
|
+
• Select relevant experts
|
|
42
|
+
|
|
43
|
+
2. PARALLEL REVIEW (30-45 seconds)
|
|
44
|
+
• Each expert reviews independently
|
|
45
|
+
• Generates vote and findings
|
|
46
|
+
|
|
47
|
+
3. CONSENSUS VOTING
|
|
48
|
+
• CRITICAL: Unanimity required (0 REJECT)
|
|
49
|
+
• NORMAL: Majority required (3/5 APPROVE)
|
|
50
|
+
|
|
51
|
+
4. RESULT
|
|
52
|
+
• APPROVED → Verification runs
|
|
53
|
+
• REJECTED → Detailed feedback provided
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Criticality Detection
|
|
59
|
+
|
|
60
|
+
Code is **CRITICAL** if it involves:
|
|
61
|
+
- Authentication/Authorization
|
|
62
|
+
- Financial operations
|
|
63
|
+
- Database schema changes
|
|
64
|
+
- External payment integrations
|
|
65
|
+
|
|
66
|
+
Critical code requires **unanimous approval** (no REJECT votes).
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Expert Responsibilities
|
|
71
|
+
|
|
72
|
+
| Expert | Checks | Rejects On |
|
|
73
|
+
|--------|--------|------------|
|
|
74
|
+
| Security | SQL injection, auth, validation | Any security hole |
|
|
75
|
+
| Performance | N+1, waterfalls, bundle size | Critical perf issues |
|
|
76
|
+
| Architecture | Types, modules, SOLID | Type violations |
|
|
77
|
+
| UX | A11y, mobile, tokens | Missing accessibility |
|
|
78
|
+
| Database | Schema, migrations | Data loss risk |
|
|
79
|
+
| Memory | Patterns | Never (ABSTAIN) |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Output Example
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
## Expert Review
|
|
87
|
+
Files: 1
|
|
88
|
+
Criticality: NORMAL
|
|
89
|
+
Experts: Security, Performance, Architecture, UX (4)
|
|
90
|
+
|
|
91
|
+
[30 seconds - parallel review]
|
|
92
|
+
|
|
93
|
+
✅ APPROVED (4/4)
|
|
94
|
+
Security: ✓ APPROVE
|
|
95
|
+
Performance: ✓ APPROVE
|
|
96
|
+
Architecture: ✓ APPROVE
|
|
97
|
+
UX: ✓ APPROVE
|
|
98
|
+
|
|
99
|
+
Running verification...
|
|
100
|
+
✓ typecheck passed
|
|
101
|
+
✓ lint passed
|
|
102
|
+
|
|
103
|
+
All checks passed! ✅
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## When to Use
|
|
109
|
+
|
|
110
|
+
✅ **Use /experts for:**
|
|
111
|
+
- Critical changes (auth, payments, schema)
|
|
112
|
+
- Before submitting PRs
|
|
113
|
+
- Large refactors
|
|
114
|
+
- Learning (get feedback)
|
|
115
|
+
|
|
116
|
+
❌ **Don't use for:**
|
|
117
|
+
- WIP code
|
|
118
|
+
- Trivial changes (typos)
|
|
119
|
+
- Generated code
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Advanced Options
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Review specific experts only
|
|
127
|
+
/experts src/file.ts --only security,architecture
|
|
128
|
+
|
|
129
|
+
# Verbose output (show reasoning)
|
|
130
|
+
/experts src/file.ts --verbose
|
|
131
|
+
|
|
132
|
+
# Dry run (no auto-improvements)
|
|
133
|
+
/experts src/file.ts --dry-run
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
*Part of cmp-memory-system - MetaNautical Group*
|
|
@@ -1,158 +1,158 @@
|
|
|
1
|
-
# Claude Code Hooks Configuration
|
|
2
|
-
|
|
3
|
-
This directory contains hook templates for Claude Code integration.
|
|
4
|
-
|
|
5
|
-
## Available Hooks
|
|
6
|
-
|
|
7
|
-
| Hook | When | Purpose |
|
|
8
|
-
|:---|:---|:---|
|
|
9
|
-
| `SessionStart` | Session begins | Load context, memories, work plan |
|
|
10
|
-
| `PreToolUse` | Before tool runs | Guards, validation, knowledge injection |
|
|
11
|
-
| `PostToolUse` | After tool runs | Change tracking, checkpoints |
|
|
12
|
-
| `NotificationReceived` | On notifications | Custom notification handling |
|
|
13
|
-
| `PromptSubmit` | Before prompt | Pre-processing user input |
|
|
14
|
-
| `SubagentStop` | Agent completes | Post-agent processing |
|
|
15
|
-
|
|
16
|
-
## Configuration
|
|
17
|
-
|
|
18
|
-
Add to your `.claude/settings.local.json`:
|
|
19
|
-
|
|
20
|
-
```json
|
|
21
|
-
{
|
|
22
|
-
"hooks": {
|
|
23
|
-
"SessionStart": [
|
|
24
|
-
{
|
|
25
|
-
"matcher": "*",
|
|
26
|
-
"hooks": [
|
|
27
|
-
{
|
|
28
|
-
"type": "command",
|
|
29
|
-
"command": "npx cmp-memory session-context"
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
"PreToolUse": [
|
|
35
|
-
{
|
|
36
|
-
"matcher": "Edit|Write",
|
|
37
|
-
"hooks": [
|
|
38
|
-
{
|
|
39
|
-
"type": "command",
|
|
40
|
-
"command": "npx cmp-memory pre-tool-guard $EVENT"
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
}
|
|
44
|
-
],
|
|
45
|
-
"PostToolUse": [
|
|
46
|
-
{
|
|
47
|
-
"matcher": "Edit|Write",
|
|
48
|
-
"hooks": [
|
|
49
|
-
{
|
|
50
|
-
"type": "command",
|
|
51
|
-
"command": "npx cmp-memory post-tool-record $EVENT"
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Environment Variables
|
|
61
|
-
|
|
62
|
-
Required for full functionality:
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
# Database connection (for memory persistence)
|
|
66
|
-
DATABASE_URL="mysql://user:pass@host:port/database"
|
|
67
|
-
|
|
68
|
-
# Embedding (for semantic search - optional)
|
|
69
|
-
OPENAI_API_KEY="sk-..."
|
|
70
|
-
# or
|
|
71
|
-
GEMINI_API_KEY="..."
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## Guard Rules
|
|
75
|
-
|
|
76
|
-
Define guards in `project.config.json`:
|
|
77
|
-
|
|
78
|
-
```json
|
|
79
|
-
{
|
|
80
|
-
"guards": {
|
|
81
|
-
"enabled": true,
|
|
82
|
-
"rules": [
|
|
83
|
-
{
|
|
84
|
-
"id": "no-modify-auth",
|
|
85
|
-
"type": "block",
|
|
86
|
-
"filePattern": "**/auth/**",
|
|
87
|
-
"message": "Auth files require explicit approval",
|
|
88
|
-
"excludeFiles": ["**/*.test.ts"]
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
"id": "no-raw-sql",
|
|
92
|
-
"type": "warn",
|
|
93
|
-
"filePattern": "**/*.ts",
|
|
94
|
-
"contentTrigger": "\\$\\{[^}]+\\}.*(?:SELECT|INSERT|UPDATE|DELETE)",
|
|
95
|
-
"message": "Potential SQL injection - use parameterized queries"
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
## Custom Hooks
|
|
103
|
-
|
|
104
|
-
Create custom hook scripts in `.claude/hooks/`:
|
|
105
|
-
|
|
106
|
-
```bash
|
|
107
|
-
#!/bin/bash
|
|
108
|
-
# .claude/hooks/my-custom-hook.sh
|
|
109
|
-
|
|
110
|
-
# Access event data
|
|
111
|
-
EVENT_DATA="$1"
|
|
112
|
-
|
|
113
|
-
# Parse with jq if needed
|
|
114
|
-
TOOL_NAME=$(echo "$EVENT_DATA" | jq -r '.tool_name')
|
|
115
|
-
|
|
116
|
-
# Your logic here
|
|
117
|
-
echo "Tool called: $TOOL_NAME"
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Register in settings:
|
|
121
|
-
|
|
122
|
-
```json
|
|
123
|
-
{
|
|
124
|
-
"hooks": {
|
|
125
|
-
"PreToolUse": [
|
|
126
|
-
{
|
|
127
|
-
"matcher": "*",
|
|
128
|
-
"hooks": [
|
|
129
|
-
{
|
|
130
|
-
"type": "command",
|
|
131
|
-
"command": ".claude/hooks/my-custom-hook.sh $EVENT"
|
|
132
|
-
}
|
|
133
|
-
]
|
|
134
|
-
}
|
|
135
|
-
]
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## Troubleshooting
|
|
141
|
-
|
|
142
|
-
### Hook not running
|
|
143
|
-
- Check that hook command is executable
|
|
144
|
-
- Verify matcher pattern matches the tool name
|
|
145
|
-
- Check `.claude/settings.local.json` syntax
|
|
146
|
-
|
|
147
|
-
### Guards not blocking
|
|
148
|
-
- Ensure `guards.enabled: true` in `project.config.json`
|
|
149
|
-
- Verify file patterns match (use glob syntax)
|
|
150
|
-
- Check that rule `type` is "block" not "warn"
|
|
151
|
-
|
|
152
|
-
### Memory not persisting
|
|
153
|
-
- Verify `DATABASE_URL` is set
|
|
154
|
-
- Check database connection with `npx cmp-memory status`
|
|
155
|
-
|
|
156
|
-
---
|
|
157
|
-
|
|
158
|
-
For more information, see the [cmp-memory-system documentation](https://github.com/carlosmartinpavon/carlosmartinpavon).
|
|
1
|
+
# Claude Code Hooks Configuration
|
|
2
|
+
|
|
3
|
+
This directory contains hook templates for Claude Code integration.
|
|
4
|
+
|
|
5
|
+
## Available Hooks
|
|
6
|
+
|
|
7
|
+
| Hook | When | Purpose |
|
|
8
|
+
|:---|:---|:---|
|
|
9
|
+
| `SessionStart` | Session begins | Load context, memories, work plan |
|
|
10
|
+
| `PreToolUse` | Before tool runs | Guards, validation, knowledge injection |
|
|
11
|
+
| `PostToolUse` | After tool runs | Change tracking, checkpoints |
|
|
12
|
+
| `NotificationReceived` | On notifications | Custom notification handling |
|
|
13
|
+
| `PromptSubmit` | Before prompt | Pre-processing user input |
|
|
14
|
+
| `SubagentStop` | Agent completes | Post-agent processing |
|
|
15
|
+
|
|
16
|
+
## Configuration
|
|
17
|
+
|
|
18
|
+
Add to your `.claude/settings.local.json`:
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"hooks": {
|
|
23
|
+
"SessionStart": [
|
|
24
|
+
{
|
|
25
|
+
"matcher": "*",
|
|
26
|
+
"hooks": [
|
|
27
|
+
{
|
|
28
|
+
"type": "command",
|
|
29
|
+
"command": "npx cmp-memory session-context"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"PreToolUse": [
|
|
35
|
+
{
|
|
36
|
+
"matcher": "Edit|Write",
|
|
37
|
+
"hooks": [
|
|
38
|
+
{
|
|
39
|
+
"type": "command",
|
|
40
|
+
"command": "npx cmp-memory pre-tool-guard $EVENT"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"PostToolUse": [
|
|
46
|
+
{
|
|
47
|
+
"matcher": "Edit|Write",
|
|
48
|
+
"hooks": [
|
|
49
|
+
{
|
|
50
|
+
"type": "command",
|
|
51
|
+
"command": "npx cmp-memory post-tool-record $EVENT"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Environment Variables
|
|
61
|
+
|
|
62
|
+
Required for full functionality:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Database connection (for memory persistence)
|
|
66
|
+
DATABASE_URL="mysql://user:pass@host:port/database"
|
|
67
|
+
|
|
68
|
+
# Embedding (for semantic search - optional)
|
|
69
|
+
OPENAI_API_KEY="sk-..."
|
|
70
|
+
# or
|
|
71
|
+
GEMINI_API_KEY="..."
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Guard Rules
|
|
75
|
+
|
|
76
|
+
Define guards in `project.config.json`:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"guards": {
|
|
81
|
+
"enabled": true,
|
|
82
|
+
"rules": [
|
|
83
|
+
{
|
|
84
|
+
"id": "no-modify-auth",
|
|
85
|
+
"type": "block",
|
|
86
|
+
"filePattern": "**/auth/**",
|
|
87
|
+
"message": "Auth files require explicit approval",
|
|
88
|
+
"excludeFiles": ["**/*.test.ts"]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"id": "no-raw-sql",
|
|
92
|
+
"type": "warn",
|
|
93
|
+
"filePattern": "**/*.ts",
|
|
94
|
+
"contentTrigger": "\\$\\{[^}]+\\}.*(?:SELECT|INSERT|UPDATE|DELETE)",
|
|
95
|
+
"message": "Potential SQL injection - use parameterized queries"
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Custom Hooks
|
|
103
|
+
|
|
104
|
+
Create custom hook scripts in `.claude/hooks/`:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
#!/bin/bash
|
|
108
|
+
# .claude/hooks/my-custom-hook.sh
|
|
109
|
+
|
|
110
|
+
# Access event data
|
|
111
|
+
EVENT_DATA="$1"
|
|
112
|
+
|
|
113
|
+
# Parse with jq if needed
|
|
114
|
+
TOOL_NAME=$(echo "$EVENT_DATA" | jq -r '.tool_name')
|
|
115
|
+
|
|
116
|
+
# Your logic here
|
|
117
|
+
echo "Tool called: $TOOL_NAME"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Register in settings:
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"hooks": {
|
|
125
|
+
"PreToolUse": [
|
|
126
|
+
{
|
|
127
|
+
"matcher": "*",
|
|
128
|
+
"hooks": [
|
|
129
|
+
{
|
|
130
|
+
"type": "command",
|
|
131
|
+
"command": ".claude/hooks/my-custom-hook.sh $EVENT"
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Troubleshooting
|
|
141
|
+
|
|
142
|
+
### Hook not running
|
|
143
|
+
- Check that hook command is executable
|
|
144
|
+
- Verify matcher pattern matches the tool name
|
|
145
|
+
- Check `.claude/settings.local.json` syntax
|
|
146
|
+
|
|
147
|
+
### Guards not blocking
|
|
148
|
+
- Ensure `guards.enabled: true` in `project.config.json`
|
|
149
|
+
- Verify file patterns match (use glob syntax)
|
|
150
|
+
- Check that rule `type` is "block" not "warn"
|
|
151
|
+
|
|
152
|
+
### Memory not persisting
|
|
153
|
+
- Verify `DATABASE_URL` is set
|
|
154
|
+
- Check database connection with `npx cmp-memory status`
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
For more information, see the [cmp-memory-system documentation](https://github.com/carlosmartinpavon/carlosmartinpavon).
|