llm-output-schema-cons…
Zod schema constraints that Anthropic rejects or silently ignores when sent as structured-output tool definitions via aiSdk.Output.object(). Use when writing…
Fix Zod schema import issues in Output SDK workflows. Use when seeing "incompatible schema" errors, type errors at step boundaries, schema validation failures, or when schemas don't match between steps.
$ npx -y skills add growthxai/output --skill output-error-zod-import --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/output-error-zod-importContext preview
The summary Claude sees to decide when to auto-load this skill.
Fix Zod schema import issues in Output SDK workflows. Use when seeing "incompatible schema" errors, type errors at step boundaries, schema validation failures, or when schemas don't match between steps.
name: output-error-zod-import description: Fix Zod schema import issues in Output SDK workflows. Use when seeing "incompatible schema" errors, type errors at step boundaries, schema validation failures, or when schemas don't match between steps. allowed-tools: [Bash, Read]
This skill helps diagnose and fix a common issue where Zod schemas are imported from the wrong source. Output SDK requires schemas to be imported from `@outputai/core`, not directly from `zod`.
You're seeing:
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.
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()
} );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';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/steps/process.ts
import { z } from 'zod'; // Wrong!
import { step } from '@outputai/core';
export const processStep = step( {
name: 'processData',
inputSchema: z.object( {
id: z.string()
} ),
outputSchema: z.object( {
result: z.string()
} ),
fn: async input => {
return { result: `Processed ${input.id}` };
}
} );// src/workflows/my-workflow/steps/process.ts
import { z, step } from '@outputai/core'; // Correct!
export const processStep = step( {
name: 'processData',
inputSchema: z.object( {
id: z.string()
} ),
outputSchema: z.object( {
result: z.string()
} ),
fn: async input => {
return { result: `Processed ${input.id}` };
}
} );# Should return no results grep -r "from 'zod'" src/ grep -r 'from "zod"' src/
npm run output:worker:build
npx output workflow run <workflowName> --input '<input>'
Add a rule to prevent direct zod imports:
// .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
The open-source TypeScript framework for building AI workflows and agents. Designed for Claude Code — describe what you want, Claude builds it, with all the best practices already in place. One framework.
Repo: growthxai/output
Zod schema constraints that Anthropic rejects or silently ignores when sent as structured-output tool definitions via aiSdk.Output.object(). Use when writing…
Guide to the providerOptions structure in .prompt files — decision tree for where an option goes, common mistakes, per-provider quick reference, and Anthropic…
Implement an Output SDK workflow from a plan document. Use when the user asks to build, implement, or code a workflow from an existing plan, or after…
View and edit encrypted credentials in an Output.ai project. Use when adding secrets, updating API keys, verifying credential values, or retrieving a specific…
Wire encrypted credentials to environment variables using the credential: convention. Use when setting up LLM provider keys (ANTHROPIC_API_KEY, OPENAI_API_KEY)…