Skip to content
flow-convert-prompts-to-files logo

Convert Prompts to .prompt Files

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.

SKILL.md

Full skill instructions

Convert Prompts to .prompt Files

Overview

This skill guides the conversion of Flow SDK inline prompts, XML prompts, and JavaScript prompt arrays to Output SDK .prompt files with YAML frontmatter.

When to Use This Skill

During Migration:

  • Converting prompts.ts or prompts.xml to .prompt files
  • Extracting inline prompts from activities to separate files
  • Setting up prompt versioning

Flow SDK Prompt Formats

Flow SDK uses several prompt formats that need conversion:

1. Inline Prompts in Activities

// activities.ts
const prompt = `You are an assistant. Analyze: ${text}`;
const response = await completion( { messages: [ { role: 'user', content: prompt } ] } );

2. JavaScript Prompt Arrays (prompts.ts)

// prompts.ts
export const analyzePrompt = [
  { role: 'system', content: 'You are an expert analyst.' },
  { role: 'user', content: 'Analyze this: {{text}}' }
];

3. XML Prompts (prompts.xml)

<prompt name="analyze">
  <system>You are an expert analyst.</​system>
  <user>Analyze this: {{text}}</​user>
</​prompt>

Output SDK .prompt File Format

Basic Structure

---
provider: openai
model: gpt-4o
temperature: 0.7
---

<system>
System message here.
</​system>

<user>
User message with {{ variable }} interpolation.
</​user>

YAML Frontmatter Fields

FieldTypeRequiredDescription
providerstringYesopenai or anthropic
modelstringYesModel identifier
temperaturenumberNo0-1 sampling temperature
max_tokensnumberNoMaximum output tokens

Common Model Values

OpenAI:

  • gpt-4o
  • gpt-4-turbo
  • gpt-3.5-turbo

Anthropic:

  • claude-3-5-sonnet-20241022
  • claude-3-opus-20240229
  • claude-3-haiku-20240307

Conversion Process

Step 1: Identify All Prompts

Find 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

Step 2: Create .prompt File

Name format: [email protected]

[email protected]
[email protected]
[email protected]

Step 3: Convert Content

From Inline Prompt:
// Before (activities.ts)
const systemPrompt = 'You are a document analyzer.';
const userPrompt = `Analyze this document: ${documentText}`;
# After ([email protected])
---
provider: openai
model: gpt-4o
temperature: 0.3
---

<system>
You are a document analyzer.
</​system>

<user>
Analyze this document: {{ documentText }}
</​user>
From JavaScript Array:
// Before (prompts.ts)
export const summarizePrompt = [
  { role: 'system', content: 'You summarize text concisely.' },
  { role: 'user', content: 'Summarize: {{text}}\nMax length: {{maxLength}}' }
];
# After ([email protected])
---
provider: openai
model: gpt-4o
temperature: 0.5
---

<system>
You summarize text concisely.
</​system>

<user>
Summarize: {{ text }}
Max length: {{ maxLength }}
</​user>
From XML:
<!-- 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 ([email protected])
---
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>

Step 4: Update Step to Use Prompt File

// 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 '@output.ai/​core';
import { generateText } from '@output.ai/​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;
  }
} );

Template Syntax Conversion

Important: Convert Handlebars to Liquid.js syntax!

HandlebarsLiquid.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.

Complete Migration Example

Before: prompts.ts (Flow SDK)

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.`
  }
];

After: [email protected] (Output SDK)

---
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>

After: steps.ts (Using the Prompt)

import { step, z } from '@output.ai/​core';
import { generateObject } from '@output.ai/​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 { result } = await generateObject<AnalysisResult>( {
      prompt: 'analyzeDocument@v1',
      variables: {
        documentType: input.documentType,
        content: input.content,
        previousAnalysis: input.previousAnalysis || ''
      },
      schema: AnalysisResultSchema
    } );

    return result;
  }
} );

Prompt Naming Convention

{descriptiveName}@{version}.prompt

Examples:
- [email protected]
- [email protected]
- [email protected]
- [email protected]

Verification Checklist

  • All prompts extracted to .prompt files
  • YAML frontmatter includes provider and model
  • Template syntax converted to Liquid.js
  • Variable spacing correct: {{ var }} not {{var}}
  • Steps use generateText() or generateObject() with prompt reference
  • Prompt file names follow naming convention

Related Skills

  • flow-convert-handlebars-to-liquid - Template syntax conversion
  • flow-convert-activities-to-steps - Step conversion
  • flow-analyze-prompts - Prompt cataloging

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View