Output SDK のワークフロー(処理の流れ)フォルダ構成のルール。次のような場合に使用: 新しいワークフローを作成するとき、ワークフロー関連ファイルを整理するとき、または標準的なプロジェクトの構成を理解するとき。
Workflow folder structure conventions for Output SDK. Use when creating new workflows, organizing workflow files, or understanding the standard project layout.
このスキルは、Output SDK ワークフローの標準フォルダ構造を定義します。 これらの規約に従うことで、コードベース全体の一貫性が保たれ、適切なツールサポートが有効になります。
src/
├── shared/ # ワークフロー間で共有するコード
│ ├── clients/ # API クライアント(@outputai/http 使用)
│ ├── utils/ # ユーティリティ関数・ヘルパー
│ ├── services/ # ビジネスロジックサービス
│ ├── steps/ # 共有ステップ(任意)
│ └── evaluators/ # 共有エバリュエーター(任意)
└── workflows/
└── {workflow-name}/ # 個別ワークフローのディレクトリ
├── workflow.ts # ワークフロー定義(必須)
├── steps.ts # または steps/ フォルダ
├── evaluators.ts # または evaluators/ フォルダ(任意)
├── types.ts # Zod スキーマと TypeScript 型
├── utils.ts # ワークフロー固有のユーティリティ(任意)
├── prompts/ # LLM プロンプトテンプレート(任意)
│ └── {promptName}@v1.prompt
└── scenarios/ # テスト入力シナリオ(任意)
└── {scenario_name}.json
workflow() 関数定義を含む関連スキル: output-dev-workflow-function
step() 関数定義を含むFatalError および ValidationError によるエラーハンドリングを含む関連スキル: output-dev-step-function
evaluator() 関数定義を含むz は @outputai/core からインポートする(zod から直接インポートしない)関連スキル: output-dev-types-file
.prompt ファイルを含む{promptName}@v1.prompt関連スキル: output-dev-prompt-file
{scenario_name}.jsoninputSchema 構造に対応する関連スキル: output-dev-scenario-file
src/workflows/{workflow-name}/
├── workflow.ts
├── steps.ts # すべてのステップを 1 ファイルにまとめる
├── evaluators.ts # すべてのエバリュエーターを 1 ファイルにまとめる(任意)
├── types.ts
└── ...
src/workflows/{workflow-name}/
├── workflow.ts
├── steps/ # ステップをファイルごとに分割
│ ├── fetch_data.ts
│ ├── process.ts
│ └── validate.ts
├── evaluators/ # エバリュエーターをファイルごとに分割
│ ├── quality.ts
│ └── accuracy.ts
├── types.ts
└── ...
Output SDK は、コンポーネントを定義できる場所について厳格なルールを適用します。
| コンポーネント | 配置場所 |
|---|---|
step() 呼び出し |
パスに 'steps' を含むファイル |
evaluator() 呼び出し |
パスに 'evaluators' を含むファイル |
workflow() 呼び出し |
workflow.ts ファイル |
例:
src/workflows/my_workflow/steps.ts ✓src/workflows/my_workflow/steps/fetch_data.ts ✓src/shared/steps/common_steps.ts ✓src/workflows/my_workflow/helpers.ts ✗(step() 呼び出しを含めることはできない)ステップとエバリュエーターは Temporal アクティビティであり、 決定論的なリプレイを保証するため、分離の制約があります。
./utils.js、./types.js、./helpers.js./clients/pokeapi.js、./lib/helpers.js../../shared/utils/*.js../../shared/clients/*.js../../shared/services/*.jsインポートの記述例:
// workflow の steps.ts から — 共有クライアントをインポート
import { GeminiImageService } from '../../shared/clients/gemini_client.js';
// workflow の steps.ts から — ローカルユーティリティをインポート
import { formatResponse } from './utils.js';
// workflow の steps.ts から — 型をインポート
import { InputSchema, OutputSchema } from './types.js';
// NG — ステップから他のステップはインポートできない
import { otherStep } from '../../shared/steps/other.js'; // ✗
ワークフロー間で共有する HTTP クライアント:
src/shared/clients/
├── gemini_client.ts # Google Gemini API クライアント
├── jina_client.ts # Jina AI クライアント
└── perplexity_client.ts # Perplexity API クライアント
ワークフローステップでのインポート例:
import { GeminiImageService } from '../../shared/clients/gemini_client.js';
関連スキル: output-dev-http-client-create
ワークフロー間で共有するユーティリティ関数:
src/shared/utils/
├── string_helpers.ts
├── date_formatters.ts
└── validators.ts
ワークフロー間で共有するビジネスロジックサービス:
src/shared/services/
├── image_service.ts
└── content_service.ts
ワークフローからインポートできる共有ステップ:
src/shared/steps/
└── common_steps.ts
注意: ワークフローは共有ステップをインポートできますが、 ステップから他のステップを直接インポートすることはできません。
snake_case を使用するimage_infographic_nano、resume_parser.ts ファイルには camelCase を使用する
(workflow.ts、steps.ts、types.ts、evaluators.ts を除く).prompt ファイルには camelCase@v{n} の形式を使用する.json ファイルには snake_case を使用するworkflow() 内の name プロパティは camelCase にするimageInfographicNanosrc/workflows/image_infographic_nano/
├── workflow.ts # workflow({ name: 'imageInfographicNano', ... })
├── steps.ts # generateImageIdeas, generateImages, validateReferenceImages
├── types.ts # WorkflowInputSchema, WorkflowOutput, ステップスキーマ
├── utils.ts # normalizeReferenceImageUrls, buildS3Url 等
├── prompts/
│ └── generateImageIdeas@v1.prompt
└── scenarios/
├── test_input_complex.json
└── test_input_solar_panels.json
ワークフロー構造をレビューする際は、以下を確認してください:
workflow.ts が存在し、デフォルトエクスポートがあるsteps.ts または steps/ フォルダが存在し、すべてのステップ定義が含まれているtypes.ts が存在し、Zod スキーマが含まれている.ts インポートで拡張子に .js を使用しているprompts/ フォルダが存在するscenarios/ フォルダが存在し、テスト入力が少なくとも 1 件あるsnake_case 規約に従っているcamelCase 規約に従っているoutput-dev-workflow-function — workflow.ts ファイルの記述output-dev-step-function — ステップ関数の記述output-dev-evaluator-function — evaluators.ts ファイルの記述output-dev-types-file — Zod スキーマの作成output-dev-prompt-file — プロンプトファイルの作成output-dev-scenario-file — テストシナリオの作成output-dev-http-client-create — 共有 HTTP クライアントの作成This skill documents the standard folder structure for Output SDK workflows. Following these conventions ensures consistency across the codebase and enables proper tooling support.
src/
├── shared/ # Shared code across workflows
│ ├── clients/ # API clients (using @outputai/http)
│ ├── utils/ # Utility functions & helpers
│ ├── services/ # Business logic services
│ ├── steps/ # Shared steps (optional)
│ └── evaluators/ # Shared evaluators (optional)
└── workflows/
└── {workflow-name}/ # Individual workflow directory
├── workflow.ts # Workflow definition (REQUIRED)
├── steps.ts # OR steps/ folder
├── evaluators.ts # OR evaluators/ folder (optional)
├── types.ts # Zod schemas and TypeScript types
├── utils.ts # Workflow-specific utilities (optional)
├── prompts/ # LLM prompt templates (optional)
│ └── {promptName}@v1.prompt
└── scenarios/ # Test input scenarios (optional)
└── {scenario_name}.json
workflow() function definitionRelated Skill: output-dev-workflow-function
step() function definitionsRelated Skill: output-dev-step-function
evaluator() function definitionsz from @outputai/core (never from zod)Related Skill: output-dev-types-file
.prompt files for LLM operations{promptName}@v1.promptRelated Skill: output-dev-prompt-file
{scenario_name}.jsonRelated Skill: output-dev-scenario-file
src/workflows/{workflow-name}/
├── workflow.ts
├── steps.ts # All steps in one file
├── evaluators.ts # All evaluators in one file (optional)
├── types.ts
└── ...
src/workflows/{workflow-name}/
├── workflow.ts
├── steps/ # Steps split into individual files
│ ├── fetch_data.ts
│ ├── process.ts
│ └── validate.ts
├── evaluators/ # Evaluators split into individual files
│ ├── quality.ts
│ └── accuracy.ts
├── types.ts
└── ...
The Output SDK enforces strict rules about where components can be defined:
| Component | Must be in |
|---|---|
step() calls |
Files containing 'steps' in path |
evaluator() calls |
Files containing 'evaluators' in path |
workflow() calls |
workflow.ts file |
Examples:
src/workflows/my_workflow/steps.ts ✓src/workflows/my_workflow/steps/fetch_data.ts ✓src/shared/steps/common_steps.ts ✓src/workflows/my_workflow/helpers.ts ✗ (cannot contain step() calls)Steps and evaluators are Temporal activities with isolation constraints to ensure deterministic replay.
./utils.js, ./types.js, ./helpers.js./clients/pokeapi.js, ./lib/helpers.js../../shared/utils/*.js../../shared/clients/*.js../../shared/services/*.jsImport Pattern Examples:
// From workflow steps.ts - importing shared client
import { GeminiImageService } from '../../shared/clients/gemini_client.js';
// From workflow steps.ts - importing local utility
import { formatResponse } from './utils.js';
// From workflow steps.ts - importing types
import { InputSchema, OutputSchema } from './types.js';
// WRONG - steps cannot import other steps
import { otherStep } from '../../shared/steps/other.js'; // ✗
HTTP clients shared across workflows:
src/shared/clients/
├── gemini_client.ts # Google Gemini API client
├── jina_client.ts # Jina AI client
└── perplexity_client.ts # Perplexity API client
Import pattern in workflow steps:
import { GeminiImageService } from '../../shared/clients/gemini_client.js';
Related Skill: output-dev-http-client-create
Utility functions shared across workflows:
src/shared/utils/
├── string_helpers.ts
├── date_formatters.ts
└── validators.ts
Business logic services shared across workflows:
src/shared/services/
├── image_service.ts
└── content_service.ts
Shared steps that can be imported by workflows:
src/shared/steps/
└── common_steps.ts
Note: Workflows import shared steps, but steps cannot import other steps directly.
snake_case for workflow folder namesimage_infographic_nano, resume_parsercamelCase for .ts files (except workflow.ts, steps.ts, types.ts, evaluators.ts)camelCase@v{n} for .prompt filessnake_case for .json scenario filesname property in workflow() should be camelCaseimageInfographicNanosrc/workflows/image_infographic_nano/
├── workflow.ts # workflow({ name: 'imageInfographicNano', ... })
├── steps.ts # generateImageIdeas, generateImages, validateReferenceImages
├── types.ts # WorkflowInputSchema, WorkflowOutput, step schemas
├── utils.ts # normalizeReferenceImageUrls, buildS3Url, etc.
├── prompts/
│ └── generateImageIdeas@v1.prompt
└── scenarios/
├── test_input_complex.json
└── test_input_solar_panels.json
When reviewing workflow structure, verify:
workflow.ts exists with default exportsteps.ts or steps/ folder exists with all step definitionstypes.ts exists with Zod schemas.ts imports use .js extensionprompts/ folder exists if LLM operations are usedscenarios/ folder exists with at least one test inputsnake_case conventioncamelCase conventionoutput-dev-workflow-function - Writing workflow.ts filesoutput-dev-step-function - Writing step functionsoutput-dev-evaluator-function - Writing evaluators.ts filesoutput-dev-types-file - Creating Zod schemasoutput-dev-prompt-file - Creating prompt filesoutput-dev-scenario-file - Creating test scenariosoutput-dev-http-client-create - Creating shared HTTP clients原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。