hook-authoring

Author and audit cross-CLI runtime event hooks with deterministic guardrail enforcement.

Updated Oct 10, 2025
One-click install
npx skills add https://github.com/FFOO6866/lead2cash --skill hook-authoring-ffoo6866
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hook-authoring
Source: https://github.com/FFOO6866/lead2cash/tree/main/.claude/skills/hook-authoring
Command: npx skills add https://github.com/FFOO6866/lead2cash --skill hook-authoring-ffoo6866

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the problem of reliably authoring and auditing runtime hooks so they enforce guardrails consistently across Claude, Codex, and Gemini without unsafe timeouts, malformed outputs, or coverage gaps.

Core Features & Use Cases

  • Cross-CLI hook correctness: Ensures a single hook implementation can run under CC, Codex, and Gemini via the shared .claude/hooks/<name>.js entry point and normalized COC_RUNTIME payload handling.
  • Deterministic halting with disciplined output: Guarantees halting branches use the canonical lib/instruct-and-wait.js::emit() shape (including severity, reporting, and waiting requirements) rather than raw exits.
  • Timeout fallback and portability: Enforces mandatory setTimeout behavior to prevent session hangs and applies correct project-dir resolution across CLIs.
  • Coverage and safety alignment: Prevents “Bash-only” enforcement blind spots by requiring predicate bijection with .claude/codex-mcp-guard/policies.json and blocking divergence at sync time.

Quick Start

Use the hook-authoring skill to audit or implement a hook script named .claude/hooks/<name>.js and verify it follows the required timeout fallback, output discipline, and predicate-coverage bijection rules.

Frequently Asked Questions about hook-authoring

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

FAQPage Schema
How do I build cross-CLI runtime hooks that enforce guardrails in Claude, Codex, and Gemini?

Cross-CLI runtime hooks enforce guardrails by using a shared `.claude/hooks/<name>.js` entry point and normalized `COC_RUNTIME` payload handling to run consistently across Claude, Codex, and Gemini. This ensures deterministic event handling without unsafe timeouts or malformed outputs.

Why do my runtime hook sessions hang during guardrail enforcement?

Runtime hook sessions hang when mandatory `setTimeout` fallback behavior is missing from the hook script. Enforcing correct timeout fallback prevents indefinite session hangs while maintaining project-dir resolution across different CLI runtimes.

How do I ensure deterministic halting behavior in a custom guardrail hook?

Deterministic halting requires using the canonical `lib/instruct-and-wait.js::emit()` shape rather than raw exits. This enforces strict output discipline by including severity, reporting, and waiting requirements in the halt branch.

Do I need MCP guard policies for hook coverage across different CLIs?

MCP guard policies are required to prevent Bash-only enforcement blind spots. You must establish predicate bijection with `.claude/codex-mcp-guard/policies.json` and block divergence at sync time to ensure full coverage alignment.

What is the best way to audit an existing hook script for cross-CLI portability?

Auditing a hook script for cross-CLI portability involves checking it against required timeout fallback, output discipline, and predicate-coverage bijection rules. The hook must include mandatory SKILL.md discovery metadata and pass runtime validation via `COC_RUNTIME`.

Can I use a single hook implementation across multiple AI coding runtimes?

A single hook implementation can run across Claude, Codex, and Gemini by normalizing event payloads through the `COC_RUNTIME` variable. This cross-CLI portability prevents coverage gaps and ensures consistent guardrail enforcement without separate scripts.