Skip to content

cli

cli

example_hook_source

example_hook_source() -> str

Read the bundled example.py scaffold from templates/example_hook.py.tmpl.

show_logs

show_logs(
    session: str | None = None, tail: int | None = None
) -> None

Print a captain-hook session log.

Parameters:

Name Type Description Default
session str | None

A session id, or a transcript path (hashed via session_hash) to locate its log file. When None, the most recently modified log is shown.

None
tail int | None

When set, print only the last tail lines.

None

cli

cli(
    ctx: Context, hooks: str | None, root_path: str | None
) -> None

Captain Hook — declarative hook framework for Claude Code lifecycle events.

generate_settings_cmd

generate_settings_cmd(
    state: CliState,
    hooks_dir: str,
    no_merge: bool,
    from_source: str,
) -> None

Generate Claude Code settings JSON for .claude/settings.local.json.

test

test(state: CliState, json_output: bool) -> None

Run inline tests from all registered hooks.

init

init(state: CliState) -> None

Scaffold hooks directory, bin script, and settings.

logs

logs(session: str | None, tail: int | None) -> None

View a recent captain-hook session log.