authoring-hooks

Drafts, fixes, and extends tested capt-hook Python hooks from user corrections.

13|Updated Jun 2, 2026
One-click install
npx skills add https://github.com/yasyf/captain-hook --skill authoring-hooks-yasyf
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: authoring-hooks
Source: https://github.com/yasyf/captain-hook/tree/main/captain_hook/skills/authoring-hooks
Command: npx skills add https://github.com/yasyf/captain-hook --skill authoring-hooks-yasyf

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Repeatedly correcting an AI coding agent wastes effort because the correction is forgotten by the next session. This Skill turns one durable user correction into a typed, inline-tested Python hook in .claude/hooks/ that enforces the rule automatically on every future event. ## Core Features & Use Cases - Create mode: Converts a verbatim user correction into a new .claude/hooks/<slug>.py file, picking the right primitive (hook(block=True), gate, nudge, lint, block_command) and writing the narrowest firing condition plus inline tests. - FIX mode: Amends a misfiring hook with the narrowest amendment (tightened condition, re-fire guard, severity demotion) and a mandatory regression test reproducing the misfire. - EXTEND mode: Broadens an existing hook to cover a newly mined rule without weakening its existing tests. - Use Case: After telling the agent "stop using pip — this repo is uv-only" for the third time, invoke this Skill to generate a uv_not_pip.py hook that warns on pip install, allows uv add, and passes uvx --isolated capt-hook test before going live. ## Quick Start Ask the agent to author a hook from the correction "never force-push to main" and verify it with capt-hook test.

Frequently Asked Questions about authoring-hooks

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

FAQPage Schema
How do I turn a user correction into a Claude Code hook?

Restate the correction as a rule, pick the primitive (block=True hook for enforcement, gate for stop checks, nudge for advice), then write a .claude/hooks/<slug>.py file with the narrowest condition, a message quoting the correction, and inline tests. Verify with uvx --isolated capt-hook test.

What is the difference between gate, nudge, and hook with block=True in capt-hook?

gate and nudge are one-shot advisories that throttle after a few fires, so they never enforce. An always-on guard for safety or correctness must use hook(..., block=True) or block_command, which fires on every matching event.

How do I fix a capt-hook hook that fires on the wrong commands?

Amend the existing hook file rather than writing a new one: tighten the condition with structural predicates like Runs or a CommandSchema, add a skip_if carve-out, or demote block to Warn. Always add a regression test asserting the misfiring input now returns Allow().

Why must capt-hook hooks pass tests before going live?

Every event is already registered by the plugin, so a hook file that raises at import errors on every event and wedges the session. Running uvx --isolated capt-hook test proves the module imports, conditions match, and messages render before dispatch.

When should a style guide not become a capt-hook hook?

A whole style guide should not be hand-written as lint or hook rules. The authoring skill delegates that case to the captain-hook:translating-styleguides skill, which owns rule atomization and the style.py enforcement report.