Remove try-catch antipattern from step calls during Flow to Output SDK migration. Use when converting workflow code that wraps step calls in try-catch blocks.
Removes try-catch antipatterns from step calls during Flow to Output SDK migration. Use this when converting workflow code that incorrectly wraps step calls in try-catch blocks, as Output SDK handles errors automatically.
/plugin marketplace add growthxai/output-claude-plugins/plugin install growthxai-outputai-flow-migrator-plugins-outputai-flow-migrator@growthxai/output-claude-pluginsThis skill is limited to using the following tools:
This skill helps identify and remove the try-catch antipattern that's common in Flow SDK code but incorrect in Output SDK. In Output SDK, step calls should NOT be wrapped in try-catch blocks - errors should propagate up the chain.
During Migration:
Code Patterns to Fix:
In Output SDK, the workflow execution engine handles errors automatically:
// WRONG: Wrapping step calls in try-catch
export default workflow( {
name: 'someWorkflow',
description: 'a workflow description',
inputSchema: WorkflowInputSchema,
outputSchema: WorkflowOutputSchema,
fn: async input => {
try {
// Step 1: Get User data
const userData = await getUserData( { userId: input.userId } );
// Step 2: Get role configuration
const roleConfig = await getRoleConfig( { role: userData.role } );
// Step 3: Ensure something
await ensureSomething( { config: roleConfig } );
return { success: true };
} catch ( error ) {
throw new FatalError( error instanceof Error ? error.message : 'Unknown workflow error' );
}
}
} );
// CORRECT: Let errors propagate naturally
export default workflow( {
name: 'someWorkflow',
description: 'a workflow description',
inputSchema: WorkflowInputSchema,
outputSchema: WorkflowOutputSchema,
fn: async input => {
// Step 1: Get User data
const userData = await getUserData( { userId: input.userId } );
// Step 2: Get role configuration
const roleConfig = await getRoleConfig( { role: userData.role } );
// Step 3: Ensure something
await ensureSomething( { config: roleConfig } );
return { success: true };
}
} );
Search for try-catch patterns in workflow files:
grep -r "try {" src/workflows/*/workflow.ts
grep -r "} catch" src/workflows/*/workflow.ts
Before removing, understand what the try-catch was doing:
Remove the try-catch wrapper but keep the step calls:
// Before
fn: async input => {
try {
const result = await someStep( input );
return result;
} catch ( error ) {
throw new FatalError( error.message );
}
}
// After
fn: async input => {
const result = await someStep( input );
return result;
}
Try-catch is still appropriate in specific cases:
Steps can use try-catch for internal logic:
export const fetchExternalData = step( {
name: 'fetchExternalData',
inputSchema: z.object( { url: z.string() } ),
fn: async ( input ) => {
try {
const response = await fetch( input.url );
return response.json();
} catch ( error ) {
// Transform to ValidationError for expected failures
throw new ValidationError( `Failed to fetch: ${input.url}` );
}
}
} );
When you need to handle a specific error type differently:
fn: async input => {
const userData = await getUserData( { userId: input.userId } );
try {
await sendNotification( { userId: userData.id } );
} catch ( error ) {
// Only catch specific expected errors
if ( error instanceof NotificationDisabledError ) {
// User has notifications disabled - continue without notification
console.log( 'Notifications disabled for user' );
} else {
throw error; // Re-throw unexpected errors
}
}
return { success: true };
}
When a failure shouldn't stop the workflow:
fn: async input => {
const result = await processData( input );
// Optional: try to cache result, but don't fail if caching fails
try {
await cacheResult( { key: input.id, value: result } );
} catch {
// Caching failed - log but continue
console.warn( 'Failed to cache result' );
}
return result;
}
import { FatalError } from '@flow/sdk';
import { getUserData, processUser, saveResults } from './activities';
export default class UserProcessingWorkflow {
async execute(input: WorkflowInput): Promise<WorkflowOutput> {
try {
const user = await getUserData(input.userId);
const processed = await processUser(user);
await saveResults(processed);
return { success: true, userId: user.id };
} catch (error) {
throw new FatalError(`Workflow failed: ${error.message}`);
}
}
}
import { workflow, z } from '@output.ai/core';
import { getUserData, processUser, saveResults } from './steps.js';
import { WorkflowInputSchema, WorkflowOutputSchema } from './types.js';
export default workflow( {
name: 'userProcessing',
description: 'Process user data',
inputSchema: WorkflowInputSchema,
outputSchema: WorkflowOutputSchema,
fn: async input => {
const user = await getUserData( { userId: input.userId } );
const processed = await processUser( { user } );
await saveResults( { data: processed } );
return { success: true, userId: user.id };
}
} );
# Should return minimal results (only appropriate uses)
grep -A5 "try {" src/workflows/*/workflow.ts
npx output workflow run <workflowName> --input '{}'
Intentionally trigger an error to verify it propagates correctly.
flow-convert-workflow-definition - Full workflow conversionflow-convert-activities-to-steps - Step conversion patternsflow-validation-checklist - Complete migration validationCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.