glori-builder 1.0.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.
Files changed (45) hide show
  1. package/.claude/CLAUDE.md +66 -0
  2. package/.claude/agents/architect.md +69 -0
  3. package/.claude/agents/database-architect.md +36 -0
  4. package/.claude/agents/designer.md +33 -0
  5. package/.claude/agents/developer.md +34 -0
  6. package/.claude/agents/git-workflow.md +60 -0
  7. package/.claude/agents/nextjs-migrator.md +28 -0
  8. package/.claude/agents/product-manager.md +44 -0
  9. package/.claude/agents/qa.md +44 -0
  10. package/.claude/agents/reviewer.md +55 -0
  11. package/.claude/agents/security-reviewer.md +34 -0
  12. package/.claude/agents/test-writer.md +26 -0
  13. package/.claude/commands/auto-pilot.md +228 -0
  14. package/.claude/commands/commit.md +7 -0
  15. package/.claude/commands/create-rules.md +356 -0
  16. package/.claude/commands/deploy-setup.md +158 -0
  17. package/.claude/commands/execute.md +101 -0
  18. package/.claude/commands/issue-prd.md +108 -0
  19. package/.claude/commands/issue-rework.md +272 -0
  20. package/.claude/commands/plan-feature.md +433 -0
  21. package/.claude/commands/plan-project.md +452 -0
  22. package/.claude/commands/prime.md +100 -0
  23. package/.claude/commands/project-setup.md +187 -0
  24. package/.claude/commands/quetrex-docs.md +188 -0
  25. package/.claude/commands/quetrex-setup.md +159 -0
  26. package/.claude/commands/quetrex-update.md +59 -0
  27. package/.claude/commands/secrets.md +122 -0
  28. package/.claude/commands/update-rules.md +143 -0
  29. package/.claude/hooks/auto-format.sh +27 -0
  30. package/.claude/hooks/check-quetrex-update.sh +34 -0
  31. package/.claude/hooks/enforce-branch.sh +66 -0
  32. package/.claude/hooks/security-check.sh +39 -0
  33. package/.claude/settings.json +89 -0
  34. package/.claude/skills/agent-browser/SKILL.md +251 -0
  35. package/.claude/skills/domain-capture/SKILL.md +385 -0
  36. package/.claude/skills/e2e-test/SKILL.md +213 -0
  37. package/.claude/skills/merge-issue/SKILL.md +126 -0
  38. package/.claude/skills/qa-verify/SKILL.md +194 -0
  39. package/.claude/skills/story-builder/SKILL.md +231 -0
  40. package/.claude/skills/tab-control/SKILL.md +92 -0
  41. package/.claude/statusline-command.sh +159 -0
  42. package/.claude/team-protocol.md +28 -0
  43. package/README.md +86 -0
  44. package/install.js +102 -0
  45. package/package.json +34 -0
@@ -0,0 +1,251 @@
1
+ ---
2
+ name: agent-browser
3
+ description: Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.
4
+ ---
5
+
6
+ # Browser Automation with agent-browser
7
+
8
+ ## Quick start
9
+
10
+ ```bash
11
+ agent-browser open <url> # Navigate to page
12
+ agent-browser snapshot -i # Get interactive elements with refs
13
+ agent-browser click @e1 # Click element by ref
14
+ agent-browser fill @e2 "text" # Fill input by ref
15
+ agent-browser close # Close browser
16
+ ```
17
+
18
+ ## Core workflow
19
+
20
+ 1. Navigate: `agent-browser open <url>`
21
+ 2. Snapshot: `agent-browser snapshot -i` (returns elements with refs like `@e1`, `@e2`)
22
+ 3. Interact using refs from the snapshot
23
+ 4. Re-snapshot after navigation or significant DOM changes
24
+
25
+ ## Commands
26
+
27
+ ### Navigation
28
+ ```bash
29
+ agent-browser open <url> # Navigate to URL
30
+ agent-browser back # Go back
31
+ agent-browser forward # Go forward
32
+ agent-browser reload # Reload page
33
+ agent-browser close # Close browser
34
+ ```
35
+
36
+ ### Snapshot (page analysis)
37
+ ```bash
38
+ agent-browser snapshot # Full accessibility tree
39
+ agent-browser snapshot -i # Interactive elements only (recommended)
40
+ agent-browser snapshot -c # Compact output
41
+ agent-browser snapshot -d 3 # Limit depth to 3
42
+ agent-browser snapshot -s "#main" # Scope to CSS selector
43
+ ```
44
+
45
+ ### Interactions (use @refs from snapshot)
46
+ ```bash
47
+ agent-browser click @e1 # Click
48
+ agent-browser dblclick @e1 # Double-click
49
+ agent-browser focus @e1 # Focus element
50
+ agent-browser fill @e2 "text" # Clear and type
51
+ agent-browser type @e2 "text" # Type without clearing
52
+ agent-browser press Enter # Press key
53
+ agent-browser press Control+a # Key combination
54
+ agent-browser keydown Shift # Hold key down
55
+ agent-browser keyup Shift # Release key
56
+ agent-browser hover @e1 # Hover
57
+ agent-browser check @e1 # Check checkbox
58
+ agent-browser uncheck @e1 # Uncheck checkbox
59
+ agent-browser select @e1 "value" # Select dropdown
60
+ agent-browser scroll down 500 # Scroll page
61
+ agent-browser scrollintoview @e1 # Scroll element into view
62
+ agent-browser drag @e1 @e2 # Drag and drop
63
+ agent-browser upload @e1 file.pdf # Upload files
64
+ ```
65
+
66
+ ### Get information
67
+ ```bash
68
+ agent-browser get text @e1 # Get element text
69
+ agent-browser get html @e1 # Get innerHTML
70
+ agent-browser get value @e1 # Get input value
71
+ agent-browser get attr @e1 href # Get attribute
72
+ agent-browser get title # Get page title
73
+ agent-browser get url # Get current URL
74
+ agent-browser get count ".item" # Count matching elements
75
+ agent-browser get box @e1 # Get bounding box
76
+ ```
77
+
78
+ ### Check state
79
+ ```bash
80
+ agent-browser is visible @e1 # Check if visible
81
+ agent-browser is enabled @e1 # Check if enabled
82
+ agent-browser is checked @e1 # Check if checked
83
+ ```
84
+
85
+ ### Screenshots & PDF
86
+ ```bash
87
+ agent-browser screenshot # Screenshot to stdout
88
+ agent-browser screenshot path.png # Save to file
89
+ agent-browser screenshot --full # Full page
90
+ agent-browser pdf output.pdf # Save as PDF
91
+ ```
92
+
93
+ ### Video recording
94
+ ```bash
95
+ agent-browser record start ./demo.webm # Start recording (uses current URL + state)
96
+ agent-browser click @e1 # Perform actions
97
+ agent-browser record stop # Stop and save video
98
+ agent-browser record restart ./take2.webm # Stop current + start new recording
99
+ ```
100
+ Recording creates a fresh context but preserves cookies/storage from your session. If no URL is provided, it automatically returns to your current page. For smooth demos, explore first, then start recording.
101
+
102
+ ### Wait
103
+ ```bash
104
+ agent-browser wait @e1 # Wait for element
105
+ agent-browser wait 2000 # Wait milliseconds
106
+ agent-browser wait --text "Success" # Wait for text
107
+ agent-browser wait --url "**/dashboard" # Wait for URL pattern
108
+ agent-browser wait --load networkidle # Wait for network idle
109
+ agent-browser wait --fn "window.ready" # Wait for JS condition
110
+ ```
111
+
112
+ ### Mouse control
113
+ ```bash
114
+ agent-browser mouse move 100 200 # Move mouse
115
+ agent-browser mouse down left # Press button
116
+ agent-browser mouse up left # Release button
117
+ agent-browser mouse wheel 100 # Scroll wheel
118
+ ```
119
+
120
+ ### Semantic locators (alternative to refs)
121
+ ```bash
122
+ agent-browser find role button click --name "Submit"
123
+ agent-browser find text "Sign In" click
124
+ agent-browser find label "Email" fill "user@test.com"
125
+ agent-browser find first ".item" click
126
+ agent-browser find nth 2 "a" text
127
+ ```
128
+
129
+ ### Browser settings
130
+ ```bash
131
+ agent-browser set viewport 1920 1080 # Set viewport size
132
+ agent-browser set device "iPhone 14" # Emulate device
133
+ agent-browser set geo 37.7749 -122.4194 # Set geolocation
134
+ agent-browser set offline on # Toggle offline mode
135
+ agent-browser set headers '{"X-Key":"v"}' # Extra HTTP headers
136
+ agent-browser set credentials user pass # HTTP basic auth
137
+ agent-browser set media dark # Emulate color scheme
138
+ ```
139
+
140
+ ### Cookies & Storage
141
+ ```bash
142
+ agent-browser cookies # Get all cookies
143
+ agent-browser cookies set name value # Set cookie
144
+ agent-browser cookies clear # Clear cookies
145
+ agent-browser storage local # Get all localStorage
146
+ agent-browser storage local key # Get specific key
147
+ agent-browser storage local set k v # Set value
148
+ agent-browser storage local clear # Clear all
149
+ ```
150
+
151
+ ### Network
152
+ ```bash
153
+ agent-browser network route <url> # Intercept requests
154
+ agent-browser network route <url> --abort # Block requests
155
+ agent-browser network route <url> --body '{}' # Mock response
156
+ agent-browser network unroute [url] # Remove routes
157
+ agent-browser network requests # View tracked requests
158
+ agent-browser network requests --filter api # Filter requests
159
+ ```
160
+
161
+ ### Tabs & Windows
162
+ ```bash
163
+ agent-browser tab # List tabs
164
+ agent-browser tab new [url] # New tab
165
+ agent-browser tab 2 # Switch to tab
166
+ agent-browser tab close # Close tab
167
+ agent-browser window new # New window
168
+ ```
169
+
170
+ ### Frames
171
+ ```bash
172
+ agent-browser frame "#iframe" # Switch to iframe
173
+ agent-browser frame main # Back to main frame
174
+ ```
175
+
176
+ ### Dialogs
177
+ ```bash
178
+ agent-browser dialog accept [text] # Accept dialog
179
+ agent-browser dialog dismiss # Dismiss dialog
180
+ ```
181
+
182
+ ### JavaScript
183
+ ```bash
184
+ agent-browser eval "document.title" # Run JavaScript
185
+ ```
186
+
187
+ ## Example: Form submission
188
+
189
+ ```bash
190
+ agent-browser open https://example.com/form
191
+ agent-browser snapshot -i
192
+ # Output shows: textbox "Email" [ref=e1], textbox "Password" [ref=e2], button "Submit" [ref=e3]
193
+
194
+ agent-browser fill @e1 "user@example.com"
195
+ agent-browser fill @e2 "password123"
196
+ agent-browser click @e3
197
+ agent-browser wait --load networkidle
198
+ agent-browser snapshot -i # Check result
199
+ ```
200
+
201
+ ## Example: Authentication with saved state
202
+
203
+ ```bash
204
+ # Login once
205
+ agent-browser open https://app.example.com/login
206
+ agent-browser snapshot -i
207
+ agent-browser fill @e1 "username"
208
+ agent-browser fill @e2 "password"
209
+ agent-browser click @e3
210
+ agent-browser wait --url "**/dashboard"
211
+ agent-browser state save auth.json
212
+
213
+ # Later sessions: load saved state
214
+ agent-browser state load auth.json
215
+ agent-browser open https://app.example.com/dashboard
216
+ ```
217
+
218
+ ## Sessions (parallel browsers)
219
+
220
+ ```bash
221
+ agent-browser --session test1 open site-a.com
222
+ agent-browser --session test2 open site-b.com
223
+ agent-browser session list
224
+ ```
225
+
226
+ ## JSON output (for parsing)
227
+
228
+ Add `--json` for machine-readable output:
229
+ ```bash
230
+ agent-browser snapshot -i --json
231
+ agent-browser get text @e1 --json
232
+ ```
233
+
234
+ ## Debugging
235
+
236
+ ```bash
237
+ agent-browser open example.com --headed # Show browser window
238
+ agent-browser console # View console messages
239
+ agent-browser errors # View page errors
240
+ agent-browser record start ./debug.webm # Record from current page
241
+ agent-browser record stop # Save recording
242
+ agent-browser open example.com --headed # Show browser window
243
+ agent-browser --cdp 9222 snapshot # Connect via CDP
244
+ agent-browser console # View console messages
245
+ agent-browser console --clear # Clear console
246
+ agent-browser errors # View page errors
247
+ agent-browser errors --clear # Clear errors
248
+ agent-browser highlight @e1 # Highlight element
249
+ agent-browser trace start # Start recording trace
250
+ agent-browser trace stop trace.zip # Stop and save trace
251
+ ```
@@ -0,0 +1,385 @@
1
+ ---
2
+ name: domain-capture
3
+ description: Build a structured business logic knowledge base for a project through codebase analysis and developer interview
4
+ argument-hint: <brownfield|greenfield> [path-to-prd-for-greenfield]
5
+ disable-model-invocation: true
6
+ allowed-tools: Bash, Read, Glob, Grep, Agent, Write, Edit, AskUserQuestion
7
+ ---
8
+
9
+ # Domain Knowledge Capture
10
+
11
+ ## Input Validation
12
+
13
+ Mode: `$ARGUMENTS`
14
+
15
+ If `$ARGUMENTS` is empty or missing, say: "Usage: `/domain-capture brownfield` or `/domain-capture greenfield path/to/prd.md`" and STOP.
16
+
17
+ Parse the first word as the mode. It must be either `brownfield` or `greenfield` (case-insensitive).
18
+
19
+ If mode is `greenfield`, the second argument must be a path to a PRD file. If missing, say: "Greenfield mode requires a PRD path: `/domain-capture greenfield .claude/prds/PROJECT-PRD.md`" and STOP.
20
+
21
+ If mode is `brownfield`, no additional arguments needed — the current working directory IS the project.
22
+
23
+ ## Step 1: Initialize Knowledge Base
24
+
25
+ Check if `.claude/knowledge-base/` exists in the current project. If not, create the directory structure:
26
+
27
+ ```bash
28
+ mkdir -p .claude/knowledge-base/entities
29
+ mkdir -p .claude/knowledge-base/rules
30
+ mkdir -p .claude/knowledge-base/workflows
31
+ mkdir -p .claude/knowledge-base/vocabulary
32
+ mkdir -p .claude/knowledge-base/webhooks
33
+ ```
34
+
35
+ If the directory already exists, read the existing files to understand what has already been captured. Report to the user:
36
+ - "Resuming knowledge capture. Already documented: {list of existing files}"
37
+ - "Starting fresh knowledge capture for {project directory name}"
38
+
39
+ ## Step 2: Codebase Analysis (BROWNFIELD) or PRD Analysis (GREENFIELD)
40
+
41
+ ### If BROWNFIELD:
42
+
43
+ Launch **three parallel research agents** to map the complete application surface:
44
+
45
+ **Agent 1: Human Actions**
46
+ > Explore this codebase thoroughly to find every human-triggered action in the UI.
47
+ > For each action found, document:
48
+ > - File path and line number
49
+ > - What the user sees (button text, menu item, page name)
50
+ > - What function, server action, or API call it triggers
51
+ > - What database operations happen as a result
52
+ > - Any status changes or count updates
53
+ > - Any side effects on other entities
54
+ >
55
+ > Organize by feature area (e.g., "Pages", "Conversations", "Messaging", "Settings").
56
+ > Read the actual handler code — do not just list file names.
57
+ > Focus on: onClick handlers, onSubmit handlers, form actions, server actions,
58
+ > Link/navigation, router.push, toggles, drag-and-drop, menu selections.
59
+
60
+ **Agent 2: Automated Triggers**
61
+ > Explore this codebase thoroughly to find every non-human trigger.
62
+ > For each trigger found, document:
63
+ > - File path and line number
64
+ > - What external system sends data (Facebook, Twilio, Stripe, etc.)
65
+ > - What data comes in (payload structure)
66
+ > - What processing and validation happens
67
+ > - What database operations occur
68
+ > - What side effects happen (notifications, status changes, count updates)
69
+ > - What cascading effects touch other entities
70
+ >
71
+ > Cover: webhook endpoints, cron jobs, event listeners, middleware,
72
+ > database triggers, real-time connections (WebSocket, SSE, polling),
73
+ > queue workers, automated status transitions.
74
+
75
+ **Agent 3: Data Model**
76
+ > Explore this codebase thoroughly to map the complete data model.
77
+ > For each table/entity, document:
78
+ > - Table name, file path, all columns with types
79
+ > - Primary keys, foreign keys, unique constraints
80
+ > - Relations to other tables
81
+ > - External ID fields (Facebook IDs, Twilio SIDs, etc.)
82
+ > - Status fields and their possible values
83
+ > - Count fields that are maintained (pending_count, message_count, etc.)
84
+ > - Soft delete patterns
85
+ > - Multi-tenancy/scoping patterns (agency, tenant, etc.)
86
+ > - Enums and their values
87
+ >
88
+ > Also find: migration files, seed data, raw SQL queries.
89
+
90
+ **Wait for all three agents to complete before proceeding.**
91
+
92
+ Compile the results into a structured summary organized by feature area. This becomes the basis for the interview.
93
+
94
+ ### If GREENFIELD:
95
+
96
+ Read the PRD file specified in the arguments.
97
+
98
+ Extract from the PRD:
99
+ - All user stories and user types
100
+ - All described features and pages
101
+ - All mentioned entities and data structures
102
+ - All described workflows and flows
103
+ - All integrations with external systems
104
+ - All described business rules and constraints
105
+
106
+ Organize these into a feature area list. This becomes the basis for the interview.
107
+
108
+ ## Step 3: Generate Interview Questions
109
+
110
+ Based on the analysis, generate a structured question set. Questions fall into categories:
111
+
112
+ ### Category A: Entity Behavior
113
+ For each entity (table/data structure) found, prepare:
114
+ - "When a {entity} is created, what else must happen?"
115
+ - "When a {entity} is updated, what cascading effects occur?"
116
+ - "When a {entity} is deleted, what cleanup is needed?"
117
+ - "Are there any fields on {entity} that must ALWAYS be set a certain way?"
118
+ - "Are there any fields that should NEVER be used for lookups?" (like UUID vs external_id)
119
+
120
+ ### Category B: Action Consequences
121
+ For each human action or trigger found, prepare:
122
+ - "When a user {action}, what EXACTLY should happen? Walk me through every step."
123
+ - "Are there any count fields that need updating when this happens?"
124
+ - "Are there any status fields on OTHER entities that change?"
125
+ - "What should happen if this action fails halfway through? Is it atomic?"
126
+
127
+ ### Category C: Scoping and Tenancy
128
+ - "What is the primary scoping/isolation boundary? (agency, tenant, org, user)"
129
+ - "Are there any entities that cross scope boundaries?"
130
+ - "What field should ALWAYS be used to look up {entity}? What should NEVER be used?"
131
+
132
+ ### Category D: Workflows
133
+ For each workflow identified, prepare:
134
+ - "Walk me through the complete lifecycle of {workflow} from start to finish"
135
+ - "What status transitions are valid? What transitions should NEVER happen?"
136
+ - "Can this workflow be reversed or cancelled? What happens to related entities?"
137
+
138
+ ### Category E: Vocabulary
139
+ - "Are there any terms in this project that mean something different from their obvious meaning?"
140
+ - "Are there any terms the team uses that an outsider wouldn't understand?"
141
+
142
+ ### Category F: Gotchas (CRITICAL)
143
+ - "What are the things that have caused bugs before?"
144
+ - "What are the rules that seem obvious to you but an AI would get wrong?"
145
+ - "Are there any 'always do this' or 'never do that' rules that aren't in the code?"
146
+
147
+ ## Step 4: Conduct Interview
148
+
149
+ Present the questions to the developer ONE CATEGORY AT A TIME. Do not dump all questions at once.
150
+
151
+ Start with: "I've analyzed the codebase and have questions organized into {N} categories. Let's start with **Entity Behavior** for {first entity}."
152
+
153
+ **Interview Rules:**
154
+ - Ask one question at a time
155
+ - Wait for the full answer before asking the next question
156
+ - If an answer reveals a new entity, workflow, or rule you didn't find in the codebase, add follow-up questions
157
+ - If the developer says "I don't know" or "I'll get back to you", mark that item as UNKNOWN and move on
158
+ - If the developer says "skip this" or "not important", respect that and move on
159
+ - If the developer volunteers information beyond what you asked, capture ALL of it
160
+ - After each category, summarize what you captured and ask "Did I miss anything in this area?"
161
+
162
+ **For BROWNFIELD specifically:**
163
+ Before each question, share what you found in the code:
164
+ "I see that when a user clicks 'Reply', the code calls `handleReply()` in `components/messaging/reply-form.tsx:45` which calls the `sendReply` server action. The server action updates the message table and calls `updateConversationCounts()`. **Is this the complete picture, or does more need to happen?**"
165
+
166
+ This is critical — showing what you found gives the developer something concrete to correct or confirm, rather than asking them to recall everything from memory.
167
+
168
+ **For GREENFIELD specifically:**
169
+ Walk through each user story from the PRD:
170
+ "The PRD says users can 'create a new project'. Walk me through what should happen when they click Create — what entities are created, what defaults are set, what notifications fire, what counts update?"
171
+
172
+ ## Step 5: Write Knowledge Base Files
173
+
174
+ After each category of the interview is complete (do NOT wait until the end), write the captured knowledge to YAML files.
175
+
176
+ ### Entity Files
177
+
178
+ For each entity discussed, create `.claude/knowledge-base/entities/{entity-name}.yaml`:
179
+
180
+ ```yaml
181
+ entity: page
182
+ table: pages
183
+ description: "Represents a connected Facebook page managed by an agency"
184
+ scoping: "Always scoped to agency. Lookup by external_id (Facebook Page ID), NEVER by UUID."
185
+ fields_of_note:
186
+ - field: external_id
187
+ note: "The Facebook Page ID. This is the PRIMARY lookup field. Never use uuid for page lookups."
188
+ - field: pending_count
189
+ note: "Count of unreplied messages across all conversations. Decremented when agent replies."
190
+ - field: status
191
+ values: ["active", "paused", "disconnected"]
192
+ transitions:
193
+ - from: active
194
+ to: paused
195
+ trigger: "User pauses page in settings"
196
+ - from: paused
197
+ to: active
198
+ trigger: "User reactivates page"
199
+ relations:
200
+ - target: conversations
201
+ type: one-to-many
202
+ note: "A page has many conversations"
203
+ - target: agency
204
+ type: many-to-one
205
+ note: "A page belongs to one agency"
206
+ created: "{today's date}"
207
+ last_validated: "{today's date}"
208
+ source: "developer interview"
209
+ ```
210
+
211
+ ### Rule Files
212
+
213
+ For each business rule captured, create `.claude/knowledge-base/rules/{rule-name}.yaml`:
214
+
215
+ ```yaml
216
+ rule: agent_reply_cascade
217
+ domain: messaging
218
+ trigger: "Agent submits a reply to a conversation"
219
+ entities_affected:
220
+ - entity: message
221
+ field: status
222
+ action: "Flag ALL messages where status='pending' in this conversation as 'agent_replied'"
223
+ scope: "All unreplied messages, not just the latest"
224
+ - entity: conversation
225
+ field: message_count
226
+ action: "Set message_count to 0"
227
+ - entity: page
228
+ field: pending_count
229
+ action: "Decrement by exact count of messages flagged"
230
+ invariants:
231
+ - "pending_count >= 0 always"
232
+ - "flagged count must equal decrement amount"
233
+ - "atomic — all succeed or none"
234
+ why: "Business tracks agent responsiveness at page level"
235
+ gotchas:
236
+ - "Must flag ALL unreplied messages, not just the most recent"
237
+ - "The count decrement must match exactly — do not hardcode 1"
238
+ created: "{today's date}"
239
+ last_validated: "{today's date}"
240
+ source: "developer interview"
241
+ ```
242
+
243
+ ### Workflow Files
244
+
245
+ For each workflow captured, create `.claude/knowledge-base/workflows/{workflow-name}.yaml`:
246
+
247
+ ```yaml
248
+ workflow: inbound_lead
249
+ description: "A new lead arrives via Facebook webhook"
250
+ trigger: "Facebook sends webhook to /api/webhooks/facebook"
251
+ steps:
252
+ - step: 1
253
+ action: "Validate webhook signature"
254
+ entity: null
255
+ note: "Reject if signature invalid"
256
+ - step: 2
257
+ action: "Find or create conversation"
258
+ entity: conversation
259
+ note: "Match by sender ID + page external_id"
260
+ - step: 3
261
+ action: "Create message record"
262
+ entity: message
263
+ note: "Status defaults to 'pending'"
264
+ - step: 4
265
+ action: "Increment conversation.message_count"
266
+ entity: conversation
267
+ - step: 5
268
+ action: "Increment page.pending_count"
269
+ entity: page
270
+ note: "This makes the page show in the agent's queue"
271
+ error_handling: "If any step fails after message creation, log error but do NOT lose the message"
272
+ created: "{today's date}"
273
+ last_validated: "{today's date}"
274
+ source: "developer interview"
275
+ ```
276
+
277
+ ### Webhook Files
278
+
279
+ For each webhook/trigger captured, create `.claude/knowledge-base/webhooks/{webhook-name}.yaml`:
280
+
281
+ ```yaml
282
+ webhook: facebook_message_received
283
+ endpoint: "/api/webhooks/facebook"
284
+ source: "Facebook Graph API"
285
+ payload_key_fields:
286
+ - field: "entry[].messaging[].sender.id"
287
+ maps_to: "conversation.external_sender_id"
288
+ - field: "entry[].messaging[].recipient.id"
289
+ maps_to: "page.external_id"
290
+ processing:
291
+ - "Validate X-Hub-Signature-256 header"
292
+ - "Extract message text, attachments, sender ID"
293
+ - "Find page by recipient ID (external_id)"
294
+ - "Find or create conversation"
295
+ - "Create message record"
296
+ - "Update counts"
297
+ side_effects:
298
+ - "page.pending_count incremented"
299
+ - "conversation.message_count incremented"
300
+ - "real-time notification sent to assigned agent"
301
+ created: "{today's date}"
302
+ last_validated: "{today's date}"
303
+ source: "developer interview"
304
+ ```
305
+
306
+ ### Vocabulary Files
307
+
308
+ Create `.claude/knowledge-base/vocabulary/terms.yaml`:
309
+
310
+ ```yaml
311
+ terms:
312
+ - term: "page"
313
+ meaning: "A connected Facebook/Instagram business page, NOT a web page or UI page"
314
+ context: "Always scoped to an agency"
315
+ - term: "external_id"
316
+ meaning: "The ID from the external platform (Facebook Page ID, Twilio number, etc.)"
317
+ context: "This is the primary lookup field for pages, NOT the internal UUID"
318
+ ```
319
+
320
+ ## Step 6: Write Summary Index
321
+
322
+ After all categories are complete, create `.claude/knowledge-base/INDEX.md`:
323
+
324
+ ```markdown
325
+ # Knowledge Base: {Project Name}
326
+
327
+ Generated: {today's date}
328
+ Mode: {brownfield|greenfield}
329
+ Interview status: {complete|partial — list remaining areas}
330
+
331
+ ## Entities
332
+ {list each entity file with one-line description}
333
+
334
+ ## Business Rules
335
+ {list each rule file with one-line description}
336
+
337
+ ## Workflows
338
+ {list each workflow file with one-line description}
339
+
340
+ ## Webhooks / Triggers
341
+ {list each webhook file with one-line description}
342
+
343
+ ## Vocabulary
344
+ {list any non-obvious terms}
345
+
346
+ ## Known Gaps
347
+ {list any areas marked UNKNOWN during interview}
348
+ {list any areas the developer said to skip}
349
+ ```
350
+
351
+ ## Step 7: Commit Knowledge Base
352
+
353
+ ```bash
354
+ git add .claude/knowledge-base/
355
+ git commit -m "docs: add domain knowledge base from capture session"
356
+ ```
357
+
358
+ Report to the user:
359
+
360
+ > **Domain knowledge capture complete.**
361
+ > - Entities documented: {count}
362
+ > - Business rules captured: {count}
363
+ > - Workflows mapped: {count}
364
+ > - Webhooks/triggers documented: {count}
365
+ > - Vocabulary terms defined: {count}
366
+ > - Known gaps: {count}
367
+ >
368
+ > Run `/domain-capture brownfield` again to fill gaps or add new areas.
369
+
370
+ Then STOP.
371
+
372
+ ## Rules
373
+
374
+ - NEVER invent business rules — only document what the developer confirms
375
+ - NEVER skip the interview — the codebase analysis is a starting point, not the answer
376
+ - If the developer corrects your understanding of the code, update your analysis immediately
377
+ - Write knowledge base files incrementally after each category, not all at the end
378
+ - If the session is interrupted, the partially-written files are still valuable — they can be resumed
379
+ - For brownfield: ALWAYS show what you found in the code before asking the question
380
+ - For greenfield: ALWAYS reference specific PRD sections when asking questions
381
+ - Mark anything uncertain as UNKNOWN rather than guessing
382
+ - Include the `source` field on every file ("developer interview", "codebase analysis", etc.)
383
+ - Include `gotchas` on rules where the developer flags non-obvious behavior
384
+ - Use today's date for `created` and `last_validated` fields
385
+ - If resuming a previous capture, update `last_validated` on re-confirmed items