hooks-mechanization

Convert Claude Code rules into deterministic lifecycle hooks with templates and debugging guides.

10|3|Updated Mar 7, 2026
One-click install
npx skills add https://github.com/Cynthia1070711/PHYCOOL_Tools --skill hooks-mechanization-cynthia1070711
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hooks-mechanization
Source: https://github.com/Cynthia1070711/PHYCOOL_Tools/tree/main/config-templates/claude/skills/hooks-mechanization
Command: npx skills add https://github.com/Cynthia1070711/PHYCOOL_Tools --skill hooks-mechanization-cynthia1070711

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve? Prompt-based rules in CLAUDE.md rely on the model's self-discipline and can be ignored; this Skill converts those rules into Claude Code hooks that execute deterministically at lifecycle events, guaranteeing enforcement instead of requesting it. ## Core Features & Use Cases - Rule-to-Hook Conversion Playbook: A 7-step process covering observable signal identification, lifecycle event selection (21 events), handler type choice (command/http/prompt/agent), script authoring, settings.json registration, testing, and rule retirement. - Copy-Paste Templates: Ready-made Node.js hook skeletons and five templates covering PreToolUse blocking, PostToolUse context injection, SessionStart injection, Stop verification, and async logging, tuned for Windows 11 + PowerShell 5.1 environments. - Debugging & Anti-Patterns: A 5-step troubleshooting flow plus 20 documented real-world failure cases (JSON pollution, infinite Stop loops, timeout misconfiguration, path escaping). - Use Case: A team wants to enforce "read a file before editing it" across all sessions. Use this Skill to build a PreToolUse hook that tracks reads and blocks edits to unread files, then retire the corresponding prompt rule. ## Quick Start Ask the AI to convert a specific rule from .claude/rules into a hook, for example: turn the encoding-discipline rule into a PreToolUse hook using this skill.

Frequently Asked Questions about hooks-mechanization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert a Claude Code rule into a hook?

Follow the 7-step playbook: identify the rule's observable signal, pick the matching lifecycle event (e.g., PreToolUse for pre-execution checks), choose a handler type, adapt the Node.js skeleton script, register it in settings.json, test with piped JSON input, then retire the original rule after the hook proves stable.

What is the difference between command, prompt, and agent hook types?

Command hooks run shell scripts for deterministic checks like regex matching. Prompt hooks send the input to an LLM for semantic judgment returning {ok: bool}. Agent hooks spawn a subagent with Read/Grep/Glob tools for cross-file verification, and are the slowest and most expensive option.

Why does my Stop hook cause an infinite loop?

A Stop hook that always exits with code 2 forces Claude to continue forever. The hook must check the stop_hook_active field in stdin and exit 0 when it is true, allowing Claude to stop after the first intervention.

Why is my hook JSON output not being parsed by Claude Code?

JSON parsing fails when stdout contains non-JSON text, typically from shell profile welcome messages or console.log debug statements. Use bash --noprofile --norc, send debug output only to stderr via console.error, and remember exit code 2 ignores JSON entirely.

Do hook changes in settings.json apply immediately?

No. Claude Code snapshots hooks at session start, so edits to settings.json do not hot-apply. Run /clear to start a new session or restart the CLI, then verify registration with the /hooks command.

When should a hook be async versus synchronous?

Use async only for side effects like logging, telemetry, or cache warming, since async hooks cannot block actions or inject context. Any hook that must influence Claude's behavior, such as blocking a dangerous command, must run synchronously.