原典: A harness for every task: dynamic workflows in Claude Code

一行要約

Claude Code にタスク専用の harness をその場で書かせる機能(dynamic workflows)であり、狙いは長時間の単一 context で必ず出る3つの失敗モード — agentic laziness / self-preferential bias / goal drift — を構造で潰すこと。

要点

何をするものか

dynamic workflow は、subagent を spawn して協調させる専用関数を持つ JavaScript を Claude 自身が書いて実行する仕組み。Claude Code の上に、そのタスク専用の harness を動的に構築する。

Workflows allow you to dynamically create harnesses built on top of Claude Code that enable Claude to solve all of those problems more natively.

workflow を使えば、Claude Code の上に harness を動的に構築し、こうした問題を Claude がより自然に解けるようにできる。

Research、セキュリティ解析、agent teams、Code Review といった機能が解いていた問題を、より native に解けるようにする位置づけ。

動機 — 単一 context の3つの失敗モード

この3つの名前が、この記事の最も持ち帰る価値のある部分。

失敗モード原典の定義
agentic laziness複雑な多要素タスクで、部分的な進捗の段階で終わったと宣言して止まってしまう
self-preferential bias特に rubric に照らして検証・判定を求められたとき、自分自身の結果や発見を好む傾向
goal drift多数のターンをまたぐうちに元の目的への忠実さが徐々に失われる。特に compaction の後

いずれも「1つの context で長く走らせる」ことに内在する問題であり、別 context の subagent に検証させる構造で緩和できる。

dynamic vs static

static workflowdynamic workflow
設計汎用的。あらゆる edge case を想定して作られるタスク固有。その場の問題に合わせて書かれる

静的なワークフローは汎用性のために冗長になる。動的なワークフローはその場のタスクにだけ最適化できる。

有用なパターン

原典が名前を付けて挙げているパターン。

パターン使いどころ
Classify-and-actまず分類し、種別ごとに処理を分ける
Fan-out-and-synthesize並列に広げて、最後に統合する
Adversarial verification別のエージェントに敵対的に検証させる(self-preferential bias 対策)
Generate-and-filter大量に生成してから絞る
Tournament候補同士を勝ち抜き戦で比較する
Loop until done条件を満たすまで回し続ける(agentic laziness 対策)

使いどころ

移行・リファクタ、深いリサーチ、深い検証、並べ替え、記憶とルール遵守、根本原因の調査、大規模なトリアージ、探索と好みの判断、evals、モデル/知能のルーティング。

使わないほうがよいとき

Keep in mind, best practices are still developing: dynamic workflows often use more tokens and are best suited for complex, high value tasks.

留意すべきこととして、ベストプラクティスはまだ発展途上である。dynamic workflow はトークンを多く使うことが多く、複雑で価値の高いタスクに最も向いている。

Workflows are new. While there are many use cases where it will create outsized results, they are not needed for every task and may end up using significantly more tokens.

workflow は新しい。並外れた結果を生む用途は多くあるが、あらゆるタスクに必要なわけではなく、結果として大幅に多くのトークンを使うことがある。

判断の基準は「本当に計算量が要るか」。

For regular coding tasks, try and ask yourself: does it really need more compute? For example, most traditional coding tasks do not need a panel of 5 reviewers.

通常のコーディングタスクでは、自分にこう問うてみよ。本当にもっと計算量が要るのか? たとえば、従来型のコーディングタスクのほとんどは5人のレビュアーの合議を必要としない。

原典はこれを1段上の設計判断と同じものだと言う。

The same judgment applies one level up, at the architecture layer: the multi-agent vs single agent decision follows similar logic — parallelism and specialization have to earn their coordination cost.

同じ判断が1段上、アーキテクチャの層にも当てはまる。multi-agent か single agent かの決定も同じ論理に従う —— 並列性と専門化は、その協調コストに見合うだけのものを稼がなければならない。

ただし大きなタスク専用というわけではない。

Workflows are not just for large tasks. You can prompt the model to use a “quick workflow.” For example, you can create a quick adversarial review of an assumption.

workflow は大きなタスク専用ではない。「quick workflow」を使うようモデルに促すこともできる。たとえば、ある前提に対する手早い敵対的レビューを作れる。

実務上の tips

  • prompting: やってほしい構造を言葉で指定する(「対立する仮説を立てろ」「1つの仮説が証拠に耐えるまで止まるな」など)
  • /goal と /loop と組み合わせる
  • トークン予算を指定できる — use 10k tokens のように書く
  • 保存と共有 — workflow メニューで s を押すと保存できる。~/.claude/workflows に チェックインするか、skill として配る。skill で配るときは JavaScript の workflow ファイルを skill のフォルダに入れて SKILL.MD から参照する。そのまま実行するスクリプトではなく雛形として 扱うよう Claude に促すと融通が利く
  • 中断と再開ができる — 止めたところから続けられる
  • subagent は隔離された worktree で走らせられ、知能レベル(モデル)を選べる

そのまま使える具体例

原典が挙げているプロンプト例(そのまま打てる形):

This test fails maybe 1 in 50 runs. Set up a workflow to reproduce it. Form competing
theories about the race, and don't stop until one theory survives the evidence.
Using a workflow, go through my last 50 sessions and mine them for corrections I keep
making and turn the recurring ones into `CLAUDE.md` rules
Use a workflow to dig through #incidents in Slack for the past six months and find
recurring root causes where nobody has filed a ticket.
Take my business plan and run a workflow where different agents tear it apart from an
investor's, a customer's, and a competitor's perspective.
Here's a folder of 80 resumes, use a workflow to rank them for the backend role and
double-check the top ten. Interview me using the AskUserQuestion tool for a rubric.
I need a name for this CLI tool. Use a workflow to brainstorm a bunch of options and run
a tournament to pick the top 3.
Use a workflow to rename our User model to Account everywhere.
Go through my blog post draft and verify every technical claim against the codebase
using a workflow, I don't want to ship anything wrong.

トークン予算を切る:

use 10k tokens

保存場所と呼び出し:

項目意味
~/.claude/workflows保存先
sworkflow メニューで押すと保存できるキー
ultracodeワークフローを起こすトリガー語

原典で言及されている関連文書