Générateur d'implémentation Destination

VérifiéPrudence

Génère le code complet d'une destination Segment action à partir de documents d'analyse (spécifications OpenAPI ou documentation web) et des actions sélectionnées par l'utilisateur. Lit un fichier d'analyse markdown, extrait les détails de l'API, l'authentification et les spécifications des actions, puis crée la structure de répertoire complète de la destination avec des fichiers TypeScript. Utile pour construire des destinations Segment en automatisant la génération de code répétitif à partir de l'analyse d'API.

Spar Skills Guide Bot
DeveloppementIntermédiaire
09/03/2026
Claude Code
#code-generation#segment-destination#openapi#scaffolding#typescript

Recommandé pour

Synthèse automatique

Génère le squelette complet du code d'une action-destination Segment (index, actions, tests) à partir d'un document d'analyse OpenAPI ou web et d'une liste d'actions choisies par l'utilisateur.

Points forts

  • Automatise la création de l'arborescence de répertoires et des fichiers d'index pour la destination et chaque action sélectionnée
  • Fournit des modèles d'authentification prêts à l'emploi (clé API custom, basic auth, OAuth géré) avec testAuthentication et extendRequest
  • Extrait des spécifications d'analyse les endpoints, schémas de corps de requête, support batch et abonnement par défaut
  • Suit un format d'analyse standardisé, ce qui rend la génération reproductible

Limites

  • Suppose qu'un document d'analyse conforme au Standard Analysis Format existe déjà ; le skill ne fait pas l'analyse lui-même
  • Les fichiers generated-types.ts ne sont créés que comme espaces réservés et doivent être générés ultérieurement
  • Les tests produits sont des tests de base, à compléter manuellement
  • Fortement couplé au dépôt Segment action-destinations et à son arborescence de packages
Quand l'utiliser

À utiliser lorsqu'un document d'analyse d'API est prêt et que vous voulez échafauder rapidement une nouvelle destination Segment avec plusieurs actions.

Quand l'éviter

À éviter si vous n'avez pas encore d'analyse conforme, ou si vous construisez une intégration en dehors de l'écosystème Segment action-destinations.

Analyse de sécurité

Prudence
Score qualité84/100

This is a legitimate code-generation workflow for Segment destinations. It contains no destructive, exfiltrating, or obfuscated instructions, but it grants powerful file-editing/shell tools and uses user-provided paths/slugs for file operations, so caution is appropriate.

Points d'attention
  • •Declares Bash, Write, and Edit tools, enabling repository file creation and modification; no destructive commands are specified.
  • •User-supplied analysis path and destination slug are used for filesystem operations without explicit sanitization guidance, so malformed input could affect unintended paths.
  • •Generated code may call API endpoints for authentication/testing, but the skill itself does not exfiltrate secrets or obfuscate payloads.
Comment cette analyse est faite

Exemples

Scaffold a new destination
Use the analysis at packages/destination-actions/.claude/openapi-analyses/acme-marketing.md to implement a destination called "Acme Marketing" (slug acme-marketing). Generate the destination index.ts plus the createOrUpdateContact and trackEvent actions.
Add actions to an existing destination
From the analysis document at .claude/openapi-analyses/braze.md, generate only the sendEmail and identifyUser actions for the braze destination, using the API-key-in-header auth scheme.
Generate tests alongside actions
Implement the destination slug acme-marketing from its analysis doc for actions createOrder, updateOrder, and deleteOrder, including the destination test and a basic test file for each action.

name: implement-destination description: Generate destination code from analysis documents (OpenAPI or web-based) and user-selected actions version: 1.0.0 allowed-tools:

  • Read
  • Write
  • Edit
  • Bash
  • Glob
  • Grep
  • AskUserQuestion disable-model-invocation: false

Destination Implementation Generator

This skill generates complete Segment action-destination code from analysis documents and user-selected actions.

Supported Analysis Sources:

  • OpenAPI specifications (via /openapi-analyze)
  • Website documentation (via /web-analyze)
  • Any analysis document following the Standard Analysis Format

All analysis documents must follow the format defined in .claude/skills/implement-destination/analysis-format.md.

Instructions

Step 1: Gather Inputs

Ask the user for the following information:

  1. Analysis Document Path - Path to the analysis markdown file (should be in packages/destination-actions/.claude/openapi-analyses/)
  2. Destination Name - Human-readable name (e.g., "Acme Marketing", "Braze")
  3. Destination Slug - Auto-suggest based on name (e.g., "acme-marketing" from "Acme Marketing")
    • Remove "actions-" prefix if user includes it - this is added automatically to the path
    • Use lowercase, hyphens instead of spaces
  4. Selected Actions - Comma-separated list of action names to implement (from the analysis doc)

Step 2: Parse Analysis Document

Read the analysis markdown file and extract:

  • API name, version, base URL
  • Authentication scheme and required fields
  • Test authentication endpoint
  • Selected action specifications:
    • Endpoint path and method
    • Operation ID
    • Description
    • Field mappings table
    • Request body schema
    • Batch support
    • Default subscription

Step 3: Create Destination Structure

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

Step 4: Generate Destination index.ts

Read the template at .claude/skills/implement-destination/templates/destination-index.md and customize it with:

  • Destination name and slug
  • Description from OpenAPI
  • Authentication scheme and fields
  • Test authentication endpoint (or TODO if not found)
  • Import statements for all selected actions
  • extendRequest implementation with proper headers
  • Regional endpoint handling if applicable

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'
    })
  }
}

Step 5: Generate Action Files

For each selected action, generate three files:

5.1: Action index.ts

Read the template at .claude/skills/implement-destination/templates/action-index.md and customize with:

  • Action title and description
  • Default subscription from analysis
  • Fields from the field mappings table:
    • Convert each field to an InputField definition
    • Set type, label, description, required
    • Add default path where suggested
    • Handle special types (objects, arrays, datetime)
  • Perform function with request to API endpoint
  • PerformBatch function if batch is supported

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
    }))
  })
}

5.2: Action generated-types.ts

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
}

5.3: Action Test File

Read the template at .claude/skills/implement-destination/templates/test-template.md and customize with:

  • Action name
  • Event type (track/identify/group)
  • Sample event data
  • Field mappings for test
  • Assertions

Step 6: Generate Destination-Level Files

6.1: Destination generated-types.ts

// 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
}

6.2: Destination Test File

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()
    })
  })
})

Step 7: Generate TypeScript Types

Run the CLI command to generate proper types:

./bin/run generate:types --path packages/destination-actions/src/destinations/[slug]/index.ts

Step 8: Create Implementation Notes

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
   ```
  1. Run tests:

    yarn test packages/destination-actions/src/destinations/[slug]
    
  2. Fix TypeScript errors (if any)

  3. Complete TODO items above

  4. Test with real API:

    • Obtain test credentials
    • Configure destination in local development
    • Send test events
    • Verify API receives correct data
  5. Code review and polish:

    • Review generated code for any OpenAPI-specific quirks
    • Add any missing edge case handling
    • Ensure error messages are helpful

Known Limitations of Generated Code

  • Error handling: Generic errors are thrown - customize for API-specific error codes
  • Complex schemas: Nested objects may need manual refinement
  • Dynamic fields: Cannot auto-generate dynamic field implementations
  • Rate limiting: No automatic rate limit handling - add if needed
  • Retries: No retry logic - add if API recommends it

API Documentation

  • Base URL: [base URL]
  • API Docs: [link if available]
  • Support: [support contact if available]

### 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.

Step 10: Present Results

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]

Tips

  • Always generate well-formatted, idiomatic TypeScript
  • Follow existing destination patterns in the codebase
  • Use proper imports from '@segment/actions-core'
  • Leave clear TODO comments for manual work
  • Ensure all files have proper error handling imports even if not fully implemented
  • Keep perform functions simple - map payload to API request
  • For complex transformations, add TODO comments explaining what's needed

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/destination-implementation-generator-mmio71yr/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/destination-implementation-generator-mmio71yr' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/destination-implementation-generator-mmio71yr/download' --output '.skill-downloads/destination-implementation-generator-mmio71yr/SKILL.md.part' && mv '.skill-downloads/destination-implementation-generator-mmio71yr/SKILL.md.part' '.skill-downloads/destination-implementation-generator-mmio71yr/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/destination-implementation-generator-mmio71yr/SKILL.md' && test -s '.skill-downloads/destination-implementation-generator-mmio71yr/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/implement-destination' && cp -R '.skill-downloads/destination-implementation-generator-mmio71yr' '.claude/skills/implement-destination'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/destination-implementation-generator-mmio71yr'

openskills read 'destination-implementation-generator-mmio71yr'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/destination-implementation-generator-mmio71yr/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires