Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 56 additions & 2 deletions .claude/commands/repo-maintenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,61 @@ fi
- 🔧 core.hooksPath を修正しました(壊れたパス → `.husky`)
- ❌ .husky ディレクトリ不在のため手動対応が必要

### 3.2.2 Check-file-length Setup Check
### 3.2.2 Husky v8 → v9 Migration Check

`.husky/_` 経由のフック実行(husky v8 スタイル)を v9 スタイルへ移行提案:

**確認ロジック:**

```bash
HOOKS_PATH=$(git config core.hooksPath 2>/dev/null || echo "")
IS_V8_STYLE=false
[ "$HOOKS_PATH" = ".husky/_" ] && IS_V8_STYLE=true
```

**v8 と v9 の違い:**

| 項目 | v8 スタイル | v9 スタイル |
| ---------- | -------------------------------------------- | ------------------------------ |
| hooksPath | `.husky/_` | `.husky` |
| フック実行 | `_/h` 経由で `.husky/pre-commit` を呼ぶ | `.husky/pre-commit` を直接実行 |
| 旧 shebang | `. "$(dirname -- "$0")/_/husky.sh"` 行が必要 | 不要(素のシェルスクリプト) |

**結果パターン:**

| 状態 | 対応 |
| --------------------------- | ------------------------------------ |
| `core.hooksPath = .husky` | ✅ v9スタイル済み |
| `core.hooksPath = .husky/_` | ⚠️ v8スタイル → full mode で移行提案 |
| 未設定 | ✅ スキップ |

**MODE が `full` かつ v8 スタイルの場合:**

```bash
# 1. hooksPath を v9 スタイルに更新
git config core.hooksPath ".husky"

# 2. 各フックファイルから旧 shebang を削除(存在する場合)
for hook in .husky/pre-commit .husky/pre-push .husky/commit-msg; do
[ ! -f "$hook" ] && continue
if grep -q "_/husky.sh" "$hook"; then
# 旧 husky v8 の source 行を削除
grep -v "_/husky.sh" "$hook" > "$hook.tmp" && mv "$hook.tmp" "$hook"
# #!/usr/bin/env sh を #!/bin/sh に統一
sed -i "" "s|#!/usr/bin/env sh|#!/bin/sh|" "$hook"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Replace BSD-only sed flag in Husky migration

The migration snippet uses sed -i "" ..., which is BSD/macOS-specific; on GNU sed (the default in Linux devcontainers/Codespaces) -i expects an optional suffix attached to the flag, so this form fails with sed: can't read ... instead of editing the hook file. In --mode full on repositories still using Husky v8, this can abort or partially apply the migration, leaving hooks unconverted on the primary Linux execution environment.

Useful? React with 👍 / 👎.

Comment on lines +399 to +401

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

tmp="$(mktemp)"
printf '#!/usr/bin/env sh\n' > "$tmp"

echo "Testing BSD-style: sed -i \"\" ..."
if sed -i "" 's|#!/usr/bin/env sh|#!/bin/sh|' "$tmp" 2>/dev/null; then
  echo "BSD-style in-place edit is supported here"
else
  echo "BSD-style in-place edit is NOT supported here"
fi

echo "sed version:"
sed --version 2>/dev/null | head -n1 || echo "BSD sed (no --version output)"

rm -f "$tmp"

Repository: keito4/config

Length of output: 166


🏁 Script executed:

fd "repo-maintenance.md" --type f

Repository: keito4/config

Length of output: 39


🏁 Script executed:

# Search for repo-maintenance in any location
find . -name "*repo-maintenance*" -o -name "*.md" | grep -i "maintenance" | head -20

Repository: keito4/config

Length of output: 95


🏁 Script executed:

# Check if .claude directory exists
ls -la .claude/ 2>/dev/null || echo ".claude directory not found"

Repository: keito4/config

Length of output: 815


🏁 Script executed:

# Check total lines in the file
wc -l ./.claude/commands/repo-maintenance.md

Repository: keito4/config

Length of output: 99


🏁 Script executed:

# Read lines around 399-401 with context
sed -n '390,410p' ./.claude/commands/repo-maintenance.md

Repository: keito4/config

Length of output: 616


🏁 Script executed:

# Get exact lines 399-401
sed -n '399,401p' ./.claude/commands/repo-maintenance.md

Repository: keito4/config

Length of output: 224


🏁 Script executed:

# Get broader context around line 400 to understand the full section
sed -n '375,415p' ./.claude/commands/repo-maintenance.md | cat -n

Repository: keito4/config

Length of output: 1740


🏁 Script executed:

# Check line 752 context
sed -n '745,760p' ./.claude/commands/repo-maintenance.md

Repository: keito4/config

Length of output: 761


Use a portable in-place edit for hook rewrites.

sed -i "" is BSD/macOS-specific and fails on GNU sed. In Linux/devcontainer environments this step will fail, breaking the migration workflow right where it's most likely to run.

Suggested fix
-    # #!/usr/bin/env sh を #!/bin/sh に統一
-    sed -i "" "s|#!/usr/bin/env sh|#!/bin/sh|" "$hook"
+    # #!/usr/bin/env sh を #!/bin/sh に統一(GNU/BSD sed 両対応)
+    tmp_hook="$(mktemp)"
+    sed 's|#!/usr/bin/env sh|#!/bin/sh|' "$hook" > "$tmp_hook" && mv "$tmp_hook" "$hook"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
grep -v "_/husky.sh" "$hook" > "$hook.tmp" && mv "$hook.tmp" "$hook"
# #!/usr/bin/env sh を #!/bin/sh に統一
sed -i "" "s|#!/usr/bin/env sh|#!/bin/sh|" "$hook"
grep -v "_/husky.sh" "$hook" > "$hook.tmp" && mv "$hook.tmp" "$hook"
# #!/usr/bin/env sh を #!/bin/sh に統一(GNU/BSD sed 両対応)
tmp_hook="$(mktemp)"
sed 's|#!/usr/bin/env sh|#!/bin/sh|' "$hook" > "$tmp_hook" && mv "$tmp_hook" "$hook"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/commands/repo-maintenance.md around lines 399 - 401, Replace the
macOS-only sed usage with a portable in-place edit: detect or avoid the
BSD-specific sed -i "" call and instead perform a portable edit flow for the
hook rewrite (the line invoking sed -i "" "s|#!/usr/bin/env sh|#!/bin/sh|"
"$hook"); for example, write the sed output to a temporary file and move it back
(similar to the grep temp approach) or use sed -i.bak and then remove the .bak
file so the same transformation works on both GNU and BSD sed without failing
the migration step.

chmod +x "$hook"
echo "🔧 $hook から旧 shebang を削除しました"
fi
done
Comment on lines +395 to +405

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

The migration only updates three hook names.

The text says 各フックファイルですが、実際には pre-commit / pre-push / commit-msg だけです。prepare-commit-msg など他の Git hooks を使う repo では移行が中途半端になります。ループを .husky/* ベースに広げるか、説明をこの 3 つ限定に寄せた方がよいです。

Suggested fix
-for hook in .husky/pre-commit .husky/pre-push .husky/commit-msg; do
-  [ ! -f "$hook" ] && continue
+for hook in .husky/*; do
+  [ ! -f "$hook" ] && continue
+  [ "$(basename "$hook")" = "_" ] && continue
+  [ "$(basename "$hook")" = ".gitignore" ] && continue
   if grep -q "_/husky.sh" "$hook"; then
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/commands/repo-maintenance.md around lines 395 - 405, The loop
currently iterates only over the three explicit hook names (".husky/pre-commit
.husky/pre-push .husky/commit-msg"), which contradicts "各フックファイル" and misses
other hooks like "prepare-commit-msg"; change the loop to iterate over all files
in the .husky directory (e.g., replace the explicit list with a glob like
".husky/*") so every hook is processed, and ensure the body
(grep/sed/chmod/echo) works for arbitrary hook filenames (update the echo text
if needed to avoid implying only those three hooks).

```

**結果:**

- ✅ v9スタイル(`.husky`)で設定済み
- 🔧 v8 → v9 へ移行しました(hooksPath 更新 + 旧 shebang 削除)
- ✅ スキップ(hooksPath 未設定)

### 3.2.3 Check-file-length Setup Check

pre-commit フックに `check-file-length` が含まれているか確認・追加:

Expand Down Expand Up @@ -695,7 +749,7 @@ npm install -D @biomejs/biome knip

## Setup (2/4)
├── Team Protection: ✅ Branch protection enabled
├── Husky: ✅ Git hooks configured\n├── hooksPath: ✅ Valid (.husky) (or 🔧 Fixed / ❌ Manual required)
├── Husky: ✅ Git hooks configured\n├── hooksPath: ✅ Valid (.husky) (or 🔧 Fixed / ❌ Manual required)\n├── Husky v8→v9: ✅ v9スタイル済み (or 🔧 移行しました / ✅ スキップ)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Split the sample summary into actual lines.

この fenced block だと \n は改行されず、そのまま表示されます。サンプル出力としては 3 行に分けた方が正しいです。

Suggested fix
-├── Husky: ✅ Git hooks configured\n├── hooksPath: ✅ Valid (.husky) (or 🔧 Fixed / ❌ Manual required)\n├── Husky v8→v9: ✅ v9スタイル済み (or 🔧 移行しました / ✅ スキップ)
+├── Husky: ✅ Git hooks configured
+├── hooksPath: ✅ Valid (.husky) (or 🔧 Fixed / ❌ Manual required)
+├── Husky v8→v9: ✅ v9スタイル済み (or 🔧 移行しました / ✅ スキップ)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
├── Husky: ✅ Git hooks configured\n├── hooksPath: ✅ Valid (.husky) (or 🔧 Fixed / ❌ Manual required)\n├── Husky v8→v9: ✅ v9スタイル済み (or 🔧 移行しました / ✅ スキップ)
├── Husky: ✅ Git hooks configured
├── hooksPath: ✅ Valid (.husky) (or 🔧 Fixed / ❌ Manual required)
├── Husky v8→v9: ✅ v9スタイル済み (or 🔧 移行しました / ✅ スキップ)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/commands/repo-maintenance.md at line 752, The fenced sample
currently contains literal "\n" sequences instead of real line breaks; locate
the fenced block containing the string "├── Husky: ✅ Git hooks configured\n├──
hooksPath: ✅ Valid (.husky) (or 🔧 Fixed / ❌ Manual required)\n├── Husky v8→v9:
✅ v9スタイル済み (or 🔧 移行しました / ✅ スキップ)" and replace it with three actual lines (one
per item) or a proper Markdown list so the output renders as three separate
lines rather than showing "\n" characters.

├── check-file-length: ✅ Configured in pre-commit (or 🔧 Added / ⏭️ Skipped)
├── Pre-PR Checklist: ✅ CI workflow exists
├── CLAUDE.md: ✅ Symlink to AGENTS.md
Expand Down