Skip to main content

Wrap any CLI command as a Claude Code hook - with correct exit codes, stderr, and JSON

Project description

hokum

Every CLI command already knows how to fail. hokum explains it to Claude Code properly.

hokum is a command-line tool that you can use to wrap any other CLI command as a Claude Code hook, dealing with the quirky semantics around exit codes, stderr, and JSON.

What Problem Does This Solve ?

Claude Code hooks look like ordinary shell commands, but Claude Code talks to them through a surprise-laden protocol all of its own — and ordinary CLI tools don't speak it:

  • Input arrives as JSON on stdin. The hook event (which tool ran, which file it touched, and so on) is delivered as a JSON document, not as command-line arguments. A tool like ruff check or eslint wants a file path in argv and has no use for a JSON blob.
  • Exit codes carry unusual meanings. 0 is success. 2 means "block with an error if relevant for this hook, and feed stderr back to Claude". Anything else — including the exit code 1 that nearly every linter, formatter, and test runner uses to report findings — is a non-blocking error: the output is shown to the user, but Claude never sees it.
  • Output routing depends on the outcome. Only stderr, and only with exit code 2, reaches Claude as feedback. Ordinary tools print their findings to stdout or stderr as they please, and exit 1 when something's wrong.

Put together, the naive setup — "run my linter after every edit" — produces a hook that fires, finds problems, exits 1, and is silently ignored. Everything looks configured, but nothing actually happens.

hokum sits between Claude Code and your command and translates in both directions: it extracts what the command needs from the event JSON, runs the command as the normal CLI tool it is, and maps the result onto the exit codes and streams that Claude Code actually respects.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hokum-0.3.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hokum-0.3.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file hokum-0.3.0.tar.gz.

File metadata

  • Download URL: hokum-0.3.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for hokum-0.3.0.tar.gz
Algorithm Hash digest
SHA256 400c8a0c882deece63cd81ba3f6ab6d9f27fe65a910e42336aa11d65ea72c8cc
MD5 9c8e84ea7e76e685327baa860c7feda0
BLAKE2b-256 9fcf4cb784907d9ce5bd4c12e26fa64a67995d8686c4d0dce468b39019ceb816

See more details on using hashes here.

Provenance

The following attestation bundles were made for hokum-0.3.0.tar.gz:

Publisher: manual-release.yml on garyd203/hokum

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hokum-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: hokum-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for hokum-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0316e6a8a3225615465d095c96c8c588713408f6fc237f0340e0252ddf629985
MD5 7dcf626cdb73ccd055c513440a2ac36a
BLAKE2b-256 966b9b49fe6c43613d0e73a3ea3b635b755d7b1b33932a597e1a44757f6a9f8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for hokum-0.3.0-py3-none-any.whl:

Publisher: manual-release.yml on garyd203/hokum

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page