Agent skill
setup-post-tool-use-hooks
プロジェクトの .claude/settings.json にPostToolUseフック(prettier, eslint等)を設定する。Use when user mentions hooks設定/フック設定/formatter hooks/PostToolUse/setup-hooks/setup-post-tool-use-hooks.
Install this agent skill to your Project
npx add-skill https://github.com/camoneart/claude-code/tree/main/skills/setup-post-tool-use-hooks
SKILL.md
PostToolUse Hooks 設定スキル
プロジェクトごとに適切なPostToolUseフックを .claude/settings.json に設定する。
前提条件チェック(必須)
設定前に必ず以下を確認すること:
1. フォーマッタ・リンターの検出
プロジェクトルートで以下を確認し、存在するツールだけをフックに追加する。
| ツール | 検出方法 |
|---|---|
| prettier | package.json の devDependencies、または .prettierrc* の存在 |
| eslint | package.json の devDependencies、または eslint.config.* / .eslintrc* の存在 |
| biome | package.json の devDependencies、または biome.json の存在 |
| ruff | pyproject.toml の [tool.ruff]、または ruff.toml の存在 |
| black | pyproject.toml の [tool.black] |
| gofmt | go.mod の存在 |
2. 既存設定の確認
.claude/settings.json が既に存在する場合は、既存の設定を壊さないようにマージする。
設定テンプレート
JavaScript/TypeScript プロジェクト(prettier)
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"command": "npx prettier --write \"$CLAUDE_FILE_PATH\" 2>/dev/null || true"
}
]
}
}
JavaScript/TypeScript プロジェクト(eslint + prettier)
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"command": "npx eslint --fix \"$CLAUDE_FILE_PATH\" 2>/dev/null; npx prettier --write \"$CLAUDE_FILE_PATH\" 2>/dev/null || true"
}
]
}
}
JavaScript/TypeScript プロジェクト(biome)
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"command": "npx biome check --write \"$CLAUDE_FILE_PATH\" 2>/dev/null || true"
}
]
}
}
Python プロジェクト(ruff)
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"command": "ruff format \"$CLAUDE_FILE_PATH\" 2>/dev/null; ruff check --fix \"$CLAUDE_FILE_PATH\" 2>/dev/null || true"
}
]
}
}
Python プロジェクト(black)
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"command": "black \"$CLAUDE_FILE_PATH\" 2>/dev/null || true"
}
]
}
}
Go プロジェクト
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"command": "gofmt -w \"$CLAUDE_FILE_PATH\" 2>/dev/null || true"
}
]
}
}
ワークフロー
- プロジェクトルートの
package.json、pyproject.toml、go.mod等を読み取る - 使用しているフォーマッタ・リンターを特定する
- 適切なテンプレートを選択する
.claude/settings.jsonに書き込む(既存設定があればマージ)- 設定内容をユーザーに報告する
注意事項
- 検出できたツールだけを設定する。推測で追加しない
2>/dev/null || trueを必ず付けて、エラーでClaudeの作業が止まらないようにする- 既存の
.claude/settings.jsonの他の設定(permissions等)を消さない
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
translating-technical-articles
Translates English technical articles (engineering blogs, documentation) to Japanese while preserving layout and structure. Use when the user asks to translate an article, convert English content to Japanese, or mentions translating a URL or technical blog post.
guiding-tdd-development
Guide Test-Driven Development with task splitting, Red-Green-Refactor cycle, and framework auto-detection. Use when developing features with TDD approach, fixing bugs test-first, or when user mentions "TDD", "テスト駆動開発", "test-first", "/tdd".
distributed-tracing
Implement distributed tracing with Jaeger and Tempo to track requests across microservices and identify performance bottlenecks. Use when debugging microservices, analyzing request flows, or implementing observability for distributed systems.
dependency-upgrade
Manage major dependency version upgrades with compatibility analysis, staged rollout, and comprehensive testing. Use when upgrading framework versions, updating major dependencies, or managing breaking changes in libraries.
stripe-integration
Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.
typescript-advanced-types
Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications. Use when implementing complex type logic, creating reusable type utilities, or ensuring compile-time type safety in TypeScript projects.
Didn't find tool you were looking for?