From 246e22be329b61070db20c0f539bdcbea1f64144 Mon Sep 17 00:00:00 2001 From: Ryo Takahashi <38057616+HighBridgeDragon@users.noreply.github.com> Date: Thu, 25 Jun 2026 11:58:50 +0900 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20Claude=20Code=20=E3=81=AB=E7=B7=A8?= =?UTF-8?q?=E9=9B=86=E3=83=95=E3=83=83=E3=82=AF=20(biome=20=E6=95=B4?= =?UTF-8?q?=E5=BD=A2=20/=20=E6=A9=9F=E5=BE=AE=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E4=BF=9D=E8=AD=B7)=20=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit .claude/settings.json を追加し、編集系ツールに 2 つのフックを設定する。 - PostToolUse(Edit|Write): 編集した ts/tsx/js/jsx/json/css 等を biome (bunx @biomejs/biome) で自動整形し、pre-commit 前に整形を揃える - PreToolUse(Edit|Write): .env / .env.* / bun.lock への自動編集をブロックし、 資格情報・ロックファイルの誤編集を防ぐ フックコマンドは jq の CRLF 出力対策として tr -d '\r' を挟み、 シェルは bash 固定とする。MCP 設定はテンプレートには含めない。 Co-Authored-By: Claude Opus 4.8 (1M context) --- .claude/settings.json | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .claude/settings.json diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..8b437a0 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/claude-code-settings.json", + "hooks": { + "PreToolUse": [ + { + "matcher": "Edit|Write", + "hooks": [ + { + "type": "command", + "shell": "bash", + "statusMessage": "機微ファイルの編集を確認中…", + "command": "jq -r '.tool_input.file_path // empty' | tr -d '\\r' | { read -r f; b=$(basename \"$f\"); case \"$b\" in .env|.env.*|bun.lock) jq -nc --arg b \"$b\" '{hookSpecificOutput:{hookEventName:\"PreToolUse\",permissionDecision:\"deny\",permissionDecisionReason:($b+\" は機微ファイル/ロックファイルのため自動編集をブロックしました。手動編集が必要な場合はユーザーが直接行ってください。\")}}';; esac; }" + } + ] + } + ], + "PostToolUse": [ + { + "matcher": "Edit|Write", + "hooks": [ + { + "type": "command", + "shell": "bash", + "statusMessage": "biome で整形中…", + "command": "jq -r '.tool_input.file_path // .tool_response.filePath // empty' | tr -d '\\r' | { read -r f; case \"$f\" in *.ts|*.tsx|*.js|*.jsx|*.mjs|*.cjs|*.json|*.jsonc|*.css) bunx @biomejs/biome check --write \"$f\";; esac; } 2>/dev/null || true" + } + ] + } + ] + } +} From 89fb104e8d7ce7458ebf56c6deb20e058578622c Mon Sep 17 00:00:00 2001 From: Ryo Takahashi <38057616+HighBridgeDragon@users.noreply.github.com> Date: Thu, 25 Jun 2026 12:06:32 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E6=95=B4=E5=BD=A2=E3=83=95=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=82=92=20lockfile=20=E5=9B=BA=E5=AE=9A=E3=81=AE?= =?UTF-8?q?=E3=83=AD=E3=83=BC=E3=82=AB=E3=83=AB=20biome=20=E7=9B=B4?= =?UTF-8?q?=E5=8F=A9=E3=81=8D=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bunx @biomejs/biome は node_modules 未導入時にレジストリから最新版を 自動取得し(--no-install でも global cache の未検証版を実行)、 それを編集のたびに実行するサプライチェーン上の懸念があった。 node_modules/.bin/biome(未導入時は .exe フォールバック)を直接呼ぶ方式に変更し、 bun install が bun.lock の整合性ハッシュで検証して配置したバイナリのみを実行する。 未導入時は何もしない(フェイルセーフ。整形は husky pre-commit が担保)。 Co-Authored-By: Claude Opus 4.8 (1M context) --- .claude/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.claude/settings.json b/.claude/settings.json index 8b437a0..5e0a66e 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -22,7 +22,7 @@ "type": "command", "shell": "bash", "statusMessage": "biome で整形中…", - "command": "jq -r '.tool_input.file_path // .tool_response.filePath // empty' | tr -d '\\r' | { read -r f; case \"$f\" in *.ts|*.tsx|*.js|*.jsx|*.mjs|*.cjs|*.json|*.jsonc|*.css) bunx @biomejs/biome check --write \"$f\";; esac; } 2>/dev/null || true" + "command": "jq -r '.tool_input.file_path // .tool_response.filePath // empty' | tr -d '\\r' | { read -r f; case \"$f\" in *.ts|*.tsx|*.js|*.jsx|*.mjs|*.cjs|*.json|*.jsonc|*.css) b=node_modules/.bin/biome; [ -f \"$b\" ] || b=\"$b.exe\"; [ -f \"$b\" ] && \"$b\" check --write \"$f\";; esac; } 2>/dev/null || true" } ] }