This is the main orchestrator for AI assistants working on this repository. It routes you to the correct templates and documentation based on the developer's task.
For every developer request: (1) Identify task type (A–F below). (2) If the work is in an existing package, widget, or test framework scope, load that scope's ai-docs (see Package and widget ai-docs reference) and follow its AGENTS.md. (3) Open the template for that type and complete its mandatory pre-steps (see Mandatory pre-steps by task type). (4) Then follow the rest of this guide and the template.
When developer provides a task, follow this workflow:
- Understand the task - Identify what type of work is needed
- Break down large or multi-part tasks - If the prompt mixes multiple tasks (for example, "create new widget" and "fix a bug" or "add a feature"), or the task is very large, split it into smaller, clearly scoped subtasks and handle them one by one
- Route to appropriate template - Use modular templates for guidance
- Load package/widget ai-docs when working in that scope - If fixing, generating, or enhancing code in an existing package or widget, read that scope's ai-docs/AGENTS.md and ARCHITECTURE.md and follow them (see CRITICAL RULES rule 3).
- Complete that template's mandatory pre-step section - See Mandatory pre-steps by task type in CRITICAL RULES. Do not generate code until pre-steps are done or the developer explicitly waives them.
- Generate/fix code - Follow established patterns
- Update documentation - Keep ai-docs in sync with code changes
- Ask for review - Confirm completion with developer
Ask developer: "What do you need help with?"
If the developer's message contains multiple distinct task types (for example, "create new widget", "fix a bug", and "add a feature" in one prompt), treat each as a separate internal task. Clarify priorities or ordering with the developer when needed, and then execute the subtasks sequentially rather than trying to complete everything at once.
A. Create New Widget
- Developer wants to build a completely new widget from scratch
- Route to: templates/new-widget/00-master.md
- Follow: All 7 modules (pre-questions → validation)
⚠️ MANDATORY FIRST STEP: Collect design input (see below)
B. Fix Bug in Existing Widget
- Developer reports a bug or issue in existing code
- Route to: templates/existing-widget/bug-fix.md
- Follow: Bug fix workflow with root cause analysis
C. Add Feature to Existing Widget
- Developer wants to enhance existing widget with new functionality
- Route to: templates/existing-widget/feature-enhancement.md
- Follow: Feature addition workflow with backward compatibility
D. Generate/Update Documentation Only
- Developer needs documentation for existing code
- Route to: templates/documentation/create-agent-md.md and templates/documentation/create-architecture-md.md
- Follow: Documentation templates (reusable for all packages)
E. Understanding Architecture
- Developer needs to understand how something works
- Read: That scope's
ai-docs/AGENTS.md(usage) andai-docs/ARCHITECTURE.md(technical details); use Package and widget ai-docs reference to find the path. - Available for: station-login, user-state, store, cc-components, cc-widgets, ui-logging, test-fixtures, playwright; for task package use per-widget ai-docs (CallControl, IncomingTask, OutdialCall, TaskList).
F. Playwright E2E Test Work
- Developer wants to add/update/stabilize Playwright tests, suites, sets, or test framework docs
- Route to: templates/playwright/00-master.md
- Follow: Playwright template workflow (pre-questions → implementation → validation)
⚠️ MANDATORY FIRST STEP: Complete pre-questions in templates/playwright/01-pre-questions.md
NEVER create these imports:
// ❌ WRONG - Circular dependencies
import { Widget } from '@webex/cc-widgets'; // In widget package code
import { Widget } from '@webex/cc-widget-name'; // In cc-components codeALWAYS use this pattern:
// ✅ CORRECT - Proper dependency flow
// In widget code:
import { Component } from '@webex/cc-components';
import store from '@webex/cc-store';
import { withMetrics } from '@webex/cc-ui-logging';
// In cc-widgets aggregator (ONLY):
import { Widget } from '@webex/cc-widget-name';Dependency Flow (One Direction Only):
cc-widgets → widget packages → cc-components → store → SDK
Validation Before Code Generation:
- Widget does NOT import from
@webex/cc-widgets - cc-components does NOT import from any widget packages
- All imports follow one-directional flow
- No circular references between packages
If circular dependency is detected → STOP and refactor imports immediately.
STOP! Before generating ANY new widget code, collect design input.
-
Figma Link/File
- Share Figma link or file
- LLM will extract design tokens, components, interactions
-
Screenshot/Mockup
- Upload image of desired widget UI
- LLM will analyze colors, layout, components, spacing
-
Design Specification
- Provide detailed specs:
- Colors (hex/RGB or Momentum tokens)
- Layout structure (flex/grid)
- Components needed (Button, Icon, Avatar, etc.)
- Typography (sizes, weights)
- Interactions (hover, click states)
- Provide detailed specs:
Analyze and document:
- Colors: Extract hex/RGB values or Momentum tokens
- Components: Identify Momentum UI components to use
- Layout: Grid, flex, spacing patterns (8px/0.5rem grid)
- Typography: Sizes, weights (Momentum typography scale)
- Interactions: Buttons, hover states, transitions
ASK THE USER:
⚠️ Design Input Required
I cannot generate a widget without visual design reference. This ensures:
- UI matches your design system
- Correct Momentum components are used
- Proper styling and theming
Please provide ONE of:
1. Figma link/file
2. Screenshot of desired UI
3. Detailed design specification (colors, layout, components)
Once provided, I'll analyze it and generate the widget accordingly.
DO NOT proceed without design input.
When fixing, generating, or enhancing code in a package or widget, you MUST read and follow that scope's ai-docs/AGENTS.md (and ai-docs/ARCHITECTURE.md where available). See Package and widget ai-docs reference in Step 2. The root AGENTS.md is the orchestrator; each package/widget AGENTS.md is the authoritative reference for that scope—use both.
Before generating or changing any code, you MUST complete the pre-step section of the template for the task type (see table below). Either fill it from the developer's message and confirm, or ask the developer for missing items. Do not proceed to implementation steps until pre-steps are done or the developer explicitly asks to skip them.
| Task type | Template | Mandatory pre-step (complete before code) |
|---|---|---|
| A. Create New Widget | new-widget/00-master.md | Design input + 01-pre-questions.md (widget name, 4 technical inputs) |
| B. Fix Bug | existing-widget/bug-fix.md | Pre-Fix Questions (bug info, scope, impact, existing tests) |
| C. Add Feature | existing-widget/feature-enhancement.md | Pre-Enhancement Questions (feature info, requirements, compatibility, design input) |
| D. Documentation only | documentation templates | Optional: confirm scope with developer (no code change) |
| E. Understanding | Package ai-docs | None (read-only) |
| F. Playwright E2E Test Work | playwright/00-master.md | Pre-Questions (scope, scenarios, setup/utilities, stability expectations) |
Before generating code, load appropriate context:
-
Pattern documentation - patterns/ folder
- typescript-patterns.md - Type safety, naming conventions
- react-patterns.md - Component patterns, hooks
- mobx-patterns.md - State management with observer HOC
- web-component-patterns.md - r2wc patterns
- testing-patterns.md - Jest, RTL, Playwright
-
Package/widget ai-docs (mandatory when working in that scope)
When fixing, generating, or enhancing code in a package or widget, you MUST read that scope'sai-docs/AGENTS.md(andARCHITECTURE.mdwhere listed) and follow its instructions. The root AGENTS.md orchestrates; package/widget AGENTS.md is the authoritative reference for that scope. Use the table below to find the right path.
Task package note: The task package has multiple widgets (CallControl, IncomingTask, OutdialCall, TaskList). When working on one of them, use that widget's ai-docs path above, not a generic task path.
If using SDK APIs:
- Scan: contact-centre-sdk-apis/contact-center.json
- Find available methods, events, types
- Check method signatures before using
If working on Playwright tests/framework:
- Read:
playwright/ai-docs/AGENTS.md - Read:
playwright/ai-docs/ARCHITECTURE.md - Use:
ai-docs/templates/playwright/00-master.mdand complete01-pre-questions.mdbefore implementation
Before using ANY SDK method, consult the SDK knowledge base.
Based on widget requirements, list needed operations:
- Making calls? → Search: "call", "dial", "telephony", "outdial"
- Fetching agents? → Search: "agent", "buddy", "team"
- Managing tasks? → Search: "task", "interaction", "contact"
- Checking state? → Search: "state", "status", "presence"
File: contact-centre-sdk-apis/contact-center.json
Search Strategy:
- Use keyword search in JSON
- Look for method names, descriptions
- Check similar/related methods
For each method found, confirm:
- ✅ Method name (exact spelling)
- ✅ Parameters (names, types, required vs optional)
- ✅ Return type
- ✅ Error conditions
- ✅ Usage notes
// ✅ CORRECT - Via store
await store.cc.methodName(params);
// ❌ WRONG - Direct SDK import
import sdk from '@webex/contact-center';
await sdk.methodName(params);try {
const result = await store.cc.methodName(params);
// Handle success
props.onSuccess?.(result);
} catch (error) {
console.error('SDK error:', error);
props.onError?.(error);
}Requirement: Make outbound call
SDK Search: "outdial", "call", "dial"
Found: startOutdial(destination: string, origin: string)
Usage:
const handleDial = async (phoneNumber: string) => {
try {
await store.cc.startOutdial(phoneNumber, 'WidgetName');
props.onDial?.(phoneNumber);
} catch (error) {
console.error('Outdial failed:', error);
props.onError?.(error);
}
};- Agent State:
store.cc.setAgentState(state, reasonCode) - Task Accept:
task.accept() - Task Hold:
task.hold() - Task End:
task.end() - Events:
store.cc.on('eventName', handler)
All code must follow this pattern:
Widget (observer HOC)
↓
Custom Hook (business logic)
↓
Presentational Component (pure UI)
↓
Store (MobX singleton)
↓
SDK (Contact Center API)
Key Rules:
- Widget consumes SDK methods via the store (through a hook) — it NEVER calls the SDK directly
- Component NEVER accesses store (receives props)
- Always use
observerHOC for widgets - Always use
runInActionfor store mutations - Always wrap with ErrorBoundary
- Always apply withMetrics HOC for exports
Follow the template you were routed to in Step 1
You must have already completed that template's pre-step section (Pre-Enhancement Questions, Pre-Fix Questions, or 01-pre-questions as applicable); if not, do that first.
During code generation:
- Follow pattern documentation strictly
- Reference existing widgets for examples
- Use proper TypeScript types (no
any) - Include error handling
- Add loading/error states
- Write tests alongside code
After generating code, VERIFY functionality layer by layer.
- SDK methods exist in contact-centre-sdk-apis/contact-center.json
- Parameters match SDK signature exactly
- Accessed via
store.cc.methodName()(not direct import) - Error handling present (try/catch)
- Success callbacks fire
- Error callbacks fire
If method not found or signature mismatch → FIX before proceeding
- Observable data accessed correctly
-
runInActionused for mutations - No direct store property assignments
- Store subscriptions cleaned up (useEffect return)
Trace each user interaction:
- User action (click, input) → Event handler called?
- Handler → State update triggered?
- State update → Re-render triggered?
- Re-render → UI updated correctly?
If ANY step fails → Debug and fix
Trace data through ALL layers:
User Action (UI)
↓
Widget Handler (index.tsx)
↓
Hook Method (helper.ts)
↓
Store/SDK Call
↓
Response/Observable Update
↓
Hook State Update
↓
Component Props
↓
UI Render
Verify each transition is correct.
Compare with design input:
- Colors match (or use Momentum tokens)
- Spacing matches (8px/0.5rem grid)
- Components match design
- Layout matches (flex/grid structure)
- Typography matches (sizes, weights)
- Interactions work (hover, click, etc.)
If visual doesn't match → Update styling
Check for circular dependencies:
# In widget code, search for:
grep -r "from '@webex/cc-widgets'" src/
# Should return: NO MATCHES
# In cc-components, search for:
grep -r "from '@webex/cc-.*-widget'" packages/contact-center/cc-components/src/
# Should return: NO MATCHESIf any matches found → Refactor imports
yarn build
# Expected: NO ERRORSCommon errors:
- Missing types → Add type definitions
- Import errors → Check paths and exports
- Circular dependencies → Refactor imports
- Syntax errors → Fix code
Fix ALL compiler errors before completing.
CRITICAL: After any code change, check if documentation needs updates
Ask developer: "The code changes are complete. Do I need to update any documentation?"
If new widget created:
- Generated via templates (AGENTS.md + ARCHITECTURE.md)
If widget modified:
- Update:
packages/contact-center/{widget-name}/ai-docs/AGENTS.md(if API changed) - Update:
packages/contact-center/{widget-name}/ai-docs/ARCHITECTURE.md(if architecture changed) - Add: New examples to AGENTS.md (if new use cases)
- Update: Troubleshooting in ARCHITECTURE.md (if new issues discovered)
If store modified:
- Update:
packages/contact-center/store/ai-docs/AGENTS.md - Update:
packages/contact-center/store/ai-docs/ARCHITECTURE.md
If component library modified:
- Update:
packages/contact-center/cc-components/ai-docs/AGENTS.md
If new pattern established:
- Update: Relevant pattern file in patterns/
If architecture changed:
- Update: Relevant architecture documentation as needed
If Playwright E2E framework/docs changed:
- Update:
playwright/ai-docs/AGENTS.md - Update:
playwright/ai-docs/ARCHITECTURE.md - Update relevant modules in:
ai-docs/templates/playwright/
Before marking task complete:
-
Run validation checks
- Tests pass:
yarn test:unit - Linting passes:
yarn test:styles - Build succeeds:
yarn build
- Tests pass:
-
Code quality checks
- Follows patterns
- No layer violations
- Error handling present
- Types are correct
- Code is precise and concise (no unnecessary complexity or dead code)
-
Documentation checks
- AGENTS.md updated if needed
- ARCHITECTURE.md updated if needed
- Examples work
-
Ask developer for review:
- "Task complete. Would you like to review the changes?"
- "Should I make any adjustments?"
- "Is the documentation clear?"
ccWidgets/
├── packages/contact-center/
│ ├── ai-docs/migration/ # Task refactor migration docs (old → new)
│ ├── station-login/ # Widget with ai-docs/
│ ├── user-state/ # Widget with ai-docs/
│ ├── task/ # Widget package
│ ├── store/ # MobX store with ai-docs/
│ ├── cc-components/ # React components with ai-docs/
│ ├── cc-widgets/ # Web Component wrappers with ai-docs/
│ ├── ui-logging/ # Metrics utilities with ai-docs/
│ └── test-fixtures/ # Test mocks with ai-docs/
├── widgets-samples/
│ └── cc/
│ ├── samples-cc-react-app/ # React sample
│ └── samples-cc-wc-app/ # Web Component sample
├── playwright/ # E2E tests
└── ai-docs/
├── AGENTS.md # This file
├── RULES.md # Repository rules
├── patterns/ # Repo-wide patterns
├── templates/ # Code generation templates
└── contact-centre-sdk-apis/ # SDK API reference
Before starting any work:
- "What component/widget are you working on?"
- "Is this a new widget, bug fix, or enhancement?"
- "Do you have design specifications (Figma, screenshots)?"
During code generation:
- "Should I add/update tests?"
- "Do you want examples in documentation?"
- "Should I update the sample apps?"
After code generation:
- "The code is complete. Should I update documentation?"
- "Would you like to review before I mark this complete?"
- "Should I check for any other impacted components?"
Location: contact-centre-sdk-apis/contact-center.json
Contents:
- All exposed SDK APIs (methods, events, types)
- Method signatures and parameters
- Event names and data structures
- Links to SDK source code (next branch)
Usage:
- Scan JSON when using SDK methods
- Search for API by name or functionality
- Check parameter types and return values
- Verify event names before subscribing
Note: This JSON is TypeDoc output from @webex/contact-center SDK
Code generation/fix is successful when:
- ✅ Follows architecture pattern (Widget → Hook → Component → Store → SDK)
- ✅ Uses patterns correctly (TypeScript, React, MobX, WC)
- ✅ Includes proper error handling
- ✅ Has tests with good coverage
- ✅ Documentation is updated (if code changed)
- ✅ Works in both sample apps (React + WC)
- ✅ No console errors or warnings
- ✅ Passes validation checks
- ✅ Developer approves changes
- Repository Rules: RULES.md
- Templates Overview: templates/README.md
- Task Refactor Migration (Contact Center): packages/contact-center/ai-docs/migration/migration-overview.md — overview and entry point for CC SDK task-refactor migration docs
Last Updated: 2025-11-26