• Projects
  • Service
  • About
  • branding.bz
  • Podcast
  • Tips
  • FAQ
  • Recruit
  • Download
  • Contact
  • branding.bz(ブランド構築SaaS)
  • DESIGN NOW(デザインメディア)
  • X
  • LinkedIn
  • Spotify
  • Facebook

213-0011 神奈川県川崎市高津区久本3-6-7-303

© 2026 ID INC. All rights reserved

claude-skills/スキル
SKILLOfficialdevelopment

output-dev-credentials

プラグイン
outputai
ソース
GitHub で見る ↗
説明

Output SDK ワークフロー内で暗号化されたシークレット(認証情報)を @outputai/credentials を使って保存・参照できます。 次のような場合に使用: API キーやデータベースのパスワード、サードパーティ製サービスのトークンを組み込むとき

原文を表示

Store and reference encrypted secrets in Output SDK workflows using @outputai/credentials. Use when integrating API keys, database passwords, or third-party tokens.

ユースケース
  • API キーを安全に保存するとき
  • データベースパスワードを管理するとき
  • サードパーティ製サービスのトークンを組み込むとき
本文(日本語訳)

暗号化認証情報の管理

概要

@outputai/credentials パッケージは、Output SDK のワークフローに対して、暗号化された認証情報(APIキーやトークンなど)を安全に管理する機能を提供します。従来の process.env パターンに代わる、構造化された暗号化YAML形式のシステムで、スコープ付き認証情報と深い階層マージに対応しています。

このスキルを使う場面

  • ワークフローに API キーやトークンを追加する
  • process.env から暗号化認証情報への移行
  • ワークフロー単位または環境単位の認証情報をセットアップする
  • 認証情報エラー(MissingCredentialError、MissingKeyError)のデバッグ
  • カスタム認証情報プロバイダー(Vault、AWS Secrets Manager など)の設定

ライブラリ API

インポート

import { credentials } from '@outputai/credentials';

credentials.get(path, defaultValue?)

オプションのデフォルト値付きで安全に読み取ります。例外をスローしません。

// 値またはundefinedを返す
const region = credentials.get('aws.region');

// 値またはデフォルトを返す
const region = credentials.get('aws.region', 'us-east-1');

credentials.require(path)

必須の読み取り。見つからない場合は MissingCredentialError をスローします。

const apiKey = credentials.require('anthropic.api_key');

エラー型

import { MissingCredentialError, MissingKeyError } from '@outputai/credentials';
エラー 発生時 対処方法
MissingCredentialError credentials.require() の指定パスが見つからない output credentials edit で認証情報を追加
MissingKeyError 復号化キーがない OUTPUT_CREDENTIALS_KEY 環境変数を設定するか、.key ファイルを作成

CLIコマンド

# 認証情報を初期化(キーを生成し、暗号化YAMLテンプレートを作成)
output credentials init                              # グローバル
output credentials init -e production                 # 環境別
output credentials init -w payment_processing         # ワークフロー別

# 認証情報を編集(復号化、$EDITOR で開く、保存時に再暗号化)
output credentials edit                               # グローバル
output credentials edit -e production                  # 環境別
output credentials edit -w payment_processing          # ワークフロー別

# 復号化された認証情報を表示(デバッグ用)
output credentials show                               # グローバル
output credentials show -e development                 # 環境別

# 単一の認証情報値を取得
output credentials get anthropic.api_key               # グローバル
output credentials get stripe.key -w payment_processing # ワークフロー別

フラグ:

  • -e / --environment: 対象環境(production、development など)
  • -w / --workflow: 特定のワークフローを対象
  • -f / --force: 既存の認証情報を上書き(init のみ)
  • 注記:-e と -w は同時に指定できません

3階層スコープシステム

1. グローバル認証情報

config/credentials.yml.enc    # 暗号化YAML
config/credentials.key        # 復号化キー(コミットしないこと)

キー環境変数:OUTPUT_CREDENTIALS_KEY

2. 環境別認証情報

config/credentials/production.yml.enc
config/credentials/production.key

キー環境変数:OUTPUT_CREDENTIALS_KEY_PRODUCTION

3. ワークフロー別認証情報

src/workflows/{name}/credentials.yml.enc
src/workflows/{name}/credentials.key

キー環境変数:OUTPUT_CREDENTIALS_KEY_{WORKFLOW_NAME}(大文字)

キー解決の順序

各スコープについて、キーは以下の順序で探索されます:

  1. 環境変数(OUTPUT_CREDENTIALS_KEY、OUTPUT_CREDENTIALS_KEY_{ENV}、または OUTPUT_CREDENTIALS_KEY_{WORKFLOW})
  2. ディスク上のキーファイル(例:config/credentials.key)
  3. 見つからない場合は MissingKeyError をスロー

ワークフロー別キーが存在しない場合、ワークフロー認証情報はグローバルキーにフォールバックします。

認証情報のマージ

ワークフローが独自の認証情報を持つ場合、グローバル認証情報に対して深い階層でマージされます。同じパスではワークフロー側の値が優先されます:

# グローバル (config/credentials.yml.enc)
anthropic:
  api_key: sk-ant-global
aws:
  region: us-east-1

# ワークフロー (src/workflows/my_workflow/credentials.yml.enc)
anthropic:
  api_key: sk-ant-workflow-specific
stripe:
  secret_key: sk_live_workflow

# 実行時のマージ結果:
# anthropic.api_key  -> sk-ant-workflow-specific  (ワークフロー側で上書き)
# aws.region         -> us-east-1                 (グローバルから)
# stripe.secret_key  -> sk_live_workflow           (ワークフロー側で追加)

process.env からの移行

移行前(従来のパターン)

import { createKyClient } from '@outputai/http';

const API_KEY = process.env.SERVICE_API_KEY || '';

const client = createKyClient({
  prefix: 'https://api.service.com',
  headers: { Authorization: `Bearer ${API_KEY}` }
});

移行後(認証情報パターン)

import { createKyClient } from '@outputai/http';
import { credentials } from '@outputai/credentials';

const apiKey = credentials.require('service.api_key');

const client = createKyClient({
  prefix: 'https://api.service.com',
  headers: { Authorization: `Bearer ${apiKey}` }
});

移行手順

  1. output credentials init を実行して暗号化ファイルとキーを生成
  2. output credentials edit を実行して認証情報を追加
  3. process.env.X の参照を credentials.require('x') または credentials.get('x', default) に置き換え
  4. .env ファイルから環境変数を削除
  5. .gitignore に *.key を追加

カスタムプロバイダー

デフォルトの暗号化YAML形式をVaultやAWS Secrets Managerなど別のシステムに置き換えられます:

import { setProvider } from '@outputai/credentials';

setProvider({
  loadGlobal: ({ environment }) => {
    return fetchFromVault(`credentials/${environment || 'default'}`);
  },
  loadForWorkflow: ({ workflowName, environment }) => {
    return fetchFromVault(`workflows/${workflowName}`) ?? null;
  }
});

プロバイダーインターフェース

interface CredentialsProvider {
  loadGlobal(context: { environment: string | undefined }): Record<string, unknown>;
  loadForWorkflow(context: {
    workflowName: string;
    workflowDir: string | undefined;
    environment?: string | undefined;
  }): Record<string, unknown> | null;
}

セキュリティに関する考慮事項

  • .key ファイルは絶対にコミットしない — .gitignore に *.key を追加
  • .yml.enc ファイルはコミット可能 — キーなしでは読み取り不可
  • キーファイルの権限 — 0o600(所有者のみ読み書き可)で作成
  • 一時ファイルの削除 — edit 中にプレーンテキストはヌルバイトで上書きしてから削除
  • CI/CD では環境変数を使用 — パイプラインで OUTPUT_CREDENTIALS_KEY を設定
  • 暗号化方式 — AES-256-GCM(毎回ランダムなnonceを使用)

確認チェックリスト

  • [ ] @outputai/credentials から credentials をインポート
  • [ ] 必須の認証情報には credentials.require() を使用(process.env ではなく)
  • [ ] オプションの値には credentials.get() をデフォルト値付きで使用
  • [ ] *.key を .gitignore に記載
  • [ ] output credentials init で認証情報を初期化
  • [ ] output credentials edit で認証情報を追加

関連スキル

  • output-credentials-init — 認証情報ファイルの初期化
  • output-credentials-edit — 認証情報の表示と編集
  • output-credentials-env-vars — credential: 規約を使った認証情報の環境変数化
  • output-dev-http-client-create — 認証情報を使う HTTP クライアントの作成
  • output-dev-step-function — ステップ関数での認証情報の使用
  • output-error-http-client — HTTP クライアントの問題対応
原文(English)を表示

Encrypted Credentials Management

Overview

The @outputai/credentials package provides encrypted secrets management for Output SDK workflows. It replaces process.env patterns with a structured, encrypted YAML-based system that supports scoped credentials with deep merging.

When to Use This Skill

  • Adding API keys or tokens to a workflow
  • Migrating from process.env to encrypted credentials
  • Setting up per-workflow or per-environment secrets
  • Debugging missing credential errors (MissingCredentialError, MissingKeyError)
  • Configuring custom credential providers (Vault, AWS Secrets Manager)

Library API

Import

import { credentials } from '@outputai/credentials';

credentials.get(path, defaultValue?)

Safe read with optional default. Never throws.

// Returns value or undefined
const region = credentials.get('aws.region');

// Returns value or default
const region = credentials.get('aws.region', 'us-east-1');

credentials.require(path)

Strict read. Throws MissingCredentialError if not found.

const apiKey = credentials.require('anthropic.api_key');

Error Types

import { MissingCredentialError, MissingKeyError } from '@outputai/credentials';
Error Thrown When Fix
MissingCredentialError credentials.require() path not found Add the credential via output credentials edit
MissingKeyError No decryption key available Set OUTPUT_CREDENTIALS_KEY env var or create .key file

CLI Commands

# Initialize credentials (generates key + encrypted YAML template)
output credentials init                              # Global
output credentials init -e production                 # Environment-specific
output credentials init -w payment_processing         # Workflow-specific

# Edit credentials (decrypts, opens $EDITOR, re-encrypts on save)
output credentials edit                               # Global
output credentials edit -e production                  # Environment
output credentials edit -w payment_processing          # Workflow

# Show decrypted credentials (debugging)
output credentials show                               # Global
output credentials show -e development                 # Environment

# Get single credential value
output credentials get anthropic.api_key               # Global
output credentials get stripe.key -w payment_processing # Workflow

Flags:

  • -e / --environment: Target environment (production, development)
  • -w / --workflow: Target a specific workflow
  • -f / --force: Overwrite existing credentials (init only)
  • Note: -e and -w are mutually exclusive

Three-Tier Scope System

1. Global Credentials

config/credentials.yml.enc    # Encrypted YAML
config/credentials.key        # Decryption key (DO NOT COMMIT)

Key env var: OUTPUT_CREDENTIALS_KEY

2. Environment-Specific Credentials

config/credentials/production.yml.enc
config/credentials/production.key

Key env var: OUTPUT_CREDENTIALS_KEY_PRODUCTION

3. Per-Workflow Credentials

src/workflows/{name}/credentials.yml.enc
src/workflows/{name}/credentials.key

Key env var: OUTPUT_CREDENTIALS_KEY_{WORKFLOW_NAME} (uppercased)

Key Resolution Chain

For each scope, the key is resolved in order:

  1. Environment variable (OUTPUT_CREDENTIALS_KEY, OUTPUT_CREDENTIALS_KEY_{ENV}, or OUTPUT_CREDENTIALS_KEY_{WORKFLOW})
  2. Key file on disk (e.g., config/credentials.key)
  3. Throws MissingKeyError if neither found

Workflow credentials fall back to the global key if no workflow-specific key exists.

Credential Merging

When a workflow has its own credentials, they deep-merge over global credentials. Workflow values win at the same path:

# Global (config/credentials.yml.enc)
anthropic:
  api_key: sk-ant-global
aws:
  region: us-east-1

# Workflow (src/workflows/my_workflow/credentials.yml.enc)
anthropic:
  api_key: sk-ant-workflow-specific
stripe:
  secret_key: sk_live_workflow

# Merged result at runtime:
# anthropic.api_key  -> sk-ant-workflow-specific  (overridden by workflow)
# aws.region         -> us-east-1                 (from global)
# stripe.secret_key  -> sk_live_workflow           (added by workflow)

Migration from process.env

Before (old pattern)

import { createKyClient } from '@outputai/http';

const API_KEY = process.env.SERVICE_API_KEY || '';

const client = createKyClient({
  prefix: 'https://api.service.com',
  headers: { Authorization: `Bearer ${API_KEY}` }
});

After (credentials pattern)

import { createKyClient } from '@outputai/http';
import { credentials } from '@outputai/credentials';

const apiKey = credentials.require('service.api_key');

const client = createKyClient({
  prefix: 'https://api.service.com',
  headers: { Authorization: `Bearer ${apiKey}` }
});

Migration Steps

  1. Run output credentials init to create the encrypted file and key
  2. Run output credentials edit to add your secrets
  3. Replace process.env.X reads with credentials.require('x') or credentials.get('x', default)
  4. Remove environment variables from .env files
  5. Add *.key to .gitignore

Custom Providers

Replace the default encrypted YAML backend with Vault, AWS Secrets Manager, etc.:

import { setProvider } from '@outputai/credentials';

setProvider({
  loadGlobal: ({ environment }) => {
    return fetchFromVault(`credentials/${environment || 'default'}`);
  },
  loadForWorkflow: ({ workflowName, environment }) => {
    return fetchFromVault(`workflows/${workflowName}`) ?? null;
  }
});

Provider Interface

interface CredentialsProvider {
  loadGlobal(context: { environment: string | undefined }): Record<string, unknown>;
  loadForWorkflow(context: {
    workflowName: string;
    workflowDir: string | undefined;
    environment?: string | undefined;
  }): Record<string, unknown> | null;
}

Security Considerations

  • Never commit .key files - Add *.key to .gitignore
  • Safe to commit .yml.enc files - Cannot be read without the key
  • Key file permissions - Created with mode 0o600 (owner-only read/write)
  • Temp file cleanup - Plaintext overwritten with null bytes before deletion during edit
  • Use env vars in CI/CD - Set OUTPUT_CREDENTIALS_KEY in your pipeline
  • Encryption - AES-256-GCM with unique random nonce per encryption

Verification Checklist

  • [ ] credentials imported from @outputai/credentials
  • [ ] credentials.require() used for mandatory secrets (not process.env)
  • [ ] credentials.get() used with default for optional values
  • [ ] *.key listed in .gitignore
  • [ ] Credentials initialized via output credentials init
  • [ ] Secrets added via output credentials edit

Related Skills

  • output-credentials-init - Initializing credentials files for the first time
  • output-credentials-edit - Viewing and editing credential values
  • output-credentials-env-vars - Wiring credentials to env vars with the credential: convention
  • output-dev-http-client-create - Creating HTTP clients that use credentials
  • output-dev-step-function - Using credentials in step functions
  • output-error-http-client - Troubleshooting HTTP client issues

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