.claude/skills/implement-destination/SKILL.md
Generate destination code from analysis documents (OpenAPI or web-based) and user-selected actions
npx skillsauth add segmentio/action-destinations implement-destinationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill generates complete Segment action-destination code from analysis documents and user-selected actions.
Supported Analysis Sources:
/openapi-analyze)/web-analyze)All analysis documents must follow the format defined in .claude/skills/implement-destination/analysis-format.md.
Ask the user for the following information:
packages/destination-actions/.claude/openapi-analyses/)Read the analysis markdown file and extract:
Create the following directory structure:
packages/destination-actions/src/destinations/[slug]/
├── index.ts # Destination definition
├── generated-types.ts # Placeholder (auto-generated later)
├── [action-1]/
│ ├── index.ts # Action definition
│ ├── generated-types.ts # Placeholder
│ └── __tests__/
│ └── index.test.ts # Basic test
├── [action-2]/
│ └── ... (same structure)
└── __tests__/
└── index.test.ts # Destination test
Read the template at .claude/skills/implement-destination/templates/destination-index.md and customize it with:
Authentication Scheme Templates:
Custom (API Key in Header):
authentication: {
scheme: 'custom',
fields: {
apiKey: {
label: 'API Key',
description: 'Your [API Name] API key',
type: 'password',
required: true
}
},
testAuthentication: (request, { settings }) => {
return request('[TEST_ENDPOINT]', {
method: 'GET'
})
}
},
extendRequest({ settings }) {
return {
headers: {
Authorization: `Bearer ${settings.apiKey}`,
'Content-Type': 'application/json'
}
}
}
Basic Auth:
authentication: {
scheme: 'basic',
fields: {
username: {
label: 'Username',
description: 'Your [API Name] username',
type: 'string',
required: true
},
password: {
label: 'Password',
description: 'Your [API Name] password',
type: 'password',
required: true
}
},
testAuthentication: (request) => {
return request('[TEST_ENDPOINT]', {
method: 'GET'
})
}
}
OAuth2 Managed:
authentication: {
scheme: 'oauth-managed',
fields: {
// No additional fields needed for managed OAuth
},
testAuthentication: (request) => {
return request('[TEST_ENDPOINT]', {
method: 'GET'
})
}
}
For each selected action, generate three files:
Read the template at .claude/skills/implement-destination/templates/action-index.md and customize with:
Field Type Conversions:
// String field
fieldName: {
label: '[Label]',
description: '[Description]',
type: 'string',
required: [true|false],
default: { '@path': '$.path.to.field' }
}
// Integer/Number field
fieldName: {
label: '[Label]',
description: '[Description]',
type: 'integer', // or 'number'
required: [true|false]
}
// Boolean field
fieldName: {
label: '[Label]',
description: '[Description]',
type: 'boolean',
required: [true|false],
default: false
}
// Object field
fieldName: {
label: '[Label]',
description: '[Description]',
type: 'object',
required: [true|false],
properties: {
nestedField: {
label: '[Nested Label]',
type: 'string'
}
}
}
// Array field (multiple values)
fieldName: {
label: '[Label]',
description: '[Description]',
type: 'string', // or object
multiple: true,
required: [true|false]
}
// Datetime field
fieldName: {
label: '[Label]',
description: '[Description]',
type: 'datetime',
required: [true|false],
default: { '@path': '$.timestamp' }
}
// Enum field
fieldName: {
label: '[Label]',
description: '[Description]',
type: 'string',
required: [true|false],
choices: [
{ label: 'Option 1', value: 'option1' },
{ label: 'Option 2', value: 'option2' }
]
}
Perform Function Template:
perform: (request, { payload, settings }) => {
return request('[API_ENDPOINT]', {
method: '[POST|PUT|PATCH]',
json: {
// Map payload fields to API fields
[apiField]: payload.[segmentField],
// ... more mappings
}
})
}
PerformBatch Function Template (if supported):
performBatch: (request, { payload, settings }) => {
return request('[API_ENDPOINT]', {
method: 'POST',
json: payload.map(event => ({
[apiField]: event.[segmentField],
// ... more mappings
}))
})
}
Create placeholder file:
// This file is generated automatically by the CLI
// Run: ./bin/run generate:types --path packages/destination-actions/src/destinations/[slug]/index.ts
export interface Payload {
// Types will be generated from the action definition
}
Read the template at .claude/skills/implement-destination/templates/test-template.md and customize with:
// This file is generated automatically by the CLI
// Run: ./bin/run generate:types --path packages/destination-actions/src/destinations/[slug]/index.ts
export interface Settings {
// Types will be generated from the destination definition
}
import { createTestIntegration } from '@segment/actions-core'
import Destination from '../index'
const testDestination = createTestIntegration(Destination)
describe('[Destination Name]', () => {
describe('testAuthentication', () => {
it('should validate authentication inputs', async () => {
const authData = { [authField]: 'test_value' }
await expect(testDestination.testAuthentication(authData)).resolves.not.toThrowError()
})
})
})
Run the CLI command to generate proper types:
./bin/run generate:types --path packages/destination-actions/src/destinations/[slug]/index.ts
Generate a markdown file at packages/destination-actions/src/destinations/[slug]/IMPLEMENTATION_NOTES.md:
# [Destination Name] Implementation Notes
**Generated:** [date]
**From OpenAPI Analysis:** [analysis file path]
## Summary
This destination was generated from an OpenAPI specification analysis. The generated code provides ~70-80% of the implementation with clear TODOs for completion.
## Generated Files
- `index.ts` - Destination definition with [auth-type] authentication
[For each action:]
- `[action-name]/index.ts` - [Action description]
- `[action-name]/__tests__/index.test.ts` - Basic test for [action-name]
## TODO: Required Completions
### 1. Authentication
- [ ] Test `testAuthentication` with real API credentials
- [ ] Verify `extendRequest` headers are correct for API
- [ ] Confirm authentication error handling works
### 2. Actions
[For each action:]
- [ ] **[Action Name]:**
- [ ] Review field mappings accuracy
- [ ] Customize request body transformation if needed
- [ ] Add error handling for API-specific errors
- [ ] Test with real API (credentials required)
### 3. Testing
- [ ] Add comprehensive unit tests with mock API responses
- [ ] Test error scenarios (network errors, API errors, validation errors)
- [ ] Test batch operations (if applicable)
- [ ] Add integration tests
### 4. Documentation
- [ ] Update field descriptions with user-friendly language
- [ ] Add examples for complex fields
- [ ] Document any prerequisites or setup steps
- [ ] Add troubleshooting notes
## Next Steps
1. **Build and verify types:**
```bash
./bin/run generate:types --path packages/destination-actions/src/destinations/[slug]/index.ts
yarn build
```
Run tests:
yarn test packages/destination-actions/src/destinations/[slug]
Fix TypeScript errors (if any)
Complete TODO items above
Test with real API:
Code review and polish:
### Step 9: Serve the Destination Locally
After generating the code, run the destination locally so the user can test it immediately:
```bash
./bin/run serve packages/destination-actions/src/destinations/[slug]
This starts a local HTTP server that exposes the destination's actions as endpoints. The user can send test requests directly to verify the destination behaves as expected before completing the TODO items.
If the serve command fails (e.g., due to TypeScript errors), inform the user and suggest running yarn build first to surface compilation errors.
Show the user a summary:
✓ Created destination: [Destination Name]
✓ Location: packages/destination-actions/src/destinations/[slug]/
✓ Generated [N] actions:
- [action-1]: [one-line description]
- [action-2]: [one-line description]
✓ Generated TypeScript type definitions
✓ Created test files
✓ Created IMPLEMENTATION_NOTES.md
✓ Destination server started
The destination is now running locally. Send test requests to verify behavior.
Next steps:
1. Review generated code in packages/destination-actions/src/destinations/[slug]/
2. Complete TODOs in IMPLEMENTATION_NOTES.md
3. Run: yarn test packages/destination-actions/src/destinations/[slug]
4. Test with real API credentials
5. To restart the server: ./bin/run serve packages/destination-actions/src/destinations/[slug]
development
Analyze API documentation from a website and generate a destination implementation plan
development
Analyze an OpenAPI specification and generate a destination implementation plan with action recommendations
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.
development
Maintainer workflow for OpenClaw releases, prereleases, changelog release notes, and publish validation. Use when Codex needs to prepare or verify stable or beta release steps, align version naming, assemble release notes, check release auth requirements, or validate publish-time commands and artifacts.