Repository navigation
Closed
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#391"
goal_ref: "issue-refinement-loop/SKILL.md を薄い entrypoint に縮小し、長文 procedure を references/ に分割する"
change_kind: workflowParent Issue
Parent Goal Ref
- Goal: issue-refinement-loop を script-first / thin entrypoint に再構成し、固定 token cost を削減する
- Desired Destination: SKILL.md を 500 行以下に縮小し、詳細 procedure は
references/に progressive disclosure 構成で分割。判定ロジックは Phase 1 の planner script を SSOT として consume する。
Current Validated Scope
.claude/skills/issue-refinement-loop/SKILL.mdの thin entrypoint 化.claude/skills/issue-refinement-loop/references/配下への詳細 procedure 移設references/index.mdによる progressive disclosure 表の整備- planner 判定条件の prose 重複を SKILL.md から除去
disable-model-invocation: true/pathsfrontmatter 採否の明示決定
Remaining Parent Gaps
- 実装: issue-refinement-loop の SubAgent-owned contract migration を行う #394: SubAgent-owned contract migration(web-researcher の retry/fallback/attempt log 等の
.claude/agents/*.md側責務整理) - perf(claude): issue-refinement-loop を script-first / thin entrypoint 化し OPEN 改善 Issue を段階統合する #391 Phase 4: 残り childen が定義された場合の対応
Required Skills
- Markdown / YAML フロントマター編集
- Claude Code skill / subagent 構造(frontmatter フィールド・progressive disclosure)の理解
- pytest によるテキスト fixture / forbidden-fragment 検証
rg/wc/ghCLI による静的検証
Depends On
- Phase 1 として 実装: issue-refinement-loop の deterministic planner/checker script を抽出する #392(planner 抽出)の PR feat(#392): extract refinement-loop prose planner to deterministic script #407 が main へ merge 済み(前提条件)
- 軽量化前提として perf(claude): issue-refinement-loop を軽量化する(max_iterations=1 デフォルト / SubAgent 条件付き) #295 が CLOSED COMPLETED 済み(前提条件)
- 上記はすべて満たされているため、ブロッカーなし
Background
- Phase 1 で deterministic planner/checker を導入した後、SKILL.md 本文から長文 procedure / guard 詳細 / schema 重複を削減する。
- 目的は単なるファイル分割ではなく、スキル起動時に毎回読む本文を薄くし、必要な詳細だけを
references/から読む progressive disclosure 構成にすること。
Baseline
- base_ref: main after PR feat(#392): extract refinement-loop prose planner to deterministic script #407 merge(2026-05-26 時点測定)
- baseline 測定値:
wc -l .claude/skills/issue-refinement-loop/SKILL.md= 1280 行wc -c .claude/skills/issue-refinement-loop/SKILL.md= 69901 bytes- frontmatter description chars / when_to_use chars / references/index.md chars / references file count は PR 本文で実測値を記録する
- 比較対象は perf(claude): issue-refinement-loop を軽量化する(max_iterations=1 デフォルト / SubAgent 条件付き) #295 Issue 当時の 1226 行 baseline ではなく、本 baseline に固定する。
Outcome
issue-refinement-loop/SKILL.mdは entrypoint / Inputs / LOOP_STATE summary / planner 呼び出し / SubAgent routing / Stop Conditions のみを保持する。- 詳細 procedure は references に分割される。
In Scope
references/の新規作成または再編- SKILL.md から以下を references へ移動:
- anchor comment handling
- scope signal guard
- AC/VC reflection confirmation
- follow-up materialization
WEB_RESEARCH_RESULT_V1の orchestrator-side routing を references に移す(retry/fallback/attempt log の詳細は link-only とし、実装: issue-refinement-loop の SubAgent-owned contract migration を行う #394 または worker/wrapper 側へ委譲)- loop termination table
- SKILL.md の行数・bytes を baseline と比較して PR 本文に記録
- Phase 1 planner の JSON contract を正本として参照
- 既存 VC の更新
references/index.mdを作成し、topic / file / loaded_when / owner / moved_from / must_not の表で progressive disclosure 構造を可視化するdisable-model-invocation: trueの採否を明示的に決定し PR 本文に記録するpathsfrontmatter の適用可否を明示的に決定し PR 本文に記録する- planner 判定条件の prose 重複(現 Step 1 等)を SKILL.md から除去する
Out of Scope
- planner script の新規判定追加
- SubAgent prompt の責務移動
- OPEN Issue の close 判断
- perf(claude): #295 軽量化後の runtime /usage 計測(3 代表 Issue) #389 runtime 計測の実施
- web-researcher / gemini-cli-headless-delegation の retry / fallback / attempt log 設計変更(実装: issue-refinement-loop の SubAgent-owned contract migration を行う #394 または worker/wrapper の責務)
- orchestrator 側で Gemini retry_count / fallback_query / raw_grounding_state を保持すること
.claude/agents/*.mdの変更(SubAgent-owned contract migration は 実装: issue-refinement-loop の SubAgent-owned contract migration を行う #394 の責務)- SubAgent frontmatter / tools / disallowedTools / skills / model / retry / fallback の変更
Acceptance Criteria
- AC1:
.claude/skills/issue-refinement-loop/references/index.mdが存在する(references/ ディレクトリ自体は 実装: issue-refinement-loop の deterministic planner/checker script を抽出する #392 で既存のため、新規 index.md の存在を baseline 失敗の signal とする) - AC2: SKILL.md が thin entrypoint であることを示す sentinel marker がある
- AC3:
.claude/skills/issue-refinement-loop/SKILL.mdの行数が 500 行以下である。500 行を超える場合は PR 本文に以下を表形式で記録する:- 残す section 名
- references に移せない理由
- 次 follow-up Issue 番号
- SKILL.md lines / bytes
- frontmatter description chars
- when_to_use chars(存在する場合)
- references/index.md chars
- references file count
単なる baseline 比減少は pass 条件にしない。VC はtest "$(wc -l < ...)" -le 500で機械的に判定する。500 超過時の PR 本文記録要件は維持。
- AC4: references に分割された各 topic が SKILL.md からリンクされている
- AC5:
REFINEMENT_LOOP_PLAN_V1を consume する記述が残っている - AC6: 既存 termination / follow-up / web research / anchor handling の意味論が失われていない
- AC7:
pnpm/pytestgate が PASS する - AC8: SKILL.md は
REFINEMENT_LOOP_PLAN_V1を consume するだけで、investigation_policy/web_research_policy/scope_signal_guardの判定条件を prose で再定義しない。 - AC9:
.claude/skills/issue-refinement-loop/tests/test_thin_entrypoint.pyに forbidden-fragment test があり、SKILL.md 内に planner 判定条件の prose 再実装が残っていないことを CI で検証する。 - AC10:
references/index.mdが存在し、topic / file / loaded_when / owner / moved_from / must_not 列を持つ表で全 references を一覧化している。 - AC11:
disable-model-invocation: trueの採否とpathsfrontmatter の適用可否が PR 本文で明示決定されている。PR 本文の Frontmatter Decision セクションで実測値を記録(baseline_vc_preflight 対象外、pr-review-judge / 人間レビューで確認)。
Verification Commands
# AC1: 新規 references/index.md ファイルの存在を baseline で fail させる
$ test -f .claude/skills/issue-refinement-loop/references/index.md # AC1
# AC2 / AC5: thin entrypoint sentinel + planner consume の明示
$ rg -n "thin entrypoint|判定ロジックは planner を SSOT|REFINEMENT_LOOP_PLAN_V1" .claude/skills/issue-refinement-loop/SKILL.md # AC2 # AC5
# AC3: SKILL.md 行数が 500 以下であること(baseline 1280 行 → fail を担保)
$ test "$(wc -l < .claude/skills/issue-refinement-loop/SKILL.md)" -le 500 # AC3
# AC4: 分割対象 topic ごとの references ファイル参照リンクが SKILL.md に存在
$ rg -n "references/anchor-comment-handling\.md|references/web-research-routing\.md|references/follow-up-materialization\.md|references/termination-policy\.md|references/ac-vc-reflection\.md|references/scope-signal-guard\.md" .claude/skills/issue-refinement-loop/SKILL.md # AC4
# AC6: 主要 topic 別ファイルが references/ に存在することを個別に検証
$ test -f .claude/skills/issue-refinement-loop/references/anchor-comment-handling.md # AC6
$ test -f .claude/skills/issue-refinement-loop/references/web-research-routing.md # AC6
$ test -f .claude/skills/issue-refinement-loop/references/follow-up-materialization.md # AC6
$ test -f .claude/skills/issue-refinement-loop/references/termination-policy.md # AC6
$ test -f .claude/skills/issue-refinement-loop/references/ac-vc-reflection.md # AC6
$ test -f .claude/skills/issue-refinement-loop/references/scope-signal-guard.md # AC6
# AC7: 必須検証コマンド(compound を回避するため 1 行 1 コマンドに分割)
$ pnpm typecheck # AC7
$ pnpm lint # AC7
$ pnpm test # AC7
$ pnpm build # AC7
$ uv run pytest .claude/skills/issue-refinement-loop/tests/ -v # AC7
# AC8: planner 判定条件の prose 再実装が SKILL.md に残っていないこと(明示 wrap で baseline fail を担保)
$ if rg -nq "codebase_required\s*[:=]\s*true|web_research_policy\.required\s*[:=]\s*true" .claude/skills/issue-refinement-loop/SKILL.md; then exit 1; else exit 0; fi # AC8
# AC9: forbidden-fragment test の存在
$ test -f .claude/skills/issue-refinement-loop/tests/test_thin_entrypoint.py # AC9
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_thin_entrypoint.py -v # AC9
# AC10: references/index.md が topic / file / loaded_when / owner / moved_from / must_not 列の表を持つ
$ rg -nq "\| topic \| file \| loaded_when \| owner \| moved_from \| must_not \|" .claude/skills/issue-refinement-loop/references/index.md # AC10Allowed Paths
.claude/skills/issue-refinement-loop/SKILL.md.claude/skills/issue-refinement-loop/references/.claude/skills/issue-refinement-loop/tests/.claude/skills/issue-refinement-loop/fixtures/
Stop Conditions
- Phase 1 planner の schema 変更が必要になった場合
- SubAgent prompt の責務移動が必要になった場合
- references 分割だけでは意味論が保持できない場合
- Allowed Paths 外の変更が必要になった場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
.claude/agents/*.mdの変更が必要になった場合 → 実装: issue-refinement-loop の SubAgent-owned contract migration を行う #394 に defer- SubAgent frontmatter / tools / disallowedTools / skills / model / retry / fallback の変更が必要になった場合 → 実装: issue-refinement-loop の SubAgent-owned contract migration を行う #394 または別 Issue
- planner script(plan_refinement_loop.py)の判定ロジック変更が必要になった場合 → 実装: issue-refinement-loop の deterministic planner/checker script を抽出する #392 follow-up Issue
Runtime Verification Applicability
decision: not_applicable
reason: skill documentation / reference structure change。静的検証と tests で確認する。
Delivery Rule
1 Issue = 1 PR- Draft PR 既定
- Phase 1 merge 後に着手
References
- 親 Issue: perf(claude): issue-refinement-loop を script-first / thin entrypoint 化し OPEN 改善 Issue を段階統合する #391(perf: issue-refinement-loop を script-first / thin entrypoint へ)
- 兄弟 Issue: 実装: issue-refinement-loop の deterministic planner/checker script を抽出する #392(planner 抽出、PR feat(#392): extract refinement-loop prose planner to deterministic script #407 で merge 済み)、実装: issue-refinement-loop の SubAgent-owned contract migration を行う #394(SubAgent-owned contract migration)
- 先例: 実装: gemini-cli-headless-delegation SKILL.md を thin routing entrypoint に再設計する #264 / PR refactor(#264): gemini-cli-headless-delegation SKILL.md を thin routing entrypoint に再設計する #311(gemini-cli-headless-delegation thin entrypoint 化、disable-model-invocation: true 採用、SKILL.md 大幅縮小)
- 関連クローズ済み: 改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203(web-researcher retry は not_planned)
- 一次情報: Claude Code Skills docs(https://code.claude.com/docs/en/skills)、Subagents docs(https://code.claude.com/docs/en/sub-agents)
- anchor comment: 実装: issue-refinement-loop SKILL.md を thin entrypoint + references 構成へ分割する #393 (comment)
Metadata
Metadata
Assignees
Labels
No labels
Activity
squne121 commentedon May 25, 2026
判定
REQUEST_CHANGES。
#393 の方向性、つまり
issue-refinement-loop/SKILL.mdを thin entrypoint にし、詳細手順をreferences/に逃がす方針自体は正しいです。ただし現状の #393 contract は、親 #391 が要求している品質ゲートに届いていません。特に「baseline より減ればよい」という AC は弱すぎます。親 #391 は #393 に対して、SKILL.md <= 500 lines原則、行数・bytes・description 長・when_to_use 長・references index size の記録、disable-model-invocationとpathsfrontmatter の検討を明示的に要求しています。Claude Code 公式 docs でも、複雑な skill は supporting files に分割し、
SKILL.mdは 500 行未満に保つこと、必要なときだけ supporting file を読む progressive disclosure が推奨されています。また skill content は呼び出し後に context に残るため、SKILL.mdの各行は継続的 token cost になります。disable-model-invocation: trueやpathsfrontmatter も activation/cost 制御として検討対象です。([Claude Code]1) ([Claude Code]1)Blockers
1. AC3 が親 #391 の要求を満たしていない
#393 の AC3 は「#295 後 baseline より減少、または減少しない理由を PR 本文に明記」となっていますが、これは pass 条件として甘すぎます。#295/PR #388 後の実態は、
SKILL.mdが 1226 → 1262 行、bytes も 66,875 → 約 69,200 に増えており、PR #388 自身が「固定 token cost は減っていない」と明記しています。修正案:
2. baseline が曖昧
#393 は「#295 後 baseline」と書いていますが、#295 Issue 本文には 1226 lines / 65.3 KB の pre-change baseline があり、PR #388 merge 後は 1262 lines / 約 69.2 KB です。#393 の実装 PR が比較すべき baseline は、PR #388 merge 後、かつ PR #407 merge 後の current main に固定すべきです。#392 は既に closed/completed で、PR #407 により
plan_refinement_loop.py、JSON Schema、fixture/tests、SKILL.md Step 0f wiring が入っています。修正案:
3. Phase 1 planner SSOT を壊す危険が残っている
#392/PR #407 で Step 0f は
plan_refinement_loop.pyによるREFINEMENT_LOOP_PLAN_V1生成・schema validation・fail_closedrouting に移っています。にもかかわらず current main のSKILL.mdには、Step 1 の直後にcodebase_required=trueの条件を prose で再列挙する記述が残っています。これは planner SSOT 化に逆行します。#393 では、単に文章を
references/に移すだけでなく、SKILL.md 側に planner 判定ロジックの再実装が残らないことを AC/pytest で検証すべきです。追加 AC 案:
4.
web research handlingの責務境界が危険#393 の In Scope には
web research handlingの移動が含まれていますが、これは #203 の経緯と衝突しやすいです。#203 では、人間コメントにより「auth_errorretry はissue-refinement-loopではなくgemini-cli-headless-delegationまたはweb-researcher.md側の責務」と整理され、#203 はnot_plannedで closed されています。したがって #393 で移してよいのは、orchestrator 側の 結果 routing だけです。Gemini retry、fallback query、attempt log、raw evidence collection は #394 / SubAgent-owned contract migration 側に残すべきです。#394 自体も、
web-researcherの retry/fallback/attempt log contract を SubAgent 側へ移す Phase 3 として定義されています。修正案:
5. references 分割の品質ゲートが足りない
#393 は
references/作成と topic 移動を AC にしていますが、現 VC はrg "references/"やrg "anchor|scope|..." references/程度です。これでは「リンクがある」「単語がある」しか検証できず、progressive disclosure が成立しているかは検証できません。references/index.mdを必須化し、各 reference にloaded_when/owner/moved_from/must_notを持たせるべきです。推奨構成:
index.md例:6. sentinel marker が曖昧
#393 AC2 は「thin entrypoint であることを示す sentinel marker」としていますが、何を保証する marker なのか未定義です。単なる文字列なら意味がありません。
修正案:
これに対応する pytest で、marker の存在だけでなく
max_skill_linesとno_prose_rejudgmentを実検証すべきです。7. SubAgent contract migration と混線している
Claude Code の subagent は独立した context window、system prompt、tool access、permission を持ち、frontmatter の
tools/disallowedTools/model/skillsは実効挙動に影響します。skillspreload は skill content を subagent context に読み込むため、Phase 2 で安易に SubAgent 側を触ると cost/behavior の変更になります。([Claude Code]2) ([Claude Code]2) (Claude Code)#393 は Phase 2 なので、
.claude/agents/*.mdは触らず、SubAgent contract は link-only に留めるべきです。SubAgent-owned contract migration は #394 の責務です。追加 Stop Condition:
参考にすべき実装パターン
#264 / PR #311 の
gemini-cli-headless-delegationthin entrypoint 化は良い先例です。PR #311 はdisable-model-invocation: trueを追加し、SKILL.mdを 225 → 190 → 111 行まで縮小し、詳細を references に移しています。#393 もこの水準の「薄い routing entrypoint」を目標にすべきです。最小修正セット
#393 本文に最低限これを追加すべきです。
投稿用レビュー案
squne121 commentedon May 25, 2026
判定
REQUEST_CHANGES。
#393 の方向性自体は妥当です。issue-refinement-loop/SKILL.md を thin entrypoint にし、詳細 procedure を references/ に逃がすのは、親 #391 の目的と一致しています。#391 は明示的に「500 行未満を原則」「行数 / bytes / description 長 / when_to_use 長 / references index size の記録」「disable-model-invocation と paths frontmatter の検討」を #393 に要求しています。
ただし、現 #393 本文のまま実装すると 「分割しただけで SKILL.md がまだ太い」「planner SSOT を prose で再実装する」「web-researcher の retry/fallback 責務を orchestrator に戻す」 失敗モードが残ります。
主要 Blocker
#393 の AC3 は「#295 後 baseline より減少、または減少しない理由を PR 本文に明記」です。これは甘いです。PR #388 では SKILL.md が 1226 → 1262 行、bytes も 66,875 → 約 69,200 に増えており、固定 token cost は減っていないと明記されています。
Claude Code docs でも、複雑な skill は supporting files に分割し、SKILL.md は 500 行未満に保つこと、また skill content は一度読み込まれると context に残るため各行が recurring token cost になることが説明されています。
修正案:
AC3:
.claude/skills/issue-refinement-loop/SKILL.mdは 500 行以下である。500 行を超える場合は、PR 本文に以下を表で明記する:
単なる「baseline より減少」は pass 条件にしない。
#393 は「#295 後 baseline」と書いていますが、比較対象は #295 Issue の古い 1226 行 baseline ではなく、PR #388 merge 後かつ PR #407 merge 後の current main に固定すべきです。#392 / PR #407 は既に planner script、JSON Schema、fixture/tests、SKILL.md Step 0f wiring を導入済みです。
追加すべき記述:
Baseline:
#392 の Outcome は、plan_refinement_loop.py と REFINEMENT_LOOP_PLAN_V1 を SSOT にし、SKILL.md は planner output を consume するだけにすることです。
しかし current main の SKILL.md には、Step 0f で planner を consume した直後に、Step 1 の prose として codebase_required=true の条件が再列挙されています。これは thin entrypoint 化の対象にすべきです。
追加 AC:
AC8: SKILL.md は
REFINEMENT_LOOP_PLAN_V1を consume するだけで、investigation_policy/web_research_policy/scope_signal_guardの判定条件を prose で再定義しない。
AC9:
tests/test_thin_entrypoint.pyに forbidden-fragment test があり、SKILL.md 内に planner 判定条件の再実装が残っていないことを検証する。
#393 の In Scope には web research handling の移動が含まれていますが、これは #203 の整理と衝突しやすいです。#203 はもともと issue-refinement-loop の Step 1b に auth_error retry を入れる Issue でしたが、最終的に not_planned で閉じられています。
current main の SKILL.md も WEB_RESEARCH_RESULT_V1 を opaque に扱い、retry_count / fallback_query / raw_grounding_state を保存しない、と境界を明示しています。
#393 で移してよいのは orchestrator-side result routing だけです。Gemini retry、fallback query、attempt log、raw evidence collection は #394 または SubAgent / wrapper 側に残すべきです。#394 も SubAgent-owned contract migration として web-researcher の retry / fallback / attempt log を扱う設計です。
追加すべき Out of Scope:
.claude/agents/*.mdの変更In Scope はこう絞るべきです。
WEB_RESEARCH_RESULT_V1の orchestrator-side routing を references に移す#393 の VC は rg "references/" や topic keyword 検索中心です。これでは「ファイルがある」「単語がある」以上を検証できません。progressive disclosure が成立しているかを検証するには、references/index.md を必須にすべきです。
推奨構成:
.claude/skills/issue-refinement-loop/references/
index.md
refinement-loop-plan-output.md
anchor-comment-handling.md
scope-signal-guard.md
ac-vc-reflection.md
follow-up-materialization.md
web-research-routing.md
termination-policy.md
index.md には最低限これを持たせるべきです。
Claude Code の subagent は独立 context window、固有 prompt、tool access、permission を持ちます。tools / disallowedTools / skills は実効挙動に影響し、skills は full skill content を subagent startup context に inject します。
したがって #393 は .claude/agents/*.md を触らず、SubAgent contract は link-only に留めるべきです。SubAgent-owned contract migration は #394 の責務です。
追加 Stop Condition:
.claude/agents/*.mdの変更が必要になった場合 → 実装: issue-refinement-loop の SubAgent-owned contract migration を行う #394 に defer参考にすべき先例
#264 / PR #311 の gemini-cli-headless-delegation thin entrypoint 化は良い先例です。PR #311 は disable-model-invocation: true を追加し、SKILL.md を 225 → 190 → 111 行まで縮小し、詳細を references に移しています。
#393 も「少し減らす」ではなく、routing entrypoint と references の明確な分離を目標にすべきです。
投稿用レビュー案
REQUEST_CHANGES
#393 の方向性は妥当です。
issue-refinement-loop/SKILL.mdは PR #388 後に 1226 → 1262 行へ増えており、固定 token cost が未解決なので、thin entrypoint + references 分割は必要です。ただし現 contract は親 #391 の要求を満たしていません。
Blockers:
AC3 が弱いです。「perf(claude): issue-refinement-loop を軽量化する(max_iterations=1 デフォルト / SubAgent 条件付き) #295 後 baseline より減少」ではなく、Claude Code docs の推奨に合わせ
SKILL.md <= 500 linesを原則 AC にしてください。超過時は section 名 / references に移せない理由 / 次 follow-up を PR 本文に必須記録してください。baseline が曖昧です。比較対象は perf(claude): issue-refinement-loop を軽量化する(max_iterations=1 デフォルト / SubAgent 条件付き) #295 Issue の 1226 lines ではなく、PR perf(#295): issue-refinement-loop の SubAgent spawn 上限を軽量化 — max_iterations=1 + policy state 化 #388 merge 後かつ PR feat(#392): extract refinement-loop prose planner to deterministic script #407 merge 後の current main に固定してください。PR 本文には lines / bytes / description chars / when_to_use chars / references index size / references file count を記録してください。
実装: issue-refinement-loop の deterministic planner/checker script を抽出する #392/PR feat(#392): extract refinement-loop prose planner to deterministic script #407 により
REFINEMENT_LOOP_PLAN_V1が SSOT になっています。実装: issue-refinement-loop SKILL.md を thin entrypoint + references 構成へ分割する #393 では SKILL.md から planner 判定条件の prose 再実装を削除し、pytest で forbidden-fragment を検出してください。web research handlingは retry/fallback/attempt log まで含めると 改善: issue-refinement-loop の web-researcher Step 1b に transient auth failure への 1-retry 機構を追加する #203 の責務整理と衝突します。実装: issue-refinement-loop SKILL.md を thin entrypoint + references 構成へ分割する #393 では orchestrator-side result routing のみを references 化し、Gemini retry / fallback / attempt log は 実装: issue-refinement-loop の SubAgent-owned contract migration を行う #394 または worker/wrapper 側に委譲してください。references/は単なる置き場ではなく、references/index.mdに topic / file / loaded_when / owner / moved_from / must_not を持たせ、progressive disclosure が検証できる構造にしてください。Phase 2 は SubAgent-owned contract migration ではありません。
.claude/agents/*.md、SubAgent frontmatter、tools/model/skills preload、retry/fallback behavior を触る必要が出た場合は 実装: issue-refinement-loop の SubAgent-owned contract migration を行う #394 へ defer してください。この修正なしに実装すると、「長文を references に移しただけで SKILL.md がまだ太い」「planner SSOT を prose で再実装する」「web-researcher の内部復旧責務を orchestrator に戻す」という失敗モードが残ります。
最小修正セット
#393 本文に最低限これを追加してください。
Contract Amendments Required
SKILL.md <= 500 linesis the default pass condition.disable-model-invocation: trueadoption must be explicitly decided.pathsfrontmatter applicability must be explicitly decided.REFINEMENT_LOOP_PLAN_V1; it must not re-derive planner decisions in prose.現状の #393 は実装に進めるより、まず Issue contract を上記の粒度まで補正した方が安全です。
squne121 commentedon May 25, 2026
Issue body 更新(edit-issue skill / issue-author SubAgent)
anchor comment #issuecomment-4537929910 を反映しました。verified by codebase-investigator + web-researcher(baseline = main after PR #407 merge)。
変更内容(normalized amendments)
WEB_RESEARCH_RESULT_V1の orchestrator-side routing 移設に限定(retry/fallback/attempt log は link-only、実装: issue-refinement-loop の SubAgent-owned contract migration を行う #394 または worker/wrapper 委譲)。references/index.md作成 /disable-model-invocation採否決定 /pathsfrontmatter 採否決定 / planner 判定条件の prose 重複除去を追加。.claude/agents/*.md変更、SubAgent frontmatter / tools / disallowedTools / skills / model / retry / fallback 変更を明示的に除外。REFINEMENT_LOOP_PLAN_V1consume のみ、investigation_policy / web_research_policy / scope_signal_guard 判定条件の prose 再定義禁止tests/test_thin_entrypoint.pyに forbidden-fragment testreferences/index.mdに topic/file/loaded_when/owner/moved_from/must_not 列を持つ表disable-model-invocation: true/pathsfrontmatter 採否を PR 本文で明示決定.claude/agents/*.md変更 → 実装: issue-refinement-loop の SubAgent-owned contract migration を行う #394 defer、SubAgent frontmatter 変更 → 実装: issue-refinement-loop の SubAgent-owned contract migration を行う #394 等、planner script 判定ロジック変更 → 実装: issue-refinement-loop の deterministic planner/checker script を抽出する #392 follow-up。Guards 通過状況
Backup
/tmp/issue_393_body_backup_20260526_082446.md(3790 bytes / 95 行)squne121 commentedon May 25, 2026
edit-issue: structural template alignment for C1/C5 deterministic checks
review-issue verdict
needs-fixの C1 / C5 blocker に対応した最小差分修正。変更セクション
追加(Machine-Readable Contract 直後に挿入、既存セクションは破壊せず):
## Parent Issue—#391## Parent Goal Ref— thin entrypoint 再構成 Goal / Desired Destination## Current Validated Scope— SKILL.md 縮小・references 分割・frontmatter 採否決定## Remaining Parent Gaps— 実装: issue-refinement-loop の SubAgent-owned contract migration を行う #394 / perf(claude): issue-refinement-loop を script-first / thin entrypoint 化し OPEN 改善 Issue を段階統合する #391 Phase 4## Required Skills— Markdown/YAML 編集・skill/subagent 構造理解・pytest・rg/wc/ghVerification Commands ブロック修正(VC annotation の
# AC<N>token を補完):# AC8を追加:! rg -n "codebase_required..." SKILL.md(planner 判定条件 prose 再定義の不在検証)# AC11を追加:echo "AC11 は PR 本文の Frontmatter Decision セクションで実測値を記録"# AC2 AC5は既存どおり 91 行目に維持変更理由
# AC<N>形式で参照される状態を回復Guard 結果サマリ
破壊しなかったもの
backup
tmp/issue_393_backup_1779751697.mdsqune121 commentedon May 25, 2026
issue-refinement-loop: 完了 (2026-05-25T23:33:37Z)
改善履歴
AC3を 500 行原則へ強化、## Baseline新設、In Scopeから web research 詳細を縮小して 実装: issue-refinement-loop の SubAgent-owned contract migration を行う #394 / worker 側へ defer、Out of Scopeに.claude/agents/*.md/ retry-fallback-attempt log / SubAgent frontmatter を追加、AC8(planner SSOT 重複禁止)/AC9(forbidden-fragment test)/AC10(references/index.md 表)/AC11(disable-model-invocation / paths frontmatter 決定の明示)を追加、Verification Commands/Stop Conditions/Referencesを補強。## Parent Issue/## Parent Goal Ref/## Current Validated Scope/## Remaining Parent Gaps/## Required Skillsを新設。AC8 / AC9 / AC11 の# AC<N>VC annotation を追加。# AC2 AC5単一コメント表記が checker regex#\s*AC(\d+)で AC5 を取りこぼす issue を解消し# AC2 # AC5の 2 コメント表記に分割。Fact-check 結果(codebase-investigator + web-researcher / haiku)
Deterministic checks
C1-C11 すべて PASS(C12 n/a)。
次アクション
issue-contract-reviewskill で実装着手前 preflight を実行可能Model usage policy: codebase-investigator / web-researcher / issue-reviewer は Haiku、issue-author(公開向け本文編集)は Opus、最終判断(fact-check 統合・final_classification 確定・C5 root-cause 解析)は Opus(本メインスレッド)が担当。
squne121 commentedon May 25, 2026
Contract Review: BLOCKED ($(date -u +%Y-%m-%dT%H:%M:%SZ))
推奨アクション
issue-refinement-loopを起動し、VC 契約を以下のように tighten すること:test -f .claude/skills/issue-refinement-loop/references/index.mdに置き換えtest "$(wc -l < .claude/skills/issue-refinement-loop/SKILL.md)" -le 500に置き換えrg -n "references/anchor-comment-handling.md|references/web-research-routing.md" .claude/skills/issue-refinement-loop/SKILL.md)に置き換えpnpm typecheck && pnpm lint && pnpm test && pnpm buildを 4 行に分割if ! rg ...; then exit 0; else exit 1; fiに wrapDepends on #295表記を見直すか GitHub native dependency を登録(perf(claude): issue-refinement-loop を軽量化する(max_iterations=1 デフォルト / SubAgent 条件付き) #295 は既に COMPLETED)これらの修正後に再度
issue-contract-reviewを実行し、status: goを確認した上でimpl-review-loopを起動してください。squne121 commentedon May 25, 2026
──────────────────────────────────────────────────────────────────
☐ 次 ア ク シ ョ ン
Issue #393 の contract が VC preflight で BLOCKED( baseline で
unexpected_pass / compound command
等 が 複 数 ) に な り ま し た 。 impl-review-loop は contract gate
で 着 手 不 可 で す 。 次 に ど う 進 め ま す か ?
❯ 1. issue-refinement-loop で VC を 再 tighten( Recommended)
BLOCKED コ メ ン ト ( #issuecomment-4538075102) を anchor と し て
issue-refinement-loop を 再 走 し 、 AC/VC を baseline で fail
す る よ う に 修 正 し て か ら impl-review-loop を 再 起 動 。 所 要 1-2
iteration。
2. 私 が body を 直 接 surgical edit し て VC の み 修 正
issue-refinement-loop を 介 さ ず 、 Opus が VC
行 を 上 記 提 案 通 り に 直 接 書 き 換 え る 。 最 短 だ が review skill
に よ る 品 質 確 認 は 省 略 。
3. Contract gate を override し て impl-review-loop を 強 行
skill の hard gate を 意 図 的 に 無 視 し て 実 装 を 開 始 。 preflight
blocked の ま ま な の で test-runner / pr-reviewer
段 階 で 同 じ 問 題 が 再 発 す る 可 能 性 が 高 い 。 非 推 奨 。
4. Type something.
────────────────────────────────────────────────────────────────
squne121 commentedon May 25, 2026
#393 (comment)
#393 (comment)
Issue作成、Issue編集、Issueレビューエージェントスキルと実装前Issue確認エージェントスキルの整合性を確認してほしい。改善案を出してほしい。
squne121 commentedon May 25, 2026
edit-issue 変更経緯
反映内容
A. Verification Commands ブロック全面差し替え
test -d .../references→test -f .../references/index.md(baseline で確実に fail)wc -l(常に exit 0)→test "$(wc -l < ...)" -le 500(baseline 1280 行で fail 担保)rg "references/"→ 個別 references ファイル名 6 件の anchor 検索rg -n "anchor|scope|..." references/(既存 dir hit)→ topic 別test -f6 件pnpm typecheck && pnpm lint && pnpm test && pnpm build(preflight 非対応)→ 1 行 1 コマンドに分割!invert(env_missing_dep誤分類)→if rg -nq ...; then exit 1; else exit 0; fi明示 wrapecho "..."(常に exit 0)→ VC ブロックから削除し、AC11 文言側で PR 本文記録要件を明記B. AC 文言の VC 整合
references/存在 →references/index.md存在(dir は 実装: issue-refinement-loop の deterministic planner/checker script を抽出する #392 で既存のため signal が弱かった)test -le 500で機械判定」を追記C. Depends On 整理
- Depends on #Nline-anchored 表現を除去(fallback parser の誤検出回避)不変
Background / Outcome / In Scope / Out of Scope / Baseline / AC リスト本体 / Allowed Paths / Stop Conditions / Runtime Verification Applicability / Delivery Rule / References / Parent Issue / Parent Goal Ref / Current Validated Scope / Remaining Parent Gaps / Required Skills / title は保持。
squne121 commentedon May 25, 2026
issue-refinement-loop: 完了(needs_second_pass)
# AC11VC annotation)iteration 1 で適用済みの改善(commit: changelog https://github.com/squne121/loop-protocol/issues/393#issuecomment-4538181498)
- Depends on #N表現を除去 → blocker check PASSiteration 2 検証結果(再 preflight)
test "$(wc -l < ...)" -le 500の command substitution が unknown 分類rg -n "thin entrypoint|..."が unknown 分類pnpm typecheck等が baseline で既に PASS → unexpected_pass(regression gate と baseline-fail パターンの構造的不整合)if rg ...; then ...; fiの;を compound_command_disallowed と判定rg -nq "table-header pattern"が unknown 分類残課題(loop 内では解決不可能)
baseline_vc_preflight.pyのexpected_baseline_failモデルでは表現不可。impl-review-loop 内の test-runner SubAgent が Step 2 で同等検証を行うため、本来 baseline preflight 対象外で良い。wcの command substitution / 複雑な rg pattern / table header 検索はbaseline_vc_preflight.pyclassifier がunknown判定。実装は問題なく動作するが preflight がhuman_judgmentを返す。# AC11annotation が見つからず C5 fail。推奨アクション(人間判断項目)
以下のいずれかを選択して進める:
! rg -q "pattern" file # AC8で再表現。AC3/AC5/AC10 は受容(contract checker は status: human_judgment 返却で impl-review-loop は依然 stop)baseline_vc_preflight.pyの classifier を拡張(command substitution / regression-gate-mode / 否定!の正規化)。別 Issue として起票し、本 #393 は preflight 拡張後に再開vc_preflight_override: truemarker があれば preflight blocked でも続行」へ拡張。別 Issue 化vc_preflight: blockedガードを手動 override して進行人間判断を待機する。
squne121 commentedon May 26, 2026
確認結果としては、4スキルは方向性としては揃っているが、契約判定のSSOTが分散しており、実装前preflightで止まるIssueを create/edit/review 側が生成・承認しうる状態です。特に VC grammar、template guard、Outcome guard、Runtime Verification、Required Skills の扱いが重複・微妙に不一致です。
結論
#393 自体は issue-refinement-loop/SKILL.md の thin entrypoint 化であり、対象パスも issue-refinement-loop 配下に限定されています。本文上でも .claude/agents/*.md や planner 判定ロジック変更は Out of Scope / Stop Conditions に明示されています。したがって、4スキル横断の整合性修正を #393 に押し込むべきではありません。#393 では references 分割時に「他スキルとの責務境界を壊さない」ことだけを要求し、横断整合は別 Issue に切るのが適切です。
整合している点
review-issue は checker script を SSOT とし、LLM が自然言語で補完・再判定しない方針になっています。needs-fix 時も loop 呼び出しなら本文更新せず diff proposal を返し、更新は issue-refinement-loop / edit-issue 側に委ねる設計です。これは責務分離として妥当です。
edit-issue は既存 Issue 更新時にバックアップ、template guard、Outcome guard、AC/VC alignment、rollback を持っており、create の既存Issue版として位置づけられています。更新系 mutation を安全に閉じ込める設計になっています。
issue-contract-review は「実装着手直前 preflight」に限定し、Issue本文の品質レビューは review-issue / issue-refinement-loop の責務だと明記しています。これは review と preflight の分離として正しいです。
主な不整合・リスク
create-issue / body-authoring 側は grep ... && ... || ... や pnpm typecheck && pnpm lint && pnpm test && pnpm build のような compound command を例示しています。一方、issue-contract-review の baseline VC preflight は && / || / | / ; / heredoc を含む compound command を compound_command_disallowed として blocked に分類します。つまり、作成側が推奨したVCを、実装前preflightが拒否する可能性があります。
改善方針は二択です。
厳格化案: VC は 1 command / 1 AC / no pipe / no shell compound に統一し、create/edit/body-authoring の例をすべて書き換える。
許容案: baseline_vc_preflight.py 側に safe compound profile を導入し、cmd1 && cmd2 や rg ... | rg ... など限定形だけ許可する。
おすすめは 厳格化案です。preflight の分類が単純になり、Terminal Agent が fail reason を誤解しにくいです。
edit-issue は VC 更新時に rg を使い、grep は環境差があるため避けるとしています。一方、create-issue / body-authoring には grep の削除確認パターンが残っています。
改善案: body-authoring.md に VC_COMMAND_PROFILE_V1 を定義し、以下に寄せる。
edit-issue の guard-issue-body.py は template が存在しない issue_kind を fail にします。一方、review-issue の checker は template 読み込みに失敗した場合、ハードコード済み required sections に fallback します。これは 同じIssue本文が edit では fail、review では pass しうる原因になります。
改善案: template 解決は fail-closed に統一する。fallback を残すなら legacy_missing_applicability のような warning ではなく、implementation Issue では blocker にするべきです。
create-issue は成果物形式・完了条件の欠落を prose でガードします。edit-issue は _OUTCOME_NG_RE で「決定される/整理される/完了する/検討する/改善する」などの末尾パターンを検出します。review-issue も VAGUE_OUTCOME_PATTERNS を持っていますが、検出語彙と判定粒度が一致していません。
改善案: Outcome 判定を issue_contract_core.py に抽出し、create/edit/review で同じ関数を呼ぶ。prose ガイドだけでなく、fixture test で「作成時に通る本文は review/edit/preflight でも通る」ことを保証する。
文書上は分離されていますが、実際には両方が AC/VC の検証可能性を見ます。review-issue は構造・契約品質、issue-contract-review は実装前に VC を baseline 実行して runnable かを見る、という境界を check matrix として固定した方がよいです。
推奨 matrix:
項目 create-issue edit-issue review-issue issue-contract-review
template required sections 生成時に保証 更新時に保証 静的判定 着手前再確認
Outcome concrete 生成時に保証 更新時に保証 静的判定 原則見ない
AC/VC番号一致 生成時に保証 更新時に保証 静的判定 着手前再確認
VC grammar 生成時に保証 更新時に保証 静的判定 実行前判定
baseline fail 原則実行しない、必要なら cheap dry-run 原則実行しない 実行しない 必ず実行
blocker/dependency 重複確認のみ 触らない 触らない 必ず確認
worktree/branch衝突 触らない 触らない 触らない 必ず確認
#393 への追加要求案
#393 に横断修正を入れるのではなく、references 分割時の破壊防止として以下だけ追加するのがよいです。
Additional Constraint: Cross-skill Contract Boundary
issue-refinement-loopは create/edit/review/preflight の判定ロジックを再実装しない。review-issue/check_issue_contract.pyを consume する。edit-issueまたはcreate-issue経由に限定する。issue-contract-reviewの責務とし、loop references に再定義しない。別Issueとして切る改善案
Issue 1: 契約判定コアの共通化
タイトル:
実装: Issue contract guard の共通 core を抽出し create/edit/review/preflight の判定差分を解消する
Outcome:
.claude/skills/shared/issue-contract-core/または.claude/lib/issue_contract/に Issue contract 判定の共通実装が追加され、create-issue / edit-issue / review-issue / issue-contract-review が同じ template / outcome / AC-VC / VC grammar ルールを参照する。In Scope:
Out of Scope:
Issue 2: VC grammar profile の統一
タイトル:
実装: VC_COMMAND_PROFILE_V1 を定義し create/edit/review/preflight の compound command 不一致を解消する
Outcome:
Issue本文に書ける Verification Commands の許容文法が
VC_COMMAND_PROFILE_V1として定義され、作成・編集・レビュー・実装前preflightの全段で同じ判定になる。Acceptance Criteria:
Issue 3: review/preflight responsibility matrix の明文化
タイトル:
実装: review-issue と issue-contract-review の責務境界 matrix を追加し重複判定を整理する
Outcome:
docs/dev/agent-skill-boundaries.mdまたは各 SKILL.md の Related/Contract に、Issue authoring pipeline の責務 matrix が追加され、review-issue が見る項目と issue-contract-review が見る項目が機械可読に分離される。重要な決定:
投稿用コメント案
#393 には横断整合性修正を直接入れず、責務境界の破壊防止だけを追加するのがよいです。
現状、create-issue / edit-issue / review-issue / issue-contract-review は方向性としては揃っていますが、Issue contract 判定の SSOT が分散しています。特に以下が不整合です。
VC grammar が衝突しています。create/body-authoring は
grep ... && ... || ...やpnpm typecheck && pnpm lint && pnpm test && pnpm buildを例示していますが、issue-contract-review の baseline preflight は&&/||/|/;を compound_command_disallowed として blocked にします。作成側が推奨したVCを実装前preflightが拒否しうる状態です。grep/rg方針が混在しています。edit-issue はrg優先・grep回避を明示していますが、create/body-authoring には grep 例が残っています。template guard が fail-open / fail-closed で揺れています。edit-issue は template missing を fail にしますが、review-issue checker は fallback required sections を使います。同じ本文が edit では fail、review では pass しうる状態です。
Outcome Quality Guard が create prose / edit script / review script に分散し、検出語彙と判定粒度が一致していません。
review-issue と issue-contract-review の責務境界は文書上は分離されていますが、AC/VC検証可能性の扱いが重複しています。review は静的本文品質、contract-review は runnable / baseline / dependency / worktree preflight に限定する matrix を明文化すべきです。
#393 では以下の制約だけ追加してください。
横断修正は別 Issue として切るべきです。候補は以下です。
実装: Issue contract guard の共通 core を抽出し create/edit/review/preflight の判定差分を解消する実装: VC_COMMAND_PROFILE_V1 を定義し create/edit/review/preflight の compound command 不一致を解消する実装: review-issue と issue-contract-review の責務境界 matrix を追加し重複判定を整理するこの方針なら、#393 は thin entrypoint 化に集中でき、横断的な契約整合は独立した検証可能な Issue として扱えます。
squne121 commentedon May 26, 2026
● Refinement loop は 仕 様 通 り iter=2 max で needs_second_pass
終 了i。HIssue body はu改l善 さ れiたtが/、pimpl-review-loop の/ hard
gate(pVC preflight blocked) を 突 破 す る に は contract と script
の 構R造r的v不e整:合sのl解-決u判h断rがd必r要v。e
完 了e報g告 : #393 (comment)
ssuecomment-4538201085
選 択 肢 A〜 D を どsれuで-進oめtるaかt教rえvてeく だ さbいs:
受R容側(の→ impl-review-loop はg依t然 stop、goverride 判で断到必達要し)て
化 ( 根 本 解 決 、 実装: issue-refinement-loop SKILL.md を thin entrypoint + references 構成へ分割する #393 は preflight 改 善 後 に 再 開 )
機 構 追 加 ( 別 Issue、 構 造 改 善 )
しtてp着:手/
squne121 commentedon May 26, 2026
結論: B で進めるべきです。D は避けるべきです。
理由は、今回止まっている原因が #393 の refinement 不足ではなく、baseline_vc_preflight.py が「baseline で fail すべき VC」と「baseline では検証不能・PR本文/人間レビューで確認すべき VC」を十分に分類できていない構造問題だからです。
#393 本文はすでに、AC11 で disable-model-invocation / paths の採否を PR本文で明示決定し、さらに「baseline_vc_preflight 対象外、pr-review-judge / 人間レビューで確認」と明記しています。これは baseline で機械的に fail させる類の VC ではありません。にもかかわらず hard gate が止めているなら、Issue body ではなく preflight classifier 側の設計不足です。
推奨方針:
B: baseline_vc_preflight.py classifier 拡張を別 Issue 化
そのうえで #393 は preflight 改善後に再開してください。
A は非推奨です。AC7/AC11 の VC を削る・簡素化する方向は、Issue contract を preflight の都合に合わせて弱めるだけです。しかも提示文どおり、impl-review-loop は依然 stop するので根本解決になりません。
C は「B の後続または補助策」としてはありです。ただし、vc_preflight_override marker は例外機構なので、先に classifier を直さずに導入すると hard gate の意味が薄くなります。入れるなら、baseline_non_applicable / human_review_only / runtime_gate などの明示理由を要求し、無条件 override にはしない方がよいです。
D は今回選ばない方がよいです。#391 は #393 に対して、500行以下、計測値記録、frontmatter 採否、単なる baseline 減少では pass しない、という品質ゲートを明示しています。ここで hard gate を override すると、今後も「契約が正しいのに preflight が誤検知する」ケースと「契約が壊れている」ケースを区別できません。
貼るなら、指示はこれで十分です。
B で進めてください。
#393 の Issue body 自体は refinement loop により改善済みで、AC11 も「baseline_vc_preflight 対象外、PR本文 / pr-review-judge / 人間レビューで確認」と明記されています。今回の停止原因は #393 contract の不足ではなく、baseline_vc_preflight.py が以下を分類できていない構造問題と判断します。
したがって #393 の AC/VC を preflight 都合で削るのではなく、baseline_vc_preflight.py classifier 拡張を別 Issue 化してください。#393 はその preflight 改善後に再開します。
D の hard gate override はしません。C の vc_preflight_override marker は、classifier 拡張後も必要な例外が残る場合に別途検討してください。
補足: #394 は Phase 3 で、#393 Phase 2 の後続に依存しています。ここで無理に #393 を弱めて進めると、SubAgent-owned contract migration 側にも歪みが伝播します。
squne121 commentedon May 26, 2026
issue-refinement-loop / impl-review-loop: 一時停止
人間 Decision(#issuecomment-4539742533)に基づき、本 #393 の refinement / 実装は一時停止し、
baseline_vc_preflight.pyclassifier 拡張を扱う #410 のマージ完了後に再開します。停止理由
現 #393 の VC contract は人間 OWNER の方針通り(AC11 で「baseline_vc_preflight 対象外、PR本文 / pr-review-judge / 人間レビューで確認」と明記済み等)であり、AC を preflight 都合で弱める方向(A 案 / D 案)は採用しません。停止原因は preflight classifier 側の構造的不足であり、
baseline_vc_preflight.py拡張を先行させます。再開条件
baseline_vc_preflight.py上で本 実装: issue-refinement-loop SKILL.md を thin entrypoint + references 構成へ分割する #393 の VC ブロックがstatus: passを返すことを再確認issue-contract-review→impl-review-loopを再起動後続検討(本 #393 とは独立)
vc_preflight_overridemarker 機構(C 案): classifier 拡張完了後に必要性を再評価pr-review-judge側でpr_review_onlyVC を検証するロジック実装: follow-up Issue 候補Issue body 状態
feat(#410): extend baseline_vc_preflight classifier to 4 scope_class (#…
fix(#393): restore refinement loop routing semantics
fix(#393): restore anchor comment metadata contract
feat(#393): thin issue-refinement-loop entrypoint (#413)