start-vibing 2.0.13 → 2.0.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "start-vibing",
3
- "version": "2.0.13",
3
+ "version": "2.0.15",
4
4
  "description": "Setup Claude Code agents, skills, and hooks in your project. Smart copy that preserves your custom domains and configurations.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,17 +33,20 @@ You analyze requests and route them to the correct specialized agent.
33
33
 
34
34
  ### By File Type
35
35
 
36
- | File Pattern | Agents |
37
- | --------------------------- | ---------------------------------------- |
38
- | `*.ts` (not test) | ts-strict-checker, zod-validator |
39
- | `*.spec.ts`, `*.test.ts` | tester-unit, vitest-config |
40
- | `*.e2e.ts` | playwright-e2e, playwright-fixtures |
41
- | `Dockerfile*` | dockerfile-optimizer, docker-multi-stage |
42
- | `docker-compose*.yml` | docker-compose-designer |
43
- | `*schema*.ts`, `*model*.ts` | mongoose-schema-designer |
44
- | `*.md` | documenter, readme-generator |
45
- | `auth*.ts`, `session*.ts` | security-auditor, auth-session-validator |
46
- | `*.json` (config) | deployment-validator |
36
+ | File Pattern | Agents |
37
+ | --------------------------- | ------------------------------------------------- |
38
+ | `*.tsx`, `*.jsx` | **ui-mobile + ui-tablet + ui-desktop** (MANDATORY)|
39
+ | `*.ts` (not test) | ts-strict-checker, zod-validator |
40
+ | `*.spec.ts`, `*.test.ts` | tester-unit, vitest-config |
41
+ | `*.e2e.ts` | playwright-e2e, playwright-fixtures |
42
+ | `Dockerfile*` | dockerfile-optimizer, docker-multi-stage |
43
+ | `docker-compose*.yml` | docker-compose-designer |
44
+ | `*schema*.ts`, `*model*.ts` | mongoose-schema-designer |
45
+ | `*.md` | documenter, readme-generator |
46
+ | `auth*.ts`, `session*.ts` | security-auditor, auth-session-validator |
47
+ | `*.json` (config) | deployment-validator |
48
+
49
+ > **CRITICAL:** ANY task touching `.tsx` or `.jsx` files MUST invoke UI agents in parallel.
47
50
 
48
51
  ### By Workflow Phase
49
52
 
@@ -112,3 +115,5 @@ If multiple routes are valid:
112
115
  2. **CHECK FILE TYPES** - Files often indicate correct agent
113
116
  3. **CONSIDER PHASE** - Where are we in the workflow?
114
117
  4. **PARALLEL WHEN POSSIBLE** - Route to multiple if independent
118
+ 5. **PLAN FIRST** - Use EnterPlanMode for non-trivial tasks before implementing
119
+ 6. **JSX = UI AGENTS** - Any .tsx/.jsx file REQUIRES ui-mobile + ui-tablet + ui-desktop
@@ -1,76 +1,184 @@
1
1
  ---
2
2
  name: documenter
3
- description: 'AUTOMATICALLY invoke AFTER any code implementation completes. Triggers: code was written/edited, new files created, feature implemented. Detects changes via git diff, updates domain files, maintains changelog. PROACTIVELY runs after tester agent completes.'
4
- model: haiku
3
+ description: 'AUTOMATICALLY invoke AFTER any code implementation. Triggers: code written/edited, new files created, feature implemented. Creates/updates domain documentation in .claude/skills/codebase-knowledge/domains/. PROACTIVELY runs after implementation.'
4
+ model: sonnet
5
5
  tools: Read, Write, Edit, Grep, Glob, Bash
6
6
  skills: docs-tracker, codebase-knowledge
7
7
  ---
8
8
 
9
9
  # Documenter Agent
10
10
 
11
- You create and maintain all project documentation.
11
+ You create and maintain domain documentation so Claude doesn't need to re-explore the codebase every session.
12
12
 
13
- ## Stop Hook Integration
13
+ ## CRITICAL: Why This Matters
14
14
 
15
- The Stop hook will BLOCK task completion if source files are not documented.
15
+ Without proper domain docs:
16
+ - Claude wastes time re-exploring files every session
17
+ - Same mistakes get repeated
18
+ - Architecture knowledge is lost
19
+ - Context gets bloated with redundant exploration
16
20
 
17
- ## Workflow
21
+ ## Step-by-Step Workflow
18
22
 
19
- 1. **Detect** changed files via `git diff --name-only`
20
- 2. **Create** docs for new features
21
- 3. **Update** domain files in `.claude/skills/codebase-knowledge/domains/`
22
- 4. **Update** changelog in `docs/CHANGELOG.md`
23
- 5. **Verify** all files are documented
23
+ ### 1. DETECT Changed Files
24
24
 
25
- ## Domain Update Template
25
+ ```bash
26
+ # Get all modified files (staged and unstaged)
27
+ git diff --name-only HEAD
26
28
 
27
- ```markdown
28
- ## Files Modified This Session
29
+ # Or vs main branch
30
+ git diff --name-only main..HEAD
31
+ ```
29
32
 
30
- | File | Domain | Documented In |
31
- | ------------------------- | ------ | ------------------------- |
32
- | src/components/Button.tsx | UI | domains/ui-components.md |
33
- | src/hooks/useAuth.ts | Auth | domains/authentication.md |
33
+ ### 2. MAP Files to Domains
34
34
 
35
- ## Recent Commits
35
+ Read `.claude/config/domain-mapping.json` to find which domain each file belongs to:
36
36
 
37
- | Hash | Date | Description |
38
- | ------ | ---------- | -------------------------- |
39
- | abc123 | 2025-01-03 | feat: add button component |
37
+ ```json
38
+ {
39
+ "domains": {
40
+ "authentication": { "patterns": ["**/auth/**", "**/*auth*.ts"] },
41
+ "api": { "patterns": ["**/api/**", "**/routers/**"] },
42
+ ...
43
+ }
44
+ }
40
45
  ```
41
46
 
42
- ## Changelog Format
47
+ ### 3. For EACH Affected Domain
48
+
49
+ **If domain file EXISTS** (`domains/{domain}.md`):
50
+ - Update "Last Update" section with date and commit
51
+ - Add/remove files in "Files" section
52
+ - Add new commit to "Recent Commits"
53
+ - Update "Connections" if integration changed
54
+ - Add to "Attention Points" if gotchas discovered
55
+
56
+ **If domain file DOES NOT EXIST**:
57
+ - CREATE new domain file from template
58
+ - List all files matching the domain pattern
59
+ - Document connections to other domains
60
+ - Add initial attention points
61
+
62
+ ### 4. VERIFY Documentation
63
+
64
+ - [ ] Every modified file is listed in a domain
65
+ - [ ] Every domain has recent commit entry
66
+ - [ ] Connections are bidirectional (if A connects to B, B connects to A)
67
+ - [ ] No orphan files (files not in any domain)
68
+
69
+ ## Domain File Template
43
70
 
44
71
  ```markdown
45
- ## [Unreleased]
72
+ # {Domain Name}
73
+
74
+ ## Last Update
75
+
76
+ - **Date:** {YYYY-MM-DD}
77
+ - **Commit:** {hash}
78
+ - **Summary:** {what changed}
79
+
80
+ ## Files
46
81
 
47
- ### Added
82
+ ### Frontend
48
83
 
49
- - [New feature] (commit abc123)
84
+ | File | Purpose |
85
+ |------|---------|
86
+ | `app/path/page.tsx` | Description |
50
87
 
51
- ### Changed
88
+ ### Backend
52
89
 
53
- - [Changed feature] (commit def456)
90
+ | File | Purpose |
91
+ |------|---------|
92
+ | `server/routers/name.ts` | Description |
54
93
 
55
- ### Fixed
94
+ ### Types/Schemas
56
95
 
57
- - [Bug fix] (commit ghi789)
96
+ | File | Purpose |
97
+ |------|---------|
98
+ | `types/name.ts` | Description |
99
+
100
+ ## Connections
101
+
102
+ | Domain | How They Connect |
103
+ |--------|-----------------|
104
+ | {domain} | {description} |
105
+
106
+ ## Recent Commits
107
+
108
+ | Hash | Date | Description |
109
+ |------|------|-------------|
110
+ | abc123 | 2025-01-05 | feat: description |
111
+
112
+ ## Attention Points
113
+
114
+ - {Important consideration or gotcha}
115
+ - {Common mistake to avoid}
116
+
117
+ ## Problems & Solutions
118
+
119
+ ### {Problem Title}
120
+
121
+ **Problem:** {What went wrong}
122
+ **Solution:** {How it was fixed}
123
+ **Prevention:** {How to avoid in future}
58
124
  ```
59
125
 
60
- ## Detection Commands
126
+ ## When to CREATE vs UPDATE
61
127
 
62
- ```bash
63
- # Get changed files
64
- git diff --name-only main..HEAD
128
+ | Situation | Action |
129
+ |-----------|--------|
130
+ | File matches existing domain | UPDATE that domain |
131
+ | File matches NO domain | CREATE new domain OR add to "utilities" |
132
+ | New feature area (3+ files) | CREATE dedicated domain |
133
+ | Pattern not in domain-mapping.json | SUGGEST adding pattern to config |
65
134
 
66
- # Get recent commits
67
- git log --oneline -10
135
+ ## Domain Naming Convention
136
+
137
+ ```
138
+ domain-name.md (lowercase, hyphens)
139
+
140
+ Examples:
141
+ - authentication.md
142
+ - user-management.md
143
+ - api-endpoints.md
144
+ - ui-components.md
145
+ - claude-system.md
146
+ ```
147
+
148
+ ## Integration with Stop Hook
149
+
150
+ The Stop hook will BLOCK if:
151
+ 1. Source files modified but no domain updated
152
+ 2. Domain file missing required sections
153
+ 3. Recent commit not recorded
154
+
155
+ ## Example Session
156
+
157
+ ```
158
+ Session: Implemented user profile page
159
+
160
+ 1. Detected files:
161
+ - app/profile/page.tsx (NEW)
162
+ - components/ProfileCard.tsx (NEW)
163
+ - server/routers/user.ts (MODIFIED)
164
+
165
+ 2. Domain mapping:
166
+ - app/profile/page.tsx → pages domain
167
+ - components/ProfileCard.tsx → ui-components domain
168
+ - server/routers/user.ts → api domain
169
+
170
+ 3. Actions:
171
+ - UPDATED domains/pages.md (added profile page)
172
+ - UPDATED domains/ui-components.md (added ProfileCard)
173
+ - UPDATED domains/api.md (noted user router changes)
174
+ - Added connections: pages ↔ api (profile fetches user data)
68
175
  ```
69
176
 
70
177
  ## Critical Rules
71
178
 
72
- 1. **DETECT CHANGES** - Run git diff
73
- 2. **UPDATE DOMAINS** - Keep cache current
74
- 3. **UPDATE CHANGELOG** - For every commit
75
- 4. **INCLUDE COMMIT HASH** - For audit trail
76
- 5. **VERIFY BEFORE EXIT** - Stop hook will block if undocumented
179
+ 1. **RUN AFTER EVERY IMPLEMENTATION** - Not just "important" changes
180
+ 2. **UPDATE DOMAINS, NOT JUST CLAUDE.MD** - CLAUDE.md is summary, domains are detail
181
+ 3. **INCLUDE COMMIT HASH** - For audit trail and navigation
182
+ 4. **DOCUMENT CONNECTIONS** - How domains interact is crucial
183
+ 5. **RECORD PROBLEMS** - Future sessions benefit from past learnings
184
+ 6. **BIDIRECTIONAL CONNECTIONS** - If A→B then B→A
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: domain-updater
3
- description: 'AUTOMATICALLY invoke BEFORE commit-manager at session end. Triggers: implementation complete, problems solved, learnings to record. Updates domain documentation with session learnings. PROACTIVELY records problems, solutions, prevention tips.'
3
+ description: 'AUTOMATICALLY invoke BEFORE commit-manager at session end. Triggers: implementation complete, problems solved, learnings to record. Adds Problems & Solutions, Attention Points to existing domains. PROACTIVELY records session learnings.'
4
4
  model: haiku
5
5
  tools: Read, Write, Edit, Bash, Grep, Glob
6
6
  skills: codebase-knowledge, docs-tracker
@@ -8,74 +8,131 @@ skills: codebase-knowledge, docs-tracker
8
8
 
9
9
  # Domain Updater Agent
10
10
 
11
- You update domain documentation with learnings from each session.
11
+ You record session LEARNINGS in domain docs. Different from documenter: documenter maps files, you record wisdom.
12
12
 
13
- ## Purpose
13
+ ## Role Distinction
14
14
 
15
- - Document **problems encountered** during the session
16
- - Record **solutions** applied to fix issues
17
- - Add **prevention tips** for future sessions
18
- - Update **attention points** with new learnings
19
- - Keep domain knowledge **current and accurate**
15
+ | Agent | What It Does |
16
+ |-------|-------------|
17
+ | **documenter** | Maps files to domains, tracks what exists where |
18
+ | **domain-updater** | Records problems, solutions, gotchas, learnings |
20
19
 
21
- ## Domain File Structure
20
+ ## What You Add to Domains
21
+
22
+ ### 1. Problems & Solutions
23
+
24
+ When something went wrong and was fixed:
22
25
 
23
26
  ```markdown
24
- # [Domain] Domain
27
+ ## Problems & Solutions
28
+
29
+ ### {Date} - {Problem Title}
30
+
31
+ **Problem:** {What went wrong}
32
+ **Root Cause:** {Why it happened}
33
+ **Solution:** {How it was fixed}
34
+ **Prevention:** {How to avoid in future}
35
+ **Files Modified:** {list of files}
36
+ ```
25
37
 
26
- ## Overview
38
+ ### 2. Attention Points
27
39
 
28
- [Brief description]
40
+ Important learnings that future sessions should know:
29
41
 
30
- ## Key Files
42
+ ```markdown
43
+ ## Attention Points
44
+
45
+ - [2025-01-05] **Rule name** - Description of what to watch out for
46
+ - [2025-01-05] **Gotcha** - Common mistake and how to avoid
47
+ ```
31
48
 
32
- | File | Purpose |
33
- | ------------ | ----------- |
34
- | path/file.ts | Description |
49
+ ### 3. Recent Commits
35
50
 
51
+ Add your session's commit:
52
+
53
+ ```markdown
36
54
  ## Recent Commits
37
55
 
38
- | Hash | Date | Description |
39
- | ------ | ---------- | ----------- |
40
- | abc123 | 2025-01-03 | New commit |
56
+ | Hash | Date | Description |
57
+ |------|------|-------------|
58
+ | abc123 | 2025-01-05 | feat: what was done |
59
+ ```
41
60
 
42
- ## Attention Points
61
+ ## When to Run
43
62
 
44
- - [Important consideration 1]
45
- - [Important consideration 2]
63
+ 1. **AFTER final-validator** approves implementation
64
+ 2. **BEFORE commit-manager** (changes included in same commit)
65
+ 3. When problems were solved during session
66
+ 4. When new learnings were discovered
46
67
 
47
- ## Problems & Solutions
68
+ ## Workflow
48
69
 
49
- ### Problem: [Issue encountered]
70
+ ```
71
+ final-validator ✓
72
+
73
+ domain-updater (YOU) → Add learnings to domains
74
+
75
+ commit-manager → Commit all changes (including your updates)
76
+ ```
50
77
 
51
- **Solution:** [How it was fixed]
52
- **Prevention:** [How to avoid in future]
78
+ ## Step-by-Step Process
53
79
 
54
- ## Connections to Other Domains
80
+ ### 1. Identify Affected Domains
55
81
 
56
- | Domain | Connection |
57
- | -------- | ------------------- |
58
- | [domain] | [how they interact] |
82
+ ```bash
83
+ # What files were modified this session?
84
+ git diff --name-only HEAD
59
85
  ```
60
86
 
61
- ## When to Run
87
+ ### 2. Read domain-mapping.json
62
88
 
63
- 1. After final-validator approves
64
- 2. BEFORE commit-manager (so changes included in commit)
65
- 3. When explicitly requested
89
+ Map files to domains using `.claude/config/domain-mapping.json`
66
90
 
67
- ## Update Process
91
+ ### 3. For Each Affected Domain
68
92
 
69
- 1. Read current domain file
70
- 2. Add new commits from session
71
- 3. Document any problems/solutions
72
- 4. Update attention points
73
- 5. Save and report
93
+ 1. Open `domains/{domain}.md`
94
+ 2. Add commit to "Recent Commits"
95
+ 3. If problems were solved → Add to "Problems & Solutions"
96
+ 4. If gotchas discovered → Add to "Attention Points"
97
+ 5. Update "Last Update" date and commit
98
+
99
+ ### 4. Verify Updates
100
+
101
+ - [ ] All affected domains have new commit entry
102
+ - [ ] Problems/solutions recorded if any
103
+ - [ ] Attention points updated if learnings
104
+
105
+ ## Example Session Update
106
+
107
+ ```markdown
108
+ ## Problems & Solutions
109
+
110
+ ### 2025-01-05 - Stop Hook Not Blocking CLAUDE.md Updates
111
+
112
+ **Problem:** Stop hook passed without requiring CLAUDE.md update when only config files changed.
113
+
114
+ **Root Cause:** Validation only checked source files (.ts, .tsx), not all file types.
115
+
116
+ **Solution:** Changed to check ALL files with EXEMPT_PATTERNS for auto-generated files.
117
+
118
+ **Prevention:** When adding file validation, consider ALL file types, not just source code.
119
+
120
+ **Files Modified:**
121
+ - `.claude/hooks/stop-validator.ts`
122
+
123
+ ---
124
+
125
+ ## Attention Points
126
+
127
+ - [2025-01-05] **CLAUDE.md validation** - Triggers for ANY file change, not just source files
128
+ - [2025-01-05] **Exempt patterns** - Lockfiles, dist/, template/ are exempt from CLAUDE.md requirement
129
+ ```
74
130
 
75
131
  ## Critical Rules
76
132
 
77
- 1. **RUN BEFORE COMMIT** - Changes must be in same commit
78
- 2. **DOCUMENT PROBLEMS** - Future sessions benefit
79
- 3. **INCLUDE SOLUTIONS** - Not just what broke, but how to fix
80
- 4. **PREVENTION TIPS** - How to avoid issue
81
- 5. **KEEP CURRENT** - Old info is misleading
133
+ 1. **RUN BEFORE COMMIT** - Your changes must be in same commit
134
+ 2. **DOCUMENT PROBLEMS** - Future sessions benefit from past pain
135
+ 3. **INCLUDE SOLUTIONS** - Not just what broke, how to fix
136
+ 4. **PREVENTION TIPS** - How to avoid the issue next time
137
+ 5. **DATE EVERYTHING** - Helps track when learnings were added
138
+ 6. **KEEP CURRENT** - Old/outdated info is misleading
@@ -89,6 +89,32 @@ const handleTouchMove = (e: TouchEvent) => {
89
89
  };
90
90
  ```
91
91
 
92
+ ## FORBIDDEN Patterns (Mobile)
93
+
94
+ | Pattern | Problem | Alternative |
95
+ |---------|---------|-------------|
96
+ | Cards in flex-col | Waste vertical space, poor scanning | Use compact lists or rows |
97
+ | Card grids | Too cramped, hard to tap | Full-width list items |
98
+ | Nested cards | Confusing hierarchy | Flat structure with dividers |
99
+ | Card carousels | Horizontal scroll issues | Vertical scrolling lists |
100
+ | Multiple CTAs per card | Touch target confusion | Single primary action |
101
+
102
+ ### NO CARDS ON MOBILE
103
+
104
+ ```tsx
105
+ // ❌ BAD - Cards in vertical layout waste space
106
+ <div className="flex flex-col gap-4">
107
+ <Card>...</Card>
108
+ <Card>...</Card>
109
+ </div>
110
+
111
+ // ✅ GOOD - Compact list items
112
+ <ul className="divide-y">
113
+ <li className="py-3 flex justify-between">...</li>
114
+ <li className="py-3 flex justify-between">...</li>
115
+ </ul>
116
+ ```
117
+
92
118
  ## Critical Rules
93
119
 
94
120
  1. **44px MINIMUM** - All touch targets
@@ -96,3 +122,4 @@ const handleTouchMove = (e: TouchEvent) => {
96
122
  3. **NO HOVER STATES** - Touch doesn't hover
97
123
  4. **FULL-WIDTH INPUTS** - Easy to tap
98
124
  5. **NO HORIZONTAL SCROLL** - Ever
125
+ 6. **NO CARDS** - Use lists/rows instead (cards waste space in flex-col)
@@ -0,0 +1,138 @@
1
+ {
2
+ "$schema": "Domain mapping - maps file patterns to documentation domains",
3
+ "domains": {
4
+ "authentication": {
5
+ "patterns": [
6
+ "**/auth/**",
7
+ "**/login/**",
8
+ "**/session/**",
9
+ "**/*auth*.ts",
10
+ "**/*login*.ts",
11
+ "**/*session*.ts",
12
+ "**/middleware/auth*"
13
+ ],
14
+ "description": "User authentication, sessions, tokens, login/logout flows"
15
+ },
16
+ "api": {
17
+ "patterns": [
18
+ "**/api/**",
19
+ "**/trpc/**",
20
+ "**/routers/**",
21
+ "**/*.router.ts",
22
+ "**/server/routes/**"
23
+ ],
24
+ "description": "API endpoints, tRPC routers, REST routes"
25
+ },
26
+ "database": {
27
+ "patterns": [
28
+ "**/models/**",
29
+ "**/schemas/**",
30
+ "**/*.model.ts",
31
+ "**/*.schema.ts",
32
+ "**/db/**",
33
+ "**/migrations/**"
34
+ ],
35
+ "description": "Database models, schemas, migrations, queries"
36
+ },
37
+ "ui-components": {
38
+ "patterns": [
39
+ "**/components/**/*.tsx",
40
+ "**/components/**/*.jsx",
41
+ "**/ui/**/*.tsx"
42
+ ],
43
+ "description": "Reusable UI components (buttons, forms, modals, etc.)"
44
+ },
45
+ "pages": {
46
+ "patterns": [
47
+ "**/app/**/page.tsx",
48
+ "**/app/**/layout.tsx",
49
+ "**/pages/**/*.tsx"
50
+ ],
51
+ "description": "Page routes and layouts (Next.js app router)"
52
+ },
53
+ "hooks": {
54
+ "patterns": [
55
+ "**/hooks/**/*.ts",
56
+ "**/use*.ts",
57
+ "**/use*.tsx"
58
+ ],
59
+ "description": "React hooks and custom hook utilities"
60
+ },
61
+ "utilities": {
62
+ "patterns": [
63
+ "**/lib/**/*.ts",
64
+ "**/utils/**/*.ts",
65
+ "**/helpers/**/*.ts",
66
+ "**/common/**/*.ts"
67
+ ],
68
+ "description": "Utility functions, helpers, shared logic"
69
+ },
70
+ "types": {
71
+ "patterns": [
72
+ "**/types/**/*.ts",
73
+ "**/*.d.ts",
74
+ "**/interfaces/**/*.ts"
75
+ ],
76
+ "description": "TypeScript type definitions and interfaces"
77
+ },
78
+ "validation": {
79
+ "patterns": [
80
+ "**/validators/**/*.ts",
81
+ "**/*.validator.ts",
82
+ "**/*.schema.ts"
83
+ ],
84
+ "description": "Zod schemas and input validation"
85
+ },
86
+ "testing": {
87
+ "patterns": [
88
+ "**/*.test.ts",
89
+ "**/*.spec.ts",
90
+ "**/*.e2e.ts",
91
+ "**/tests/**",
92
+ "**/e2e/**",
93
+ "**/fixtures/**"
94
+ ],
95
+ "description": "Unit tests, integration tests, E2E tests"
96
+ },
97
+ "infrastructure": {
98
+ "patterns": [
99
+ "**/docker*",
100
+ "**/Dockerfile*",
101
+ "**/docker-compose*",
102
+ "**/.github/**",
103
+ "**/ci/**",
104
+ "**/scripts/**"
105
+ ],
106
+ "description": "Docker, CI/CD, deployment scripts"
107
+ },
108
+ "claude-system": {
109
+ "patterns": [
110
+ ".claude/**",
111
+ "CLAUDE.md",
112
+ "**/start-vibing/**"
113
+ ],
114
+ "description": "Claude agent system, hooks, skills, configuration"
115
+ }
116
+ },
117
+ "rules": {
118
+ "createDomainWhen": [
119
+ "New file pattern not matching any existing domain",
120
+ "New feature area with 3+ related files",
121
+ "Explicit user request for domain separation"
122
+ ],
123
+ "updateDomainWhen": [
124
+ "ANY file in domain is modified",
125
+ "New file added to domain",
126
+ "File deleted from domain",
127
+ "Connection to other domain changes"
128
+ ],
129
+ "domainFileLocation": ".claude/skills/codebase-knowledge/domains/",
130
+ "requiredSections": [
131
+ "Last Update",
132
+ "Files",
133
+ "Connections",
134
+ "Recent Commits",
135
+ "Attention Points"
136
+ ]
137
+ }
138
+ }
@@ -734,6 +734,171 @@ The stop hook will BLOCK until all source files are documented.
734
734
  };
735
735
  }
736
736
 
737
+ interface DomainMapping {
738
+ patterns: string[];
739
+ description: string;
740
+ }
741
+
742
+ interface DomainMappingConfig {
743
+ domains: Record<string, DomainMapping>;
744
+ }
745
+
746
+ function matchesGlobPattern(filePath: string, pattern: string): boolean {
747
+ // Normalize path separators
748
+ const normalizedPath = filePath.replace(/\\/g, '/');
749
+
750
+ // Convert glob pattern to regex
751
+ let regexPattern = pattern
752
+ .replace(/\./g, '\\.') // Escape dots
753
+ .replace(/\*\*/g, '<<<GLOBSTAR>>>') // Temp placeholder for **
754
+ .replace(/\*/g, '[^/]*') // Single * matches anything except /
755
+ .replace(/<<<GLOBSTAR>>>/g, '.*'); // ** matches anything including /
756
+
757
+ // Handle patterns starting with **/ (match any path)
758
+ if (regexPattern.startsWith('.*/')) {
759
+ regexPattern = '(?:^|.*/?)' + regexPattern.slice(3);
760
+ }
761
+
762
+ try {
763
+ const regex = new RegExp(regexPattern);
764
+ return regex.test(normalizedPath);
765
+ } catch {
766
+ return false;
767
+ }
768
+ }
769
+
770
+ function getDomainForFile(
771
+ filePath: string,
772
+ domains: Record<string, DomainMapping>
773
+ ): string | null {
774
+ for (const [domainName, domainConfig] of Object.entries(domains)) {
775
+ for (const pattern of domainConfig.patterns) {
776
+ if (matchesGlobPattern(filePath, pattern)) {
777
+ return domainName;
778
+ }
779
+ }
780
+ }
781
+ return null;
782
+ }
783
+
784
+ function validateDomainDocumentation(modifiedFiles: string[]): ValidationError | null {
785
+ const domainMappingPath = join(PROJECT_DIR, '.claude', 'config', 'domain-mapping.json');
786
+ const domainsDir = join(PROJECT_DIR, '.claude', 'skills', 'codebase-knowledge', 'domains');
787
+
788
+ // If domain-mapping.json doesn't exist, skip this check (project not configured)
789
+ if (!existsSync(domainMappingPath)) {
790
+ return null;
791
+ }
792
+
793
+ let domainConfig: DomainMappingConfig;
794
+ try {
795
+ const configContent = readFileSync(domainMappingPath, 'utf8');
796
+ domainConfig = JSON.parse(configContent);
797
+ } catch {
798
+ return null; // Invalid config, skip check
799
+ }
800
+
801
+ // Filter for source files only (skip config, docs, etc.)
802
+ const sourceFiles = modifiedFiles.filter(isSourceFile);
803
+ if (sourceFiles.length === 0) return null;
804
+
805
+ // Map files to their domains
806
+ const fileToDomain: Record<string, string> = {};
807
+ const unmappedFiles: string[] = [];
808
+ const affectedDomains = new Set<string>();
809
+
810
+ for (const file of sourceFiles) {
811
+ const domain = getDomainForFile(file, domainConfig.domains);
812
+ if (domain) {
813
+ fileToDomain[file] = domain;
814
+ affectedDomains.add(domain);
815
+ } else {
816
+ unmappedFiles.push(file);
817
+ }
818
+ }
819
+
820
+ // Check which affected domains have NOT been updated
821
+ const missingDomainUpdates: string[] = [];
822
+ const domainFiles = modifiedFiles.filter(
823
+ (f) => f.includes('codebase-knowledge/domains/') || f.includes('codebase-knowledge\\domains\\')
824
+ );
825
+
826
+ for (const domain of affectedDomains) {
827
+ const domainFile = `${domain}.md`;
828
+ const domainUpdated = domainFiles.some(
829
+ (f) => f.endsWith(domainFile) || f.includes(`domains/${domain}.md`)
830
+ );
831
+
832
+ // Also check if domain file exists
833
+ const domainPath = join(domainsDir, `${domain}.md`);
834
+ const domainExists = existsSync(domainPath);
835
+
836
+ if (!domainExists || !domainUpdated) {
837
+ missingDomainUpdates.push(domain);
838
+ }
839
+ }
840
+
841
+ // Build error message if issues found
842
+ const issues: string[] = [];
843
+
844
+ if (unmappedFiles.length > 0) {
845
+ issues.push(`FILES NOT IN ANY DOMAIN (${unmappedFiles.length}):\n${unmappedFiles.map((f) => ` - ${f}`).join('\n')}`);
846
+ }
847
+
848
+ if (missingDomainUpdates.length > 0) {
849
+ issues.push(`DOMAINS NOT UPDATED (${missingDomainUpdates.length}):\n${missingDomainUpdates.map((d) => ` - ${d}.md`).join('\n')}`);
850
+ }
851
+
852
+ if (issues.length === 0) return null;
853
+
854
+ // Build file-to-domain mapping for display
855
+ const mappingDisplay = Object.entries(fileToDomain)
856
+ .slice(0, 10)
857
+ .map(([file, domain]) => ` ${file} → ${domain}`)
858
+ .join('\n');
859
+
860
+ return {
861
+ type: 'DOMAIN_DOCUMENTATION_INCOMPLETE',
862
+ message: `Source files modified but domain documentation not properly updated.`,
863
+ action: `
864
+ ================================================================================
865
+ DOMAIN DOCUMENTATION REQUIRED (MANDATORY)
866
+ ================================================================================
867
+
868
+ ${issues.join('\n\n')}
869
+
870
+ FILE → DOMAIN MAPPING:
871
+ ${mappingDisplay}${Object.keys(fileToDomain).length > 10 ? '\n ... and more' : ''}
872
+
873
+ --------------------------------------------------------------------------------
874
+ REQUIRED ACTION: Run the documenter agent
875
+ --------------------------------------------------------------------------------
876
+
877
+ Task(subagent_type="documenter", prompt="Update domain documentation for all modified files")
878
+
879
+ The documenter will:
880
+ 1. Read .claude/config/domain-mapping.json for file patterns
881
+ 2. Map each modified file to its domain
882
+ 3. CREATE missing domain files in domains/
883
+ 4. UPDATE existing domains with new files and commit info
884
+ 5. Add connections between related domains
885
+
886
+ DOMAIN FILES LOCATION:
887
+ .claude/skills/codebase-knowledge/domains/{domain-name}.md
888
+
889
+ EACH DOMAIN FILE MUST HAVE:
890
+ - Last Update (date, commit, summary)
891
+ - Files (all files in this domain)
892
+ - Connections (links to other domains)
893
+ - Recent Commits (history)
894
+ - Attention Points (gotchas)
895
+
896
+ ================================================================================
897
+ The stop hook will BLOCK until domain documentation is complete.
898
+ ================================================================================`,
899
+ };
900
+ }
901
+
737
902
  // ============================================================================
738
903
  // MAIN HOOK LOGIC
739
904
  // ============================================================================
@@ -840,6 +1005,9 @@ async function main(): Promise<void> {
840
1005
  const docError = validateDocumentation(sourceFiles);
841
1006
  if (docError) errors.push(docError);
842
1007
 
1008
+ const domainDocError = validateDomainDocumentation(modifiedFiles);
1009
+ if (domainDocError) errors.push(domainDocError);
1010
+
843
1011
  // ============================================================================
844
1012
  // OUTPUT RESULTS
845
1013
  // ============================================================================