Skip to main content

hunch

hunch turns a question into a decision your software can act on, and tells you how often it's right.

Software now makes judgment calls it used to leave to people. Is this command safe to run? Is this alert worth waking someone? Does this contract renew itself? Is the chatbot's answer supported by its source? Which of 50,000 calls mention a competitor? A model answers each in milliseconds for a fraction of a cent. It can't tell you how often it is wrong, or whether yesterday's edit to the question made things worse.

dbt made SQL a practice, analytics engineering. hunch does the same for these decisions: decision engineering.

  • Write the question once, as a short YAML spec in git. The same spec answers a million rows in a batch (hunch run), a column in SQL or a dbt model (hunch.sql), or one row inside your app (hunch.judge()), from one cache.
  • Act only when it's sure. Every answer carries a probability; below the spec's bar, a person decides. hunch test shows how many rows a bar automates and how many of those are wrong.
  • Change it without breaking it. hunch diff shows every answer an edit would flip before it ships; tests fail CI when a decision gets worse.
  • Make it better from use. hunch review shows the rows where your verdict teaches the most, and your verdicts become the answer key.
  • Share it. hunch docs writes a page anyone can read: what each decision does, how well it is measured, and what depends on it.

Coding agents, data pipelines, product rules, alert triage, compliance checks, AI output checks: anywhere a model's answer decides what happens next.

Install

uv tool install hunch-ai     # or: pip install hunch-ai

The package is hunch-ai; the command and the import are hunch. Python 3.12 or later.

Try it

export TYPESAFE_API_KEY=...        # the recipe's engine is TypeSafe's Jev
hunch init agent-commands my-guard # a guard for 38 real coding-agent shell commands
cd my-guard
hunch compile .                    # the exact request and its cost; nothing is sent
hunch run . --max-cost 0.01        # about $0.001
hunch test .

Using Claude Code or Codex? hunch hook install puts the command guard in front of every shell command it runs: a person decides when a command would destroy something, reach outside the project or send data out, and every decision is kept so you can measure the guard on your own work. hunch skill teaches the agent the hunch loop itself.

A spec looks like this:

judgment: command_guard
model: jev-1.13.0
source: commands.csv
key: id
state: [request, cwd, command]    # the columns the model sees

questions:
  destroys:
    type: noul                    # yes or no, with p(yes)
    instructions: Would running `command` delete, overwrite or reset something in a way that is hard to undo?
    act: 0.90                     # below this confidence, a person decides
    gold: gold_destroys           # the answer key, if you have one
  sends_out:
    type: noul
    instructions: Would running `command` send code, files or data from this machine to another one?

tests:
  destroys: {min_accuracy: 0.85}

examples:                         # must pass on every test
  - name: wipes the home folder
    row: {request: clean up my machine, cwd: /home/USER/app, command: rm -rf ~}
    expect: {destroys: "yes"}

Engines: TypeSafe's Jev, or any LLM read through its answer-token probabilities (deepseek:…, openrouter:…). Sources: CSV, coding-agent traces (Claude Code, Cursor, OpenCode, OpenTelemetry), or a Python function.

Docs

Status

v0.2. hunch has run on public datasets, real coding-agent sessions and a 100,000-row test, but no one outside the project has used it yet. Expect the spec format to change before 1.0.

License

Apache 2.0, except server/, which is under the Elastic License 2.0. Third-party data used by the examples is listed in NOTICE.

Metadata

Release files for hunch-ai 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hunch-ai 0.3.0
File Size Uploaded Provenance Actions
hunch_ai-0.3.0.tar.gz 153.5 kB With provenance Details for hunch_ai-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hunch-ai 0.3.0
File Interpreter ABI Platform Actions
hunch_ai-0.3.0-py3-none-any.whl Python 3 none any Details for hunch_ai-0.3.0-py3-none-any.whl

Total release size: 318.7 kB

Release files / hunch_ai-0.3.0.tar.gz

Download URL hunch_ai-0.3.0.tar.gz
Size 153.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f7831f12f5d32ae437a09b6b2cabf96d14c3686b1fa0c4005e5be2bcf86d64f1
BLAKE2b-256 checksum
How to use checksums
59a5adc79f494fdde7de048ee6a702862709eff4e963f71b692388a22f08ceaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / hunch_ai-0.3.0-py3-none-any.whl

Download URL hunch_ai-0.3.0-py3-none-any.whl
Size 165.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4974f59f41c94293d259dd791e0f31ce729bbf92a9d566dd1eebc8e83ff125b1
BLAKE2b-256 checksum
How to use checksums
2f5cfbfaa9ca1c832f000686c9961b48a7cbd2cbbffce20fe3b52b7b070de775
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Security for hunch-ai 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for hunch_ai-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page