MI

mistral-upgrade-migration

Plan and execute Mistral AI SDK upgrades while safely managing breaking changes and API deprecations.

Install

mkdir -p .claude/skills/mistral-upgrade-migration && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/4224" && unzip -o skill.zip -d .claude/skills/mistral-upgrade-migration && rm skill.zip

Installs to .claude/skills/mistral-upgrade-migration

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Analyze, plan, and execute Mistral AI SDK upgrades with breaking change
71 charsno explicit “when” trigger
Advanced

Key capabilities

  • Detect current and latest Mistral AI SDK versions
  • Identify known breaking changes between SDK versions
  • Automate code transformations for API surface changes
  • Upgrade the Mistral AI SDK to the latest version
  • Update hardcoded model name references
  • Provide a procedure for rolling back SDK upgrades

How it works

This skill analyzes the installed Mistral AI SDK version, applies automated code transformations based on known breaking changes between major versions, and guides the user through the upgrade and validation process.

Inputs & outputs

You give it
Existing codebase with Mistral AI SDK usage
You get back
Codebase updated to a newer Mistral AI SDK version with applied transformations

When to use mistral-upgrade-migration

  • Upgrading Mistral SDK to v1.x
  • Detecting breaking API changes
  • Migrating from CommonJS to ESM
  • Analyzing SDK version compatibility

About this skill

Mistral AI Upgrade & Migration

Current State

!npm list @mistralai/mistralai 2>/dev/null || echo 'not installed' !pip show mistralai 2>/dev/null | grep -E "^(Name|Version)" || echo 'not installed'

Overview

Guide for upgrading the Mistral AI SDK between major versions. The TypeScript SDK (@mistralai/mistralai) moved from CommonJS to ESM-only in v1.x, with significant API surface changes. This skill covers version detection, breaking change migration, automated code transforms, and rollback.

Prerequisites

  • Current Mistral AI SDK installed
  • Git for version control
  • Test suite available

Instructions

Step 1: Check Versions

set -euo pipefail
# Current version
npm list @mistralai/mistralai 2>/dev/null

# Latest available
npm view @mistralai/mistralai version

# All versions
npm view @mistralai/mistralai versions --json | jq '.[-5:]'

# Python
pip show mistralai 2>/dev/null | grep Version

Step 2: Known Breaking Changes (v0.x to v1.x)

Changev0.x (old)v1.x (current)
Module formatCommonJS + ESMESM only
Importimport MistralClient from '...'import { Mistral } from '...'
Constructornew MistralClient(apiKey)new Mistral({ apiKey })
Chat methodclient.chat(params)client.chat.complete(params)
Streamingclient.chatStream(params)client.chat.stream(params)
Stream eventsfor await (const chunk of stream)for await (const event of stream) access .data
Embeddingsclient.embeddings(params)client.embeddings.create(params)
Response typesLonger namesShorter type names
Enum valuesString constantsForward-compatible unions

Step 3: Automated Migration Script

// scripts/migrate-mistral-v1.ts
import { readFileSync, writeFileSync } from 'fs';
import { glob } from 'glob';

const TRANSFORMS = [
  // Import statement
  {
    find: /import\s+MistralClient\s+from\s+['"]@mistralai\/mistralai['"]/g,
    replace: "import { Mistral } from '@mistralai/mistralai'",
  },
  // Constructor
  {
    find: /new\s+MistralClient\((\w+)\)/g,
    replace: 'new Mistral({ apiKey: $1 })',
  },
  // Chat method (careful: only top-level .chat(), not .chat.complete())
  {
    find: /\.chat\((?!\.)/g,
    replace: '.chat.complete(',
  },
  // Streaming
  {
    find: /\.chatStream\(/g,
    replace: '.chat.stream(',
  },
  // Embeddings
  {
    find: /\.embeddings\((?!\.)/g,
    replace: '.embeddings.create(',
  },
];

async function migrate() {
  const files = await glob('src/**/*.{ts,js}');
  let totalChanges = 0;

  for (const file of files) {
    let content = readFileSync(file, 'utf-8');
    let changes = 0;

    for (const { find, replace } of TRANSFORMS) {
      const newContent = content.replace(find, replace);
      if (newContent !== content) {
        changes++;
        content = newContent;
      }
    }

    if (changes > 0) {
      writeFileSync(file, content);
      console.log(`Migrated: ${file} (${changes} changes)`);
      totalChanges += changes;
    }
  }

  console.log(`\nTotal: ${totalChanges} changes across ${files.length} files`);
}

migrate();

Step 4: Upgrade Procedure

set -euo pipefail
# Create branch
git checkout -b upgrade/mistral-sdk-v1

# Backup lock file
cp package-lock.json package-lock.json.bak

# Upgrade
npm install @mistralai/mistralai@latest

# Ensure package.json has "type": "module"
node -e "const p=require('./package.json'); if(p.type!=='module') console.warn('WARNING: Add \"type\": \"module\" to package.json for ESM')"

# Run migration script
npx tsx scripts/migrate-mistral-v1.ts

# Verify
npm run typecheck
npm test

Step 5: Model Name Updates

Model names change over time. Update hardcoded references:

// Model alias mapping — update when models deprecate
const MODEL_ALIASES: Record<string, string> = {
  // Deprecated → Current
  'mistral-tiny': 'mistral-small-latest',
  'mistral-medium': 'mistral-small-latest', // Deprecated Q1 2025
  'open-mistral-7b': 'mistral-small-latest',
  'open-mixtral-8x7b': 'mistral-small-latest',

  // Current (no change needed)
  'mistral-small-latest': 'mistral-small-latest',
  'mistral-large-latest': 'mistral-large-latest',
  'codestral-latest': 'codestral-latest',
  'mistral-embed': 'mistral-embed',
};

function resolveModel(model: string): string {
  const resolved = MODEL_ALIASES[model];
  if (resolved && resolved !== model) {
    console.warn(`Model "${model}" is deprecated, using "${resolved}"`);
  }
  return resolved ?? model;
}

Step 6: Validation Tests

import { describe, it, expect } from 'vitest';
import { Mistral } from '@mistralai/mistralai';

describe('SDK Upgrade Validation', () => {
  it('should import Mistral correctly', () => {
    expect(Mistral).toBeDefined();
    expect(typeof Mistral).toBe('function');
  });

  it('should construct client', () => {
    const client = new Mistral({ apiKey: 'test-key' });
    expect(client.chat).toBeDefined();
    expect(client.chat.complete).toBeDefined();
    expect(client.chat.stream).toBeDefined();
    expect(client.embeddings).toBeDefined();
    expect(client.embeddings.create).toBeDefined();
    expect(client.models).toBeDefined();
    expect(client.models.list).toBeDefined();
  });
});

Step 7: Rollback

set -euo pipefail
# Quick rollback
npm install @mistralai/[email protected] --save-exact
git checkout -- src/  # Restore pre-migration code
npm test

# Or just revert the branch
git checkout main
git branch -D upgrade/mistral-sdk-v1

Error Handling

Error After UpgradeCauseSolution
ERR_REQUIRE_ESMMissing "type": "module"Add to package.json
Mistral is not a constructorOld import styleUse import { Mistral }
.chat is not a functionOld method callUse .chat.complete()
Type errorsInterface changesUpdate types to match v1.x
Test failuresResponse shape changedUpdate assertions and mocks

Resources

Output

  • Updated SDK to latest version
  • Automated code migration applied
  • Model name references updated
  • Test suite passing after upgrade
  • Rollback procedure documented

When not to use it

  • When no test suite is available for validation

Prerequisites

Current Mistral AI SDK installedGit for version controlTest suite available

Limitations

  • Automated script may not cover all custom usage patterns
  • Requires `package.json` to have `"type": "module"` for ESM
  • Type errors may occur due to interface changes

How it compares

This skill automates the migration of Mistral AI SDK usage, reducing manual effort and potential errors compared to manually updating code for breaking changes.

Compared to similar skills

mistral-upgrade-migration side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
mistral-upgrade-migration (this skill)127dReviewAdvanced
mcp-builder1363moReviewAdvanced
stripe-integration482moNo flagsAdvanced
copilot-sdk74moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

mcp-builder

anthropics

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

136215

stripe-integration

wshobson

Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.

48165

copilot-sdk

github

Build agentic applications with GitHub Copilot SDK. Use when embedding AI agents in apps, creating custom tools, implementing streaming responses, managing sessions, connecting to MCP servers, or creating custom agents. Triggers on Copilot SDK, GitHub SDK, agentic app, embed Copilot, programmable agent, MCP server, custom agent.

763

documenso-install-auth

jeremylongshore

Install and configure Documenso SDK/API authentication. Use when setting up a new Documenso integration, configuring API keys, or initializing Documenso in your project. Trigger with phrases like "install documenso", "setup documenso", "documenso auth", "configure documenso API key".

11

gamma-upgrade-migration

jeremylongshore

Upgrade Gamma SDK versions and migrate between API versions. Use when upgrading SDK packages, handling deprecations, or migrating to new API versions. Trigger with phrases like "gamma upgrade", "gamma migration", "gamma new version", "gamma deprecated", "gamma SDK update".

10

posthog-install-auth

jeremylongshore

Install and configure PostHog SDK/CLI authentication. Use when setting up a new PostHog integration, configuring API keys, or initializing PostHog in your project. Trigger with phrases like "install posthog", "setup posthog", "posthog auth", "configure posthog API key".

10

Search skills

Search the agent skills registry