Logo de Contentful Migration

Contentful Migration

Organisation
contentful
contentful-migration

Write and run Contentful content model migration scripts using the contentful-migration library and the Contentful CLI. Covers creating, editing, and deleting content types and fields, validations, editor interface configuration, editor layouts, sidebar widgets, entry transformations, tags, annotations, and the migration context object. Use when asked to write a migration, create or add a content type, add, rename, or delete fields, change or update a content model, transform entries, derive linked entries, configure editor controls, or run a migration script. Also triggers on "migration script", "contentful-migration", "schema migration", "content model migration", "field validation", "editor interface", "editor layout", "sidebar widget", "moveField", "changeFieldId", "rich text field", "reference field", "link field". Not for SDK client setup or Next.js integration (contentful-nextjs). Not for Contentful terminology or API routing (contentful-guide).

Présentation

Éditeurcontentful
Dépôtskills
Nom de la compétencecontentful-migration
Étoiles
41
Forks
3
Fichiers inclus
4
LicenceMIT
Liens
  • Instructions en Markdown

    Un fichier SKILL.md que le modèle charge à la demande : il ne consomme donc des tokens que lorsqu’une demande correspond réellement à la compétence.

  • Compatible avec tous les LLM

    Les compétences IA sont en simple Markdown, et non en code propre à un fournisseur. Elles fonctionnent donc avec GPT, Claude, Gemini, Grok ou un modèle local.

  • 4 fichiers inclus

    Des scripts, des modèles de documents et des références que le modèle peut consulter pendant son travail. Les fichiers sont en lecture seule et ne sont jamais exécutés.

  • Open source

    Publiée par contentful sur GitHub. Consultez les sources avant de l’installer.

Installation

Installez la compétence IA Contentful Migration dans TypingMind pour l’utiliser avec n’importe quel LLM, ou ajoutez-la à un autre agent capable de lire SKILL.md.

1

Installer dans TypingMind

TypingMind installe une compétence directement depuis son dossier GitHub : l’application lit SKILL.md, regroupe les fichiers de ressources et enregistre le tout localement.

  1. Ouvrez l’application et accédez à Plugins → Compétences.
  2. Choisissez « Installer depuis GitHub ».
  3. Collez l’URL du dossier de la compétence indiquée ci-dessous, puis confirmez.
    https://github.com/contentful/skills/tree/main/skills/contentful-migration
  4. Activez la compétence dans chaque discussion où vous souhaitez pouvoir l’utiliser.
Plugins → Compétences → Ajouter → Via URL GitHub, puis collez l’URL du dossier et appuyez sur Continuer.
2

Installer dans un autre agent

Tout agent capable de lire le format Agent Skills peut utiliser cette compétence : copiez le dossier dans le répertoire des compétences de cet agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/contentful/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/skills/contentful-migration .claude/skills/contentful-migration
Redémarrez Claude Code après la copie pour que la nouvelle compétence soit prise en compte.

Utilisez cette compétence dans TypingMind

Activez Contentful Migration dans n’importe quelle discussion TypingMind et le modèle s’occupe du reste. Le nom et la description de la compétence figurent dans le prompt système. Dès qu’une demande correspond, le modèle charge lui-même l’intégralité des instructions : vous n’avez jamais à l’invoquer manuellement, et elle ne consomme aucun token tant qu’elle n’est pas utilisée.

Le modèle charge automatiquement Contentful Migration dès qu’une demande correspond à cette compétence.

Compatible avec tous les modèles IA

Les compétences IA sont de simples instructions Markdown, et non du code propre à un fournisseur. Ainsi, Contentful Migration n’est pas lié au modèle pour lequel cette compétence a été conçue. Installez-la une seule fois dans TypingMind et utilisez-la avec GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou un modèle local que vous exécutez vous-même, le tout avec vos propres clés API.

  • Chargée uniquement en cas de besoin

    Le prompt système ne contient que le nom et la description. Les instructions sont récupérées à la première demande correspondante : une compétence inutilisée ne coûte donc rien.

  • Changez de modèle en cours de discussion

    La compétence étant constituée d’instructions et non de code, elle reste fonctionnelle lorsque vous changez de modèle : le nouveau modèle lit le même fichier SKILL.md.

Instructions de la compétence

Voici le contenu de SKILL.md que le modèle charge. Lisez-le avant l’installation : une compétence contient des instructions que votre modèle suivra.

Contentful Migration

The contentful-migration tool lets you describe and execute content model changes as code. Migrations are TypeScript scripts that create, edit, or delete content types, fields, editor interfaces, and entries.

Install:

bash
npm install contentful-migration

GitHub: https://github.com/contentful/contentful-migration

Scope

This skill covers:

  • Content type and field CRUD operations
  • Field types, validations, and editor interface configuration
  • Entry transformations (in-place transforms, deriving linked entries, cross-type transforms)
  • Tags, annotations, taxonomy validations
  • Editor layouts, sidebar widgets
  • Running migrations via npx contentful space migration (Contentful CLI) and programmatic API

Do not run migrations with npx contentful-migration. Use contentful-cli for CLI execution, install it as a dev dependency when needed, and run via npx contentful ....

Not covered: SDK client setup (the contentful-nextjs skill), Contentful concepts and API routing (the contentful-guide skill).

Contentful MCP note

  • For users who want easier agent interaction with Contentful while planning or reviewing migrations, point them to the Contentful MCP server docs: https://www.contentful.com/developers/docs/tools/mcp-server/.
  • Continue to use contentful-migration scripts and contentful-cli for actual migration execution.

Migration Script Format

Every migration file exports a function that receives a migration object:

typescript
import type { MigrationFunction } from 'contentful-migration'

const migration: MigrationFunction = (migration) => {
  const blogPost = migration.createContentType('blogPost', {
    name: 'Blog Post',
    description: 'A blog post entry',
    displayField: 'title',
  })

  blogPost.createField('title')
    .name('Title')
    .type('Symbol')
    .required(true)
}

export = migration

The function also receives a context object as its second parameter, providing makeRequest (direct CMA access), spaceId, and accessToken. Use makeRequest when you need data not available through the migration API.

Project state

echo "=== Existing migrations ===" && ls migrations/ 2>/dev/null || echo "(no migrations/ directory found)"
echo ""
echo "=== Contentful env vars ===" && grep -h CONTENTFUL .env .env.local 2>/dev/null | sed 's/=.*/=<set>/' || echo "(no Contentful env vars found in .env or .env.local)"

Workflow

When writing a migration:

  1. Confirm required env vars first. If values are missing, ask the user to add them to a local .env file before proceeding.
  2. Assess the change. Identify which content types and fields need to change. Check the current content model in the Contentful web app or via CMA.
  3. Write the migration script. Use the operations below. Prefer chaining over object notation — it gives better error messages with line numbers.
  4. Test in a sandbox environment. Never run untested migrations against production. Create a sandbox environment first: contentful environment create --name sandbox --source master.
  5. Run the migration. See Running Migrations for CLI and programmatic options.
  6. Verify. Check the content model in the web app. Confirm entries are intact.

Required environment variables

  • CONTENTFUL_SPACE_ID - Space ID. Find it in the Contentful web app URL (/spaces/<SPACE_ID>/...) or in Space settings -> API keys.
  • CONTENTFUL_MANAGEMENT_ACCESS_TOKEN - CMA token used for migrations. Create it in Account settings -> CMA tokens (https://app.contentful.com/account/profile/cma_tokens) or from a space-scoped CMA tokens page (https://app.contentful.com/spaces/<SPACE_ID>/api/cma_tokens).
  • CONTENTFUL_ENVIRONMENT_ID (optional) - Target environment ID (for example master or sandbox) when you want to avoid passing --environment-id.

If any required value is missing, explicitly ask the user for the missing values and tell them where to find each one.

Content Type Operations

Create a content type:

typescript
const page = migration.createContentType('page', {
  name: 'Page',
  description: 'A generic page',
  displayField: 'title',
})

Edit an existing content type:

typescript
const page = migration.editContentType('page')
page.description('Updated description')
page.displayField('internalName')

Delete a content type:

typescript
migration.deleteContentType('page')

Content type must have zero entries before deletion. Delete all entries first, or use transformEntriesToType to move them.

Field Operations

Create a field:

typescript
page.createField('title')
  .name('Title')
  .type('Symbol')
  .required(true)
  .localized(true)

Edit an existing field:

typescript
page.editField('title')
  .name('Page Title')
  .required(false)

Delete a field:

typescript
page.deleteField('legacyField')

Deleting a field permanently removes its content from all entries.

Change a field ID:

typescript
page.changeFieldId('oldName', 'newName')

Existing content is preserved — only the ID changes.

Move a field:

typescript
page.moveField('slug').afterField('title')
page.moveField('featured').toTheTop()
page.moveField('metadata').toTheBottom()
page.moveField('author').beforeField('publishDate')

Field Types Quick Reference

TypeDescriptionExtra config
SymbolShort text (max 256 chars)—
TextLong text (max 50,000 chars)—
IntegerWhole number—
NumberDecimal number—
DateISO 8601 date/time—
BooleanTrue/false—
ObjectArbitrary JSON—
LocationLat/lon coordinates—
RichTextStructured rich textenabledNodeTypes, enabledMarks validations
ArrayList of values or referencesRequires items: { type, linkType?, validations? }
LinkSingle referenceRequires linkType: 'Asset' or 'Entry'
ResourceLinkCross-space referenceRequires allowedResources

See API Reference — Field Types for full configuration details.

Validations Quick Reference

ValidationApplies toExample
inSymbol, Integer, Number{ in: ['draft', 'published', 'archived'] }
uniqueSymbol, Integer, Number{ unique: true }
sizeArray, Text, Symbol{ size: { min: 1, max: 5 } }
rangeInteger, Number{ range: { min: 0, max: 100 } }
regexpSymbol, Text{ regexp: { pattern: '^[a-z0-9-]+$' } }
dateRangeDate{ dateRange: { min: '2020-01-01', max: '2030-12-31' } }
linkContentTypeLink, Array of Links{ linkContentType: ['author', 'organization'] }
linkMimetypeGroupLink (Asset){ linkMimetypeGroup: ['image', 'video'] }
assetFileSizeLink (Asset){ assetFileSize: { min: 0, max: 5242880 } }
assetImageDimensionsLink (Asset){ assetImageDimensions: { width: { min: 100, max: 2000 } } }

Apply validations via .validations([...]) on a field. See API Reference — Validations for all options.

Entry Transformations

Transform entries in place:

typescript
migration.transformEntries({
  contentType: 'blogPost',
  from: ['firstName', 'lastName'],
  to: ['fullName'],
  transformEntryForLocale: (fields, locale) => {
    const first = fields.firstName[locale]
    const last = fields.lastName[locale]
    if (!first && !last) return
    return { fullName: `${first || ''} ${last || ''}`.trim() }
  },
})

Options: shouldPublish (true, false, or 'preserve' — default 'preserve').

Derive linked entries:

typescript
migration.deriveLinkedEntries({
  contentType: 'blogPost',
  derivedContentType: 'author',
  from: ['authorName'],
  toReferenceField: 'authorRef',
  derivedFields: ['name'],
  identityKey: (fields) =>
    fields.authorName['en-US'].toLowerCase().replace(/\s+/g, '-'),
  deriveEntryForLocale: (fields, locale) => {
    if (locale !== 'en-US') return
    return { name: fields.authorName[locale] }
  },
})

This creates new author entries from existing blogPost.authorName data and links them via authorRef.

See Patterns — Transform Entries and Patterns — Derive Linked Entries for more examples.

Editor Interface

Change the widget for a field:

typescript
const page = migration.editContentType('page')

page.changeFieldControl('slug', 'builtin', 'slugEditor', {
  helpText: 'URL-friendly identifier',
  trackingFieldId: 'title',
})

page.changeFieldControl('category', 'builtin', 'dropdown')
page.changeFieldControl('publishDate', 'builtin', 'datePicker', { format: 'dateonly' })

Widget namespaces: builtin, extension (UI extensions), app (custom apps).

See API Reference — Editor Interface for all built-in widgets and their settings.

Best Practices

  1. Number migration files sequentially: 001-create-blog-post.ts, 002-add-author-field.ts, 003-transform-categories.ts.
  2. One logical change per migration. Easier to debug, revert, and review.
  3. Always test in a sandbox environment before running against production.
  4. Use shouldPublish: 'preserve' (the default) to maintain existing publish states during transforms.
  5. Prefer chaining over object notation — chaining gives line-level error messages.
  6. Split data transforms from schema changes. First migration changes the schema, second transforms data. This makes each step independently verifiable.
  7. Use context.makeRequest sparingly — only when the migration API doesn't cover your use case.

Common Mistakes

  • Forgetting items on Array fields. type: 'Array' requires an items property specifying the element type.
  • Deleting a content type with entries. You must delete all entries first, or move them with transformEntriesToType.
  • Missing linkType on Link fields. type: 'Link' requires linkType: 'Asset' or linkType: 'Entry'.
  • Running against master. Always test in a sandbox environment. Use --environment-id sandbox on the CLI.
  • Not handling missing locales in transforms. transformEntryForLocale is called for every locale — return undefined to skip.
  • Setting displayField to a non-Symbol field. The display field must be of type Symbol.

References

Related Skills

  • the contentful-guide skill — Contentful concepts, terminology, API routing
  • the contentful-nextjs skill — Next.js integration with Contentful

Fichiers inclus

Le modèle lit ces fichiers à la demande lorsque la compétence est chargée. Ils sont accessibles en lecture et ne sont jamais exécutés.

Foire aux questions

À quoi sert la compétence IA Contentful Migration ?

Write and run Contentful content model migration scripts using the contentful-migration library and the Contentful CLI. Covers creating, editing, and deleting content types and fields, validations, editor interface configuration, editor layouts, sidebar widgets, entry transformations, tags, annotations, and the migration context object. Use when asked to write a migration, create or add a content type, add, rename, or delete fields, change or update a content model, transform entries, derive linked entries, configure editor controls, or run a migration script. Also triggers on "migration sc...

Pourquoi utiliser Contentful Migration sur TypingMind ?

Parce que vous l’installez une seule fois pour l’utiliser avec n’importe quel modèle. Contentful Migration se compose de simples instructions en Markdown plutôt que de code propre à un fournisseur. La même compétence fonctionne donc avec GPT-5, Claude, Gemini, Grok ou un modèle local, et vous pouvez changer de modèle en cours de discussion sans perturber son fonctionnement. TypingMind utilise vos propres clés API : vous payez donc directement les fournisseurs plutôt qu’un abonnement par siège, et vos compétences et discussions restent dans votre propre espace de stockage.

Comment installer Contentful Migration dans TypingMind ?

Dans TypingMind, ouvrez Plugins → Compétences → Installer depuis GitHub et collez https://github.com/contentful/skills/tree/main/skills/contentful-migration. TypingMind lit le fichier SKILL.md, regroupe les fichiers associés et installe le tout sous forme de compétence que vous pouvez activer pour chaque discussion.

Quels modèles d’IA peuvent utiliser Contentful Migration ?

N’importe quel modèle que vous connectez dans TypingMind. Les compétences IA sont de simples instructions en Markdown, et non du code propre à un fournisseur. GPT, Claude, Gemini, Grok et les modèles locaux peuvent donc tous charger cette compétence lorsqu’une demande lui correspond.

Combien de modèles d’IA puis-je utiliser avec Contentful Migration ?

Autant que vous le souhaitez. Tant qu’un modèle prend en charge les compétences, vous pouvez utiliser Contentful Migration avec lui : GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama et bien d’autres, le tout dans TypingMind avec vos propres clés API.

La compétence IA Contentful Migration est-elle gratuite ?

Oui. Cette compétence est publiée sur GitHub par contentful sous licence MIT. Vous ne payez que votre propre fournisseur d’IA pour les tokens utilisés.

Que sont les compétences IA ?

Une compétence IA est un ensemble d’instructions réutilisables qui apprend à un modèle d’IA à accomplir une tâche précise. Elle suit le format ouvert Agent Skills : un fichier SKILL.md contenant un nom et une description, ainsi que les éventuels scripts, modèles de documents ou fichiers de référence dont le modèle peut avoir besoin. Le modèle ne lit les instructions que lorsque votre demande correspond à la compétence. Une compétence installée ne coûte donc rien tant qu’elle n’est pas utilisée.

En quoi les compétences IA diffèrent-elles des plugins ou des serveurs MCP ?

Un plugin ou un serveur MCP fournit au modèle de nouveaux outils à appeler : du code qui s’exécute quelque part et renvoie un résultat. Une compétence IA lui apporte plutôt des connaissances et une méthode : comment aborder une tâche, quelles étapes suivre et à quoi ressemble un bon résultat. Les compétences sont de simples instructions en Markdown. Elles ne nécessitent donc ni serveur, ni clé API, ni environnement d’exécution, et fonctionnent avec n’importe quel modèle.

Tout voir

Créez votre propre espace IA dès maintenant

Abonnez-vous à notre newsletter pour être informé des nouvelles fonctionnalités et des prochains cadeaux à gagner 👇