Skip to content

実装: issue-contract-review の git branch --list false positive を git rev-parse --verify に修正する #160

Open

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "issue-contract-review SKILL.md の worktree/branch naming preflight でブランチ存在確認コマンドが false positive を返す問題を決定論的パターンに修正する"
change_kind: workflow

Parent Issue

なし(単独改善)

Parent Goal Ref

Current Validated Scope

  • .claude/skills/issue-contract-review/SKILL.md の Step 6 git branch --list "$EXPECTED_BRANCH" 記述を決定論的パターンに修正する

Remaining Parent Gaps

なし(単独改善 Issue のため)

Background

issue-contract-review skill の Step 6 worktree/branch naming preflight で以下のコマンドを使っている:

git branch --list "$EXPECTED_BRANCH"

git branch --list <pattern> は対象ブランチが存在しない場合でも exit 0 を返し、stdout が空になるだけである。このため && echo "[WARN] branch exists" が常に実行される false positive が発生する(PR #143 実装中に観測)。

根本原因: git branch --list は「パターンにマッチするブランチ一覧」を出力するコマンドであり、0 件でも正常終了(exit 0)を返す。存在確認に exit code を使うには不適。

決定論的修正(採用方針): 以下のいずれかに切り替える:

  1. git rev-parse --verify "refs/heads/$BRANCH" — ブランチ存在時 exit 0、非存在時 exit 128
  2. git branch --list "$BRANCH" | grep -q . — 出力が空なら grep が exit 1

いずれも決定論的で標準的なパターン。Option 1 の git rev-parse --verify を推奨する(grep のパイプ追加が不要で可読性が高い)。

Outcome

.claude/skills/issue-contract-review/SKILL.md の Step 6 のブランチ存在確認が git rev-parse --verify "refs/heads/$EXPECTED_BRANCH" パターンに修正され、ブランチが存在しない場合は [OK] branch clear、存在する場合のみ [WARN] branch exists が出力される正確な判定になった状態。

In Scope

  • .claude/skills/issue-contract-review/SKILL.md の Step 6 git branch --list "$EXPECTED_BRANCH" 記述を git rev-parse --verify "refs/heads/$EXPECTED_BRANCH" に修正する
  • 修正後のコマンドの判定ロジック(存在する場合 / しない場合)を SKILL.md 内に明示する

Out of Scope

  • issue-contract-review の他のステップへの変更
  • branch naming 以外の preflight への変更
  • shell スクリプト化(SKILL.md はドキュメント形式のため prose/code block での記述に留める)

Acceptance Criteria

  • AC1: .claude/skills/issue-contract-review/SKILL.md に git branch --list "$EXPECTED_BRANCH" の記述が残っていない
  • AC2: .claude/skills/issue-contract-review/SKILL.md の Step 6 に git rev-parse --verify を用いたブランチ確認パターンが記載されている
  • AC3: 修正後の記述でブランチが存在しない場合の判定([OK] branch clear 相当)とブランチが存在する場合の判定([WARN] branch exists 相当)の両方が明示されている

Verification Commands

# AC1: 旧コマンドが残っていないことを確認
rg -q "git branch --list" .claude/skills/issue-contract-review/SKILL.md && echo "FAIL: AC1 (old command remains)" || echo "PASS: AC1"

# AC2: 新パターンが存在することを確認
rg -q "git rev-parse --verify" .claude/skills/issue-contract-review/SKILL.md && echo "PASS: AC2" || echo "FAIL: AC2"

# AC3: branch clear / branch exists の両判定が記述されていることを確認
rg -q "branch clear\|branch exists\|OK.*branch\|WARN.*branch" .claude/skills/issue-contract-review/SKILL.md && echo "PASS: AC3" || echo "FAIL: AC3"

Allowed Paths

  • .claude/skills/issue-contract-review/SKILL.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

  • bash / git コマンド仕様(git rev-parse --verify、git branch --list の exit code 挙動)

Scope Delta

  • 追加: なし
  • 削除: git branch --list "$EXPECTED_BRANCH" 記述
  • 変更: .claude/skills/issue-contract-review/SKILL.md の Step 6 ブランチ確認コマンド

Runtime Verification Applicability

  • decision: not_applicable
  • reason: 静的なテキストパターン grep で全 AC が検証可能。docs のみ変更のため実動作検証は不要。

Delivery Rule

  • 1 Issue = 1 PR
  • worktree: .claude/worktrees/issue-<N>-issue-contract-review-branch-fix
  • branch: worktree-issue-<N>-issue-contract-review-branch-fix
  • Draft PR で起票し、人間レビュー後にマージ

Activity

  1. added
    enhancement
    phase/implementation
    state/queued
    agent/implementer
    on May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementationstate/queued

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions