Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: 293
goal_ref: "claude/AI 運用の usage コスト削減"
change_kind: workflow
closure_mode: pr-mergedParent Issue
Parent Goal Ref
- Goal: issue-refinement-loop 軽量化・deterministic reviewer Haiku 化・OUTPUT_BUDGET_V1 全 SubAgent 導入・巨大 SKILL.md 分割の 4 施策を実装し、claude/AI 運用コストを削減する
- Desired Destination: 施策 A〜D が
.claude/配下に反映され、2026-05-23 時点の usage ホットスポット(skill 28% 相当)が削減されている
Preconditions
事実確認済み(2026-05-24 anchor comment fact-check)。実装はこれらを前提として書き直す。
- perf(claude): deterministic reviewer SubAgent を Haiku / script-first 化する #294 / PR perf(claude): deterministic reviewer SubAgent を Haiku / script-first 化する #304 merged (2026-05-23):
issue-reviewerHaiku 化 +pr-reviewer-litebaseline 完了。Step 2 は既にissue-reviewerSubAgent (Haiku) 経由になっており、review-issueSkill を直接呼ぶ経路は存在しない。 - perf(claude): 全 SubAgent に OUTPUT_BUDGET_V1 出力制約を導入する #296 / PR perf(claude): 全 SubAgent に OUTPUT_BUDGET_V1 出力制約を導入する #310 merged (2026-05-23): 全 SubAgent に
OUTPUT_BUDGET_V1baseline 導入済み。本 Issue で同制約を破る変更を入れない。 - 実装: gemini-cli-headless-delegation SKILL.md を thin routing entrypoint に再設計する #264 / PR refactor(#264): gemini-cli-headless-delegation SKILL.md を thin routing entrypoint に再設計する #311 merged (2026-05-23):
gemini-cli-headless-delegationに thin entrypoint +references/分割パターンが確立。同パターンを D (perf(claude): AI 運用コスト削減施策 — refinement-loop 軽量化 / Haiku 化 / output budget / SKILL.md 分割 #293 の SKILL.md 分割) と本 Issue 設計の参考にする。 - 設計変更: issue-refinement-loop に Product/Spec Kit routing gate のみ追加し、成果物 preflight は review / contract / impl / speckit adapter に分割する #332 / PR feat(#332): issue-refinement-loop に Product/Spec Kit routing gate を追加する #336 merged (2026-05-23): 同じ
issue-refinement-loop/SKILL.mdに Step 0d (plan_issue_scope_rollup.pypreflight) と Step 0e (Product/Spec Kit routing gate) が追加済み。実装 PR は最新 main から rebase 必須。 - 改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 OPEN: 同 SKILL.md の Step 1b に
auth_error1回 retry を入れる予定。本 Issue は Step 1b のfailure_class/verification_route/ retry 拡張点を破壊してはならない。 - 現行 main の
.claude/skills/issue-refinement-loop/SKILL.mdは 1226 lines / 65.3 KB (2026-05-24 計測)。本 Issue は SKILL.md の純増を許容しない(policy 化で行数中立または減少を目指す)。
Current Validated Scope
本 Issue で .claude/skills/issue-refinement-loop/SKILL.md に加える write-capable な変更 (anchor comment fact-check 後の確定スコープ):
max_iterations既定値を3→1に変更(Inputs 説明 / LOOP_STATE 例の両方、残骸ゼロ)LOOP_STATEにinvestigation_policyYAML state を追加(codebase_required/codebase_reason/target_paths/repo_claims/skip_reason)LOOP_STATEにweb_research_policyYAML state を追加(required/reason/critical_external_claims/skip_reason)— 既存web_researchstate のfailure_class/verification_routeを破壊しない形で並置codebase-investigator起動条件をinvestigation_policy.codebase_required == trueに集約web-researcher起動条件をweb_research_policy.required == trueに集約NEEDS_SECOND_PASSquality escape hatch を Step 2 終端処理に追加(termination_reason: needs_second_pass)- 各 skip 判断を
LOOP_STATE.<policy>.skip_reasonに必ず記録
Remaining Parent Gaps
Parent #293 のうち、本 Issue で塞がない / 既に塞がれた gap:
- B: deterministic reviewer Haiku / script-first 化 — perf(claude): deterministic reviewer SubAgent を Haiku / script-first 化する #294 / PR perf(claude): deterministic reviewer SubAgent を Haiku / script-first 化する #304 で完了 (2026-05-23 merged)
- C: 全 SubAgent
OUTPUT_BUDGET_V1出力制約導入 — perf(claude): 全 SubAgent に OUTPUT_BUDGET_V1 出力制約を導入する #296 / PR perf(claude): 全 SubAgent に OUTPUT_BUDGET_V1 出力制約を導入する #310 で完了 (2026-05-23 merged) - D 関連:
gemini-cli-headless-delegationthin entrypoint 化 — 実装: gemini-cli-headless-delegation SKILL.md を thin routing entrypoint に再設計する #264 / PR refactor(#264): gemini-cli-headless-delegation SKILL.md を thin routing entrypoint に再設計する #311 で完了 (2026-05-23 merged) - D (本丸):
issue-refinement-loop/SKILL.md自体の thin entrypoint +references/構造分割 — 本 Issue では実施しない(perf(claude): AI 運用コスト削減施策 — refinement-loop 軽量化 / Haiku 化 / output budget / SKILL.md 分割 #293 の D アイテムとして別 Issue で扱う) - Step 0d / Step 0e 固定コスト最適化: 観測のみ実施し、結果が dominate するなら follow-up Issue を起票(本 Issue Out of Scope)
- 改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 Step 1b
auth_errorretry 機構の実装: 別 Issue として並行進行。本 Issue は拡張点を保持するのみ
Outcome
.claude/skills/issue-refinement-loop/SKILL.md で以下が成立している:
max_iterationsの既定値が1になっている。ただしNEEDS_SECOND_PASSquality escape hatch が用意され、blocking ambiguity を黙って 1周で打ち切らない。codebase-investigatorおよびweb-researcherはLOOP_STATE上のinvestigation_policy/web_research_policy(YAML state)に基づいて条件付き起動される。prose 条件ではなく機械可読な state として表現される。web_research_policyは 改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 が予定するauth_errorretry 拡張点(failure_class/verification_route/ retry_count)を破壊しない。- 各 skip 判断は
skip_reasonとして LOOP_STATE に記録される("no_repo_fact_claim" / "no_critical_external_claim" 等)。 - 実装 PR 本文に structural baseline(SKILL.md 行数 / bytes / LOOP_STATE schema delta / trigger 表現方式 before→after /
termination_reasonenum delta)が記録されている。runtime/usage計測(代表 Issue 3 件の token stats / agent_spawn_count / iteration_count / skip_reason の before/after)は perf(claude): #295 軽量化後の runtime /usage 計測(3 代表 Issue) #389(follow-up) に分離。
Background
2026-05-23 の /usage 統計で issue-refinement-loop が skill 16% + SubAgent 12% のホットスポットと判明。通常の小規模 Issue 修正でも「調査 → レビュー → 編集 → 再レビュー」の多段 SubAgent ループになりやすい構造が原因。Issue #293 の施策 A として対応する。
anchor comment fact-check 知見 (2026-05-24): 単に SubAgent を条件付きにしても、Skills は SKILL.md 本文がスキル使用時に読み込まれる設計(Claude Code docs で確認)であり、1226 行の SKILL.md 自体が固定コストになる。したがって本 Issue は「prose 追加で軽量化」ではなく「LOOP_STATE 上の policy state + skip_reason 化」によって、行数を増やさずに分岐を機械的に表現する方針を採る。Step 0d / Step 0e の固定コスト最適化は本 Issue では扱わず、観測コストを記録した上で必要なら follow-up で別 Issue 化する。
In Scope
.claude/skills/issue-refinement-loop/SKILL.md—max_iterations既定値を3→1に変更(Inputs / LOOP_STATE 両方)。max_iterations: 3の残骸を残さない。LOOP_STATEにinvestigation_policyを追加(機械可読 state):investigation_policy: codebase_required: false codebase_reason: none | requires_fact_check | target_paths | repo_claim_detected | related_issue_conflict | reviewer_request target_paths: [] repo_claims: [] skip_reason: null
LOOP_STATEにweb_research_policyを追加(改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 の retry 拡張点を保持):web_research_policy: required: false reason: none | critical_external_spec_claim critical_external_claims: - claim: "" affects: Outcome | InScope | AC | VC | StopCondition source_hint: "" skip_reason: null
codebase-investigator起動条件をinvestigation_policy.codebase_required == trueに集約。下記のいずれかが true のとき required=true にする:anchor_comment.requires_fact_check == truetarget_pathsが non-empty- Outcome / AC / VC に具体的 repo path / コマンド / script / agent / skill / schema / workflow 名が含まれる
- scope rollup preflight が same-file / same-skill-family 衝突を検出
- reviewer が repo-fact 検証を要求
web-researcher起動条件をweb_research_policy.required == trueに集約。critical_external_claimsが非空のときのみ required=true。max_iterations=1の品質エスケープハッチNEEDS_SECOND_PASSを Step 2 出力に追加:- 1 周後に blocking ambiguity が残るとき、自動で次周を回さず
NEEDS_SECOND_PASSを emit する termination_reason: needs_second_passで停止し、user 明示のmax_iterations > 1または human decision を要求する
- 1 周後に blocking ambiguity が残るとき、自動で次周を回さず
- 各 step の skip 判断を
LOOP_STATE.<policy>.skip_reasonに必ず記録(no_repo_fact_claim/no_critical_external_claim/iteration_limit_reached等)。 - 計測アーティファクト要件(structural baseline のみ): 実装 PR 本文に SKILL.md 行数 / bytes、LOOP_STATE schema delta(追加 fields)、trigger 表現方式(prose → YAML state)、
termination_reasonenum delta、max_iterations既定値 delta を記録する。runtime/usage計測は perf(claude): #295 軽量化後の runtime /usage 計測(3 代表 Issue) #389(follow-up) に分離する。
Out of Scope
issue-reviewer.mdの model 変更(施策 B / perf(claude): deterministic reviewer SubAgent を Haiku / script-first 化する #294 で完了済み)- OUTPUT_BUDGET_V1 の導入(施策 C / perf(claude): 全 SubAgent に OUTPUT_BUDGET_V1 出力制約を導入する #296 で完了済み)
- SKILL.md の thin entrypoint +
references/構造分割(施策 D / perf(claude): AI 運用コスト削減施策 — refinement-loop 軽量化 / Haiku 化 / output budget / SKILL.md 分割 #293 の D アイテムで別 Issue。本 Issue では実施しない) - Step 0d (
plan_issue_scope_rollup.pypreflight) の固定コスト最適化: 観測コストを PR 本文に記録するに留め、本 Issue では最適化しない。観測結果が dominate するなら follow-up Issue を起票する。 - Step 0e (Product/Spec Kit Signal Detection / Routing Gate) の固定コスト最適化: 同上。
- 改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 が予定する Step 1b
auth_errorretry の実装そのもの(本 Issue は拡張点を破壊しないことのみ保証) - ゲーム本体への変更
Acceptance Criteria
- AC1:
.claude/skills/issue-refinement-loop/SKILL.mdのmax_iterations既定値記述が1になっており、max_iterations: 3の残骸が存在しない(Inputs 説明・LOOP_STATE 例の両方)。 - AC2:
LOOP_STATEにinvestigation_policy(codebase_required / codebase_reason / target_paths / repo_claims / skip_reason) が機械可読 YAML として定義されており、codebase-investigator起動条件がinvestigation_policy.codebase_required == trueに集約されている。 - AC3:
LOOP_STATEにweb_research_policy(required / reason / critical_external_claims / skip_reason) が機械可読 YAML として定義されており、web-researcher起動条件がweb_research_policy.required == trueに集約されている。 - AC4: 既存の Step 1b
web_researchstate(status/failure_class/verification_route/result)が削除されていない。改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 の retry 拡張点が保持されている。 - AC5:
NEEDS_SECOND_PASSquality escape hatch が定義されており、max_iterations=1で blocking ambiguity が残ったときtermination_reason: needs_second_passで停止する記述が存在する。 - AC6: 実装 PR 本文に structural baseline(SKILL.md 行数 / bytes、LOOP_STATE schema delta、trigger 表現方式 before→after、
termination_reasonenum delta、max_iterations既定値 delta)が表形式で記録されている。runtime/usage計測は perf(claude): #295 軽量化後の runtime /usage 計測(3 代表 Issue) #389 に分離(本 AC では問わない)。 - AC7:
issue-refinement-loop/SKILL.mdの行数が 1226 行(実装前 baseline)を超えない。超える場合は PR 本文に理由を明記する。 - AC8:
pnpm typecheck && pnpm lint && pnpm test && pnpm buildがすべて PASS する。 - AC9: 既存の SKILL.md 末尾 Verification Commands(B1〜AC7 系の rg / awk チェック)がすべて引き続き PASS する。
Verification Commands
# AC1: max_iterations: 3 の残骸が無い
$ rg -n "max_iterations:?\s*3" .claude/skills/issue-refinement-loop/SKILL.md && echo FAIL || echo PASS # AC1
# AC1: 既定値 1 への変更が明記
$ rg -n "max_iterations.*1|デフォルト\s*1" .claude/skills/issue-refinement-loop/SKILL.md # AC1
# AC2: investigation_policy state が定義されている
$ rg -n "investigation_policy" .claude/skills/issue-refinement-loop/SKILL.md # AC2
$ rg -n "codebase_required|skip_reason" .claude/skills/issue-refinement-loop/SKILL.md # AC2
# AC3: web_research_policy state が定義されている
$ rg -n "web_research_policy" .claude/skills/issue-refinement-loop/SKILL.md # AC3
$ rg -n "critical_external_claims" .claude/skills/issue-refinement-loop/SKILL.md # AC3
# AC4: #203 retry 拡張点 (failure_class / verification_route) が保持されている
$ rg -n "failure_class|verification_route" .claude/skills/issue-refinement-loop/SKILL.md # AC4
# AC5: NEEDS_SECOND_PASS escape hatch 定義
$ rg -n "NEEDS_SECOND_PASS|needs_second_pass" .claude/skills/issue-refinement-loop/SKILL.md # AC5
# AC6: 実装 PR 本文の structural baseline 記録は PR 本文 review 時に確認する (refinement では非実行)
# AC6: 確認手順 — gh pr view <N> --json body --jq .body | rg "行数|bytes|LOOP_STATE schema delta|termination_reason" # AC6
# AC6 runtime 計測は #389 で実施する(本 Issue の AC では問わない)
# AC7: SKILL.md 行数中立性 (1226 を超えない)
$ test "$(wc -l < .claude/skills/issue-refinement-loop/SKILL.md)" -le 1226 && echo PASS || echo FAIL # AC7
# AC8: 既定品質ゲート
$ pnpm typecheck && pnpm lint && pnpm test && pnpm build # AC8
# AC9: 既存 SKILL.md 末尾 VC (B1~AC7 系) が引き続き PASS する
$ bash -c "$(awk '/^## Verification Commands/,/^## Delivery Rule/' .claude/skills/issue-refinement-loop/SKILL.md | sed -n '/^```bash/,/^```/p' | sed '/^```/d')" # AC9Allowed Paths
.claude/skills/issue-refinement-loop/(SKILL.mdの policy state 化、関連 references/ 追加可)docs/dev/agent-skill-boundaries.md(optional: investigation_policy / web_research_policy の概念追記が必要な場合)
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- 既存 LOOP_STATE フィールド (
anchor_comment/web_research/product_spec_context/scope_rollup_decision等) のキー集合・スキーマ変更が必要になった場合 → 別 Issue - 改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 が予定する Step 1b
auth_errorretry 拡張点(failure_class/verification_route/ retry 構造)を破壊する変更が必要になった場合 → 別 Issue + 改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 と統合検討 - PR feat(#332): issue-refinement-loop に Product/Spec Kit routing gate を追加する #336 が変更した Step 0d / 0e に手を入れる必要が出た場合 → 別 Issue(本 Issue の Out of Scope)
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- SKILL.md の変更により既存 VC(SKILL.md 末尾 B1〜AC7 系チェック)が FAIL する場合
max_iterations=1化が既存の他 Issue 改善フローを大規模に壊すと観測された場合(measurement AC で検知)- SKILL.md 行数が 1226 を超え、かつ正当化困難な場合
Runtime Verification Applicability
decision: not_applicable
reason: .claude/ 配下の workflow 設定変更のみ。ゲームの runtime 動作に影響しない。/usage 計測は AI 運用観測であり、ゲーム runtime ではない。
Required Skills
- なし(本 Issue は SKILL.md の policy 書き換え + structural baseline 記録のみ)。
- runtime
/usage計測 +issue-refinement-loop実走に必要な skill は perf(claude): #295 軽量化後の runtime /usage 計測(3 代表 Issue) #389(follow-up) で要求する。
Delivery Rule
1 Issue = 1 PR- Draft PR 既定
- rebase 要件: PR feat(#332): issue-refinement-loop に Product/Spec Kit routing gate を追加する #336 が同じ
SKILL.mdを 2026-05-23 に変更しているため、実装 PR は必ず最新 main から rebase して開始する。 - 改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 との順序: 改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 が先に merge された場合、本 PR は 改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 の
web_research.retry_count/auth_error1回 retry の構造を保持してweb_research_policyを追加する。本 Issue が先に merge された場合、改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 側でweb_research_policyを踏まえて retry 構造を組み込む(本 Issue 側で拡張点を残しておく)。
Related
- Parent: perf(claude): AI 運用コスト削減施策 — refinement-loop 軽量化 / Haiku 化 / output budget / SKILL.md 分割 #293
- Sibling implementations (merged baseline):
- perf(claude): deterministic reviewer SubAgent を Haiku / script-first 化する #294 / PR perf(claude): deterministic reviewer SubAgent を Haiku / script-first 化する #304 (Haiku reviewer baseline)
- perf(claude): 全 SubAgent に OUTPUT_BUDGET_V1 出力制約を導入する #296 / PR perf(claude): 全 SubAgent に OUTPUT_BUDGET_V1 出力制約を導入する #310 (OUTPUT_BUDGET_V1 baseline)
- 実装: gemini-cli-headless-delegation SKILL.md を thin routing entrypoint に再設計する #264 / PR refactor(#264): gemini-cli-headless-delegation SKILL.md を thin routing entrypoint に再設計する #311 (thin entrypoint pattern)
- Same-file dependency (OPEN):
- 改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 (Step 1b
auth_errorretry — 拡張点保持必須)
- 改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 (Step 1b
- Same-file recently merged (rebase target):
- Sibling Issues touching same skill family:
- 実装: issue-refinement-loop の Scope 変更シグナル検出に anchor-comment 由来 reframe の除外規定を追加する #220, 実装: issue-refinement-loop が anchor_comment_url 未指定時に trusted author コメントを自動検出して Step 0a/0b を起動する #228 (anchor_comment 関連)
- docs(issue-refinement-loop): superseded_by_decision / max_iterations 終了時の派生改善候補追跡手順を明確化する #300 (superseded_by_decision / max_iterations 終端)
- Follow-up (runtime 計測):
- perf(claude): #295 軽量化後の runtime /usage 計測(3 代表 Issue) #389 (本 Issue AC6 から分離された runtime
/usage3 代表 Issue 計測)
- perf(claude): #295 軽量化後の runtime /usage 計測(3 代表 Issue) #389 (本 Issue AC6 から分離された runtime
Source
- parent_issue: perf(claude): AI 運用コスト削減施策 — refinement-loop 軽量化 / Haiku 化 / output budget / SKILL.md 分割 #293
- dedupe_key:
perf-claude-issue-refinement-loop-lite-2026-05-23 - chatgpt_analysis: perf(claude): AI 運用コスト削減施策 — refinement-loop 軽量化 / Haiku 化 / output budget / SKILL.md 分割 #293 (comment)
- human_decision: perf(claude): AI 運用コスト削減施策 — refinement-loop 軽量化 / Haiku 化 / output budget / SKILL.md 分割 #293 (comment)
- adversarial_review (REQUEST_CHANGES → 本文反映): perf(claude): issue-refinement-loop を軽量化する(max_iterations=1 デフォルト / SubAgent 条件付き) #295 (comment)
- fact_check_baseline: 2026-05-24 (codebase-investigator + web-researcher 両方で 11 critical repo/PR claims + 4 web claims を supported 判定)
- pr_review_amendment (REQUEST_CHANGES → AC6 scope 分離 + perf(claude): #295 軽量化後の runtime /usage 計測(3 代表 Issue) #389 起票): 2026-05-25, PR perf(#295): issue-refinement-loop の SubAgent spawn 上限を軽量化 — max_iterations=1 + policy state 化 #388 review
Activity
feat(#332): issue-refinement-loop に Product/Spec Kit routing gate を追加…
squne121 commentedon May 24, 2026
判定
REQUEST_CHANGES / No-Go as-is。
Issue #295 の狙い自体は妥当です。
issue-refinement-loopの既定max_iterations=3と常時的な SubAgent 起動が usage コストの温床になっている、という問題設定は Parent #293 と一致しています。ただし、Issue 本文が現行 main と関連 Issue/PR の進捗に追随しておらず、このまま実装すると「コスト削減したつもりで別の固定コストを残す」「同一ファイル競合で #203/#332 系の変更を壊す」「計測不能な soft constraint だけが増える」リスクが高いです。([GitHub]1)関連 Issue / PR の現状整理
#295 は Parent #293 の A:
issue-refinement-loop軽量化に対応しています。一方で Parent #293 の B/C/D は、すでに #294 → PR #304、#296 → PR #310、#264 → PR #311 で大きく進んでいます。したがって #295 本文の「Remaining Parent Gaps: B/C/D 未起票」系の記述は stale です。レビュー対象としては、まず #295 の contract/comment を現行状態へ更新すべきです。([GitHub]2)現行 main の
.claude/skills/issue-refinement-loop/SKILL.mdは 1226 lines / 65.3 KB とかなり大きく、max_iterationsの既定値もまだ3です。また、Step 0d にplan_issue_scope_rollup.pyを使う scope rollup preflight、Step 0e に Product/Spec Kit routing gate が追加済みです。#295 が Step 1/1b だけを軽量化しても、固定コストの入口が Step 0d/0e と巨大 SKILL.md 側に残ります。([GitHub]3)Blocker 1: 「SubAgent 条件付き」だけではコスト削減の実効性を証明できない
Claude Code の Skills は、
SKILL.mdの本文がスキル使用時にロードされる設計です。つまり、issue-refinement-loop自体が 1226 行級である限り、SubAgent を減らしてもスキル起動時の固定コンテキストコストは残ります。Claude 公式 docs でも、Skills は必要時に本文をロードする一方、Subagents は別 context で動き、preloaded skills や CLAUDE.md などが context に入ると説明されています。([Claude Code]4)したがって #295 の AC は不足しています。
max_iterations=1とcodebase-investigator/web-researcher条件付きだけではなく、最低限次を AC に入れるべきです。Claude docs 上も、
/usageは session token stats の確認に使える一方、ドル額はローカル見積もりであり請求の source of truth ではありません。PR #310 でも soft constraint だけでは削減効果が未証明で、フォローアップ計測が必要と整理されています。#295 は同じ失敗を繰り返すべきではありません。([Claude Code]5)Blocker 2:
codebase-investigatorの条件が狭すぎる#295 の案では、
codebase-investigatorをrequires_fact_check == trueまたはtarget_paths明示時に限定しています。この方向性は正しいですが、条件が粗いです。Issue refinement では、ユーザーがtarget_pathsを明示していなくても、Outcome / AC / VC に具体的なファイル名、コマンド、既存挙動、関連 Issue/PR の claims が入ることがあります。そこで repo fact check を完全にスキップすると、もっとも危険な「もっともらしいが未検証の AC/VC」を生成する可能性があります。([GitHub]1)修正案は、「SubAgent を常時起動しない」ではなく、軽量な deterministic preflight → 必要時だけ SubAgent です。
トリガーは次のように切るのがよいです。
逆に、単純な文面整理・scope 明確化・ユーザー意図の構造化だけなら
codebase-investigatorは skip でよいです。公式 docs でも、Subagents は独立した重い調査や verbose output に向き、短い targeted work は main context 側が適するとされています。([Claude Code]6)Blocker 3:
web-researcher条件は #203 と衝突しやすい#295 の
web-researcher条件、「Outcome/AC/VC に影響する外部仕様 claim がある場合のみ」は妥当です。ただし、現行 main には Step 1b があり、#203 は同じ Step 1b にauth_error1回 retry を入れる open Issue です。#295 が先に Step 1b を書き換えると、#203 の retry 設計と競合する可能性があります。([GitHub]7)#295 側の contract に、次の依存関係を明記すべきです。
外部仕様 claim の分類も必要です。
これにより、「外部サービス名が本文にあるだけ」で web-researcher が起動する状態を避けられます。
Blocker 4:
max_iterations=1は品質低下の逃げ道がないmax_iterations=1を既定にするのはよいです。ただし、Issue refinement の性質上、1回でneeds-fixが残るケースはあります。ここで単に停止すると、コストは下がりますが、未成熟な Issue を Done 扱いするリスクが出ます。#295 の AC には「既定 1」しかなく、品質側の escape hatch がありません。([GitHub]1)修正案です。
つまり、自動で 3周するのではなく、1周で止める。ただし blocking ambiguity は
NEEDS_SECOND_PASSとして可視化するのが安全です。Blocker 5: 現行 main の Step 0d/0e を無視している
#332/PR #336 により、
issue-refinement-loopには Product/Spec Kit routing gate と scope rollup が入っています。現行 main の Step 0d はgh issue list --limit 1000/gh pr list --limit 1000相当の preflight と script 実行を含みます。これは usage というより wall-clock / GitHub API / context summary の固定コストになり得ます。#295 は Step 1 以降だけを見ており、ここが blind spot です。(GitHub)#295 のスコープを広げないなら、少なくとも次を追記すべきです。
そうしないと、PR 後に「SubAgent を減らしたのに usage が大して下がらない」という検証不能な状態になります。
Blocker 6: Parent #293 / #264 / #294 / #296 の反映漏れ
#295 は Parent #293 の一部ですが、関連する B/C/D がすでに進んでいます。特に #264/PR #311 は
gemini-cli-headless-delegationの thin entrypoint 化で、#295 が扱うissue-refinement-loopにも同じ設計思想を適用すべき先行例です。#294/PR #304 は Haiku / script-first / pr-reviewer-lite、#296/PR #310 は OUTPUT_BUDGET_V1 を入れています。#295 はこれらを「前提」として書き直す必要があります。([GitHub]8)最低限、#295 本文の Related / Preconditions に次を入れるべきです。
推奨パッチ方針
最小修正で #295 を高品質化するなら、順序はこれです。
perf(claude): issue-refinement-loop を軽量化する(max_iterations=1 デフォルト / SubAgent 条件付き) #295 の本文を現行 main に合わせて更新
review-issue Skill直呼び前提や B/C/D 未起票の記述を消す。Step 2 はissue-reviewer SubAgent前提にする。max_iterationsの既定値を 1 に変更Inputs と LOOP_STATE の両方を変える。
max_iterations: 3の残骸がないことを VC にする。investigation_policyを導入requires_fact_check/target_paths/ repo claim / related Issue conflict を明示的に state 化する。単なる prose 条件にしない。web_research_policyを導入critical external claim のみ起動。改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 の retry 拡張点を壊さない。
計測 AC を追加
/usage、Agent spawn count、iteration count、skip reason、代表 Issue での before/after を PR 本文に記録する。巨大 SKILL.md の増量を禁止
本 PR で thin-entrypoint 化までやらないなら、少なくとも行数増加禁止と follow-up を入れる。
Issue #295 に投稿するなら、このコメント案
最終評価
#295 は「やるべき Issue」ですが、現状のまま PR 化すると危険です。
特に、SubAgent 条件付き起動だけを入れて cost reduction を達成した扱いにするのは不十分です。現行 main では巨大 SKILL.md、Step 0d/0e、#203 同一箇所競合、#294/#296/#311 の既存成果との整合がすべて絡みます。
推奨は、#295 を一度 “workflow lightweight policy + measurable cost reduction” Issue として書き直し、実装 PR では prose 追加ではなく
LOOP_STATE上の明示 policy と skip reason を中心に差分を作ることです。squne121 commentedon May 24, 2026
issue-refinement-loop body update (issue-refinement-loop iteration #1)
Status: Body updated via edit-issue skill (2026-05-24)
Summary of Changes
Stale content removal: Removed "Current Validated Scope" and "Remaining Parent Gaps" sections that referenced unmerged PRs (perf(claude): deterministic reviewer SubAgent を Haiku / script-first 化する #294, perf(claude): 全 SubAgent に OUTPUT_BUDGET_V1 出力制約を導入する #296, 実装: gemini-cli-headless-delegation SKILL.md を thin routing entrypoint に再設計する #264). Confirmed all three are now merged (2026-05-23):
issue-reviewerHaiku化 +pr-reviewer-litebaselineOUTPUT_BUDGET_V1baseline 導入gemini-cli-headless-delegationthin entrypoint patternPreconditions section added: Documented actual baseline state (merged PRs, current SKILL.md size 1226 lines, 設計変更: issue-refinement-loop に Product/Spec Kit routing gate のみ追加し、成果物 preflight は review / contract / impl / speckit adapter に分割する #332/feat(#332): issue-refinement-loop に Product/Spec Kit routing gate を追加する #336 recent additions)
Outcome refined: Restructured into 5 concrete, measurable conditions:
In Scope enhanced: Clarified machine-readable state definitions (investigation_policy schema, web_research_policy schema with critical_external_claims, skip_reason examples)
AC count increased: 9 ACs covering:
Out of Scope clarified: Explicitly marked Step 0d/0e cost optimization as deferred (observation-only in PR body, follow-up if dominate)
Delivery Rule additions:
Related section structured: Sibling implementations / same-file dependency / same-file-recently-merged clearly separated
Source section enhanced: Added
adversarial_reviewandfact_check_baselineprovenance markersGuards Passed
🤖 Generated with Claude Code
squne121 commentedon May 24, 2026
issue-refinement-loop iteration 1: needs-fix 対応完了
本文を以下の観点で更新しました。
対応内容
C1 必須セクション復活:
## Current Validated Scopeと## Remaining Parent Gapsを復活C5 AC↔VC 整形: Verification Commands を bash コードブロックに整形
# AC<N>インラインコメントを付与し、AC との対応を機械可読化C11 html comment 非採用の根拠:
Runtime Verification Applicability: not_applicableを宣言済みruntime-verification: trueを付けると decision tag consistency に違反するため、reviewer が提案した HTML コメント形式は採用しない変更経歴
本文の実装内容・文面変更は一切行わず、構成・フォーマット・参照リンク整備のみです。
squne121 commentedon May 24, 2026
iteration 2 needs-fix (C4) 対応完了
Reviewer Haiku verdict: needs-fix (blocking C4)
対応内容:
$shell prompt prefix を機械的に前置#開始)は変更しない(文面変更なし)/tmp/issue_295_new_body.mdより gh issue edit で本文アップロード変更行数: Verification Commands 内の 8 行の実行コマンドに prefix 追加
本文の実質的な意味内容は変更なし。C4 (Verification Commands 実行形式) 要件対応。
squne121 commentedon May 24, 2026
issue-refinement-loop: 完了 (2026-05-24T07:25:47Z)
Fact-check baseline (iter 0)
改善履歴
investigation_policy/web_research_policy(LOOP_STATE 上の機械可読 YAML state) を In Scope / AC2 / AC3 に追加failure_class/verification_routeを破壊しないことを AC4 で保証役割分担 (本ループ)
派生改善候補 (自動起票なし)
plan_issue_scope_rollup.pyのgh issue list --limit 1000+gh pr list --limit 1000の固定コスト)次アクション
issue-contract-reviewskill で着手前 preflight を実行するimpl-review-loopまたはimplement-issueskill で実装着手squne121 commentedon May 25, 2026
Contract Snapshot (2026-05-25 / Issue #295)
.claude/skills/issue-refinement-loop/SKILL.mdで max_iterations 既定値=1、investigation_policy/web_research_policy 機械可読 state、NEEDS_SECOND_PASS escape hatch、各 step skip_reason 記録が成立し、改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 retry 拡張点を破壊しない.claude/skills/issue-refinement-loop/docs/dev/agent-skill-boundaries.md(optional).claude/worktrees/issue-295-perf-claude-issue-refinement-loop-liteworktree-issue-295-perf-claude-issue-refinement-loop-litedecision: go) = 6、想定外 pass = 1 (AC4)、compound disallowed = 3 (AC7/AC8/AC9)squne121 commentedon May 25, 2026
impl-review-loop iteration 0 / Step 1+2 完了
/usage計測は follow-up 候補(reviewer 判定要)squne121 commentedon May 25, 2026
impl-review-loop: APPROVE (2026-05-25)
/usage計測を分離、Depends on #295)fix(#295): human REQUEST_CHANGES (PR #388 review) を反映 — Step 0f / SoT…
fix(#295): human review iter 2 (PR #388 4532431421) — enum 整合 / extra…
perf(#295): issue-refinement-loop の SubAgent spawn 上限を軽量化 — max_itera…