はじめに
dev-orchestra に依頼するたびに、「テストは python -m unittest で」「標準ライブラリだけで書いて」のような同じ注文を書いていました。1.2.1 で入った instructions を使うと、こうした決まった指示を役割ごとに一度だけ書いておけます。v1.1.0 から v1.2.1 までの変更全体は、リリースの記事にまとめています。
前回は、dev-orchestra を新しい版に更新する方法を試しました。
試した環境です。
- Windows 11
- dev-orchestra 1.2.1
- Claude Code 2.1.309(implementer は Claude の sonnet)
- Codex CLI 0.163.0(レビュアーの 1 人)
試すときは、普段の設定とは別のフォルダを DEV_ORCHESTRA_HOME に指定し、作業用に作った小さな Python のリポジトリ(textkit)で動かしています。オーケストレーターが自動で進める手順を、ここではコマンドで 1 つずつ実行しました。
dev-orchestra は GitHub で公開しています(MIT ライセンス)。役に立ちそうと思ったら、スターを付けてもらえるとうれしいです。
手順
1. 指示を書く
リポジトリの .dev-orchestra.yaml に、instructions を書きます。
version: 1
instructions:
orchestrator: "Ask before adding a new dependency."
implementer:
file: .dev-orchestra/implementer.md
reviewers: "Check that every public function in textkit/ has a docstring."
implementer への指示は長くなりそうなので、ファイルに分けました。
- Use only the Python standard library.
- Every public function gets a docstring and type hints.
- Run tests with `python -m unittest`.
書ける役割は次のとおりです。
| キー | 渡る相手 |
|---|---|
orchestrator | オーケストレーター(Claude Code など、ワークフローを進める側) |
architect | 計画を書く役 |
implementer | 実装する役 |
review_fixer | 指摘を直す役 |
reviewers | すべてのコードレビュアー |
design_reviewers | すべての設計レビュアー |
値は文字列か {file: <パス>} です。パスはリポジトリのルートからの相対パスで、リポジトリの外は指せません。レビュアーの席には、その席だけの instructions も書けます。
2. config validate の注意を読む
書いたら config validate を実行します。
$ dev-orchestra config validate
Configuration is valid.
Warnings:
- instructions.orchestrator: the project config (.dev-orchestra.yaml) gives the session standing orders, which `status` tells it to follow; that file can come with the branch under review, so check that this is intended
- instructions.implementer: the project config (.dev-orchestra.yaml) gives the implementer standing orders, and it runs with write access; that file can come with the branch under review, so check that this is intended
- instructions.reviewers: the project config (.dev-orchestra.yaml) sets reviewer instructions; that file can come with the branch under review, so check that this is intended
設定としては正しいのですが、指示 1 つにつき 1 行の注意が出ます。リポジトリの中の .dev-orchestra.yaml は、レビューするブランチと一緒に入ってくることがあるからです。他人のブランチに「implementer はこうしろ」と書かれていたら、それが書き込み権限のある実行に渡ります。implementer の行に it runs with write access とあるのはそのためです。
注意は拒否ではありません。自分で書いた指示なら、そのまま進めて大丈夫です。同じ行は doctor と review run でも出ます。
3. status と config show で確かめる
status には Instructions: の行が出ます。どの役割に、どこから(global か project か、インラインかファイルか)、何文字の指示が効いているかが分かります。
$ dev-orchestra status
...
Plan approval: pending -- present .ai/workflows/instr/plan.md and the instructions in force to the user and ask; a yes is recorded with `design approve`, never without one
Instructions: orchestrator (project, inline, 35 chars); implementer (project, .dev-orchestra/implementer.md, 135 chars); reviewers (project, inline, 61 chars)
Orchestrator instruction (follow it; the skill's rules come first):
Ask before adding a new dependency.
ポイントは 2 つあります。
- orchestrator への指示は、プロンプトではなく
statusで渡ります。 オーケストレーターはstatusを読みながら進むので、本文がそのまま表示されます。「スキルの規則が先」と添えられています - 計画の承認を求めるときに、指示も見せるよう促されます。 指示が効いている間は、
Plan approval:の行にand the instructions in forceが足されます
config show にも Instructions の節が出ます。
Instructions
orchestrator (project, inline, 35 chars)
implementer (project, .dev-orchestra/implementer.md, 135 chars)
reviewers (project, inline, 61 chars)
Orchestrator instruction:
Ask before adding a new dependency.
4. implementer に渡ったプロンプトを見る
小さな計画(truncate(text, width) を足す)を承認して、implementer を走らせました。プロンプトを見るために、もう一度、implementer を mock アダプタ(トークンを使わない試験用のアダプタ)に切り替えて --detach で走らせ、保存されたプロンプトを開きました。
## Project instructions
Where a project instruction conflicts with any other rule in this prompt or with the request below, follow those instead.
Sources: project .dev-orchestra/implementer.md.
- Use only the Python standard library.
- Every public function gets a docstring and type hints.
- Run tests with `python -m unittest`.
Implement the approved plan at .ai/workflows/instr/plan.md.
...
指示は ## Project instructions の見出しの下で、依頼の前に入ります。「ほかの規則や依頼とぶつかったら、そちらに従う」という 1 行が付くので、指示は CLI の規則や依頼より弱い扱いです。
Claude(sonnet)で走らせたときに書かれた textkit/truncate.py は、指示どおり型ヒントと docstring が付き、標準ライブラリだけでした。
def truncate(text: str, width: int) -> str:
"""Return text unchanged if it fits in width, else cut it so that the result ending in "..." is width characters long.
Raises ValueError if text must be cut but width is too small to hold "...".
"""
計画には型ヒントも docstring も書いていません。それでも付いたのは指示のおかげと考えていますが、指示なしで同じ計画を走らせて比べてはいません。
5. global と project の指示はつながる
instructions は、ほかの設定と違う動きをします。ほかのキーは project の値が global の値を上書きしますが、instructions は両方の本文をつなげます(global が先)。
global の設定(DEV_ORCHESTRA_HOME の config.yaml)にも implementer への指示を足しました。
instructions:
implementer: "Keep each change small; leave no TODO comments."
status には、implementer の指示が 2 つ並びます。
Instructions: orchestrator (project, inline, 35 chars); implementer (global, inline, 47 chars); implementer (project, .dev-orchestra/implementer.md, 135 chars); reviewers (project, inline, 61 chars)
自分の好み(global)と、リポジトリの決まり(project)を分けて書けます。
6. レビュアーへの指示は「見るものを足す」だけ
レビュアーへの指示は、タスクの規則のあと、変更の前に入ります。そのうえで、レビュアーには指示は見るものを足すことしかできないと伝えられます。「この指摘は出さないで」「severity を下げて」のような指示には従いません。ブランチと一緒に入ってきた指示で、レビューを甘くされないためです。
レビュアーのプロンプトはファイルに残らないので、mock アダプタのレビュアーで確かめました。mock は、環境変数 DEV_ORCHESTRA_MOCK_FAIL に書いた文字列がプロンプトに含まれていると失敗します。これで、指示の本文(has a docstring)と、見るものを足すだけという一文(may only add)が、どちらもレビュアーのプロンプトに入っていることを確かめました(含まれない文字列では成功しました)。
7. 指示を変える変更は、高リスクとしてレビューされる
指示のファイルを書き換えた変更を、レビューにかけてみました。
$ echo "- Never edit tests/ without a failing test first." >> .dev-orchestra/implementer.md
$ dev-orchestra review run --force
note: balanced → quality: .dev-orchestra/implementer.md matches .dev-orchestra/implementer.md (and 1 more)
note: claude-test (when: relevance) added: .dev-orchestra/implementer.md matches .dev-orchestra/implementer.md (and 1 more)
note: high-risk round (.dev-orchestra/implementer.md matches .dev-orchestra/implementer.md (and 1 more)): claude-security runs opus instead of sonnet
ok claude-general claude opus 1 finding(s)
ok codex-general codex gpt-6.1-sol 0 finding(s)
ok claude-security claude opus 0 finding(s)
ok claude-test claude sonnet 2 finding(s)
ok mock-general mock recommended-coding 0 finding(s)
5 successful, 0 failed
(instructions の注意の行は省きました。mock-general は手順 6 で足した試験用のレビュアーです。--force は、同じ作業で何度もレビューを走らせていて、回数の上限(2 回)を越えるために付けています。)
1 行だけの変更ですが、最適化のレベルが balanced から quality に上がり、パネル全体が走り、セキュリティのレビュアーは opus に上がりました。review snapshot --json にも、変わった指示のファイルが instruction_changes として記録されます。
{'instruction_changes': ['.dev-orchestra/implementer.md']}
指示は、これからのすべての実行に効きます。だから、指示を変える変更は認証や決済のコードと同じく、高リスクとして扱われます。
8. 指示のファイルが無いとき
指示のファイルを消してみると、status は 0 chars: not found と出し、doctor は note を出しました。
Instructions: orchestrator (project, inline, 35 chars); implementer (global, inline, 47 chars); implementer (project, .dev-orchestra/implementer.md, 0 chars: not found); reviewers (project, inline, 61 chars)
- instructions for implementer (project file): .dev-orchestra/implementer.md not found; runs go on without it
実行は止まらず、その指示なしで続きます。ファイルが 32 KB より大きいとき、リンクやジャンクションを通るときも同じ扱いだと、リファレンスにあります(こちらは試していません)。
9. 作業単位向けの設定もいっしょに入った
1.2.1 では、作業単位(1.2.0)向けの設定も 2 つ増えました。
| 設定 | 内容 |
|---|---|
implementation.unit_tests: after_merge | 各作業単位はテストを流さず、すべてをマージしたあとに 1 回だけ流す。テスト用のデータベースやポートを共有しているとき向け |
implementation.worktree_files | git が無視するファイル(config/database.yml、.env.test など)を、作業単位の worktree にコピーする |
unit_tests: after_merge は、作業単位の記事で使いました。worktree_files は今回は試していません。
まとめ
.dev-orchestra.yaml(または global の設定)のinstructionsに、役割ごとの決まった指示を書ける。インラインでも、ファイルでもよい- project ファイルの指示には、
config validate/doctor/review runが注意を 1 行ずつ出す。ブランチと一緒に入ってくることがあるため - 指示は
## Project instructionsの下でプロンプトに入り、CLI の規則や依頼より弱い。orchestrator への指示はstatusに出る - global と project の指示はつながる(ほかの設定のように上書きしない)
- レビュアーへの指示は見るものを足すだけ。指摘を控えさせることはできない
- 指示を変える変更は高リスクとしてレビューされる
- 指示のファイルが無くても、実行は止まらない
次回は、計画を作業単位に分けて、並べて実装します。
GitHub: istb16/dev-orchestra(スターを付けてもらえると励みになります)
この連載の記事は、「dev-orchestra」の一覧でまとめて読めます。
関連記事
dev-orchestra のレビューだけを使って、手元の変更を複数のAIに見せてみた
dev-orchestra の設計・実装の工程は使わず、レビューだけを使う方法を紹介します。review snapshot・review run・review show の 3 つのコマンドで、手元のブランチを Claude と Codex にレビューさせました。--base の選び方、よく使うオプション、記事のレビューに使う例も書きます。
dev-orchestra で、最後に変更全体をもう一度レビューさせてみた
dev-orchestra 1.3.0 で入った「最後に変更全体をレビューする」(review.whole_change_recheck)を、小さな Python のパッケージで試しました。修正だけを見た回が 0 件で終わったあと、全体の回が修正と前の変更の食い違いを 1 件見つけました。わざとぶつかる修正では、修正だけの回が先に見つけました。
dev-orchestra の所要時間と、レビュアーの人数ごとの指摘数を測ってみた
dev-orchestra 1.2.1 で小さな機能追加を1件依頼し、かかった時間(承認待ちを除いて約6分)と、レビュアーを1人・2人・4人にしたときの指摘数と採用数を測りました。人数を増やすと採用できる指摘は増えましたが、増えたのはテストの指摘でした。