file-granularity-auditlisted
Install: claude install-skill ttamakijp/dev-templates
# Skill: File Granularity Audit
[`source/rules/common/file-granularity.md`](../../source/rules/common/file-granularity.md)
の「目安 300 行 / 厳格上限 500 行」を **任意プロジェクトに対して機械適用**
し、🔴/🟡/🟢 三段階分類 + 分割候補提案までを 1 セッションで完了させる
health check skill。
## When to invoke
- ユーザが「ファイル分割 audit」「リファクタ前のチェック」「コード健康度」
と尋ねた時
- 月次運用(scheduled-task `monthly-file-granularity-audit` 起動時、未配置の
場合は本 skill から候補として提案)
- 大規模 refactor / 機能追加の **着手前** に技術的負債の現況を把握する時
軽量変更(バグ修正・既存 🟢 ファイルの小規模追記)では起動不要。
## 要件
- 1 ファイル目安 **300 行以下**、厳格上限 **500 行**([[file-granularity]] 準拠)
- 上限超過の検出 → 責務粗推定 → 分割候補提案を **1 回のセッションで完了**
- 自動生成 / フィクスチャ / migration は [[file-granularity]] の例外節準拠で除外
- 提案は「根拠付き」(class / object / 責務単位の grep ベース)
## 手順
### Step 1: 全ファイル行数集計
対象拡張子はプロジェクトに応じて拡張(既定は主要言語のみ):
```bash
# POSIX (Linux / macOS / Git Bash on Windows)
find . -type f \
\( -name "*.kt" -o -name "*.kts" \
-o -name "*.swift" \
-o -name "*.ts" -o -name "*.tsx" \
-o -name "*.py" \
-o -name "*.go" \
-o -name "*.rs" \) \
-not -path "*/build/*" \
-not -path "*/node_modules/*" \
-not -path "*/.git/*" \
-not -path "*/dist/*" \
-not -path "*/.gradle/*" \
-not -path "*/__pycache__/*" \
| xargs wc -l 2>/dev/null \
| sort -n -r \
| head -50
```
```powershell
# Windows PowerShell(Git Bash 不在環境)
Get-ChildItem -Recurse -File -Include *.kt,*.kts,*.swift,*.ts,*.tsx,*.py,*.go,*.rs `
| Where-Object { $_.FullName -notmatch '\\(build|node_modules|\.git|dist|\.gradle|__pycache__)\\' } `
| ForEach-Obj