Repository navigation
Description
概要
CI/test-lane 関連の file path または Bash command を PreToolUse hook で検出し、Claude Code および Codex CLI のエージェントに対して ci-test-performance Skill の参照と CI_TEST_PERFORMANCE_DECISION_V1 の後続出力を 非ブロッキングで 助言する仕組みを実装する。
#1060 / PR #1078 の Out of Scope 項目「hook による advisory suggestion の実装(別 follow-up Issue で対応)」を本 Issue で完結させる。
背景
- 実装: CI test lane policy docs と ci-test-performance skill を追加する #1060 の Out of Scope に「hook による advisory suggestion の実装(別 follow-up Issue で対応)」と明記済み
- PR feat(#1060): CI test lane policy docs と ci-test-performance skill を追加する #1078 でも
hook advisory 実装: follow-up Issue で対応と非対応を明記 CI_TEST_PERFORMANCE_DECISION_V1output contract は 実装: CI test lane policy docs と ci-test-performance skill を追加する #1060 で確立済み(.claude/skills/ci-test-performance/SKILL.mdに定義)docs/dev/hook-boundaries.mdに hook 分類の正本 manifest あり。ci_test_performance_advisoryエントリを追記する必要がある- hook は fail-open / advisory であり、Claude Code
additionalContextによる非ブロッキング注入を使用する - Codex CLI 側も
.codex/hooks.jsonの PreToolUse で同様の advisory を追加する
Goal
CI/test-lane 関連 path または command を hook で検出し、エージェントに ci-test-performance Skill の参照と CI_TEST_PERFORMANCE_DECISION_V1 の後続出力を非ブロッキングで助言する。CI_TEST_PERFORMANCE_DECISION_V1 schema 自体は変更しない。
In Scope
- Claude Code:
.claude/settings.jsonのPreToolUseに非ブロッキング advisory hook を登録(matcher:Bash|Write|Edit|MultiEdit) - Claude Code:
.claude/hooks/ci_test_performance_advisory.sh+ unit test を追加 - Codex CLI:
.codex/hooks.jsonのPreToolUseに非ブロッキング advisory hook を登録(matcher:^(Bash|apply_patch|Edit|Write)$) - Codex CLI:
.codex/hooks/ci_test_performance_advisory.sh+ unit test を追加 docs/dev/hook-boundaries.mdにci_test_performance_advisoryのwarning/fail_openエントリを追記schemas/ci_test_performance_advisory_v1.schema.json— advisory output schema を定義- hook output contract:
CI_TEST_PERFORMANCE_ADVISORY_V1(block: false、reason_code、matched_paths、required_skill、expected_followup_contractを含む) - classifier:
ci-test-performanceSkill のpathsfrontmatter とtest-lane-policy判断マトリクスに基づき CI/test-lane 関連 path のみで発火
Out of Scope
.claude/agents/*.mdの routing 更新(→ 実装: .claude/agents/implementation-worker.md / pr-reviewer.md / test-runner.md に ci-test-performance routing 契約を追記する #1097).claude/skills/issue-contract-review/SKILL.mdの gate 化CI_TEST_PERFORMANCE_DECISION_V1schema 変更.github/workflows/ci.yml/pyproject.toml/uv.lock変更- hook による block / deny / enforcement(fail-open のみ)
- CI runtime baseline の生成・比較ロジック本体
.codex/config.tomlへの hook 追記(禁止)FileChangedを主軸にした実装(literal filename matcher の制約と no-decision-control のため)
Allowed Paths
.claude/settings.json.claude/hooks/ci_test_performance_advisory.sh.claude/hooks/tests/test_ci_test_performance_advisory.py.codex/hooks.json.codex/hooks/ci_test_performance_advisory.shtests/codex/test_ci_test_performance_advisory.pytests/codex/test_codex_hook_surface_guard.pydocs/dev/hook-boundaries.mdschemas/ci_test_performance_advisory_v1.schema.json
Acceptance Criteria
- AC1:
.claude/hooks/ci_test_performance_advisory.shが新規作成されCI_TEST_PERFORMANCE_ADVISORY_V1を出力する - AC2: advisory hook は fail-open であり、Claude / Codex のいずれでも通常 match 時に tool call を block しない(
block: false) - AC3:
schemas/ci_test_performance_advisory_v1.schema.jsonが新規作成されCI_TEST_PERFORMANCE_ADVISORY_V1スキーマを定義する - AC4: Claude Code 側は
.claude/settings.jsonのPreToolUseに hook が登録され、既存 fail-closed hooks の責務を変更しない - AC5: Codex CLI 側は
.codex/hooks.jsonのPreToolUseのみを更新し、.codex/config.tomlには hook を追加しない - AC6: classifier が CI/test-lane 関連 path で発火することを unit test で検証する(high-confidence trigger:
.github/workflows/**、pyproject.toml、uv.lock、docs/dev/test-lane-policy.md、docs/dev/ci-performance.md、.claude/skills/ci-test-performance/**、.agents/skills/ci-test-performance/**、.codex/agents/**、schemas/**) - AC7: 通常の
src/**/*.ts編集や一般 docs 編集では advisory が発火しないことを unit test で検証する - AC8:
docs/dev/hook-boundaries.mdにci_test_performance_advisoryがwarning/fail_openとして追記される - AC9:
CI_TEST_PERFORMANCE_DECISION_V1schema 自体は変更されない(.claude/skills/ci-test-performance/SKILL.mdの schema 定義が変更されていない) - AC10:
.claude/agents/*.mdの routing 更新は 実装: .claude/agents/implementation-worker.md / pr-reviewer.md / test-runner.md に ci-test-performance routing 契約を追記する #1097 に委譲し、本 Issue では変更しない(pnpm build が正常終了する)
Verification Commands
# AC1
# baseline-expect: fail
$ rg -l "CI_TEST_PERFORMANCE_ADVISORY_V1" .claude/hooks/ci_test_performance_advisory.sh
# AC2
$ uv run pytest .claude/hooks/tests/test_ci_test_performance_advisory.py -q
# AC3
# baseline-expect: fail
$ rg -l "CI_TEST_PERFORMANCE_ADVISORY_V1" schemas/ci_test_performance_advisory_v1.schema.json
# AC4
$ rg -n "ci_test_performance_advisory" .claude/settings.json
# AC5
$ rg -n "ci_test_performance_advisory" .codex/hooks.json
# AC6
$ uv run pytest tests/codex/test_ci_test_performance_advisory.py -q
# AC7
$ uv run pytest tests/codex/test_codex_hook_surface_guard.py -q
# AC8
$ rg -n "ci_test_performance_advisory" docs/dev/hook-boundaries.md
# AC9
$ rg -n "CI_TEST_PERFORMANCE_DECISION_V1" .claude/skills/ci-test-performance/SKILL.md
# AC10
$ pnpm buildStop Conditions
- hook が CI/test-lane 以外の通常 tool call を block または deny する実装になった場合は停止する
.codex/config.tomlに hook 設定を追記しようとした場合は停止する.claude/agents/*.mdを変更しようとした場合は停止し、実装: .claude/agents/implementation-worker.md / pr-reviewer.md / test-runner.md に ci-test-performance routing 契約を追記する #1097 に委譲するCI_TEST_PERFORMANCE_DECISION_V1schema を変更しようとした場合は停止するblock: trueを返す hook 実装になった場合は停止する- Allowed Paths 外のファイル変更が必要になった場合は停止する
Runtime Verification Applicability
decision: deferred
reason: advisory hook の非ブロッキング挙動・CI/test-lane path での発火と非 CI path での非発火は、pytest fixture test(subprocess 経由での hook 直接呼び出し)で検証する。テスト自体が実装物のため事前実行不可。
deferred_destination:
destination_type: pytest
destination_ref: "uv run pytest .claude/hooks/tests/test_ci_test_performance_advisory.py および uv run pytest tests/codex/test_ci_test_performance_advisory.py"
deferred_verification_condition: "uv run pytest .claude/hooks/tests/test_ci_test_performance_advisory.py が exit 0 かつ uv run pytest tests/codex/test_ci_test_performance_advisory.py が exit 0"Required Skills
ci-test-performance(.claude/skills/ci-test-performance/SKILL.md)
Parent Issue
Parent Goal Ref
CI test lane ポリシーを docs 化し、ci-test-performance Skill を追加・consumer routing を確立した後、hook advisory layer として AI エージェントが CI 関連操作を検出した際に ci-test-performance Skill の参照と CI_TEST_PERFORMANCE_DECISION_V1 の後続出力を促す非ブロッキング仕組みを実装する(#1060 Out of Scope 項目)。
Current Validated Scope
.claude/hooks/ci_test_performance_advisory.shは未作成(新規追加).claude/hooks/tests/test_ci_test_performance_advisory.pyは未作成(新規追加).codex/hooks/ci_test_performance_advisory.shは未作成(新規追加)tests/codex/test_ci_test_performance_advisory.pyは未作成(新規追加)schemas/ci_test_performance_advisory_v1.schema.jsonは未作成(新規追加).claude/settings.jsonは既存(更新: PreToolUse hook エントリ追加).codex/hooks.jsonは既存(更新: PreToolUse hook エントリ追加)docs/dev/hook-boundaries.mdは既存(更新:ci_test_performance_advisoryエントリ追記)tests/codex/test_codex_hook_surface_guard.pyは既存(更新: ci_test_performance_advisory を guard テストに追加)CI_TEST_PERFORMANCE_DECISION_V1schema は変更しない.claude/agents/*.mdは変更しない(→ 実装: .claude/agents/implementation-worker.md / pr-reviewer.md / test-runner.md に ci-test-performance routing 契約を追記する #1097)
Remaining Parent Gaps
.claude/agents/implementation-worker.md/pr-reviewer.md/test-runner.mdへの CI skill routing 追記(→ 実装: .claude/agents/implementation-worker.md / pr-reviewer.md / test-runner.md に ci-test-performance routing 契約を追記する #1097)issue-contract-reviewの CI gate 化(別 follow-up)
Outcome
.claude/hooks/ci_test_performance_advisory.sh(Claude Code)と .codex/hooks/ci_test_performance_advisory.sh(Codex CLI)が追加され、CI/test-lane 関連 path 操作時に CI_TEST_PERFORMANCE_ADVISORY_V1 を non-blocking で返す。schemas/ci_test_performance_advisory_v1.schema.json で schema が定義され、docs/dev/hook-boundaries.md に warning / fail_open 分類が追記され、pnpm typecheck / test / build がすべて通ること。
関連 Issue
- 実装: .claude/agents/implementation-worker.md / pr-reviewer.md / test-runner.md に ci-test-performance routing 契約を追記する #1097(
.claude/agents/*.mdrouting 更新 — Out of Scope)
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "1060"
goal_ref: "CI/test-lane 関連 path または command を hook で検出し、エージェントに ci-test-performance Skill の参照と CI_TEST_PERFORMANCE_DECISION_V1 の後続出力を非ブロッキングで助言する"
change_kind: hook-advisory
risk_class: agent_ops_guard
affected_runtimes:
- claude_code
- codex_cli
readiness: ready_after_refinement
hooks_boundary_contract_kind: warning
hooks_fail_policy: fail_open
Activity
squne121 commentedon Jun 21, 2026
結論
#1080 は follow-up Issue としては妥当です。ただし、現本文は implementation issue ではなく placeholder です。今のまま実装に入ると、hook advisory が「非ブロッキング助言」ではなく新しいノイズ源・誤停止源・#1097 との重複スコープになりやすいです。#1080 本文自体も
readiness: needs_refinement、change_kind: tbdで、コメントも 0 件です。#1060 / PR #1078 側では、
ci-test-performanceSkill、test lane policy、Codex 側 routing、consumer routing の設計は追加済みで、hook advisory と Claude Code agent 実更新は明示的に follow-up 化されています。PR #1078 は merge 済みで、AC1〜AC14 と CI は pass と報告されています。敵対的レビュー
1. 最大の問題:
CI_TEST_PERFORMANCE_DECISION_V1を “hook が読む” という表現が危険#1080 の goal は「PreToolUse hook 等から
CI_TEST_PERFORMANCE_DECISION_V1を読み取り advisory suggestion を提供する」となっていますが、これは時系列が曖昧です。CI_TEST_PERFORMANCE_DECISION_V1は本来、ci-test-performanceSkill を読んだ agent が 変更パス分類・baseline確認・artifact整合性確認の結果として出力する contract です。既存 Skill でも、Step 1〜4 の手順の最後にCI_TEST_PERFORMANCE_DECISION_V1を構築・出力する設計です。したがって、編集前の PreToolUse hook がやるべきことは「既存の decision を読む」ではなく、CI 関連の tool call / file path / command を検出して、Skill を読むことと後続で
CI_TEST_PERFORMANCE_DECISION_V1を残すことを助言することです。レビュー時にだけ、PR body / コメント / artifact に decision があるかを確認する、という分離が必要です。2. FileChanged を主軸にすると誤設計になりやすい
#1060 の docs では将来案として
FileChanged/PreToolUsehook からadditionalContextを返すと書かれています。 ただし Claude Code のFileChangedは watched file 変更時に動く一方、matcher は|区切りの literal filename であり、regex ではありません。またFileChangedには decision control がなく、block できません。([Claude API Docs]1)そのため、
.github/workflows/**やschemas/**のような広い path pattern に対しては、FileChangedより PreToolUse のWrite|Edit|MultiEdit|Bash入力を分類する方式を主軸にするべきです。FileChangedは exact file watcher 用の補助に留めるか、初回実装では non-goal にした方が安全です。3. advisory hook は fail-open でなければならない
この repo の hook 境界文書は、hook をローカルガードレールであってセキュリティ境界ではないと明記し、hook failure は non-blocking でも transcript を汚染しうると警告しています。 既存の fail-closed PreToolUse は secret / local main / worktree scope のような「止めるべき安全境界」に限定されています。
#1080 の hook は “advisory suggestion” なので、
permissionDecision: deny、Claude の exit 2、Codex の deny/block 相当は使うべきではありません。Claude Code ではadditionalContextによって Claude の context へ system reminder として短い助言を注入できます。([Claude API Docs]1) Codex CLI でも PreToolUse でhookSpecificOutput.additionalContextによる非ブロッキング context 追加が可能ですが、Codex の PreToolUse は完全な enforcement boundary ではなく、plain stdout や unsupported fields の扱いにも制約があります。([OpenAI Developers]2)4. Codex / Claude の hook surface を混同しない
Claude 側は
.claude/settings.jsonに hooks が定義されており、現状 PreToolUse / Stop / SubagentStop / PostToolUse / PreCompact が登録されています。 Codex 側は.codex/hooks.jsonが正本で、PreToolUse / PermissionRequest / Stop / SubagentStart 等が登録されています。#1080 は、Claude Code と Codex CLI の両方を扱うなら Allowed Paths と AC を分ける必要があります。特に Codex は
.codex/config.tomlに hook を混ぜない方針が既存 Issue / docs で固定されています。5. #1097 と重複してはいけない
#1097 は
.claude/agents/implementation-worker.md、pr-reviewer.md、test-runner.mdにCI_SKILL_ROUTINGを追記する別 Issue です。#1080 が Claude Code agent ファイルまで触ると、#1097 と衝突します。#1080 の責務は hook advisory の実装 に限定し、Claude agent routing の本体更新は #1097、
issue-contract-reviewの gate 化はさらに別 Issue として分離するのが妥当です。現行の consumer routing も「設計上の routing 定義であり、各 agent/skill ファイルの実更新は別 follow-up」と書かれています。推奨する #1080 の仕様化方針
Machine-readable contract 案
Scope
In Scope
.claude/settings.jsonに非ブロッキング advisory hook を登録.claude/hooks/ci_test_performance_advisory.*と unit test を追加.codex/hooks.jsonに非ブロッキング advisory hook を登録.codex/hooks/ci-test-performance-advisory.*と unit test を追加docs/dev/hook-boundaries.mdにci_test_performance_advisoryの fail-open / advisory contract を追記CI_TEST_PERFORMANCE_ADVISORY_V1を定義ci-test-performanceSkill の existingpathsとdocs/dev/test-lane-policy.mdの判断マトリクスに沿って classifier を実装Out of Scope
.claude/agents/*.mdの routing 更新(実装: .claude/agents/implementation-worker.md / pr-reviewer.md / test-runner.md に ci-test-performance routing 契約を追記する #1097).claude/skills/issue-contract-review/SKILL.mdの gate 化CI_TEST_PERFORMANCE_DECISION_V1schema の変更.github/workflows/ci.yml/pyproject.toml/uv.lockの変更hook 設計案
イベント
Claude Code:
Codex CLI:
{ "event": "PreToolUse", "matcher": "^(Bash|apply_patch|Edit|Write)$", "classification": "warning", "fail_policy": "fail_open" }trigger path
既存 Skill の frontmatter
pathsを正本にします。すでに.github/workflows/**、pyproject.toml、uv.lock、docs/dev/test-lane-policy.md、.claude/skills/ci-test-performance/**、.codex/agents/**、.claude/agents/**、.agents/skills/ci-test-performance/**、schemas/**、docs/dev/agent-skill-boundaries.mdが列挙されています。ただし、advisory のノイズを避けるため、初期実装では以下を high-confidence trigger とするのがよいです。
.claude/agents/**は #1097 と関連しますが、#1080 側で編集対象にするべきではありません。classifier の trigger として扱う場合も、「#1097 の routing scope と衝突しないこと」を AC に入れるべきです。advisory output
hook は block せず、短い context だけを返すべきです。Codex Skills は progressive disclosure 方式で、最初は skill 名・description・path だけを見て、必要時に
SKILL.md本文を読む設計です。([OpenAI Developers]3) そのため hook がSKILL.md本文を丸ごと注入するのは不適切です。推奨 payload:
推奨 AC
推奨 Verification Commands
既存
package.jsonでもtypecheck、lint、test、build、hook / session-recording 系の検証 script が定義されています。Claude Code / Codex CLI 仕様面からの品質改善ポイント
Claude Code では PreToolUse が tool call 前に動き、JSON output で decision や additional context を返せます。
additionalContextは Claude の context に system reminder として挿入されるため、今回の advisory には適しています。([Claude API Docs]1) ([Claude API Docs]1)Codex CLI の PreToolUse は Bash / apply_patch / Edit / Write 等を捕捉できますが、完全な enforcement boundary ではありません。しかも unsupported fields を返すと hook failed 扱いになり継続されるため、#1080 は Codex 側の stdout schema を厳密に fixture 化する必要があります。([OpenAI Developers]2)
したがって、#1080 の品質目標は「強制」ではなく 高信頼・低ノイズ・fail-open な context injection です。hook が agent の判断を代替するのではなく、
ci-test-performanceSkill の progressive disclosure を促し、PR 証跡としてCI_TEST_PERFORMANCE_DECISION_V1を残させる補助線に限定するべきです。Claude Code / Codex CLI に渡す実行プロンプト案
squne121 commentedon Jun 21, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jun 21, 2026
CONTRACT_REVIEW_RESULT_V1
squne121 commentedon Jun 21, 2026
IMPLEMENT_ISSUE_RESULT_V1
PR: #1099
fix(#1080): update hook stdout to hookSpecificOutput.additionalContex…
feat(#1080): ci_test_performance_advisory hook を追加する(Claude Code / Co…