Skip to content

Comments

docs(contact-center): add SDD templates for new method creation#4735

Open
ciscoRankush wants to merge 1 commit intowebex:task-refactorfrom
ciscoRankush:SPARK-775697Templates-new-method
Open

docs(contact-center): add SDD templates for new method creation#4735
ciscoRankush wants to merge 1 commit intowebex:task-refactorfrom
ciscoRankush:SPARK-775697Templates-new-method

Conversation

@ciscoRankush
Copy link

COMPLETES #SPARK-775697

This pull request addresses

AI agents need structured templates to guide new method addition in the @webex/contact-center SDK, ensuring they gather complete requirements including API contracts, event contracts, and metrics before implementation.

by making the following changes

Adds ai-docs/templates/new-method/ with 5 template files:

  • 00-master.md — Orchestrator with workflow overview and pattern links
  • 01-requirements.md — STOP gate with 12 interrogative questions covering method identity, signature, API integration, event contract, metrics, and behavior details. Includes completion gate, spec summary template, and getBuddyAgents example
  • 02-implementation.md — Method implementation patterns
  • 03-tests.md — Unit test generation patterns
  • 04-validation.md — Quality checklist with correct workspace commands (test:styles, test:unit, build:src)

Change Type

  • Documentation update

The following scenarios were tested

  1. Simulated "Add getBuddyAgents method" prompt — verified STOP gate, all 12 questions interrogative, event contract table present, completion gate, and spec summary with example
  2. Link validation — all relative paths verified correct (pattern links use ../../patterns/)
  3. Workspace commands verified against actual package.json scripts

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was used to create a draft that was subsequently customized or modified
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Other - Claude Code (Claude Opus 4.6)
  • This PR is related to
    • Tech Debt

I certified that

  • I have read and followed contributing guidelines
  • I discussed changes with code owners prior to submitting this pull request
  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the documentation accordingly

Add Spec-Driven Development templates for adding new methods:
- 00-master.md — Orchestrator with workflow overview
- 01-requirements.md — STOP gate with 12 interrogative questions,
  event contract table, metrics section, spec summary with example
- 02-implementation.md — Method implementation patterns
- 03-tests.md — Unit test generation patterns
- 04-validation.md — Quality checklist with correct workspace commands

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ciscoRankush ciscoRankush requested a review from a team as a code owner February 23, 2026 08:54
@Shreyas281299 Shreyas281299 added the validated If the pull request is validated for automation. label Feb 23, 2026
@@ -0,0 +1,80 @@
# New Method - Master Template

> **Purpose**: Orchestrator for adding new methods to existing services.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> **Purpose**: Orchestrator for adding new methods to existing services.
> **Purpose**: Orchestrator for adding new methods to existing services and utils.

## Workflow Overview

```
Step 1: Requirements → Step 2: Implementation → Step 3: Tests → Step 4: Validation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make this a flowchart

| Endpoint | "What is the full endpoint path?" |
| Request Payload | "What fields does the request body contain? Which are required vs optional?" |
| Response Structure | "What does the response look like?" |
| Error Shape | "What error reason codes can this return?" |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the response received? WS or in response of the request?


---

## Method Template (for cc.ts)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove 'for cc.ts' part from the heading. The same tmeplate can be used anywhere in the sdk

);

// 11. Throw augmented error
throw detailedError;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this template can we emit an event so that there is an example of emitting events. A success and failure event

Add tests to existing test file or create new one:
- For `cc.ts` methods: `test/unit/spec/cc.ts`
- For service methods: `test/unit/spec/services/[service]/index.ts`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also have an entry for files not in service fodler.

Comment on lines +163 to +166
yarn workspace @webex/contact-center test -- --testPathPattern=cc --testNamePattern="methodName"

# Run with coverage
yarn workspace @webex/contact-center test -- --coverage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
yarn workspace @webex/contact-center test -- --testPathPattern=cc --testNamePattern="methodName"
# Run with coverage
yarn workspace @webex/contact-center test -- --coverage
yarn workspace @webex/contact-center test:unit -- <path_to_specific-file>
# Run with coverage
yarn workspace @webex/contact-center test:unit --coverage

Comment on lines +65 to +67
1. [`../../patterns/typescript-patterns.md`](../../patterns/typescript-patterns.md)
2. [`../../patterns/sdk-plugin-patterns.md`](../../patterns/sdk-plugin-patterns.md) - For cc.ts methods
3. [`../../patterns/testing-patterns.md`](../../patterns/testing-patterns.md)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs update now

## Use Case

Use this template when:
- Adding a new method to an existing service
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be adding a new method or feature


Use this template when:
- Adding a new method to an existing service
- Adding a new public API method to `cc.ts`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same update here as well adding public method from cc or taks object

```
## Spec Summary — New Method

**Method**: `getBuddyAgents(data: BuddyAgents): Promise<BuddyAgentsResponse>`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also be talking about where and ho BuddyAgent, BuddyAgnetresponse type are defined and how that data can be figured

}

// 4. Call service method
const result = await this.services.someService.method({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For method implementations, there is also this small note we should add that actula method implementation sometime shappen in the service module but we still need to write a method from public object like cc or task and we do internal invocation if service method. And soemtimes we could be directly calling cc.service.method also.


## Pattern Verification

### Correct Logging Pattern
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error logging section should be added too under logging pattern and also dofferentiation ebtween when to use warn and when to use error


```bash
# Run specific test
yarn workspace @webex/contact-center test -- --testPathPattern=cc --testNamePattern="methodName"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be test:unit


// Assert
expect(mockServicesInstance.someService.method).toHaveBeenCalledWith({
data: expect.objectContaining({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid using objectcontaining. We should highlight that expect statement macthes should be accurate in most cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

validated If the pull request is validated for automation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants