with one click
flow-error-zod-import
// Fix Zod schema import issues during Flow to Output SDK migration. Use when seeing "incompatible schema" errors, type errors at step boundaries, or when migrating files that import from 'zod' directly.
// Fix Zod schema import issues during Flow to Output SDK migration. Use when seeing "incompatible schema" errors, type errors at step boundaries, or when migrating files that import from 'zod' directly.
Validate and fix folder structure for Output SDK workflows. Use to ensure migrated workflows follow the correct structure conventions.
Convert Flow SDK activities.ts to Output SDK steps.ts. Use when migrating activity functions to step definitions with typed parameters.
Convert inline prompts and prompt arrays to .prompt files with YAML frontmatter. Use when migrating prompts from Flow SDK format to Output SDK prompt files.
Convert Flow SDK workflow class to Output SDK workflow() function. Use when migrating workflow.ts files from class-based to functional definitions.
Create scenario files for testing migrated Output SDK workflows. Use to set up test inputs in the scenarios/ subfolder.
Fix ESLint issues in migrated Output SDK code. Use when seeing lint errors after migration, or when writing new Output SDK code that needs to follow project conventions.
| name | flow-error-zod-import |
| description | Fix Zod schema import issues during Flow to Output SDK migration. Use when seeing "incompatible schema" errors, type errors at step boundaries, or when migrating files that import from 'zod' directly. |
| allowed-tools | ["Bash","Read","Write","Grep","Edit"] |
This skill helps diagnose and fix a critical issue where Zod schemas are imported from the wrong source during migration. Output SDK requires schemas to be imported from @outputai/core, not directly from zod.
During Migration:
import { z } from 'zod'Error Symptoms:
The issue occurs when you import z from zod instead of @outputai/core. While both provide Zod schemas, they create different schema instances that aren't compatible with each other within the Output SDK context.
Why this matters: Output SDK uses a specific version of Zod internally for serialization and validation. When you use a different Zod instance, the schemas are technically different objects even if they define the same shape. This causes runtime validation failures and TypeScript errors.
Error: Incompatible schema types
Error: Schema validation failed: expected compatible Zod instance
TypeError: Cannot read property 'parse' of undefined
// WRONG: Importing from 'zod' directly
import { z } from 'zod';
const inputSchema = z.object({
name: z.string(),
});
export const myStep = step({
name: 'myStep',
inputSchema,
fn: async (input) => {
// ...
}
});
// CORRECT: Import z from @outputai/core
import { z, step } from '@outputai/core';
const inputSchema = z.object( {
name: z.string()
} );
export const myStep = step( {
name: 'myStep',
inputSchema,
fn: async ( input ) => {
// ...
}
} );
Search your codebase for incorrect imports:
grep -r "from 'zod'" src/
grep -r 'from "zod"' src/
Change all imports from:
// Wrong
import { z } from 'zod';
To:
// Correct
import { z } from '@outputai/core';
Tip: Often you can combine with other imports:
import { z, step, workflow } from '@outputai/core';
Check your imports don't accidentally use zod elsewhere:
grep -r "import.*zod" src/
All matches should show @outputai/core, not zod.
// src/workflows/my-workflow/types.ts
import { z } from 'zod';
export const UserSchema = z.object({
id: z.string(),
email: z.string().email(),
});
export type User = z.infer<typeof UserSchema>;
// src/workflows/my-workflow/activities.ts
import { z } from 'zod';
import { UserSchema } from './types';
export async function getUser(userId: string): Promise<User> {
// ...
}
// src/workflows/my-workflow/types.ts
import { z } from '@outputai/core';
export const UserSchema = z.object( {
id: z.string(),
email: z.string().email()
} );
export type User = z.infer<typeof UserSchema>;
// src/workflows/my-workflow/steps.ts
import { z, step } from '@outputai/core';
import { UserSchema, User } from './types.js';
export const getUser = step( {
name: 'getUser',
inputSchema: z.object( {
userId: z.string()
} ),
outputSchema: UserSchema,
fn: async ( input ) => {
const { userId } = input;
// ...
}
} );
# Should return no results
grep -r "from 'zod'" src/
grep -r 'from "zod"' src/
npm run output:workflow:build
npx output workflow run <workflowName> '<input>'
Add a rule to prevent direct zod imports in your ESLint config:
// .eslintrc.js
module.exports = {
rules: {
'no-restricted-imports': ['error', {
paths: [{
name: 'zod',
message: "Import { z } from '@outputai/core' instead of 'zod'"
}]
}]
}
};
Configure your editor to auto-import from @outputai/core:
For VS Code, add to settings.json:
{
"typescript.preferences.autoImportFileExcludePatterns": ["zod"]
}
Even one wrong import can cause issues:
import { z } from '@outputai/core';
import { z as zod } from 'zod'; // This causes problems!
If a utility file uses the wrong import and is shared:
// utils/schemas.ts
import { z } from 'zod'; // Wrong! This affects all files using these schemas
export const idSchema = z.string().uuid();
If using external Zod schemas, you may need to recreate them:
// Don't use: externalLibrary.schema
// Instead: recreate the schema with @outputai/core's z
flow-convert-activities-to-steps - Full activity to step conversionflow-error-eslint-compliance - ESLint compliance for migrated codeflow-validation-checklist - Complete migration validation