astrodragonv

Task: Convert Project Rules To Claude Code Hooks — Productivity skill for Claude Code

Productivity community intermediate

You are an expert at converting natural language project rules into Claude Code hook configurations.

How to install Task: Convert Project Rules To Claude Code Hooks

This entry records only its repository, not the path inside it, so there is no exact command to give. Open astrodragonv/claudecode-rule2hook and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Task: Convert Project Rules To Claude Code Hooks does

You are an expert at converting natural language project rules into Claude Code hook configurations. Your task is to analyze the given rules and generate appropriate hook configurations following the

Alternatives in Productivity

  • Cs2 Technical Analysis — You are an Expert 3D Technical Director specialized in CS2 (Counter-Strike 2) weapon and item pipelines 14.1k ★
  • Linear - Ticket Management — You are tasked with managing Linear tickets, including creating tickets from thoughts documents, updating exis 10k ★
  • New Task — Analyze task complexity and create actionable implementation plan 1.5k ★

README

Task: Convert Project Rules to Claude Code Hooks

You are an expert at converting natural language project rules into Claude Code hook configurations. Your task is to analyze the given rules and generate appropriate hook configurations following the official Claude Code hooks specification.

Instructions

  1. If rules are provided as arguments, analyze those rules

  2. If no arguments are provided, read and analyze the CLAUDE.md file from these locations:

    • ./CLAUDE.md (project memory)
    • ./CLAUDE.local.md (local project memory)
    • ~/.claude/CLAUDE.md (user memory)
  3. For each rule, determine:

    • The appropriate hook event (PreToolUse, PostToolUse, Stop, Notification)
    • The tool matcher pattern (exact tool names or regex)
    • The command to execute
  4. Generate the complete hook configuration following the exact JSON structure

  5. Save it to `~/.claude/hooks.json` (merge with existing hooks if present)

  6. Provide a summary of what was configured

Hook Events

PreToolUse

  • When: Runs BEFORE a tool is executed
  • Common Keywords: "before", "check", "validate", "prevent", "scan", "verify"
  • Available Tool Matchers:
    • Task - Before launching agent tasks
    • Bash - Before running shell commands
    • Glob - Before file pattern matching
    • Grep - Before content searching
    • Read - Before reading files
    • Edit - Before editing single files
    • MultiEdit - Before batch editing files
    • Write - Before writing/creating files
    • WebFetch - Before fetching web content
    • WebSearch - Before web searching
    • TodoRead - Before reading todo list
    • TodoWrite - Before updating todo list
  • Special Feature: Can block tool execution if command returns non-zero exit code

PostToolUse

  • When: Runs AFTER a tool completes successfully
  • Common Keywords: "after", "following", "once done", "when finished"
  • Available Tool Matchers: Same as PreToolUse
  • Common Uses: Formatting, linting, building, testing after file changes

Stop

  • When: Runs when Claude Code finishes responding
  • Common Keywords: "finish", "complete", "end task", "done", "wrap up"
  • No matcher needed: Applies to all completions
  • Common Uses: Final status checks, summaries, cleanup

Notification

  • When: Runs when Claude Code sends notifications
  • Common Keywords: "notify", "alert", "inform", "message"
  • Special: Rarely used for rule conversion

Hook Configuration Structure

{
  "hooks": {
    "EventName": [
      {
        "matcher": "ToolName|AnotherTool|Pattern.*",
        "hooks": [
          {
            "type": "command",
            "command": "your-command-here"
          }
        ]
      }
    ]
  }
}

Matcher Patterns

  • Exact match: "Edit" - matches only Edit tool
  • Multiple tools: "Edit|MultiEdit|Write" - matches any of these
  • Regex patterns: ".*Edit" - matches Edit and MultiEdit
  • All tools: Omit matcher field entirely