一键导入
flow-convert-prompts-to-files
// 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 inline prompts and prompt arrays to .prompt files with YAML frontmatter. Use when migrating prompts from Flow SDK format to Output SDK prompt files.
| name | flow-convert-prompts-to-files |
| description | 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. |
| allowed-tools | ["Bash","Read","Write","Grep","Edit"] |
This skill guides the conversion of Flow SDK inline prompts, XML prompts, and JavaScript prompt arrays to Output SDK .prompt files with YAML frontmatter.
During Migration:
prompts.ts or prompts.xml to .prompt filesFlow SDK uses several prompt formats that need conversion:
// activities.ts
const prompt = `You are an assistant. Analyze: ${text}`;
const response = await completion( { messages: [ { role: 'user', content: prompt } ] } );
// prompts.ts
export const analyzePrompt = [
{ role: 'system', content: 'You are an expert analyst.' },
{ role: 'user', content: 'Analyze this: {{text}}' }
];
<prompt name="analyze">
<system>You are an expert analyst.</system>
<user>Analyze this: {{text}}</user>
</prompt>
---
provider: openai
model: gpt-4o
temperature: 0.7
---
<system>
System message here.
</system>
<user>
User message with {{ variable }} interpolation.
</user>
| Field | Type | Required | Description |
|---|---|---|---|
provider | string | Yes | openai or anthropic |
model | string | Yes | Model identifier |
temperature | number | No | 0-1 sampling temperature |
max_tokens | number | No | Maximum output tokens |
OpenAI:
gpt-4ogpt-4-turbogpt-3.5-turboAnthropic:
claude-3-5-sonnet-20241022claude-3-opus-20240229claude-3-haiku-20240307Find prompts in the Flow SDK workflow:
# Check for prompt files
ls src/workflows/my-workflow/prompts.*
# Check for inline prompts in activities
grep -n "role: 'system'" src/workflows/my-workflow/activities.ts
grep -n "role: 'user'" src/workflows/my-workflow/activities.ts
Name format: promptName@version.prompt
analyzeDocument@v1.prompt
generateSummary@v1.prompt
extractEntities@v1.prompt
// Before (activities.ts)
const systemPrompt = 'You are a document analyzer.';
const userPrompt = `Analyze this document: ${documentText}`;
# After (analyzeDocument@v1.prompt)
---
provider: openai
model: gpt-4o
temperature: 0.3
---
<system>
You are a document analyzer.
</system>
<user>
Analyze this document: {{ documentText }}
</user>
// Before (prompts.ts)
export const summarizePrompt = [
{ role: 'system', content: 'You summarize text concisely.' },
{ role: 'user', content: 'Summarize: {{text}}\nMax length: {{maxLength}}' }
];
# After (summarize@v1.prompt)
---
provider: openai
model: gpt-4o
temperature: 0.5
---
<system>
You summarize text concisely.
</system>
<user>
Summarize: {{ text }}
Max length: {{ maxLength }}
</user>
<!-- Before (prompts.xml) -->
<prompt name="extract">
<system>You extract key entities from text.</system>
<user>
Extract entities from:
{{#if includeContext}}
Context: {{context}}
{{/if}}
Text: {{text}}
</user>
</prompt>
# After (extract@v1.prompt)
---
provider: openai
model: gpt-4o
temperature: 0.2
---
<system>
You extract key entities from text.
</system>
<user>
Extract entities from:
{% if includeContext %}
Context: {{ context }}
{% endif %}
Text: {{ text }}
</user>
// Before (activities.ts)
import { summarizePrompt } from './prompts';
export async function summarize( text: string ): Promise<string> {
const response = await completion( {
model: 'gpt-4',
messages: summarizePrompt.map( m => ( {
...m,
content: m.content.replace( '{{text}}', text )
} ) )
} );
return response.content;
}
// After (steps.ts)
import { step, z } from '@outputai/core';
import { generateText } from '@outputai/llm';
export const summarize = step( {
name: 'summarize',
inputSchema: z.object( { text: z.string() } ),
outputSchema: z.string(),
fn: async ( input ) => {
const { result } = await generateText( {
prompt: 'summarize@v1',
variables: {
text: input.text
}
} );
return result;
}
} );
Important: Convert Handlebars to Liquid.js syntax!
| Handlebars | Liquid.js |
|---|---|
{{variable}} | {{ variable }} |
{{#if cond}} | {% if cond %} |
{{/if}} | {% endif %} |
{{#each items}} | {% for item in items %} |
{{/each}} | {% endfor %} |
{{else}} | {% else %} |
See flow-convert-handlebars-to-liquid for detailed conversion rules.
export const analyzeDocumentPrompt = [
{
role: 'system',
content: `You are a document analysis expert. Analyze documents for:
- Key themes
- Important entities
- Sentiment
- Action items`
},
{
role: 'user',
content: `Document Type: {{documentType}}
{{#if previousAnalysis}}
Previous Analysis:
{{previousAnalysis}}
{{/if}}
Document Content:
{{content}}
Provide a comprehensive analysis.`
}
];
---
provider: openai
model: gpt-4o
temperature: 0.3
max_tokens: 4000
---
<system>
You are a document analysis expert. Analyze documents for:
- Key themes
- Important entities
- Sentiment
- Action items
</system>
<user>
Document Type: {{ documentType }}
{% if previousAnalysis %}
Previous Analysis:
{{ previousAnalysis }}
{% endif %}
Document Content:
{{ content }}
Provide a comprehensive analysis.
</user>
import { step, z } from '@outputai/core';
import { generateText, Output } from '@outputai/llm';
import { AnalysisResultSchema, AnalysisResult } from './types.js';
const AnalyzeDocumentInputSchema = z.object( {
documentType: z.string(),
content: z.string(),
previousAnalysis: z.string().optional()
} );
export const analyzeDocument = step( {
name: 'analyzeDocument',
inputSchema: AnalyzeDocumentInputSchema,
outputSchema: AnalysisResultSchema,
fn: async ( input ) => {
const { output } = await generateText( {
prompt: 'analyzeDocument@v1',
variables: {
documentType: input.documentType,
content: input.content,
previousAnalysis: input.previousAnalysis || ''
},
output: Output.object( {
schema: AnalysisResultSchema
} )
} );
return output;
}
} );
{descriptiveName}@{version}.prompt
Examples:
- analyzeDocument@v1.prompt
- generateSummary@v1.prompt
- extractEntities@v2.prompt
- translateContent@v1.prompt
.prompt files{{ var }} not {{var}}generateText() with prompt reference (use Output.object() for structured output)flow-convert-handlebars-to-liquid - Template syntax conversionflow-convert-activities-to-steps - Step conversionflow-analyze-prompts - Prompt catalogingValidate 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 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.
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.