cometchat
Entry-point for CometChat integration. Guides a multi-step interactive conversation to understand the project, gather requirements, and write production-quality integration code.
cometchat · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add cometchat/cometchat-skills --skill cometchat技能说明
name: cometchat description: Entry-point for CometChat integration. Guides a multi-step interactive conversation to understand the project, gather requirements, and write production-quality integration code. license: "MIT" allowed-tools: "executeBash, readFile, fileSearch, listDirectory, AskUserQuestion" metadata: author: "CometChat" version: "3.0.0" tags: "cometchat dispatcher entry react chat"
Use this skill when
The user wants to add CometChat to any kind of project. Trigger phrases:
/cometchat- "add cometchat", "integrate cometchat", "add chat to my app"
- "add messaging", "add chat ui"
This is the entry point. Do not invoke framework-specific skills directly — this dispatcher will route to the right ones.
How v3 works
v3 skills are interactive and conversational. You don't just detect the framework and dump code. You have a conversation with the developer to understand their project, their use case, and exactly where chat should go — THEN you write code that fits.
The pattern skills teach you:
cometchat-core— initialization, login, CSS, env vars, provider patterncometchat-components— every component name, props, composition patternscometchat-placement— WHERE to put chat (route, modal, drawer, embed, widget)cometchat-{framework}-patterns— framework-specific integration patterns
Key principle: ask, don't assume. Every piece of information you need from the user should be asked explicitly. Don't guess the route path, don't guess where the trigger button goes, don't guess the auth system.
Steps
Step 1 — Detect framework + map the project
First, check if .cometchat/config.json exists:
npx @cometchat/skills-cli config show --json
If config exists with previous answers, tell the user:
"I see you've set up CometChat before. Using your saved config: Framework: {framework}, App: {appId}, Intent: {intent}. Want to continue with these, or start fresh?"
If no config, run detection:
npx @cometchat/skills-cli detect --json
Then read the project yourself — this is critical:
package.json— name, dependencies, scripts- The source directory structure — list all directories under
src/orapp/ - Find the router: look for
createBrowserRouter,app/directory,pages/,react-router.config.ts,astro.config.* - Find the layout:
App.tsx,layout.tsx,root.tsx,Layout.astro - Find the nav: look for components with "nav", "header", "sidebar" in name
- Find existing pages/routes: list them so you can reference them later
Store this mental map — you'll use it throughout the conversation.
If compatibility.supported is false, stop and surface the warnings.
Step 2 — Set up credentials (onboarding)
CRITICAL: All onboarding happens via CLI commands. NEVER send the user to a browser or dashboard. The CLI handles signup, login, app creation, and credential writing — all from the terminal.
If config has appId set, verify credentials are in .env and skip to Step 3.
Otherwise check:
npx @cometchat/skills-cli auth status --json
If status is "logged-in", skip to Step 2c (app selection).
If status is "logged-out", ask:
Use AskUserQuestion:
- question: "Let's set up CometChat. Do you have an account?"
- header: "Account"
- multiSelect: false
- options:
- label: "Create a new account", description: "Free signup — I'll handle it right here, no browser needed."
- label: "Sign in to existing account", description: "Log in and pick one of your apps."
- label: "I'll paste credentials myself", description: "I already have my App ID, Region, and Auth Key."
Option 1 → Step 2b. Option 2 → Step 2a. Option 3 → Step 2d.
Step 2a — Sign in (existing account, browser flow)
npx @cometchat/skills-cli auth login
This command:
- Generates a short-lived session via the CLI auth API.
- Opens
https://app.cometchat.com/login?sessionId=<hex>in the user's default browser. - Polls the auth API every 5 seconds for up to 15 minutes.
- 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.
- Prints
✓ Logged in as <email> (backend: keychain-macos).
Let the CLI block — do NOT background it, do NOT race it with other prompts. The user completes sign-in in the browser tab; the terminal waits.
Terminal error handling (surface verbatim, stop, do not retry silently):
ACCESS_DENIED— user clicked Deny in the dashboard.EXPIRED— 15-minute window elapsed.TIMEOUT— max polls exhausted before user authorized.ABORTED— user Ctrl-C'd the CLI.NETWORK— couldn't reach the auth host.ALREADY_AUTHENTICATED— this session was already consumed. Re-runauth loginto mint a fresh session.
After success, verify:
npx @cometchat/skills-cli auth status --json
If status is "logged-in", proceed to Step 2c.
Step 2b — Sign up (new account, browser flow)
npx @cometchat/skills-cli auth signup
Same polling flow as Step 2a, but the CLI opens
https://app.cometchat.com/signup?sessionId=<hex>. The browser
handles everything — email, name, password, verification email, role,
industry. The CLI never sees any of those values. When the user
finishes signup in the browser, the next poll stores the bearer token
in the OS keychain and the CLI prints ✓ Logged in as <email>.
No role / name / verification-code questions in the chat. The dashboard owns that flow now; skipping it keeps the user's password and verification code out of the transcript.
Error codes match Step 2a (ACCESS_DENIED, EXPIRED, TIMEOUT, ABORTED, NETWORK, ALREADY_AUTHENTICATED). Surface verbatim and stop.
After success, verify:
npx @cometchat/skills-cli auth status --json
If status is "logged-in", proceed to **Ste