claude-skills/

Anthropic公式スキル・プラグインの日本語ディレクトリ

last sync 22h ago
スキルOfficialdevelopment

📁output-dev-folder-structure

プラグイン
outputai

説明

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.ts(必須)

  • メインの workflow() 関数定義を含む
  • ワークフローをデフォルトエクスポートする
  • 決定論的でなければならない(直接的な I/O 操作は不可)
  • ステップ呼び出しのオーケストレーションを担う

関連スキル: output-dev-workflow-function

steps.ts または steps/ フォルダ(必須)

  • すべての step() 関数定義を含む
  • すべての I/O 操作(HTTP、LLM、ファイルシステム等)を処理する
  • 各ステップ関数を名前付きエクスポートする
  • FatalError および ValidationError によるエラーハンドリングを含む

関連スキル: output-dev-step-function

evaluators.ts または evaluators/ フォルダ(任意)

  • evaluator() 関数定義を含む
  • ワークフローの品質評価・検証に使用する
  • 各エバリュエーター関数を名前付きエクスポートする

types.ts(必須)

  • 入出力バリデーション用の Zod スキーマを含む
  • スキーマから導出した TypeScript 型をエクスポートする
  • z@outputai/core からインポートする(zod から直接インポートしない)

関連スキル: output-dev-types-file

utils.ts(任意)

  • 純粋なヘルパー関数を含む
  • I/O 操作は含めない(それらはステップに記述する)
  • ワークフロー内で共有するユーティリティロジックを置く

prompts/ フォルダ(任意)

  • LLM 操作用の .prompt ファイルを含む
  • ファイル命名規則: {promptName}@v1.prompt
  • YAML フロントマターと Liquid.js テンプレートを使用する

関連スキル: output-dev-prompt-file

scenarios/ フォルダ(任意)

  • JSON 形式のテスト入力ファイルを含む
  • ファイル命名規則: {scenario_name}.json
  • ワークフローの inputSchema 構造に対応する

関連スキル: output-dev-scenario-file

構成オプション

オプション 1: フラットファイル構成(小規模ワークフローに推奨)

src/workflows/{workflow-name}/
├── workflow.ts
├── steps.ts           # すべてのステップを 1 ファイルにまとめる
├── evaluators.ts      # すべてのエバリュエーターを 1 ファイルにまとめる(任意)
├── types.ts
└── ...

オプション 2: フォルダ分割構成(大規模ワークフロー向け)

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'; // ✗

共有リソース

src/shared/clients/

ワークフロー間で共有する 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/

ワークフロー間で共有するユーティリティ関数:

src/shared/utils/
├── string_helpers.ts
├── date_formatters.ts
└── validators.ts

src/shared/services/

ワークフロー間で共有するビジネスロジックサービス:

src/shared/services/
├── image_service.ts
└── content_service.ts

src/shared/steps/(任意)

ワークフローからインポートできる共有ステップ:

src/shared/steps/
└── common_steps.ts

注意: ワークフローは共有ステップをインポートできますが、 ステップから他のステップを直接インポートすることはできません。

命名規則

フォルダ名

  • ワークフローのフォルダ名には snake_case を使用する
  • 例: image_infographic_nanoresume_parser

ファイル名

  • .ts ファイルには camelCase を使用する (workflow.tssteps.tstypes.tsevaluators.ts を除く)
  • .prompt ファイルには camelCase@v{n} の形式を使用する
  • シナリオ用 .json ファイルには snake_case を使用する

ワークフロー名

  • workflow() 内の name プロパティは camelCase にする
  • 例: imageInfographicNano

例: 完全なワークフロー構造

src/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 を使用している
  • [ ] LLM 操作を使用している場合、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 クライアントの作成
原文(English)を表示

Workflow Folder Structure Conventions

Overview

This skill documents the standard folder structure for Output SDK workflows. Following these conventions ensures consistency across the codebase and enables proper tooling support.

When to Use This Skill

  • Creating a new workflow from scratch
  • Reorganizing an existing workflow
  • Understanding where to place different file types
  • Reviewing workflow structure for compliance

Standard Project Structure

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

File Purposes

workflow.ts (Required)

  • Contains the main workflow() function definition
  • Default exports the workflow
  • Must be deterministic - no direct I/O operations
  • Orchestrates step calls

Related Skill: output-dev-workflow-function

steps.ts or steps/ folder (Required)

  • Contains all step() function definitions
  • Handles all I/O operations (HTTP, LLM, file system, etc.)
  • Named exports for each step function
  • Includes error handling with FatalError and ValidationError

Related Skill: output-dev-step-function

evaluators.ts or evaluators/ folder (Optional)

  • Contains evaluator() function definitions
  • Used for workflow quality assessment and validation
  • Named exports for each evaluator function

types.ts (Required)

  • Contains Zod schemas for input/output validation
  • Exports TypeScript types derived from schemas
  • Imports z from @outputai/core (never from zod)

Related Skill: output-dev-types-file

utils.ts (Optional)

  • Contains pure helper functions
  • No I/O operations - those belong in steps
  • Shared utility logic for the workflow

prompts/ folder (Optional)

  • Contains .prompt files for LLM operations
  • File naming: {promptName}@v1.prompt
  • Uses YAML frontmatter and Liquid.js templating

Related Skill: output-dev-prompt-file

scenarios/ folder (Optional)

  • Contains JSON test input files
  • File naming: {scenario_name}.json
  • Matches workflow inputSchema structure

Related Skill: output-dev-scenario-file

Organization Options

Option 1: Flat Files (Recommended for smaller workflows)

src/workflows/{workflow-name}/
├── workflow.ts
├── steps.ts           # All steps in one file
├── evaluators.ts      # All evaluators in one file (optional)
├── types.ts
└── ...

Option 2: Folder-Based (For larger workflows)

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
└── ...

Component Location Rules (Strict)

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)

Import Rules (Activity Isolation)

Steps and evaluators are Temporal activities with isolation constraints to ensure deterministic replay.

Steps CAN import from:

  • Local workflow files: ./utils.js, ./types.js, ./helpers.js
  • Local subdirectories: ./clients/pokeapi.js, ./lib/helpers.js
  • Shared utilities: ../../shared/utils/*.js
  • Shared clients: ../../shared/clients/*.js
  • Shared services: ../../shared/services/*.js

Steps CANNOT import:

  • Other steps (activity isolation)
  • Evaluators
  • Workflow files

Evaluators follow the same rules:

  • CAN import local files and shared code
  • CANNOT import other evaluators, steps, or workflows

Import 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'; // ✗

Shared Resources

src/shared/clients/

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

src/shared/utils/

Utility functions shared across workflows:

src/shared/utils/
├── string_helpers.ts
├── date_formatters.ts
└── validators.ts

src/shared/services/

Business logic services shared across workflows:

src/shared/services/
├── image_service.ts
└── content_service.ts

src/shared/steps/ (Optional)

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.

Naming Conventions

Folder Names

  • Use snake_case for workflow folder names
  • Example: image_infographic_nano, resume_parser

File Names

  • Use camelCase for .ts files (except workflow.ts, steps.ts, types.ts, evaluators.ts)
  • Use camelCase@v{n} for .prompt files
  • Use snake_case for .json scenario files

Workflow Names

  • The name property in workflow() should be camelCase
  • Example: imageInfographicNano

Example: Complete Workflow Structure

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

Verification Checklist

When reviewing workflow structure, verify:

  • [ ] workflow.ts exists with default export
  • [ ] steps.ts or steps/ folder exists with all step definitions
  • [ ] types.ts exists with Zod schemas
  • [ ] All .ts imports use .js extension
  • [ ] prompts/ folder exists if LLM operations are used
  • [ ] scenarios/ folder exists with at least one test input
  • [ ] Folder naming follows snake_case convention
  • [ ] Workflow name in code follows camelCase convention
  • [ ] Steps only import allowed dependencies (local files, shared code)
  • [ ] No cross-component imports (steps don't import other steps)

Related Skills

  • output-dev-workflow-function - Writing workflow.ts files
  • output-dev-step-function - Writing step functions
  • output-dev-evaluator-function - Writing evaluators.ts files
  • output-dev-types-file - Creating Zod schemas
  • output-dev-prompt-file - Creating prompt files
  • output-dev-scenario-file - Creating test scenarios
  • output-dev-http-client-create - Creating shared HTTP clients

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。