Migrate email templates to Knock with an AI coding agent
Learn how to migrate your existing email templates into Knock layouts, partials, and workflows using an AI coding agent, the Knock CLI, and the Knock MCP server.
Storing your email templates in Knock comes with many advantages. In this tutorial, you'll use the knock-email-template-migration skill with an AI coding agent to migrate a directory of existing email templates into Knock. The skill parses your existing templates into reusable building blocks in Knock: shared headers and footers become email layouts, repeated components become partials that can be used as blocks in the dashboard's template editor, and each email is added as a channel step on a workflow with a documented trigger payload.
The skill does the analysis, planning, building, and verification to ensure that the migrated templates are a faithful representation of the original. You'll answer a few questions up front, approve the plan before anything is written to Knock, and sign off on the final result.
How the migration runs
#The skill runs in five phases and keeps a record of each decision it makes along the way. This record can be used to resume a migration from where it left off, or take a second pass over more templates later.
- Preflight and intake. The agent checks that the Knock CLI and MCP server are available and connected, inventories the resources already in your Knock account, copies your templates into your local workspace, and confirms its intake answers with you.
- Analyze. The agent groups your templates by shared content, then analyzes them one at a time.
- Plan and checkpoint. The agent proposes its plan for layouts, partials, variable mapping, and workflows, then stops for your approval. Nothing is written to Knock before this point.
- Build. The agent creates partials, then layouts, then workflows, validating, pushing, reading back, and committing each stage to your Development environment.
- Verify and report. The agent renders every template, compares it to the original, and writes a final report with the trigger payload contract for each workflow and instructions for promoting to production.
Prerequisites
#Before getting started, you'll need the following:
- A Knock account with a configured email provider. Navigate to Integrations > Channels in your dashboard to set this up if you haven't already.
- Your email template files. Knock supports HTML and MJML natively; component-based templates such as React Email need to be rendered to HTML first, and the skill will ask you to run your build if it can't.
- An AI coding agent that supports agent skills, such as Claude Code, Cursor, or Codex, using the most capable model available to you.
- The Knock CLI installed and authenticated.
- The Knock MCP server connected to your agent. See the get started section of the MCP server docs for setup instructions.
- Optional: a service token for your Knock account. This is only needed if the MCP server isn't available to your agent, or if you'd like to keep a full archive of every rendered template during the verification step of your migration. It's used to make requests to the management API directly.
MCP capabilities
#When you connect to the MCP server, you'll be prompted to select which capabilities to enable. The skill uses the following:
Install the skills
#Install the migration skill along with the knock-cli skill, which teaches your agent the CLI mechanics the migration relies on:
Run this command from the project directory where you want the migration to live. Skills activate automatically when you ask your agent for a related task.
Background
#While not required reading, you may want to familiarize yourself with the following Knock concepts so you can follow the agent's plan and the questions it asks:
- Workflows and channel steps
- Email layouts
- Partials
- Referencing variables and your Knock data in templates
- Knock Liquid helpers
- Commits and environments
Migration steps
#Troubleshooting
#- The preflight phase stops at the MCP check. Confirm the server is connected for this project and that the capabilities above are enabled. Most agents configure MCP servers per project directory, so a server that works elsewhere isn't automatically available in a new one.
- A render doesn't match the original. Point the agent at the specific difference and ask it to re-verify the template.
- The migration was interrupted. Start a new session in the same directory and ask the agent to continue. The skill records its progress as it works, so it can resume from where it left off.
- You have more templates to add later on. Ask the agent to migrate them into the same directory. The skill reuses the layouts and partials it already built and appends a new pass to the record rather than starting over.