agentleFS
oubakiououbakiou/delegate-skills/skills/delegate-chore/SKILL.md

delegate-chore

Skill3 starsChanged 5 months agoMITView on GitHub

token cost の削減を第一目標として、explore / implement / review のどれにも明確に当てはまらない雑務のうち、 対象 content を読んで判断する必要があり、 親エージェントの context を膨らませたくない作業を安価な subagent に委譲するフォールバックスキル。 単一コマンドで処理できる軽微な整形・リネーム・一括置換・定型コマンド実行は原則として main が直接実行し、 この skill は使わない。専用スキルが当てはまる場合はそちらを優先する。 chore の作業を委譲する場合は、この skill を使う。generic な subagent で代替しない。

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    run は内部で prepare → dispatch → read-response を順に実行し、stdout は成功・失敗とも単一 JSON(exit_code / status / content / content_truncated / response_file …

    line 38
  2. Very specific:

    follow-up run: 親の差分確認で不具合が見つかった場合のみ使う。prepare.sh の第 6 引数に followup=<前回observe_file> を渡す。exit 5 は検証失敗なので中止し、通常 delegate として出し直す。暗黙 fallback …

    line 67
  3. Very specific:

    follow-up request には、親が見つけた不具合、最新 git diff の見るべき範囲、前回 response_file の参照を必ず含める。worker の古い会話文脈だけに依存させない。

    line 71

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

delegate-chore

雑務のフォールバック先。task_type=chore、既定モデル haiku(最安)。実行系分岐(Codex / Devin / Cursor / Claude / OpenCode)は dispatch.sh が行う。opencode/<provider>/<model> を使う場合は opencode CLI(ログイン済み)が必要。

スクリプトパス

  • Claude Code: skill_dir=.claude/skills/delegate-chore
  • Codex: skill_dir=.agents/skills/delegate-chore

以降のコマンド例は Claude Code の .claude/skills/delegate-chore を使う。Codex で使う場合は、同じ相対構造の .agents/skills/delegate-chore に読み替える。

モデル価格参照

コスト分析・単価比較が必要な場合のみ、<skill_dir>/model-token-prices.json を読む。このデータは参照用であり、delegate の起動可否判定には使わない。

委譲する前に(コストゲート)

委譲はオーバーヘッド(worker 起動・request/response の往復・main 側の読み取り)を伴う。この chore が単一コマンド(sed / find / chmod 等)でスクリプト化でき、対象内容をモデル context に載せずに済むなら、委譲は純損になりやすい(オーバーヘッドが context 衛生・トークン両面の利得を上回る)。その場合は委譲せず main が直接実行するか、繰り返すなら下記フィードバックループの自動化提案へ回す。委譲が見合うのは、content をモデルが読み込んで処理する必要がある嵩んだ作業。根拠は docs/design/delegate-chore.md §5。

実行フロー(one-shot)

  1. リクエスト作成: Objective / Scope / Context / Acceptance criteria / Verification / Constraints の Markdown を stdin で渡す。request は terse に書く: Context にファイル内容を貼らず、パス(必要なら行範囲)で参照させる(main の出力=課金トークンを増やさないため)。
    • ユーザーが会話でモデルや effort を指定した場合は、run 呼び出しにインライン env を前置する(例: DELEGATE_CHORE_MODEL=gpt-5.5@high bash .../run.sh ...)。exit 6 の場合は、許容値列挙を含む stderr の 1 行をそのままユーザーへの説明に使う。
  2. 実行: out="$(printf '%s' "$req_md" | bash .claude/skills/delegate-chore/scripts/run.sh chore DELEGATE_CHORE_MODEL haiku "$PARENT_TASK_TYPE_CHAIN" "$REQUESTER_SESSION_ID")"(top-level 起動なら $PARENT_TASK_TYPE_CHAIN は空でよい)。
    • run は内部で prepare → dispatch → read-response を順に実行し、stdout は成功・失敗とも単一 JSON(exit_code / status / content / content_truncated / response_file / observe_file / run_dir)を返す。
    • selector 省略時の既定は auto。第 6 位置引数は read-response の selector であり、prepare.sh の第 6 位置引数 session_mode とは意味が異なる。
    • exit code は内部スクリプトを透過する。exit 3=前提不足 / exit 4=委譲サイクルなら中止する。
    • run.sh は dispatch 前に observe_file: <path> を stderr へ先出しする。run.sh が Bash timeout で background へ退避しただけの場合は再実行しない(再実行は worker の二重起動になり、implement / chore では同一 worktree の同時書き換えになる)。復旧は bash .claude/skills/delegate-chore/scripts/read-json.sh .state.phase "$observe_file" を見て分岐する。ended / stalled / interrupted なら終端なので、いずれでも bash .claude/skills/delegate-chore/scripts/read-json.sh .run.response_file "$observe_file" で応答パスを取得して bash .claude/skills/delegate-chore/scripts/read-response.sh で読む(stalled では failed response が書かれる。interrupted は dispatcher が終端を書けずに落ちた run を wrapper が代わりに記録したもので、.state.response_present が true なら完走した response がある)。running の間は .heartbeat.ts が進んでいれば待つ。running のまま .heartbeat.ts が DELEGATE_OBSERVE_HEARTBEAT_INTERVAL(既定 10 秒)を大きく超えて進まない場合は dispatcher が終端を書けずに落ちている。wrapper も同時に落ちていれば phase は終端へ遷移しないので、待っても応答は来ない。新しい run を出す前に順に確認する。(1) read-json.sh .run.response_file "$observe_file" を読む。dispatcher だけが死んだ場合、wrapper が完全な response を書き終えていることがある。(2) response が Child CLI failed or did not write a response. の stub なら、read-json.sh .run.run_dir "$observe_file" の <run_dir>/worker-stdout.capture に子 CLI の生 stream が残っている。wrapper が finalize まで到達していれば observe の .streams.stdout.content にも DELEGATE_OBSERVE_STREAM_MAX_BYTES(既定 65536 バイト)まで入る。構造化された response ではないが、長い run では再実行より安く回収できる。(3) read-json.sh .heartbeat.child_pid "$observe_file" の pid の生存を確認する。wrapper は dispatcher と別プロセスなので孤児化して動き続けることがあり、生きている間に implement / chore で新しい run を出すと同一 worktree の二重書き換えになる。確認後に新しい run を出す。background 退避した出力ファイルは stdout と stderr が合流するが、read-json.sh は既知の harness 行(空行 / observe_file: 行 / [exited with ...] 行)に囲まれた JSON object を切り出して読める。
    • 非対話モードの親(claude -p 等)では run を必ずフォアグラウンドで実行し、委譲所要時間より長い Bash timeout(Claude Code なら BASH_DEFAULT_TIMEOUT_MS / BASH_MAX_TIMEOUT_MS または Bash tool の timeout 引数)を設定する。
  3. レスポンス消費: status="$(printf '%s' "$out" | bash .claude/skills/delegate-chore/scripts/read-json.sh .status)" / content="$(printf '%s' "$out" | bash .claude/skills/delegate-chore/scripts/read-json.sh .content)" を読む。content_truncated が true なら response_file="$(printf '%s' "$out" | bash .claude/skills/delegate-chore/scripts/read-json.sh .response_file)" を取り出し、bash .claude/skills/delegate-chore/scripts/read-response.sh "$response_file" <N> で必要 section だけ段階読みする。読了後、worker の本文を 要約し直さない(echo しない)。status が failed なら Error section をユーザーへ伝える。completed でも Summary 先頭に警告行があればその旨を伝える(警告は response 本体に載るので selector に関わらず Summary とともに返る)。main のユーザー向け応答は Summary を指す 1 行に留める(main の出力=課金トークンを増やさないため。spec.md §6)。

高度なフロー(個別スクリプト)

dispatch 中の observe 監視、background 実行、resumable / follow-up など、途中で親の判断を挟むフローでは従来の個別スクリプトを使う。

  1. 準備(集約): 前提チェック→モデル解決→チェーン確認→リクエスト生成を prepare.sh 1 本に畳む(個別呼び出しの bash 往復と main context への出力を削減)。Objective / Scope / Context / Acceptance criteria / Verification / Constraints の Markdown を stdin で渡す。request は terse に書く: Context にファイル内容を貼らず、パス(必要なら行範囲)で参照させる(main の出力=課金トークンを増やさないため)。exit 3=前提不足 / exit 4=委譲サイクルなら中止。
    • ユーザーが会話でモデルや effort を指定した場合は、prepare 呼び出しにインライン env を前置する(例: DELEGATE_CHORE_MODEL=gpt-5.5@high bash .../prepare.sh ...)。prepare が exit 6 の場合は、許容値列挙を含む stderr の 1 行をそのままユーザーへの説明に使う。
    • out="$(printf '%s' "$req_md" | bash .claude/skills/delegate-chore/scripts/prepare.sh chore DELEGATE_CHORE_MODEL haiku "$PARENT_TASK_TYPE_CHAIN" "$REQUESTER_SESSION_ID")"(top-level 起動なら $PARENT_TASK_TYPE_CHAIN は空でよい)
    • model="$(printf '%s' "$out" | bash .claude/skills/delegate-chore/scripts/read-json.sh .model)" / request_file="$(printf '%s' "$out" | bash .claude/skills/delegate-chore/scripts/read-json.sh .request_file)" / response_file="$(printf '%s' "$out" | bash .claude/skills/delegate-chore/scripts/read-json.sh .response_file)" / run_dir="$(printf '%s' "$out" | bash .claude/skills/delegate-chore/scripts/read-json.sh .run_dir)" / observe_file="$(printf '%s' "$out" | bash .claude/skills/delegate-chore/scripts/read-json.sh .observe_file)"
  2. 実行: bash .claude/skills/delegate-chore/scripts/dispatch.sh "$model" chore "$request_file" "$response_file" "$run_dir" "$observe_file"。モデル名プレフィックスによる実行系分岐(Codex / Devin / Cursor / Claude / OpenCode)は dispatch.sh が行う。stdout は response_file のパスのみ。非対話モードの親(claude -p 等)では dispatch を必ずフォアグラウンドで実行し、委譲所要時間より長い Bash timeout(Claude Code なら BASH_DEFAULT_TIMEOUT_MS / BASH_MAX_TIMEOUT_MS または Bash tool の timeout 引数)を設定する。実行中の通常監視は observe_file から state.phase / state.started_at / heartbeat.ts / heartbeat.stdout_bytes / heartbeat.stderr_bytes / heartbeat.last_stream_change_at だけを read-json.sh で読む。state.phase は prepared | running | superseded | stalled | interrupted | ended。prepared / superseded は dispatch されなかった observe(state.started_at == null、usage は未設定で read-json.sh では null 相当)なので、usage を集計する場合は分母から除外する。
  3. レスポンス読み取り: bash .claude/skills/delegate-chore/scripts/read-response.sh "$response_file" auto。auto は response が小さい(既定 10KB 未満)なら status と全 section を 1 回で丸読みし、大きい場合は status + index + Summary section を返すので、必要 section だけ ... "$response_file" <N> で追加取得する。読了後、worker の本文を 要約し直さない(echo しない)。status が failed なら Error section をユーザーへ伝える。completed でも Summary 先頭に警告行があればその旨を伝える(警告は response 本体に載るので selector に関わらず Summary とともに返る)。main のユーザー向け応答は Summary を指す 1 行に留める(main の出力=課金トークンを増やさないため。spec.md §6)。

セッション再利用(resumable / follow-up)

resumable / follow-up は one-shot 対象外のため、個別スクリプトを使う。

既定は通常 run。大きめの横断修正など、親レビューで差し戻す可能性が高い場合だけ初回から resumable initial run を明示する。過剰使用しない。Claude / Codex / Devin / Cursor / OpenCode が resumable / follow-up に対応する。

  • resumable initial run: prepare.sh の第 6 引数に resumable を渡す。dispatch は第 7 引数に resumable、第 8・9 引数に空文字を渡す。
    • out="$(printf '%s' "$req_md" | bash .claude/skills/delegate-chore/scripts/prepare.sh chore DELEGATE_CHORE_MODEL haiku "$PARENT_TASK_TYPE_CHAIN" "$REQUESTER_SESSION_ID" resumable)"
    • session_mode="$(printf '%s' "$out" | bash .claude/skills/delegate-chore/scripts/read-json.sh .session_mode)" / lineage_id="$(printf '%s' "$out" | bash .claude/skills/delegate-chore/scripts/read-json.sh .lineage_id)"
    • bash .claude/skills/delegate-chore/scripts/dispatch.sh "$model" chore "$request_file" "$response_file" "$run_dir" "$observe_file" "$session_mode" "" ""
    • response 読了後に bash .claude/skills/delegate-chore/scripts/read-json.sh .backend_session.persistence "$observe_file" を確認する。resumable 以外なら follow-up 不可としてその場で判断し、後から暗黙 fallback を期待しない。
  • follow-up run: 親の差分確認で不具合が見つかった場合のみ使う。prepare.sh の第 6 引数に followup=<前回observe_file> を渡す。exit 5 は検証失敗なので中止し、通常 delegate として出し直す。暗黙 fallback しない。
    • out="$(printf '%s' "$req_md" | bash .claude/skills/delegate-chore/scripts/prepare.sh chore DELEGATE_CHORE_MODEL haiku "$PARENT_TASK_TYPE_CHAIN" "$REQUESTER_SESSION_ID" "followup=$previous_observe_file")"
    • session_mode="$(printf '%s' "$out" | bash .claude/skills/delegate-chore/scripts/read-json.sh .session_mode)" / resume_id="$(printf '%s' "$out" | bash .claude/skills/delegate-chore/scripts/read-json.sh .resume_id)" / backend_session_home="$(printf '%s' "$out" | bash .claude/skills/delegate-chore/scripts/read-json.sh .backend_session_home)"
    • bash .claude/skills/delegate-chore/scripts/dispatch.sh "$model" chore "$request_file" "$response_file" "$run_dir" "$observe_file" "$session_mode" "$resume_id" "$backend_session_home"
    • follow-up request には、親が見つけた不具合、最新 git diff の見るべき範囲、前回 response_file の参照を必ず含める。worker の古い会話文脈だけに依存させない。

skill 昇格提案(フィードバックループ)

delegate-chore に流れるタスクは「専用 skill が無い作業」のシグナル。レスポンス消費後、その作業が

  • 繰り返し現れる / 明確にスコープされた再利用可能なカテゴリ

であれば、専用 delegate-<name> skill の新規作成を AskUserQuestion でユーザーに提案する(想定名 / 既定モデル / ツール権限 / 起動種別を添える)。合意後は skill-creator で雛形を作り本プロトコルに沿わせる。一度きりの些末な chore では提案しない。

決定論的プロセスの自動化提案

skill 昇格提案と同じ精神で、同じ多段コマンド列・検証手順・定型編集が繰り返し現れ、かつ分岐が固定的で LLM の判断を要さないと気づいたら、AskUserQuestion でスクリプト化 / git hook / npm script / CI など適切な自動化手段を提案する(対象手順 / 自動化先 / 想定トリガを添える)。一度きりの手順や判断が絡む手順は提案しない。

待ち時間の隠蔽(対話親向け)

対話親では体感待ち時間を隠蔽できる。経路は起動スクリプトで異なる。dispatch.sh 経由は prepare.sh で response_file を事前取得済みなので、dispatch.sh を background で実行し、observe_file の state.phase / heartbeat を確認して ended / stalled / interrupted になった後に read-response.sh する。run.sh 経由は response_file を事前に取得できないので、run.sh を background で実行した場合は read-json.sh .run.response_file "$observe_file" で応答パスを取るか、合流した出力 JSON をそのまま read-json.sh で読む。総所要時間(wall time)は変わらない体感改善であり、非対話モードの親では従来どおりフォアグラウンド実行必須。

制約

  • 編集は可。ただし push はしない(push・PR は親エージェントが直接扱う)
  • task_type_chain 内種別への再委譲はしない(別種別 delegate は可)
  • main は worker 出力を echo / 再要約しない。ユーザー向けは Summary を指す 1 行に留める(出力=課金トークンを増やさないため。spec.md §6)
  • OpenCode: cwd 外への出力は保証されない(direct な edit / write と明示パスの読み取りは拒否され、bash のリダイレクトは通る)。request が DELEGATE_REQUEST_INLINE_MAX を超えると child 起動前に fail-closed する
  • OpenCode の read-only 抑止は管理者設定のない環境を前提とする(管理者設定は注入した permission を override し得る)
  • この種別は project plugin を継承する。DELEGATE_OPENCODE_PURE が 1 / true / yes なら --pure を付けて無効化する(read-only 種別と htmldoc は既定で --pure)。DELEGATE_OPENCODE_MCP_SOURCE(claude / cursor / codex)で MCP 入力元を明示し、未指定なら注入しない

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.