@cometchat/skills 3.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.
@@ -0,0 +1,662 @@
1
+ ---
2
+ name: cometchat
3
+ description: Entry-point for CometChat integration. Guides a multi-step interactive conversation to understand the project, gather requirements, and write production-quality integration code.
4
+ license: "MIT"
5
+ allowed-tools: "executeBash, readFile, fileSearch, listDirectory, AskUserQuestion"
6
+ metadata:
7
+ author: "CometChat"
8
+ version: "3.0.0"
9
+ tags: "cometchat dispatcher entry react chat"
10
+ ---
11
+
12
+ ## Use this skill when
13
+
14
+ The user wants to add CometChat to any kind of project. Trigger phrases:
15
+
16
+ - `/cometchat`
17
+ - "add cometchat", "integrate cometchat", "add chat to my app"
18
+ - "add messaging", "add chat ui"
19
+
20
+ This is the **entry point**. Do not invoke framework-specific skills
21
+ directly — this dispatcher will route to the right ones.
22
+
23
+ ## How v3 works
24
+
25
+ v3 skills are **interactive and conversational**. You don't just detect
26
+ the framework and dump code. You have a conversation with the developer
27
+ to understand their project, their use case, and exactly where chat
28
+ should go — THEN you write code that fits.
29
+
30
+ The pattern skills teach you:
31
+ - `cometchat-core` — initialization, login, CSS, env vars, provider pattern
32
+ - `cometchat-components` — every component name, props, composition patterns
33
+ - `cometchat-placement` — WHERE to put chat (route, modal, drawer, embed, widget)
34
+ - `cometchat-{framework}-patterns` — framework-specific integration patterns
35
+
36
+ **Key principle: ask, don't assume.** Every piece of information you need
37
+ from the user should be asked explicitly. Don't guess the route path,
38
+ don't guess where the trigger button goes, don't guess the auth system.
39
+
40
+ ## Steps
41
+
42
+ ### Step 1 — Detect framework + map the project
43
+
44
+ First, check if `.cometchat/config.json` exists:
45
+ ```bash
46
+ npx @cometchat/skills-cli config show --json
47
+ ```
48
+
49
+ If config exists with previous answers, tell the user:
50
+ > "I see you've set up CometChat before. Using your saved config:
51
+ > Framework: {framework}, App: {appId}, Intent: {intent}.
52
+ > Want to continue with these, or start fresh?"
53
+
54
+ If no config, run detection:
55
+ ```bash
56
+ npx @cometchat/skills-cli detect --json
57
+ ```
58
+
59
+ **Then read the project yourself — this is critical:**
60
+ - `package.json` — name, dependencies, scripts
61
+ - The source directory structure — list all directories under `src/` or `app/`
62
+ - Find the router: look for `createBrowserRouter`, `app/` directory, `pages/`,
63
+ `react-router.config.ts`, `astro.config.*`
64
+ - Find the layout: `App.tsx`, `layout.tsx`, `root.tsx`, `Layout.astro`
65
+ - Find the nav: look for components with "nav", "header", "sidebar" in name
66
+ - Find existing pages/routes: list them so you can reference them later
67
+
68
+ Store this mental map — you'll use it throughout the conversation.
69
+
70
+ If `compatibility.supported` is `false`, stop and surface the warnings.
71
+
72
+ ### Step 2 — Set up credentials (onboarding)
73
+
74
+ **CRITICAL: All onboarding happens via CLI commands. NEVER send the user
75
+ to a browser or dashboard. The CLI handles signup, login, app creation,
76
+ and credential writing — all from the terminal.**
77
+
78
+ If config has `appId` set, verify credentials are in `.env` and skip to Step 3.
79
+
80
+ Otherwise check:
81
+ ```bash
82
+ npx @cometchat/skills-cli auth status --json
83
+ ```
84
+
85
+ If `status` is `"logged-in"`, skip to **Step 2c** (app selection).
86
+
87
+ If `status` is `"logged-out"`, ask:
88
+
89
+ Use `AskUserQuestion`:
90
+ - **question:** "Let's set up CometChat. Do you have an account?"
91
+ - **header:** "Account"
92
+ - **multiSelect:** false
93
+ - **options:**
94
+ 1. label: "Create a new account", description: "Free signup — I'll handle it right here, no browser needed."
95
+ 2. label: "Sign in to existing account", description: "Log in and pick one of your apps."
96
+ 3. label: "I'll paste credentials myself", description: "I already have my App ID, Region, and Auth Key."
97
+
98
+ Option 1 → **Step 2b**. Option 2 → **Step 2a**. Option 3 → **Step 2d**.
99
+
100
+ #### Step 2a — Sign in (existing account, browser flow)
101
+
102
+ ```bash
103
+ npx @cometchat/skills-cli auth login
104
+ ```
105
+
106
+ This command:
107
+ 1. Generates a short-lived session via the CLI auth API.
108
+ 2. Opens `https://app.cometchat.com/login?sessionId=<hex>` in the user's default browser.
109
+ 3. Polls the auth API every 5 seconds for up to 15 minutes.
110
+ 4. When the user finishes signing in (email+password, Google, or GitHub — whatever their account uses), the dashboard marks the session authenticated. The next poll receives the bearer token and stores it in the OS keychain.
111
+ 5. Prints `✓ Logged in as <email> (backend: keychain-macos).`
112
+
113
+ Let the CLI block — do NOT background it, do NOT race it with other
114
+ prompts. The user completes sign-in in the browser tab; the terminal
115
+ waits.
116
+
117
+ Terminal error handling (surface verbatim, stop, do not retry silently):
118
+ - `ACCESS_DENIED` — user clicked Deny in the dashboard.
119
+ - `EXPIRED` — 15-minute window elapsed.
120
+ - `TIMEOUT` — max polls exhausted before user authorized.
121
+ - `ABORTED` — user Ctrl-C'd the CLI.
122
+ - `NETWORK` — couldn't reach the auth host.
123
+ - `ALREADY_AUTHENTICATED` — this session was already consumed. Re-run
124
+ `auth login` to mint a fresh session.
125
+
126
+ After success, verify:
127
+ ```bash
128
+ npx @cometchat/skills-cli auth status --json
129
+ ```
130
+
131
+ If `status` is `"logged-in"`, proceed to **Step 2c**.
132
+
133
+ #### Step 2b — Sign up (new account, browser flow)
134
+
135
+ ```bash
136
+ npx @cometchat/skills-cli auth signup
137
+ ```
138
+
139
+ Same polling flow as Step 2a, but the CLI opens
140
+ `https://app.cometchat.com/signup?sessionId=<hex>`. The browser
141
+ handles everything — email, name, password, verification email, role,
142
+ industry. The CLI never sees any of those values. When the user
143
+ finishes signup in the browser, the next poll stores the bearer token
144
+ in the OS keychain and the CLI prints `✓ Logged in as <email>`.
145
+
146
+ No role / name / verification-code questions in the chat. The dashboard
147
+ owns that flow now; skipping it keeps the user's password and verification
148
+ code out of the transcript.
149
+
150
+ Error codes match Step 2a (ACCESS_DENIED, EXPIRED, TIMEOUT, ABORTED,
151
+ NETWORK, ALREADY_AUTHENTICATED). Surface verbatim and stop.
152
+
153
+ After success, verify:
154
+ ```bash
155
+ npx @cometchat/skills-cli auth status --json
156
+ ```
157
+
158
+ If `status` is `"logged-in"`, proceed to **Step 2c**.
159
+
160
+ #### Step 2c — Pick or create an app
161
+
162
+ **Run this immediately — do NOT ask the user to go to any dashboard:**
163
+ ```bash
164
+ npx @cometchat/skills-cli provision list --json
165
+ ```
166
+
167
+ **If the user has existing apps**, show them and ask which to use:
168
+ > "I found these CometChat apps on your account:
169
+ > 1. my-marketplace-chat (us) — Developer plan
170
+ > 2. test-app (eu) — Developer plan
171
+ >
172
+ > Which one should I use, or should I create a new one?"
173
+
174
+ **For an existing app**, fetch credentials and wire everything in one call
175
+ (pass `--framework` from Step 1 detection — one of `reactjs`, `nextjs`,
176
+ `react-router`, `astro`):
177
+ ```bash
178
+ npx @cometchat/skills-cli provision setup \
179
+ --app-id "<selected-appId>" --framework "<framework>" --json
180
+ ```
181
+
182
+ This creates/updates `.env` with the correct prefix AND writes
183
+ `.cometchat/config.json` in one step. Output is compact:
184
+ `{ appId, region, framework, envFile, configPath }` — no authKey echoed
185
+ back, no multi-command chain. Skip ahead to "Tell the user" below.
186
+
187
+ **If no apps exist** (or user wants new), collect:
188
+ 1. App name — suggest `<project-name>-chat` from package.json `name`
189
+ 2. Region — use `AskUserQuestion`:
190
+ - **question:** "Which region for your CometChat app?"
191
+ - **header:** "Region"
192
+ - **options:**
193
+ 1. label: "US", description: "United States (recommended)"
194
+ 2. label: "EU", description: "Europe"
195
+ 3. label: "India", description: "India"
196
+
197
+ **Region key mapping** (CLI expects lowercase):
198
+ | Label | `--region` value |
199
+ |---|---|
200
+ | US | `us` |
201
+ | EU | `eu` |
202
+ | India | `in` |
203
+ 3. Industry — use `AskUserQuestion`:
204
+ - **question:** "What's your app's industry?"
205
+ - **header:** "Industry"
206
+ - **options:**
207
+ 1. label: "SaaS / Business", description: ""
208
+ 2. label: "Marketplace", description: ""
209
+ 3. label: "Social / Community", description: ""
210
+ 4. label: "Other", description: ""
211
+
212
+ **Industry key mapping:**
213
+
214
+ | Label | --industry value |
215
+ |---|---|
216
+ | SaaS / Business | `saas_businesses` |
217
+ | Marketplace | `online_marketplaces` |
218
+ | Social / Community | `community_and_social` |
219
+ | Healthcare | `healthcare` |
220
+ | Dating | `dating` |
221
+ | Education | `online_education` |
222
+ | Events / Streaming | `events_and_streaming` |
223
+ | Sports / Gaming | `sports_and_gaming` |
224
+ | Team Communication | `team_comms_and_workflows` |
225
+ | On-demand Services | `on_demand_services` |
226
+ | Other | `other` |
227
+
228
+ **Confirm before creating:**
229
+ > "I'll create a CometChat app:
230
+ > - Name: test-cometchat-vite-chat
231
+ > - Region: US
232
+ > - Industry: SaaS / Business
233
+ >
234
+ > Go ahead?"
235
+
236
+ Then create the app AND wire `.env` AND save config in one step. Pass
237
+ `--framework` from Step 1 detection (one of `reactjs`, `nextjs`,
238
+ `react-router`, `astro`):
239
+ ```bash
240
+ npx @cometchat/skills-cli provision setup \
241
+ --name "<name>" --region "<region>" --industry "<industry_key>" \
242
+ --framework "<framework>" --json
243
+ ```
244
+
245
+ Output is compact: `{ appId, region, framework, envFile, configPath }`.
246
+ The authKey is written to the env file but is NOT echoed to stdout, so
247
+ credentials don't appear multiple times in the transcript. This replaces
248
+ the old `provision create` → `provision use` → `config init` chain.
249
+
250
+ Tell the user: "Your CometChat account and app are ready. Credentials
251
+ saved to `.env`. Let's set up the integration."
252
+
253
+ #### Step 2d — Paste keys manually
254
+
255
+ Tell the user which env vars to set based on the detected framework:
256
+
257
+ | Framework | Env file | Variables |
258
+ |---|---|---|
259
+ | reactjs (Vite) | `.env` | `VITE_COMETCHAT_APP_ID`, `VITE_COMETCHAT_REGION`, `VITE_COMETCHAT_AUTH_KEY` |
260
+ | nextjs | `.env.local` | `NEXT_PUBLIC_COMETCHAT_APP_ID`, `NEXT_PUBLIC_COMETCHAT_REGION`, `NEXT_PUBLIC_COMETCHAT_AUTH_KEY` |
261
+ | react-router | `.env` | `VITE_COMETCHAT_APP_ID`, `VITE_COMETCHAT_REGION`, `VITE_COMETCHAT_AUTH_KEY` |
262
+ | astro | `.env` | `PUBLIC_COMETCHAT_APP_ID`, `PUBLIC_COMETCHAT_REGION`, `PUBLIC_COMETCHAT_AUTH_KEY` |
263
+
264
+ > "Grab your credentials from https://app.cometchat.com → Your App →
265
+ > API & Auth Keys. Create the env file above and tell me when done."
266
+
267
+ After they confirm, verify:
268
+ ```bash
269
+ npx @cometchat/skills-cli config init --json
270
+ ```
271
+
272
+ ### Step 3 — Interactive requirements gathering
273
+
274
+ This is the core of v3. A multi-step conversation that gathers everything
275
+ you need before writing a single line of code.
276
+
277
+ #### 3a. "What are you building?"
278
+
279
+ If config has `intent` set, confirm it and move on.
280
+
281
+ Otherwise, use `AskUserQuestion`:
282
+ - **question:** "What kind of app are you building?"
283
+ - **header:** "Your app"
284
+ - **multiSelect:** false
285
+ - **options:**
286
+ 1. label: "Messaging app", description: "Chat is the main feature — like Slack, Discord, or WhatsApp."
287
+ 2. label: "Marketplace or platform", description: "Buyers and sellers communicate — like Airbnb, eBay, or Fiverr."
288
+ 3. label: "SaaS or dashboard", description: "Team chat or support chat inside a product — like Notion or Intercom."
289
+ 4. label: "Social or community", description: "User profiles with messaging — like a dating app or forum."
290
+ 5. label: "Support or helpdesk", description: "Customer-to-agent communication."
291
+ 6. label: "Just exploring", description: "Quick demo — fastest path to see chat working."
292
+
293
+ **If "Just exploring":** skip the rest of Step 3. Use `cometchat apply`
294
+ demo mode in Step 5.
295
+
296
+ #### 3b. Show what you recommend and why
297
+
298
+ Based on the intent, present the recommendation:
299
+
300
+ | Intent | What you'll set up |
301
+ |---|---|
302
+ | **Messaging app** | A dedicated messages page at a route you choose. Two-pane: conversation list + active chat. |
303
+ | **Marketplace** | A "Chat with seller" drawer on your product page + an inbox page at /messages. |
304
+ | **SaaS / dashboard** | A chat modal triggered from your navbar + a full messages page. |
305
+ | **Social / community** | A full messenger page with tabs: Chats, Calls, Users, Groups. |
306
+ | **Support** | A floating widget bubble in the bottom-right corner. |
307
+
308
+ When explaining, reference the ASCII art from `cometchat-placement`
309
+ ("Visual reference — experience layouts") so the user can visualize it.
310
+
311
+ Ask: "Does this sound right, or do you want a different approach?"
312
+ Let them override.
313
+
314
+ #### 3c. Ask where things should go
315
+
316
+ **Show the user their actual project structure** — list the pages/routes
317
+ you found in Step 1. Then ask placement-specific questions:
318
+
319
+ **For Route placement (messaging, social):**
320
+ > "I found these pages in your project:
321
+ > - / (home)
322
+ > - /about
323
+ > - /products
324
+ > - /profile
325
+ >
326
+ > Where should the messages page live?"
327
+
328
+ Default suggestion: `/messages`. Let user type a custom path.
329
+
330
+ **For Drawer placement (marketplace):**
331
+ > "Which page should have the 'Chat' button that opens the drawer?
332
+ > I found these pages:
333
+ > - app/products/[id]/page.tsx
334
+ > - app/listings/page.tsx
335
+ > - app/profile/[id]/page.tsx
336
+ >
337
+ > Which one?"
338
+
339
+ After they pick, read that page file. Look for existing buttons,
340
+ actions, or interactive elements. Ask:
341
+ > "I see a 'Contact Seller' button in ProductDetail.tsx at line 45.
342
+ > Should I wire the chat drawer to that button, or add a new one?"
343
+
344
+ **For Modal placement (SaaS):**
345
+ > "Where should the 'Open chat' button go? I found these components
346
+ > that look like navigation:
347
+ > - src/components/Navbar.tsx
348
+ > - src/components/Sidebar.tsx
349
+ >
350
+ > Which one should have the chat trigger?"
351
+
352
+ **For Widget placement (support):**
353
+ > "Should the widget appear on all pages, or only specific ones?"
354
+
355
+ **For combinations (marketplace = drawer + route):**
356
+ Ask both questions in sequence. The drawer and route are separate
357
+ components wired into separate places.
358
+
359
+ #### 3d. Detect and ask about authentication
360
+
361
+ Read the project's `package.json` and source files. Look for auth:
362
+
363
+ - `next-auth` / `@auth/core` → NextAuth
364
+ - `@clerk/nextjs` / `@clerk/clerk-react` → Clerk
365
+ - `@supabase/supabase-js` + auth usage → Supabase Auth
366
+ - `firebase` / `firebase/auth` → Firebase Auth
367
+ - `passport` → Passport.js
368
+ - `jsonwebtoken` / `jose` → Custom JWT
369
+ - None detected → no auth
370
+
371
+ Report what you found and ask:
372
+
373
+ If auth detected:
374
+ > "I see you're using [NextAuth / Clerk / etc.]. Here's how CometChat
375
+ > will work with it:
376
+ >
377
+ > - **Development (now):** I'll use CometChat's Auth Key for quick
378
+ > testing with pre-seeded users (cometchat-uid-1, uid-2, etc.)
379
+ > - **Production (later):** Your server will call CometChat's REST API
380
+ > to generate per-user auth tokens. I can set this up now or later.
381
+ >
382
+ > Start with dev mode for now? You can upgrade to production auth
383
+ > anytime by choosing 'Set up production auth' from the menu."
384
+
385
+ If no auth detected:
386
+ > "I don't see an authentication system in your project yet. For now,
387
+ > I'll set up CometChat with a hardcoded test user (cometchat-uid-1).
388
+ >
389
+ > When you add auth later, run `/cometchat` again and choose
390
+ > 'Set up production auth' to connect them."
391
+
392
+ #### 3e. Ask about user mapping (if auth detected)
393
+
394
+ If the user has auth AND wants to set up production mode now:
395
+
396
+ > "How should your app's users map to CometChat users?
397
+ >
398
+ > 1. Use your existing user ID as the CometChat UID (simplest)
399
+ > 2. Generate a separate CometChat UID and store it in your database
400
+ > 3. Let me just set up dev mode for now
401
+ >
402
+ > Option 1 works if your user IDs are alphanumeric strings (no spaces,
403
+ > no special characters). What does a typical user ID look like in
404
+ > your system?"
405
+
406
+ If they share an example, validate it's CometChat-compatible
407
+ (alphanumeric, underscores, hyphens — no spaces or special chars).
408
+
409
+ #### 3f. Confirm the plan
410
+
411
+ **This is critical. Show EXACTLY what you'll do before doing it.**
412
+
413
+ > "Here's what I'll create:
414
+ >
415
+ > **New files:**
416
+ > - `app/providers/CometChatProvider.tsx` — initialization + login
417
+ > - `app/messages/page.tsx` — inbox with conversation list + message view
418
+ > - `app/components/ChatDrawer.tsx` — slide-out drawer for product page chat
419
+ > - `.env.local` — CometChat credentials (already filled)
420
+ >
421
+ > **Files I'll modify:**
422
+ > - `app/products/[id]/page.tsx` — add ChatDrawer import + trigger button
423
+ > - `app/layout.tsx` — wrap children with CometChatProvider
424
+ > - `app/components/Navbar.tsx` — add 'Messages' link
425
+ >
426
+ > **Files I will NOT touch:**
427
+ > - `app/page.tsx` (your home page)
428
+ > - Any other existing pages
429
+ >
430
+ > **Dependencies to install:**
431
+ > - @cometchat/chat-sdk-javascript
432
+ > - @cometchat/chat-uikit-react
433
+ >
434
+ > **Auth mode:** Development (Auth Key). Upgrade to production
435
+ > with `/cometchat` → 'Set up production auth' when ready.
436
+ >
437
+ > Proceed? [y/n]"
438
+
439
+ Wait for explicit confirmation. If the user says no or wants changes,
440
+ go back to the relevant question and re-ask.
441
+
442
+ ### Step 4 — Reference pattern skills
443
+
444
+ **All 13 skills are already loaded in your context** as `.claude/skills/`
445
+ files. Do NOT use the `Skill()` tool — that's for a different system.
446
+ Instead, simply read and follow the instructions in these skills:
447
+
448
+ 1. `cometchat-core` — initialization, provider, CSS, anti-patterns
449
+ 2. `cometchat-components` — component catalog, composition patterns
450
+ 3. Framework skill for the detected framework:
451
+ - `reactjs` → `cometchat-react-patterns`
452
+ - `nextjs` → `cometchat-nextjs-patterns`
453
+ - `react-router` → `cometchat-react-router-patterns`
454
+ - `astro` → `cometchat-astro-patterns`
455
+ 4. `cometchat-placement` — placement pattern for the chosen approach
456
+
457
+ These are reference documents in your context, not tool calls.
458
+
459
+ ### Step 5 — Write the integration
460
+
461
+ Execute the confirmed plan. For each file:
462
+
463
+ 1. **CometChatProvider** — follow the framework skill's provider pattern.
464
+ Use the correct env var prefix. Module-level `initialized` guard.
465
+ Mount at the level agreed in Step 3f.
466
+
467
+ 2. **Chat component(s)** — follow the placement skill's pattern.
468
+ Use the component compositions from the components skill.
469
+ If drawer/modal: connect to the specific user/group the user specified.
470
+
471
+ 3. **Wire into existing project** — READ each file before modifying:
472
+ - Router: add the route entry. Show the user the diff.
473
+ - Nav: add the link. Show the user the diff.
474
+ - Trigger page: add the drawer/modal import + trigger button. Show diff.
475
+
476
+ 4. **CSS import** — add once at the root level per framework conventions.
477
+
478
+ 5. **Environment variables** — write `.env` with the correct prefix.
479
+ If auth key is already there from the wizard, don't duplicate.
480
+
481
+ 6. **Install dependencies:**
482
+ ```bash
483
+ npm install @cometchat/chat-sdk-javascript @cometchat/chat-uikit-react
484
+ ```
485
+
486
+ 7. **Update config.json** — save all the choices in one call:
487
+ ```bash
488
+ npx @cometchat/skills-cli config save \
489
+ --intent "<intent>" \
490
+ --experience <n> \
491
+ --placement "<type>" \
492
+ --placement-path "<path>" \
493
+ --auth-mode "<mode>" --json
494
+ ```
495
+ Pass only the fields you have — `config save` accepts any subset.
496
+ This replaces the old 5-command `config set k v` chain. Omit
497
+ `--experience` in the AI-written path (it only applies to CLI-
498
+ generated experiences 1/2/3).
499
+
500
+ 8. **Record state so Phase B commands work — DO NOT SKIP.** Every
501
+ Phase B command (`info`, `status`, `doctor`, `verify`, `uninstall`,
502
+ `apply-theme`, `apply-feature`, `add-widget`, `add-user-mgmt`,
503
+ `production-auth`) reads `.cometchat/state.json` to know what the
504
+ integration looks like. Without this step, every one of them reports
505
+ "not integrated in this project" even though the code is there, and
506
+ the user can't iterate on their integration at all.
507
+
508
+ Pass every file you wrote (owned) and every existing file you patched:
509
+ ```bash
510
+ npx @cometchat/skills-cli state record \
511
+ --framework "<framework>" \
512
+ --placement "<type>" \
513
+ --placement-path "<path>" \
514
+ --auth-mode "<mode>" \
515
+ --files-owned "src/providers/CometChatProvider.tsx,src/components/ChatDrawer.tsx,src/pages/MessagesPage.tsx" \
516
+ --files-patched "src/main.tsx:v3/main.tsx,src/App.tsx:v3/App.tsx,src/components/Layout.tsx:v3/Layout.tsx" \
517
+ --json
518
+ ```
519
+
520
+ - `--files-owned` — comma-separated list of every NEW file you wrote
521
+ (the provider, drawer, inbox page, etc.). The CLI computes SHA-256
522
+ checksums for each so it can detect drift later.
523
+ - `--files-patched` — comma-separated `path:patch_id` pairs for every
524
+ EXISTING file you modified (main.tsx, App.tsx, Layout.tsx, nav, the
525
+ trigger page). `patch_id` can be any stable label — `v3/<filename>`
526
+ is a reasonable default.
527
+
528
+ If this call errors (CLI flag mismatch, missing --framework, etc.),
529
+ surface the error and retry with the correct flags rather than moving
530
+ on. A completed Phase A with a missing state.json is worse than a
531
+ visible error — the user discovers the breakage later when they try
532
+ to add a feature or run diagnostics.
533
+
534
+ **Exception — "Just exploring" / demo mode:**
535
+ ```bash
536
+ npx @cometchat/skills-cli apply --experience 1 --framework <detected>
537
+ npx @cometchat/skills-cli verify --json
538
+ npx @cometchat/skills-cli install
539
+ ```
540
+
541
+ ### Step 6 — Verify + show result
542
+
543
+ Run a TypeScript check to verify the code compiles:
544
+ ```bash
545
+ npx tsc --noEmit
546
+ ```
547
+
548
+ **Do NOT run `npx @cometchat/skills-cli verify`** — it checks for
549
+ CLI-generated `.cometchat/state.json` which doesn't exist in v3
550
+ (AI writes code directly, not via `cometchat apply`). Use `tsc` instead.
551
+
552
+ Surface any issues. Then:
553
+
554
+ > "CometChat is integrated! Here's what was set up:
555
+ >
556
+ > - Messages page at /messages ✓
557
+ > - Chat drawer on product page ✓
558
+ > - Provider + CSS wired ✓
559
+ > - Dependencies installed ✓
560
+ >
561
+ > Run `npm run dev` and try it out. Pre-seeded test users
562
+ > (cometchat-uid-1 through uid-5) are ready to chat.
563
+ >
564
+ > What would you like to do next?"
565
+
566
+ ### Step 7 — Iteration menu
567
+
568
+ Use `AskUserQuestion`:
569
+ - **question:** "What would you like to do next?"
570
+ - **header:** "Next step"
571
+ - **multiSelect:** false
572
+ - **options:**
573
+ 1. label: "Customize look and feel (themes)", description: "Pick a preset (slack, whatsapp, imessage, discord, notion) or set brand colors."
574
+ 2. label: "Add a feature", description: "Browse ~35 features — calls, reactions, polls, AI, and more."
575
+ 3. label: "Customize a component", description: "Custom bubbles, headers, composer actions, details views — I'll read the docs and write it."
576
+ 4. label: "Add a floating chat widget", description: "An overlay button + drawer on top of your existing app."
577
+ 5. label: "Set up production auth", description: "Replace the dev Auth Key with a server-side token endpoint. Read `cometchat-production` skill."
578
+ 6. label: "Set up user management", description: "Server endpoints for creating, updating, deleting CometChat users."
579
+ 7. label: "Run diagnostics", description: "Check for drift, missing env vars, broken imports."
580
+ 8. label: "I'm done", description: "Exit."
581
+
582
+ For **component customization**: read `cometchat-components` + docs MCP,
583
+ then write the customization code directly. This is pure AI work — no
584
+ CLI command. Ask the user what they want to customize, read the relevant
585
+ component's props from the catalog, and propose changes.
586
+
587
+ For **production auth**: read the `cometchat-production` skill (already
588
+ in your context). It's interactive — ask the user about their auth
589
+ system and generate the server-side token endpoint for their framework.
590
+
591
+ ### Re-rendering the menu after each action
592
+
593
+ After every Phase B action completes, you **MUST** re-invoke
594
+ `AskUserQuestion` with the **exact same 8 options** listed above
595
+ (same `question`, `header`, `multiSelect: false`, same option labels
596
+ and descriptions — verbatim). This gives the user arrow-key selection
597
+ in their terminal.
598
+
599
+ **Do NOT:**
600
+ - Present the options as a prose bullet list (`"What would you like to
601
+ do next?\n - Customize the theme...\n - Add calls..."`) — this
602
+ forces the user to type their answer, which is a worse UX.
603
+ - Invent new options based on what the user just did (e.g. "Customize
604
+ theme to match Nestly's brand", "Swap the drawer header for a custom
605
+ view"). The 8 options above are the canonical set and don't change
606
+ between iterations.
607
+ - Skip the menu and ask a freeform "What's next?" — always route
608
+ through `AskUserQuestion`.
609
+ - Drop options or add new ones. The user expects the same 8 choices
610
+ every time, even if some are redundant with what they just did
611
+ (they may want to do the same kind of action twice, e.g. add two
612
+ features).
613
+
614
+ The iteration loop is the whole point of Phase B. Re-rendering the
615
+ canonical menu via `AskUserQuestion` after every action is how the
616
+ user controls the session.
617
+
618
+ ## Hard rules
619
+
620
+ - **Ask, don't assume.** Every integration decision should be confirmed.
621
+ - Always run `detect` first. Do not assume the framework.
622
+ - Always use `npx @cometchat/skills-cli` for CLI commands.
623
+ - NEVER replace existing project files unless the user chose demo mode.
624
+ - ALWAYS read existing files before modifying them.
625
+ - ALWAYS show the plan (Step 3f) and get confirmation before writing.
626
+ - For component names and props, use the `cometchat-components` skill
627
+ or docs MCP — never invent from training data.
628
+ - After writing code, update `.cometchat/config.json` with the choices made.
629
+ - **NEVER use the `Skill()` tool** to load CometChat skills. All 13
630
+ skills are already in your context as `.claude/skills/` files. Just
631
+ read and follow them directly.
632
+
633
+ ## Error handling
634
+
635
+ If the CLI's `--json` output includes `human_message` / `suggestion` fields,
636
+ show those to the user. Then show the raw `error` in parentheses for
637
+ debuggability. If `retryable: false`, do NOT offer a retry.
638
+
639
+ ## Optional: docs MCP
640
+
641
+ For deeper component customization:
642
+ ```
643
+ claude mcp add --transport http cometchat-docs https://www.cometchat.com/docs/mcp
644
+ ```
645
+
646
+ Not required for integration or Phase B CLI flows.
647
+
648
+ ## Skill routing reference
649
+
650
+ | Skill | When to load |
651
+ |---|---|
652
+ | `cometchat-core` | Always — before any integration code |
653
+ | `cometchat-components` | Always — before writing component code |
654
+ | `cometchat-placement` | When integrating — for placement patterns |
655
+ | `cometchat-react-patterns` | framework = reactjs |
656
+ | `cometchat-nextjs-patterns` | framework = nextjs |
657
+ | `cometchat-react-router-patterns` | framework = react-router |
658
+ | `cometchat-astro-patterns` | framework = astro |
659
+ | `cometchat-theming` | When customizing themes |
660
+ | `cometchat-features` | When adding features |
661
+ | `cometchat-production` | When setting up production auth |
662
+ | `cometchat-troubleshooting` | When diagnosing problems |