jpskill.com
🛠️ 開発・MCP コミュニティ

orchestration-native-invoke

Invoke external AI CLIs via native Task agents (Claude, Codex, Gemini, Cursor). Primary mode for multi-provider orchestration with fork-terminal fallback for auth.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o orchestration-native-invoke.zip https://jpskill.com/download/18036.zip && unzip -o orchestration-native-invoke.zip && rm orchestration-native-invoke.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/18036.zip -OutFile "$d\orchestration-native-invoke.zip"; Expand-Archive "$d\orchestration-native-invoke.zip" -DestinationPath $d -Force; ri "$d\orchestration-native-invoke.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して orchestration-native-invoke.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → orchestration-native-invoke フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

目的

注記: これはドキュメント/ガイドスキルです。Claude Code のネイティブ Task エージェントを使用して外部 AI CLI を呼び出すための手順を提供します。このスキルを読んでパターンを学習し、subagent_type="general-purpose" を指定して Task ツールを手動で使用してください。

Claude Code のネイティブ Task エージェントを使用して、外部 AI コーディング CLI を呼び出します。これは、マルチプロバイダーオーケストレーションの主要なモードであり、認証のフォールバックとして fork-terminal が使用されます。

変数

変数 デフォルト 説明
DEFAULT_AGENT gemini 明示的に指定されていない場合に使用するエージェント
ENABLED_CODEX true ネイティブエージェント経由で OpenAI Codex を有効にする
ENABLED_GEMINI true ネイティブエージェント経由で Google Gemini を有効にする
ENABLED_CURSOR true ネイティブエージェント経由で Cursor Agent を有効にする
RUN_IN_BACKGROUND true エージェントを非同期で実行する
PARALLEL_EXECUTION true 複数のエージェントを並行して起動する
AUTO_RETRY_ON_AUTH true 認証失敗時に fork-terminal で自動再試行する
READ_ONLY_MODE true エージェントがコードベースを変更するのを防ぐ
CLEANUP_AGENT_FILES true エージェントがリポジトリに書き込むファイルをクリーンアップする

前提条件

サブエージェントの CLI 権限

ネイティブ Task エージェント(サブエージェント)は、CLI コマンドを実行するための事前承認された権限が必要です。これがないと、Bash ツールは「自動拒否(プロンプトは利用不可)」になります。

.claude/settings.json で必須:

{
  "permissions": {
    "allow": [
      "Bash(codex:*)",
      "Bash(gemini:*)",
      "Bash(cursor-agent:*)"
    ]
  }
}

セットアップ: /ai-dev-kit:setup を実行して、権限を自動的に構成します。

手動: Claude Code の設定から権限を追加するか、プロンプトが表示されたら承認します。

フォールバック: 権限が拒否された場合は、fork-terminal を使用してインタラクティブに実行します。

手順

必須 - 以下のワークフローの手順を順番に実行する必要があります。手順をスキップしないでください。

エージェントの選択

  1. 明示的なリクエスト: ユーザーがエージェントを指定した場合は、そのエージェントを使用します。
  2. エージェントが指定されていない: DEFAULT_AGENT を使用します。
  3. 有効化の確認: 続行する前に、ENABLED_* フラグが true であることを確認します。

クックブックの読み込み

  • 選択したエージェントに基づいて、../spawn/agent/cookbook/ から適切なクックブックを読み込みます。
  • コマンドを構築する前に、必ず CLI で --help を実行してください。
  • 非インタラクティブなフラグについては、クックブックの指示に従ってください。

危険信号 - STOP してクックブックに従ってください

もしあなたが以下をしようとしているなら:

  • 最初にクックブックを読まずにネイティブエージェントを起動する
  • --help を実行せずに CLI コマンドを実行する
  • 「これは簡単だ」という理由で手順をスキップする
  • 非インタラクティブなコンテキストでインタラクティブなフラグを使用する

STOP -> 適切なクックブックファイルを読み込む -> --help を確認する -> その後、続行する

重要: ネイティブエージェントは TTY 入力を処理できません。常に非インタラクティブなフラグを使用してください。

  • Codex: codex exec --full-auto
  • Cursor: cursor-agent --force -p
  • Gemini: 位置指定プロンプトを使用する(-i ではない)

ワークフロー

必須チェックポイント - 続行する前にそれぞれを確認してください。

  1. [ ] ユーザーのリクエストを理解する
  2. [ ] エージェントの選択: 使用するエージェントを決定する
  3. [ ] 読み込み: ../spawn/agent/cookbook/ から選択した各エージェントのクックブック
  4. [ ] HELP の実行: <cli> --help を実行して、利用可能なフラグを確認する
  5. [ ] コマンドの構築: クックブックに従って非インタラクティブなコマンドを構築する
  6. [ ] チェックポイント: クックブックの指示に従ったことを確認する
  7. [ ] run_in_background: true を指定して Task ツール経由で実行する
  8. [ ] TaskOutput 経由で結果を収集する
  9. [ ] 認証失敗時: fork-terminal フォールバックをトリガーする(認証リカバリを参照)

読み取り専用モードと書き込みモード

デフォルト: READ_ONLY_MODE = true

READ_ONLY_MODE が有効になっている場合、エージェントは分析とレポートのみを行い、ファイルを変更してはいけません。

プロバイダー別の読み取り専用フラグ

プロバイダー 読み取り専用コマンド 書き込みモードコマンド
Codex codex exec --sandbox read-only --full-auto codex exec --sandbox workspace-write --full-auto
Gemini gemini --sandbox --yolo gemini --yolo
Cursor cursor-agent -p (no --force) cursor-agent --force -p

読み取り専用のプロンプト

READ_ONLY_MODE が true の場合は、常にプロンプトに以下を含めてください。

"ファイルを変更しないでください。分析して結果を報告するだけです。
通常ファイルを書き込む場合は、代わりにコンテンツをレスポンスで返してください。"

ワークツリーの分離(書き込みモードに推奨)

エージェントが書き込みアクセスを必要とする場合は、git ワークツリーを使用して真の分離を実現します。

# エージェントの作業用に分離されたワークツリーを作成する
git worktree add /tmp/agent-workspace-<id> -b agent/<provider>-<task>

# ワークツリーでエージェントを実行する
cd /tmp/agent-workspace-<id>
<agent-command>

# 変更を確認する
git diff

# 承認された場合は、マージバックする
git checkout main
git merge agent/<provider>-<task>

# クリーンアップ
git worktree remove /tmp/agent-workspace-<id>
git branch -d agent/<provider>-<task>

ワークツリー分離の利点

  • 完全な書き込みアクセス: エージェントは自由に任意の変更を行うことができます
  • 選択的なマージ: 承認された変更のみをマージします
  • クリーンアップ不要: ワークツリーを破棄して変更を拒否します
  • 並列エージェント: 並列プロバイダー用の複数のワークツリー
  • ブランチ履歴: 変更は git で追跡されます

ワークツリーを使用するタイミング

シナリオ アプローチ
分析/レビューのみ READ_ONLY_MODE + CLI フラグ
単一ファイルの編集 クリーンアップ付きの書き込みモード
複数ファイルのリファクタリング ワークツリーの分離
試験的な変更 ワークツリー(破棄が簡単)
並列エージェントの作業 エージェントごとに個別のワークツリー

クリーンアッププロトコル

CLEANUP_AGENT_FILES が true(デフォルト)で、ワークツリーを使用していない場合:

  1. 作業ディレクトリ内の新しいファイルを確認します
  2. 削除する前にファイルを読み取って、価値のあるコンテンツを保持します
  3. エージェントが作成したファイルを削除します(例:*_REVIEW_OUTPUT.md*_analysis.json
  4. 監査証跡のためにクリーンアップアクションをログに記録します
# クリーンアップパターン
cleanup_patterns = [
    "*_REVIEW_OUTPUT.md",
    "*_analysis.json",
    "*_findings.md",
    "agent_output_*.txt"
]

クックブック

Codex (OpenAI)

  • IF:

(原文がここで切り詰められています)

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Purpose

Note: This is a documentation/guide skill. It provides instructions for invoking external AI CLIs using Claude Code's native Task agents. Read this skill to learn the patterns, then use the Task tool manually with subagent_type="general-purpose".

Invoke external AI coding CLIs using Claude Code's native Task agents. This is the primary mode for multi-provider orchestration, with fork-terminal as fallback for authentication.

Variables

Variable Default Description
DEFAULT_AGENT gemini Agent to use when not explicitly specified
ENABLED_CODEX true Enable OpenAI Codex via native agent
ENABLED_GEMINI true Enable Google Gemini via native agent
ENABLED_CURSOR true Enable Cursor Agent via native agent
RUN_IN_BACKGROUND true Run agents asynchronously
PARALLEL_EXECUTION true Launch multiple agents in parallel
AUTO_RETRY_ON_AUTH true Auto-retry with fork-terminal on auth failure
READ_ONLY_MODE true Prevent agents from modifying codebase
CLEANUP_AGENT_FILES true Clean up any files agents write to repo

Prerequisites

CLI Permissions for Subagents

Native Task agents (subagents) require pre-approved permissions to execute CLI commands. Without these, the Bash tool will be "auto-denied (prompts unavailable)".

Required in .claude/settings.json:

{
  "permissions": {
    "allow": [
      "Bash(codex:*)",
      "Bash(gemini:*)",
      "Bash(cursor-agent:*)"
    ]
  }
}

Setup: Run /ai-dev-kit:setup to configure permissions automatically.

Manual: Add permissions via Claude Code settings or approve when prompted.

Fallback: If permissions are denied, use fork-terminal for interactive execution.

Instructions

MANDATORY - You MUST follow the Workflow steps below in order. Do not skip steps.

Agent Selection

  1. Explicit request: If user specifies an agent, use that agent
  2. No agent specified: Use DEFAULT_AGENT
  3. Check enabled: Verify the ENABLED_* flag is true before proceeding

Reading Cookbooks

  • Based on the selected agent, read the appropriate cookbook from ../spawn/agent/cookbook/
  • You MUST run --help on the CLI before constructing the command
  • Follow cookbook instructions for non-interactive flags

Red Flags - STOP and follow Cookbook

If you're about to:

  • Launch a native agent without reading the cookbook first
  • Execute a CLI command without running --help
  • Skip steps because "this is simple"
  • Use interactive flags in non-interactive context

STOP -> Read the appropriate cookbook file -> Check --help -> Then proceed

Critical: Native agents cannot handle TTY input. Always use non-interactive flags:

  • Codex: codex exec --full-auto
  • Cursor: cursor-agent --force -p
  • Gemini: Use positional prompt (not -i)

Workflow

MANDATORY CHECKPOINTS - Verify each before proceeding:

  1. [ ] Understand the user's request
  2. [ ] SELECT AGENT(S): Determine which agent(s) to use
  3. [ ] READ: Cookbook for each selected agent from ../spawn/agent/cookbook/
  4. [ ] RUN HELP: Execute <cli> --help to verify available flags
  5. [ ] CONSTRUCT COMMAND: Build non-interactive command per cookbook
  6. [ ] CHECKPOINT: Confirm cookbook instructions were followed
  7. [ ] Execute via Task tool with run_in_background: true
  8. [ ] Collect results via TaskOutput
  9. [ ] ON AUTH FAILURE: Trigger fork-terminal fallback (see Auth Recovery)

Read-Only vs Write Mode

Default: READ_ONLY_MODE = true

When READ_ONLY_MODE is enabled, agents should only analyze and report - not modify files.

Read-Only Flags by Provider

Provider Read-Only Command Write Mode Command
Codex codex exec --sandbox read-only --full-auto codex exec --sandbox workspace-write --full-auto
Gemini gemini --sandbox --yolo gemini --yolo
Cursor cursor-agent -p (no --force) cursor-agent --force -p

Prompting for Read-Only

Always include in prompt when READ_ONLY_MODE is true:

"Do NOT modify any files. Only analyze and report findings.
If you would normally write to a file, instead return the content in your response."

Worktree Isolation (Recommended for Write Mode)

When agents need write access, use git worktrees for true isolation:

# Create isolated worktree for agent work
git worktree add /tmp/agent-workspace-<id> -b agent/<provider>-<task>

# Run agent in worktree
cd /tmp/agent-workspace-<id>
<agent-command>

# Review changes
git diff

# If approved, merge back
git checkout main
git merge agent/<provider>-<task>

# Cleanup
git worktree remove /tmp/agent-workspace-<id>
git branch -d agent/<provider>-<task>

Benefits of Worktree Isolation

  • Full write access: Agents can make any changes freely
  • Selective merge: Only merge approved changes
  • No cleanup needed: Discard worktree to reject changes
  • Parallel agents: Multiple worktrees for parallel providers
  • Branch history: Changes are tracked in git

When to Use Worktrees

Scenario Approach
Analysis/review only READ_ONLY_MODE + CLI flags
Single file edit Write mode with cleanup
Multi-file refactor Worktree isolation
Experimental changes Worktree (easy to discard)
Parallel agent work Separate worktrees per agent

Cleanup Protocol

When CLEANUP_AGENT_FILES is true (default) and NOT using worktrees:

  1. Check for new files in the working directory
  2. Preserve valuable content by reading files before deletion
  3. Delete agent-created files (e.g., *_REVIEW_OUTPUT.md, *_analysis.json)
  4. Log cleanup actions for audit trail
# Cleanup pattern
cleanup_patterns = [
    "*_REVIEW_OUTPUT.md",
    "*_analysis.json",
    "*_findings.md",
    "agent_output_*.txt"
]

Cookbook

Codex (OpenAI)

  • IF: User requests Codex/OpenAI and 'ENABLED_CODEX' is true
  • THEN: Read ../spawn/agent/cookbook/codex-cli.md
  • Native command pattern (read-only):
    codex exec --sandbox read-only --full-auto --model gpt-5.2-codex "<prompt>"
  • Native command pattern (write mode):
    codex exec --sandbox workspace-write --full-auto --model gpt-5.2-codex "<prompt>"
  • Auth failure pattern: "Please log in", "authentication required"
  • Login command: codex login

Gemini (Google)

  • IF: User requests Gemini/Google and 'ENABLED_GEMINI' is true
  • THEN: Read ../spawn/agent/cookbook/gemini-cli.md
  • Native command pattern (read-only):
    gemini --model gemini-3-pro --sandbox --yolo "<prompt>"
  • Native command pattern (write mode):
    gemini --model gemini-3-pro --yolo "<prompt>"
  • Auth failure pattern: "Please authenticate", "run gemini auth"
  • Login command: gemini auth login

Cursor

  • IF: User requests Cursor and 'ENABLED_CURSOR' is true
  • THEN: Read ../spawn/agent/cookbook/cursor-cli.md
  • Native command pattern (read-only - prompts for approval):
    cursor-agent --model claude-sonnet-4.5 -p "<prompt>"
  • Native command pattern (write mode - auto-approves):
    cursor-agent --model claude-sonnet-4.5 --force -p "<prompt>"
  • Auth failure pattern: "Please log in", browser popup needed
  • Login command: cursor-agent login

Auth Recovery

When a native agent reports an authentication failure:

  1. Detect: Check output for auth failure patterns
  2. Fork for login: Use fork-terminal with login command
  3. Wait: Monitor for terminal close
  4. Retry: Re-launch native agent
# Auth recovery flow
def handle_auth_failure(provider: str, original_prompt: str):
    login_commands = {
        "codex": "codex login",
        "gemini": "gemini auth login",
        "cursor": "cursor-agent login"
    }

    # Fork terminal for interactive login
    fork_terminal(login_commands[provider], wait_for_close=True)

    # After terminal closes, retry native invocation
    return invoke_native(provider, original_prompt)

Parallel Invocation

To invoke multiple agents in parallel, use a single message with multiple Task tool calls:

# Launch Gemini, Codex, and Cursor in parallel
Task(subagent_type="general-purpose", run_in_background=true, prompt="gemini ...")
Task(subagent_type="general-purpose", run_in_background=true, prompt="codex ...")
Task(subagent_type="general-purpose", run_in_background=true, prompt="cursor ...")

Collect results:

TaskOutput(task_id="...", block=false)  # Check progress
TaskOutput(task_id="...", block=true)   # Wait for completion

Result Collection

Native agents return results via TaskOutput tool:

Parameter Value Behavior
block=false Check status Non-blocking progress check
block=true Wait for completion Blocks until agent finishes
timeout milliseconds Max wait time before timeout

Example Collection Pattern

# Check progress (non-blocking)
TaskOutput(task_id="abc123", block=false)

# Wait for completion (blocking)
TaskOutput(task_id="abc123", block=true, timeout=120000)

Comparison: Native vs Fork-Terminal

Aspect Native Task Agent Fork-Terminal
Parallel execution Excellent Good
Result collection TaskOutput (clean) File parsing
TTY/Interactive NO YES
Auth handling Reports failure Interactive login
Resume capability YES (agent ID) NO

Use Native when:

  • Automating multi-provider tasks
  • Parallel execution needed
  • Clean result collection required

Use Fork-Terminal when:

  • Interactive mode needed
  • Browser-based auth required
  • Real-time streaming output needed