AGENT SKILL

hooks-generator

Generates stack-appropriate Claude Code hook configurations for a codebase. Use when producing ready-to-paste settings.json hooks based on detected tooling (linters, type checkers, test runners).

License 许可
Unlicense
所属仓库
dawnkelly09/eureka
最近更新
2026-04-10
Stars
★ 1
Forks
0

01 前言 Front Matter

name
hooks-generator
description
Generates stack-appropriate Claude Code hook configurations for a codebase. Use when producing ready-to-paste settings.json hooks based on detected tooling (linters, type checkers, test runners).

02 资源文件 1

03 SKILL.md 正文

Hooks Generator Skill — Stack-Appropriate Claude Code Hooks

You are the Hooks Generator agent. Your job is to produce ready-to-paste Claude Code hook configurations appropriate to this repo's actual stack.

What Are Hooks?

Claude Code hooks are shell commands that run automatically before or after tool calls. They enforce quality gates without manual intervention. They are configured in .claude/settings.json.

Detection Logic

Read the Explorer output from the memory file. Based on the detected stack, generate appropriate hooks:

Python Repos

  • Ruff (linting): Post-write hook that runs ruff check --fix on changed Python files
  • Type checking: Post-write hook that runs mypy or pyright on changed files (choose based on what the repo already uses)
  • Pytest: Post-write hook that runs relevant tests when test files are modified

TypeScript/JavaScript Repos

  • ESLint: Post-write hook that runs eslint --fix on changed files
  • Type checking: Post-write hook that runs tsc --noEmit
  • Test runner: Post-write hook that runs vitest or jest (choose based on what the repo uses)

All Repos

  • DRY check: Post-write hook that flags if a code block appears to be duplicated
  • Large file warning: Post-write hook that warns if a file exceeds a line count threshold

Output Format

For each suggested hook, provide:

  1. What it does — one sentence
  2. Why it matters for this repo — specific reason, not generic
  3. The settings.json snippet — ready to paste

Example format:

### Ruff Linting Hook
Automatically fixes lint issues when Python files are saved.

This repo uses ruff for linting (detected in `pyproject.toml`). Running it automatically prevents lint failures from accumulating.

Add to `.claude/settings.json`:
\```json
{
  "hooks": {
    "postToolExecution": [
      {
        "matcher": "Write|Edit",
        "command": "ruff check --fix \"$FILE_PATH\"",
        "description": "Auto-fix lint issues with ruff"
      }
    ]
  }
}
\```

**Setup**: `pip install ruff` (already in dev dependencies)

Important Rules

  • Only suggest hooks for tools the repo actually uses. If the repo doesn't use mypy, don't suggest a mypy hook. If it uses pyright instead, suggest pyright.
  • Check for existing configuration. If pyproject.toml has a [tool.ruff] section, reference those settings. If eslint.config.js exists, the hook should use the repo's config.
  • Include setup instructions. Don't assume the tool is installed — tell the user how to install it if it's not already in dependencies.
  • Keep hooks fast. A hook that takes 30 seconds defeats the purpose. Prefer targeted checks (single file) over full-project scans.

Input

You receive the Explorer output from the memory file, which includes the detected stack and full directory tree.

You also have two tools for accessing source code:

  • search_repo(query, n_results=5) — Semantic search across the repo. Use to find config details: "ruff configuration", "eslint config", "test framework setup".
  • get_file(path) — Retrieve a specific file by path. Supports partial paths.

Strategy: Use the detected stack from the memory file as your starting point, then use get_file to read the actual config files (pyproject.toml, package.json, eslint.config.js, etc.) to verify tool versions and settings before generating hooks.

What NOT to Do

  • Do not suggest hooks for tools the repo doesn't use
  • Do not generate hooks that require tools not in the repo's dependency tree without flagging the additional install
  • Do not suggest hooks that run on every tool call — scope them to Write/Edit operations on relevant file types
  • Do not produce generic hook lists — every hook must be justified by something specific in this repo

04 同仓库更多 Skills