Index of every page on this site: llms.txt
All skills
jeremylongshore avatar

/clade-migration-deep-dive

@0d57af8
Run it yourself

Migrate from OpenAI/GPT to Anthropic/Claude — API differences, Use when working with migration-deep-dive patterns. prompt adaptation, SDK swap, and feature mapping. Trigger with "migrate to claude", "openai to anthropic", "switch from gpt to claude", "replace openai with anthropic".

Use this Skill: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/clade-migration-deep-dive

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈78 tokens for metadata: the name and description. ≈987 when used: this file. ≈426 more on demand in 1 file.

Description uses 3.9% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈311 characters, or 3.9%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Migrate from OpenAI to Anthropic

Overview

Migrate from OpenAI/GPT to Anthropic/Claude. Covers the complete API mapping (endpoints, models, response shapes), SDK swap with before/after code, five key differences (max_tokens required, system as top-level param, alternating messages, response path, streaming events), and tool use migration.

API Mapping

OpenAI Anthropic Notes
openai.chat.completions.create() anthropic.messages.create() Different request/response shape
model: 'gpt-4o' model: 'claude-sonnet-4-20250514' Different model IDs
response.choices[0].message.content response.content[0].text Different response path
system in messages array system as separate parameter Claude uses top-level system
response_format: { type: 'json_object' } System prompt: "Respond in JSON only" No native JSON mode
tools / function_calling tools (similar but different schema) Input schema differences
openai.embeddings.create() N/A — use Voyage or Cohere No embeddings API

SDK Swap

Instructions

Step 1: Before (OpenAI)

import OpenAI from 'openai';
const openai = new OpenAI();

const response = await openai.chat.completions.create({
  model: 'gpt-4o',
  messages: [
    { role: 'system', content: 'You are helpful.' },
    { role: 'user', content: 'Hello' },
  ],
});
console.log(response.choices[0].message.content);

Step 2: After (Anthropic)

import Anthropic from '@claude-ai/sdk';
const anthropic = new Anthropic();

const response = await anthropic.messages.create({
  model: 'claude-sonnet-4-20250514',
  max_tokens: 1024, // Required (not optional like OpenAI)
  system: 'You are helpful.', // Separate from messages
  messages: [
    { role: 'user', content: 'Hello' },
  ],
});
console.log(response.content[0].text);

Key Differences

  1. max_tokens is required — OpenAI defaults it, Anthropic requires it
  2. system is a top-level param — not a message in the array
  3. First message must be user — can't start with assistant
  4. Messages must alternate — no two user or two assistant messages in a row
  5. Response shape — content[0].text not choices[0].message.content
  6. Streaming events — different event types and structure

Tool Use Migration

// OpenAI tool definition
{ type: 'function', function: { name: 'get_weather', parameters: { ... } } }

// Anthropic tool definition
{ name: 'get_weather', input_schema: { ... } }  // Flatter structure

Grep & Replace

# Find all OpenAI imports
grep -rn "from 'openai'" --include="*.ts" .
grep -rn "import OpenAI" --include="*.ts" .

# Find response access patterns to update
grep -rn "choices\[0\]" --include="*.ts" .
grep -rn "message.content" --include="*.ts" .  # May need updating

Output

  • All openai imports replaced with @claude-ai/sdk
  • Response access patterns updated (choices[0].message.content → content[0].text)
  • System prompts moved from messages array to top-level system parameter
  • max_tokens added to all API calls (required, not optional)
  • Tool definitions restructured to Anthropic format

Error Handling

Error Cause Solution
API Error Check error type and status code See clade-common-errors

Examples

See API Mapping table, Before/After SDK code, Key Differences list, Tool Use Migration, and Grep & Replace commands above.

Resources

Next Steps

See clade-sdk-patterns for production Anthropic SDK patterns.

Prerequisites

  • Existing OpenAI integration to migrate
  • Access to codebase with search capability
  • Test suite for comparing outputs between providers

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

2 warnings2mo3 checks · Risk MEDIUM
  • Gen Agent Trust Hub2mo

    The skill provides a migration guide from OpenAI to Anthropic but recommends using an unofficial and non-standard Node.js package name (@claude-ai/sdk) instead of the official SDK (@anthropic-ai/sdk). This presents a potential supply chain risk if users install the non-standard package.

  • Socket2mo

    1 alert: gptAnomaly

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 0d57af8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 2 months ago
What it can do
Reads files Edits files
version
1.1.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
[
  "saas",
  "anthropic",
  "claude",
  "migration",
  "openai"
]
All 4 allowed tools
ReadWriteEditGrep
Other metadata
compatibility
Designed for Claude Code

README badge

README badge for jeremylongshore/tons-of-skills-marketplace/clade-migration-deep-dive