Skip to main content

Run Claude Code agents in parallel from a YAML-frontmatter Markdown manifest, with git worktree isolation for write tasks.

Project description

parallel-orchestra

複数の Claude Code ヘッドレスエージェントを 並列実行し、結果を一つのブランチに自動マージする CLI ツール。

claude -p を内部でオーケストレートし、書き込みタスクごとに独立した git worktree を確保するので、お互いの変更が衝突しません。タスクが終わると PO が auto-commit して main に取り込みます。


できること

  • 1 枚の Markdown マニフェスト(YAML フロントマター)から複数タスクを定義し、並列起動する
  • 書き込みタスクは worktree に隔離 → 自動コミット → 完了後に元ブランチへマージ
  • 失敗・タイムアウト・transient エラーをカテゴリ分けして、必要に応じて自動リトライ(デフォルト 1 回・1 秒バックオフ・係数 2)
  • タスク間の依存関係(depends_on)と書き込みパスの宣言(writes)でスケジュールを最適化
  • ANSI 進捗ダッシュボード、JSON / Markdown サマリレポート、レジューム機能(--resume

インストール

git clone https://github.com/satoh-y-0323/parallel-orchestra.git
cd parallel-orchestra
pip install -e .

要件: Python 3.10+ / Claude Code CLIclaude コマンドとして PATH に通っていること。


5 分で動かす

リポジトリ直下に example/ という自己完結の雛形が入っています。

parallel-orchestra run example/.claude/reports/plan-report-tdd-example.md

これは以下を並列で実行します:

  • example/src/addition.pyadd(a, b) を TDD で実装
  • example/src/multiplication.pymultiply(a, b) を TDD で実装

それぞれが独立した worktree で tester → developer → tester のサブエージェントを回し、テスト全件合格を確認してから main へマージされます。


マニフェスト形式

---
po_plan_version: "0.1"
name: "my-plan"
cwd: "."

tasks:
  - id: feature-a
    agent: developer
    read_only: false
    prompt: |
      実装してください: ...

  - id: feature-b
    agent: developer
    read_only: false
    depends_on:
      - feature-a
    prompt: |
      ...
---

# 自由記述の説明文

このセクション以降は人間向けのメモ。PO は読みません。

主なフィールド:

フィールド 必須 説明
po_plan_version "0.1" 固定
name プランの名前(ログ等に使われる)
cwd manifest からの相対パスで「プロジェクトの作業ディレクトリ」を指す。worktree のコピー元 .claude/ もここから探す
tasks[].id [A-Za-z0-9_-]+
tasks[].agent claude -p --agent <agent> に渡される名前。<cwd>/.claude/agents/<agent>.md が定義
tasks[].read_only false の場合 worktree が作られる
tasks[].prompt エージェントへの指示文
tasks[].depends_on 先に成功している必要のあるタスク ID
tasks[].max_retries リトライ回数(未指定なら defaults.max_retries、それも無ければ 1)
defaults.max_retries manifest 全体のデフォルトリトライ回数

詳細な仕様は example/.claude/docs/parallel-orchestra-manifest.md にあります。


CLI

parallel-orchestra run <manifest_path> [options]
オプション 既定値 説明
--max-workers N 3 並列タスクの最大数
--claude-exe PATH claude claude 実行ファイルの場所
--quiet off 成功タスクの詳細出力を抑制
--log-dir PATH <git-root>/.claude/logs per-task の stdout/stderr 保存先
--no-log off per-task ログを保存しない
--dry-run off 計画だけ表示して実行しない
--resume off 前回成功タスクをスキップして再開
--report PATH .json / .md でサマリレポートを出力
--dashboard / --no-dashboard TTY 自動 ANSI ダッシュボード強制 ON/OFF

python -m parallel_orchestra ... でも同じ CLI が呼べます。

終了コード

コード 意味
0 すべてのタスクが成功
1 1 つ以上のタスクが失敗
2 マニフェストエラー
3 ランナーエラー(claude バイナリ不在など)

アーキテクチャ

parallel-orchestra run <manifest>
    │
    ├─ マニフェスト解析(manifest.py)
    │   └─ Task / Defaults / Manifest dataclass
    │
    ├─ DependencyScheduler(runner.py)
    │   └─ depends_on と writes に従って起動順を決定
    │
    └─ タスクごと:
        ├─ read_only=true  → cwd でそのまま claude -p を起動
        └─ read_only=false → git worktree を切り、.claude/ を複製
                              ↓
                              claude -p --agent <name> -p <prompt>
                              ↓
                              auto-commit
                              ↓
                              元ブランチへ merge
                              ↓
                              worktree cleanup

成功時の test-report 等は worktree branch の auto-commit に乗って merge 経由で main に取り込まれます。失敗時は worktree から手元へ post-mortem 用にコピーされます。


環境変数

変数 用途
PO_KEEP_WORKTREE=1 タスク終了後も worktree を残す(デバッグ用)
PO_WORKTREE_GUARD 内部用。ユーザーは設定しない

開発

pip install -e ".[dev]"
pytest                 # 185 件のユニット / 統合テスト
ruff check src tests
mypy src

example/ を使ったエンドツーエンド検証:

parallel-orchestra run example/.claude/reports/plan-report-tdd-example.md

ライセンス

未定(公開時に追記)。


関連

並列で動かす個々のエージェントを「どう書くか」「どうワークフローを定義するか」は本ツールの守備範囲外です。example/.claude/agents/example/.claude/skills/TDD ワークフローの最小例を含めているので参考にしてください。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parallel_orchestra-0.1.1.tar.gz (63.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parallel_orchestra-0.1.1-py3-none-any.whl (35.0 kB view details)

Uploaded Python 3

File details

Details for the file parallel_orchestra-0.1.1.tar.gz.

File metadata

  • Download URL: parallel_orchestra-0.1.1.tar.gz
  • Upload date:
  • Size: 63.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for parallel_orchestra-0.1.1.tar.gz
Algorithm Hash digest
SHA256 247ddbdc7274e7bc68a01711ae0d18aaa9eb022d13e2ea1732e753b2021b89cf
MD5 b7c6bc9a86e594da0ef389cafb63b0c7
BLAKE2b-256 97372af0ac36bad9df925278bfd840a2dbe1649dc0bdd671c8425b30fcc48b9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for parallel_orchestra-0.1.1.tar.gz:

Publisher: publish.yml on satoh-y-0323/parallel-orchestra

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file parallel_orchestra-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for parallel_orchestra-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae4399888159c4f363fabee7781747e62b95686102ee5f8026bcbac1c9b3c9bb
MD5 22ef64bee26992cec33e1a1bbc92b808
BLAKE2b-256 650d3d3528c9cdd9d975f123bb6889c511db5845c4991d885ec484702908d008

See more details on using hashes here.

Provenance

The following attestation bundles were made for parallel_orchestra-0.1.1-py3-none-any.whl:

Publisher: publish.yml on satoh-y-0323/parallel-orchestra

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page