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.

Stars 5
Forks 0

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)

json
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Write|Edit",
        "command": "npx prettier --write \"$CLAUDE_FILE_PATH\" 2>/dev/null || true"
      }
    ]
  }
}

JavaScript/TypeScript プロジェクト(eslint + prettier)

json
{
  "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)

json
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Write|Edit",
        "command": "npx biome check --write \"$CLAUDE_FILE_PATH\" 2>/dev/null || true"
      }
    ]
  }
}

Python プロジェクト(ruff)

json
{
  "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)

json
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Write|Edit",
        "command": "black \"$CLAUDE_FILE_PATH\" 2>/dev/null || true"
      }
    ]
  }
}

Go プロジェクト

json
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Write|Edit",
        "command": "gofmt -w \"$CLAUDE_FILE_PATH\" 2>/dev/null || true"
      }
    ]
  }
}

ワークフロー

  1. プロジェクトルートの package.jsonpyproject.tomlgo.mod 等を読み取る
  2. 使用しているフォーマッタ・リンターを特定する
  3. 適切なテンプレートを選択する
  4. .claude/settings.json に書き込む(既存設定があればマージ)
  5. 設定内容をユーザーに報告する

注意事項

  • 検出できたツールだけを設定する。推測で追加しない
  • 2>/dev/null || true を必ず付けて、エラーでClaudeの作業が止まらないようにする
  • 既存の .claude/settings.json の他の設定(permissions等)を消さない

Expand your agent's capabilities with these related and highly-rated skills.

camoneart/claude-code

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.

5 0
Explore
camoneart/claude-code

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".

5 0
Explore
camoneart/claude-code

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.

5 0
Explore
camoneart/claude-code

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.

5 0
Explore
camoneart/claude-code

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.

5 0
Explore
camoneart/claude-code

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.

5 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results