Skip to content

generate

Terminal window
ctkit generate

Connects to your Contentful space, compares your local schema definitions against the remote content model, and produces a timestamped migration file containing the diff.

The generated file lands in your migrations/ directory:

migrations/20250702T143021_crystal_lion_hammer.js

File names combine a UTC timestamp with a randomly generated human-readable slug so they sort chronologically and are easy to reference in conversation.

Terminal window
ctkit generate --name add-author-bio

Replaces the random slug with your chosen name:

migrations/20250702T143021_add-author-bio.js
Terminal window
ctkit generate --custom

Creates a migration file with an empty scaffold instead of auto-generated steps. Use this when you need to write migration logic by hand — for example, transforming existing entry data or running a content backfill.

migrations/20250702T143021_custom.js
export default {
up(migration) {
// Write your migration steps here
},
};
Terminal window
ctkit generate schema blogPost

Scaffolds a new schema file in your schemas/ directory with the boilerplate already filled in:

schemas/blogPost.ts
import { contentType, fields } from '@ctkit/core';
export const blogPost = contentType('blogPost', {
name: 'Blog Post',
fields: {},
});

This is a convenience shortcut — you can always create schema files manually.

FlagDescription
--name <name>Set a custom name for the migration file instead of a random slug.
--customGenerate an empty migration template instead of auto-diffing schemas.
  1. ctkit loads all schema definitions from your schemas/ directory.
  2. It fetches the current content model from Contentful via the Content Management API.
  3. It diffs the two and produces a migration file with the minimal set of changes needed to bring the remote model in line with your local schemas.
  4. The migration file is written to migrations/ but not executed — run ctkit migrate to apply it.

If there are no differences between local and remote, ctkit will tell you everything is already in sync and skip file creation.