Skip to content
Development
Command

/from-hook

Convert Python SDK hooks to declarative rules

From plugin
claude-night-market
343162 skills60 agents162 commands1 MCP
> /plugin marketplace add athola/claude-night-market

Command definition

from-hook.md
name: from-hook
description: Convert Python SDK hooks to declarative rules

/hookify:from-hook

Convert Python SDK hooks to declarative hookify rules.

Usage

/hookify:from-hook <hook_file.py>           # Convert single hook
/hookify:from-hook --scan <hooks_dir>       # Scan directory
/hookify:from-hook <hook.py> -o rules.md    # Output to file

Run

python3 "${CLAUDE_PLUGIN_ROOT}/scripts/hook_to_hookify.py" $ARGUMENTS

The script prints each hook it did not convert, with the reason, to stderr as a `Not converted:` line. It exits 1 when no hook converted. Report the generated rules and every `Not converted:` line.

What It Does

1. Parses Python hook AST 2. Extracts regex patterns, string checks, startswith/endswith 3. Generates equivalent hookify rule YAML 4. Reports unconvertible hooks (network, file I/O, complex logic)

Example

Input hook. The converter reads the hook type from the filename (`pre_tool_*.py`) or from a `PreToolUse`-style comment, as here:

# PreToolUse
import re
def hook(context):
    if re.search(r"rm -rf /", context["command"]):
        return {"action": "block", "message": "Dangerous!"}

Output rule:

---
name: block-rm-rf
event: bash
pattern: 'rm -rf /'
action: warn
---

Every generated rule is `action: warn`. Review it, then change it to `block` by hand where the original hook blocked.

Limitations

Cannot convert hooks with:

  • Network calls (API requests)
  • File I/O operations
  • Complex conditional logic
  • External dependencies

See Also

  • `hookify:rule-catalog` - Browse available rules
  • `hookify:install` - Install rules
Read more
@athola
Ships withclaude-night-market

A plugin marketplace for Claude Code. Install only the plugins you need to run git workflows, code review, spec-driven development, and autonomous agents from inside your Claude Code session.

343200 skills60 agents1 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
343
Star history of athola/claude-night-market on GitHub, a chart by star-history.com

Other commands on claude-night-market.

More commands from other plugins.

build
Auto-invoked

build

Command

Implement tasks incrementally — build, test, verify, commit. Add "auto" to run the whole plan in one approved pass.

@addyosmani@addyosmaniInstall Command