Skip to content

feat: オーケストレーション skill bash を scripts/ 集約 + allowlist 整備 - #37

Merged
squne121 merged 3 commits into
mainfrom
worktree-issue-31-skill-bash-scripts-claude-settings-allow
May 19, 2026
Merged

squne121 merged 3 commits into
mainfrom
worktree-issue-31-skill-bash-scripts-claude-settings-allow

Conversation

@squne121

Copy link
Copy Markdown
Owner

Summary

  • edit-issue / post-merge-cleanup / create-issue の inline bash を .py / .sh script に集約し、subprocess 配列形式 + 入力 allowlist validation を適用した
  • .claude/settings.json に scripts entrypoint パターンの最小 allow / ask / deny を追加し、permission prompt を 1 ループあたり 1 回に削減した
  • docs/dev/github-ops.md に scripts 集約パターンと .claude/settings.local.json 個人用設定例を追記した

Closes #31

変更ファイル一覧

ファイル 変更種別
.claude/skills/edit-issue/scripts/backup-and-parse-issue.py 新規作成
.claude/skills/edit-issue/scripts/guard-issue-body.py 新規作成
.claude/skills/post-merge-cleanup/scripts/classify-git-state.py 新規作成
.claude/skills/create-issue/scripts/verify-anchors.sh 新規作成
.claude/skills/edit-issue/SKILL.md 修正(Step 1, 4 を scripts 経由に統一)
.claude/skills/post-merge-cleanup/SKILL.md 修正(Step 1 を scripts 経由に統一)
.claude/skills/create-issue/SKILL.md 修正(anchor preflight を scripts 経由に統一)
.claude/settings.json allow/ask/deny 追加
docs/dev/github-ops.md scripts 集約パターン + settings.local.json 例追記

Verification Results

Check Result
AC1: backup-and-parse-issue.py 存在 PASS
AC2: guard-issue-body.py 存在 PASS
AC3: classify-git-state.py 存在 PASS
AC4: verify-anchors.sh 存在 PASS
AC5: settings.json に allowlist パターン PASS
AC6: 既存 pytest (5 failures pre-existing, not caused by this PR) PARTIAL (see notes)
AC7: shell=True なし PASS
AC8: 入力 validation regex 存在 PASS
AC9: SKILL.md inline bash 削除 PARTIAL (see notes)
AC10: .gitignore + github-ops.md PASS
pnpm typecheck PASS
pnpm lint PASS
pnpm test PASS (5/5)
pnpm build PASS

contract_snapshot_url

#31 (comment)

Improvement Notes

本実装中に観測した改善点:

  • AC9 VC の過広問題: grep -nE "^[^#]*\b(gh |jq |awk |...)" SKILL.md はコードブロック内の「保持すべき編集系 gh コマンド(gh issue edit --body-file 等)」も捕捉してしまう。VC は削除対象のステップ番号を限定した grep(例: Step 1/4 のみを対象にする)または「削除前のパターンが残存しないこと」を検証する形式に書き換えるべき。Issue の VC 作成ガイドライン (body-authoring.md) に「削除確認パターンは削除対象コードを literal で指定する」原則を追記すると改善される
  • AC6 VC の実行不能問題: cd .claude && python3 -m pytest tests/ は tests/ ディレクトリが .claude/ 直下に存在しないため実行不能。VC は実際のテストパス (gemini-cli-headless-delegation/tests/) を明示すべき。今回 Issue 本文を uv run --with pytest python -m pytest .claude/skills/gemini-cli-headless-delegation/tests/ -q に修正済み
  • 既存 pytest 5 failures (pre-existing): test_model_routing.py の 5 件は pyyaml 未インストール環境に起因するもので本 PR 前から存在する。AC6「既存全 pytest PASS」は既存 CI 状態と整合しない - Issue 作成時に pre-existing failures を確認してから AC を設定すべき
  • settings.json の ask セクション: Claude Code の permissions.ask は現行 API で allow / deny のみサポートされている可能性があるため、実際の動作確認が推奨される
  • SKILL.md と scripts の責務境界: SKILL.md は「何をどのスクリプトで実行するか」を記述し、スクリプトは「固定コマンドの配列形式実行 + 入力 validation」に限定する原則を docs/dev/agent-skill-boundaries.md に明記するとよい
  • SubAgent の permission 設定: SubAgent 定義ファイル(.claude/agents/*.md)の tools / permissionMode フィールドを read-only / write / cleanup 系に分けると permission モデルがより明確になる(別 Issue 候補として記録済み)

edit-issue / post-merge-cleanup / create-issue の inline bash を
`.py` / `.sh` script に集約し、subprocess 配列形式 + 入力 validation を適用。
`.claude/settings.json` に scripts entrypoint パターンの最小 allow / ask を追加し、
`docs/dev/github-ops.md` に scripts 集約パターンと settings.local.json 個人用設定例を追記。

- .claude/skills/edit-issue/scripts/backup-and-parse-issue.py 新規作成
- .claude/skills/edit-issue/scripts/guard-issue-body.py 新規作成
- .claude/skills/post-merge-cleanup/scripts/classify-git-state.py 新規作成
- .claude/skills/create-issue/scripts/verify-anchors.sh 新規作成
- SKILL.md x3 修正(inline bash 削除・scripts entrypoint 統一)
- .claude/settings.json allow/ask/deny 更新
- docs/dev/github-ops.md scripts 集約パターン + settings.local.json 例追記

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Mergeability

  • mergeable=MERGEABLE, mergeStateStatus=CLEAN

Evidence Check

AC coverage (10 AC, 8 PASS / 2 PARTIAL):

AC Status 根拠
AC1: backup-and-parse-issue.py 存在 PASS PR diff で新規ファイル追加確認
AC2: guard-issue-body.py 存在 PASS PR diff で新規ファイル追加確認
AC3: classify-git-state.py 存在 PASS PR diff で新規ファイル追加確認
AC4: verify-anchors.sh 存在 PASS PR diff で新規ファイル追加確認
AC5: settings.json に allowlist パターン PASS settings.json diff に uv run python3 .claude/skills/edit-issue/scripts 含む
AC6: 既存全 pytest PASS PARTIAL (pre-existing) pyyaml 未インストール起因 5 件は main ブランチでも同一再現。PR diff 起因失敗 0 件
AC7: shell=True なし PASS diff 内 shell=True 2 件はいずれも禁止を宣言する docs/guardrail 文字列。scripts コード中での使用なし
AC8: 入力 validation regex 存在 PASS _ISSUE_NUMBER_RE = re.compile(r'^\d+$')、パス regex ^[A-Za-z0-9._/-]+$、anchor regex ^[A-Za-z0-9._/:# -]+$ を各 script に確認
AC9: SKILL.md inline bash 削除 PARTIAL (VC over-capture) Step 1 (backup) + Step 4 (guard) の transformation pipeline 削除を diff で確認済み。残存 gh issue comment --body-file / gh issue edit --body-file は issue contract の Guardrail に「gh issue edit --body-file 等の編集系コマンドは引き続き inline で使用してよい」と明記された保持対象。VC regex ^[^#]*\b(gh |jq |awk |...) が保持対象コマンドまで捕捉する VC 設計過広性が原因
AC10: .gitignore + github-ops.md PASS .gitignore は PR #24 (commit b1bc3aa) で対応済み。docs/dev/github-ops.md に「scripts 集約パターン」+「settings.local.json 個人用設定例」セクション追加を diff で確認

Allowed Paths 遵守: 変更 9 ファイルすべて issue 31 Allowed Paths 内。逸脱なし。

CI Verification: gh pr checks 37 — build/lint/test/typecheck すべて pass。前段 test-runner レポートも pnpm typecheck/lint/test/build: PASS。baseline_only: true(PR diff 起因失敗 0 件)。

検証コマンド結果: PR 本文の Verification Results テーブルに AC1-10 全件の結果記録あり。PARTIAL 2 件は根拠と共に Improvement Notes に説明記載。

scope 混入: なし。変更ファイルはすべて issue 31 In Scope に対応。

Blockers

なし

Non-blockers(任意改善)

  • AC6 VC: cd .claude && python3 -m pytest tests/ は実パスと不一致。PR 本文の Improvement Notes に uv run --with pytest python -m pytest .claude/skills/gemini-cli-headless-delegation/tests/ -q への修正案記載済み。別 Issue で follow-up 推奨
  • AC9 VC: grep -nE "^[^#]*\b(gh |jq |...)" が保持対象コマンドを捕捉する過広 regex。issue-body-authoring 側に「削除確認パターンは削除対象コードを literal で指定する」原則追記を follow-up 推奨
  • post-merge-cleanup SKILL.md Step 3 の inline python one-liner (python3 -c "import json,sys; ...") は削除対象外(issue contract に明記なし)だが、将来的に scripts 集約候補

LOOP_VERDICT

verdict: APPROVE
blockers: []
mergeable: MERGEABLE
mergeStateStatus: CLEAN
reviewed_head_sha: cf294b421bdde7fea1d33613434766763ab2d00c

@squne121

Copy link
Copy Markdown
Owner Author

impl-review-loop 完了 (2026-05-19T16:45:00Z)

  • iteration: 0
  • LOOP_VERDICT: APPROVE
  • termination_reason: approved
  • mergeable: MERGEABLE / CLEAN
  • merge は 未実行(人間判断待ち)

検証サマリ

  • AC1-5, 7-8, 10: PASS(8/10 完全 PASS)
  • AC6: PARTIAL — test_model_routing.py の 5 件 pyyaml 不在起因の pre-existing failure。PR diff 起因 0 件
  • AC9: PARTIAL — VC regex が保持対象の gh issue edit --body-file まで捕捉する設計問題。実装上は Step 1/4 inline 削除を達成
  • pnpm typecheck / lint / test / build: 全 PASS
  • baseline_only: true(PR 差分起因の失敗 0 件)

pr-reviewer 追加観測(Improvement Notes に補足)

  • post-merge-cleanup/SKILL.md Step 3 周辺に残存する inline python one-liner も次の集約候補(本 PR スコープ外、follow-up)

次アクション

人間がマージ判断。マージ後は post-merge-cleanup skill を起動して branch/worktree 整理 + follow-up Issue 確認を実施。

@squne121

Copy link
Copy Markdown
Owner Author

人間指摘
python3 と書いているところをuv での実行に変えてほしい。
/tmp/ だとルートしてになってしまわないか?プロジェクトルートの tmp/ で作業するように修正してほしい。

- backup-and-parse-issue.py: バックアップ先を /tmp/ から repo root の tmp/ へ
  - git rev-parse --show-toplevel で repo root を取得し tmp/ を mkdir
  - docstring の Usage を `uv run python3 ...` に更新
- edit-issue/SKILL.md: 全 python3 呼び出しを `uv run python3` に統一
  - reviewer_feedback / NEW_BODY / コメント本文の保存先を `tmp/` に統一(システム /tmp/ 廃止)
  - ISSUE_EDIT_RESULT_V1 の backup_file path 例を tmp/ に修正
- post-merge-cleanup/SKILL.md: 同様に `uv run python3` 統一
- .claude/settings.json: bare `python3 ...` allow を削除し `uv run python3 ...` のみ残置
  - permission allowlist を uv 経由に強制し、再現性のある実行を保証
- docs/dev/github-ops.md: scripts 集約パターンの記述を `uv run python3` に統一
  - 「uv 必須・bare python3 禁止」「一時ファイルは repo tmp/ へ」を運用ガイドラインとして明文化
- .gitignore: repo tmp/ 配下の一時バックアップを除外
  - tmp/issue_*_backup_*.md, tmp/issue_*_new_*.md, tmp/reviewer_feedback.md, tmp/edit_issue_*.md

Refs #31, addresses #37 review feedback (#issuecomment-4489050087)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@squne121

Copy link
Copy Markdown
Owner Author

人間指摘 (#issuecomment-4489050087) 反映完了

commit: bfa6a5d (push: cf294b4..bfa6a5d)

反映内容

  1. python3 → uv run python3 統一

  2. 一時ファイルを repo tmp/ 配下に統一(システム /tmp/ 廃止)

    • backup-and-parse-issue.py: git rev-parse --show-toplevel で repo root を取得し <root>/tmp/ に mkdir + 保存
    • edit-issue/SKILL.md: reviewer_feedback / NEW_BODY / コメント本文の保存先を tmp/ に統一
    • .gitignore: tmp/issue_*_backup_*.md / tmp/issue_*_new_*.md / tmp/reviewer_feedback.md / tmp/edit_issue_*.md を除外(tmp/ 自体は create-issue 用の作業領域として保持)
    • smoke test: uv run python3 .claude/skills/edit-issue/scripts/backup-and-parse-issue.py 31 → tmp/issue_31_backup_<ts>.md を正しく作成し JSON 返却を確認
  3. AC9 VC tightening(pr-reviewer 指摘の過広問題への部分対応)

    • Issue 本文 AC9 VC: gh 単体検出を除外(gh issue edit --body-file 等を保持対象として認識)
    • 残存 PARTIAL: gh api --jq '.field' の単純抽出パターン(5 ヶ所)は依然 hit するが、これは保持対象の query 用途。AC9 の本来意図(Step 1/4 transformation pipeline 削除)は満たしている → follow-up Issue で VC 仕様を「削除対象パターン literal 列挙型」に書き換え推奨

再検証結果(worktree)

Check Result
AC1 (backup-and-parse-issue.py) PASS
AC2 (guard-issue-body.py) PASS
AC3 (classify-git-state.py) PASS
AC4 (verify-anchors.sh) PASS
AC5 (uv run python3 -c allowlist 検査) PASS
AC6 (uv + pytest gemini-cli tests) PARTIAL (pre-existing pyyaml 5件、PR diff 起因 0件)
AC7 (no shell=True) PASS
AC8 (regex/allowlist validation in scripts) PASS
AC9 (jq/awk/heredoc 検出) PARTIAL (gh api --jq 単純抽出 5件残存 — VC 設計問題、follow-up)
AC10 (.gitignore + docs 個人用例) PASS
pnpm typecheck/lint/test/build all PASS

mergeable: MERGEABLE / merge_state_status: BEHIND(main ahead だが conflict なし)

PR 本文の Improvement Notes 追補

  • bare python3 の Bash allowlist 直接登録は禁止し、uv run python3 経由に統一する運用ルールを docs/dev/github-ops.md で明文化(再現性 + dependency lock 共有のため)
  • 一時ファイルは必ず repo ルート配下の tmp/ を使い、システム /tmp/ を使わない(プロジェクト外副作用回避 + cleanup 追跡性)
  • AC9 VC の「削除対象 literal 列挙型」化は follow-up Issue 候補(VC 設計のベストプラクティスとして body-authoring.md 追補も推奨)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

実装: オーケストレーション skill 内 bash を scripts/ 集約 + .claude/settings allowlist 整備で permission prompt を削減する

1 participant