Metadata-Version: 2.4
Name: handyhank
Version: 1.0.0
Summary: Your coding agent draws the plans; Hank does the work — a local LLM executes tasks inside a sandbox while the foreman designs and inspects.
Author: Handy Hank contributors
License-Expression: MIT
Project-URL: Homepage, https://github.com/Fr3nky88/handy-hank
Project-URL: Repository, https://github.com/Fr3nky88/handy-hank
Project-URL: Issues, https://github.com/Fr3nky88/handy-hank/issues
Project-URL: Changelog, https://github.com/Fr3nky88/handy-hank/releases
Keywords: llm,local-model,agent,sandbox,mcp,lm-studio,claude-code
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyYAML>=6.0
Provides-Extra: images
Requires-Dist: Pillow>=10.0; extra == "images"
Dynamic: license-file

# Handy Hank

Your coding agent draws the plans. Hank does the work.

[![CI](https://github.com/Fr3nky88/handy-hank/actions/workflows/ci.yml/badge.svg)](https://github.com/Fr3nky88/handy-hank/actions/workflows/ci.yml)
![License: MIT](https://img.shields.io/badge/license-MIT-blue)
![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue)
![Platforms: Linux, macOS](https://img.shields.io/badge/platform-linux%20%7C%20macos-lightgrey)
![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-blue)

## Contents

- [What it is](#what-it-is)
- [How it works](#how-it-works)
- [Features](#features)
- [Requirements](#requirements)
- [Quickstart](#quickstart)
- [Configuration](#configuration)
- [The task spec](#the-task-spec)
- [Commands](#commands)
- [Using Hank from your coding agent](#using-hank-from-your-coding-agent)
- [Security](#security)
- [Benchmarks](#benchmarks)
- [How Hank was tuned](#how-hank-was-tuned)
- [Limitations](#limitations)
- [Tips](#tips)
- [FAQ](#faq)
- [Contributing](#contributing)
- [License](#license)
- [Acknowledgements](#acknowledgements)

## What it is

Handy Hank lets a frontier coding agent — Claude Code, Codex CLI, Gemini CLI, Cursor, OpenCode and others — act as architect, foreman and inspector while a local LLM does the actual work on your machine. The goal: spend frontier-model tokens only on design, decisions and review; let a local GPU do the legwork.

Any task, not only code: documents, research, data analysis, media (video, images, 3D) through scripts and command-line tools. "Local" means cheap and open, not necessarily on the same machine — any OpenAI-compatible endpoint works (LM Studio, llama.cpp `llama-server`, Ollama, vLLM, a hosted open-model provider); API keys only via environment variables.

## How it works

The foreman writes a spec in YAML — the goal and the checks that prove it is done. `hank run` executes it as an agent loop with native tool calling against any OpenAI-compatible server, inside a sandbox. The worker runs the checks itself; finishing is refused while one fails. At the end Hank prints a short report: status, steps and segment, model summary, checks, outputs, changed files and local token usage. The foreman reviews it and records a verdict (`hank verdict <id> pass|fail "note"`).

```
foreman agent (Claude Code, Codex CLI, Gemini CLI...)
        | writes spec.yml: goal + checks
        v
   hank run spec.yml
        | agent loop with native tool calling, inside a sandbox
        v
local model server (LM Studio, llama.cpp, Ollama, vLLM)
        | the worker runs the checks itself; finish is refused while one fails
        v
report on stdout -> foreman reviews -> hank verdict pass|fail
```

## Features

- Any task, not only code — documents, research, data analysis and media through scripts and command-line tools. Domain lessons (video, 3D, docs, data, research) are picked by `topics:` in the spec.
- Sandboxed commands — the whole filesystem read-only except the project, the run's tmp, package caches and `writable_dirs`; credentials hidden; git read-only; Docker blocked unless `allow_docker: true` (details under Security).
- Checks gate finish — shell commands or judge checks defined in the spec; `finish` is refused while one fails.
- Staged specs — `steps:` split a long task into steps, each with its own goal and optional checks; a finished step restarts the conversation at the next one.
- Dynamic budget segments — when a segment's `max_steps` runs out, the checks are scored and the run gets another segment while they improve (at most 4), else it pauses for the foreman.
- Stall detection — repeated action, repeated error, monologue and ping-pong patterns trigger a warning, then a pause.
- Lessons per topic, profile and model — short facts injected into the system prompt; `hank lesson` adds one after each correction.
- Judge checks — for results only a viewer can verify (a chart is readable): a fresh request to the worker's or another model with criteria and files.
- Run history — every run recorded in its own folder (state, events, log); `hank stats` numbers per run, `--card` report card, `hank cost` foreman-side token ledger.
- Agent-agnostic — the CLI works with any agent that can run shell commands; an Agent Skill teaches the foreman when to delegate and how to write specs.

## Requirements

- Linux with bubblewrap (`bwrap`), or macOS (its `sandbox-exec` runs the sandbox; checked in CI only). On Windows, run
  Hank inside WSL2 (not tested): see the FAQ.
- Python 3.10 or newer
- An OpenAI-compatible model server with a local model loaded — LM Studio, llama.cpp `llama-server`, Ollama, vLLM; API keys only via environment variables
- Optional: Node + playwright-core for the browser tool; Pillow for image downscaling

## Quickstart

1. Install Hank:

   ```sh
   pipx install handyhank        # or: uv tool install handyhank
   ```

   or the latest code from GitHub: `pipx install git+https://github.com/Fr3nky88/handy-hank`

2. Start a model server such as LM Studio and load a model that supports tool calling. LM Studio's endpoint is `http://localhost:1234/v1/chat/completions`, the package default.

3. Write the config file `~/.config/handyhank/config.yml` (it overrides the package defaults), with the model's id as the server lists it (`curl http://localhost:1234/v1/models`):

   ```yaml
   url: http://localhost:1234/v1/chat/completions
   model: your-model-id
   profile: small
   ```

4. Write a spec outside the work folder — for example `spec.yml` in your home directory or /tmp, with an absolute path to the project:

   ```yaml
   title: add stopwords to wordfreq
   repo: /absolute/path/of/the/work/folder
   goal: |
     Add a --stopwords FILE option to the CLI that removes those words from the report.
     Keep the existing tests passing.
   checks:
     - name: tests
       cmd: python3 -m unittest -q
   ```

5. Run it — `hank run spec.yml` runs until done or paused and prints the report at the end:

   ```sh
   hank run spec.yml
   ```

   Exit codes: 0 = done, 3 = paused for the foreman (a question, out of steps, a stall, a server error), 1 = failed.

## Configuration

The config file is `~/.config/handyhank/config.yml` (or `$HANDYHANK_CONFIG`); the package defaults in `src/handyhank/default_config.yml` are overridden by it. Every key:

| Key | What it does | Example |
|---|---|---|
| `url` | Chat completions endpoint of the model server (package default: `http://localhost:1234/v1/chat/completions`) | `url: http://localhost:1234/v1/chat/completions` |
| `model` | The model name sent to the server (default: `local-model`) | `model: local-model` |
| `sandbox` | Run commands in the sandbox (bubblewrap on Linux, sandbox-exec on macOS); set `false` only if you accept no isolation (default: `true`) | `sandbox: true` |
| `vision` | Whether the worker can see images (default: `false`) | `vision: false` |
| `language` | Language of the summaries and reports (default: `en`) | `language: en` |
| `web_search` | How web search works: `foreman` (default; pauses for the foreman to search), `searxng` (needs `url`) or `brave` (needs `key_file`) | `web_search: {backend: foreman}` |
| `models` | Several OpenAI-compatible endpoints; each entry can set `url`, `model`, `profile`, `context_tokens` and `api_key_env`. The spec's `model:` picks one (default: the first in file) | see below |
| `default_model` | Which configured model is used when the spec does not pick one (default: the first entry of `models`, else the top-level settings) | `default_model: local` |
| `profile` | `small` (default) / `medium` / `large` — sets max steps per segment, explore budget, plan cadence and stall thresholds | `profile: small` |
| `context_tokens` | Tokens the model is loaded with; read from LM Studio or llama.cpp when possible, else 32k assumed with a warning: set it for servers that do not report it, such as Ollama or vLLM (default: none) | `context_tokens: 32768` |
| `api_key_env` | Name of an environment variable holding the API key — sent as a Bearer token, never stored in the config file (default: none) | `api_key_env: OPENAI_API_KEY` |
| `extra_body` | Extra JSON fields merged into every request body (default: `{}`) | `extra_body: {top_p: 0.9}` |
| `send_reasoning` | Whether reasoning content is sent back to the model (default: `false`) | `send_reasoning: false` |
| `temperature` | Sampling temperature (default: `0.2`) | `temperature: 0.2` |
| `max_tokens` | Reply cap per request in tokens (default: `24000`) | `max_tokens: 24000` |
| `timeout` | Seconds per request (default: `1800`) | `timeout: 1800` |
| `retry_waits` | Waits between retries on server errors, in seconds (default: `[5, 20, 60]`) | `retry_waits: [5, 20, 60]` |

Several endpoints — the top level keeps working as a single "default" model; with `models`, the spec's `model:` picks one and `default_model` sets the fallback:

```yaml
url: http://localhost:1234/v1/chat/completions
model: local-model
profile: small
models:
  fast:
    url: http://localhost:1234/v1/chat/completions
    model: local-model
    profile: small
  big:
    url: https://api.example.com/v1/chat/completions
    model: open-large
    api_key_env: OPENAI_API_KEY
default_model: fast
```

## The task spec

The foreman writes the spec in YAML, outside the work folder. Every field (one line each):

- `title` — short name of the task; shown in reports and `hank list`. Example: `title: add stopwords to wordfreq`
- `repo` — absolute path of the work folder (a repository or a plain folder). Example: `repo: /absolute/path/of/the/work/folder`
- `goal` — what "done" means, in prose; the first thing in the task message. Optional when every step has its own goal. Example: see the Quickstart spec
- `acceptance` — list of strings shown as acceptance criteria bullets (not enforced by code). Example: `acceptance: [tests pass, README updated]`
- `checks` — list of checks that gate finish; each has a `name` and either a `cmd` or a `judge` (see below). Example: see the Quickstart spec
- `steps` — optional staged plan; each step has its own `goal` and optional `checks`, run in order. Example: `steps: [{goal: part 1}, {goal: part 2}]`
- `outputs` — list of paths (relative to the project) that must exist and be non-empty at finish. Example: `outputs: [report.md]`
- `context_files` — list of files (relative to the project) whose content is injected into the first message. Example: `context_files: [README.md]`
- `topics` — list of domain topics; picks the lessons injected into the system prompt and, for media tasks, the toolkit. Example: `topics: [docs]`
- `tools` — extra tools to send, besides the core tools and those of the topics. Example: `tools: [browser]`
- `model` — picks one of the configured models from the config's `models:` section. Example: `model: fast`
- `worktree` — run in a git worktree instead of the project folder (default: false). Example: `worktree: true`
- `branch` — the new branch for the worktree, created from `base` (default: `handyhank/<run id>`). Example: `branch: hank/add-stopwords`
- `base` — git ref to create the worktree branch from (default: HEAD). Example: `base: main`
- `commit` — commit the changes at the end of a successful run (default: false). Example: `commit: true`
- `writable_dirs` — extra directories writable inside the sandbox, in addition to the project and caches. Example: `writable_dirs: [/tmp/scratch]`
- `env` — environment variables for the task's commands (e.g. `LC_NUMERIC=C` is set by default; override with this). Example: `env: {MY_VAR: value}`
- `allow_docker` — allow Docker inside the sandbox (default: false). Example: `allow_docker: true`
- `judge_model` — picks one of the configured models for judge checks (default: the worker's model). Example: `judge_model: big`
- `max_steps` — overrides the profile's steps per segment; the profile's other knobs (`max_explore`, `plan_every`, `max_segments`, the `stall_*` thresholds) can be overridden the same way. Example: `max_steps: 40`

Each check in `checks:` (and each step's own `checks:`) has a `name` and either a `cmd` or a `judge`:

- `name` — name of the check; shown in reports. Example: `name: tests`
- `cmd` — shell command for a check; must exit 0 (default timeout 1500 s). Example: `cmd: python3 -m unittest -q`
- `judge` — criteria string for a judge check: a fresh request to the worker's or another model with these files and this question. Example: `judge: "The chart is readable..."`
- `files` — list of paths (relative to the project) attached to a judge check; missing files fail it. Example: `files: [chart.png]`
- `timeout` — seconds before a command check fails (default 1500). Example: `timeout: 600`

A full spec with steps and checks looks like this:

```yaml
title: add stopwords to wordfreq
repo: /absolute/path/of/the/work/folder
goal: |
  Add a --stopwords FILE option to the CLI that removes those words from the report.
steps:
  - goal: implement the flag and its tests
    checks: [{name: unit-tests, cmd: python3 -m unittest -q test_cli}]
  - goal: update the README with the new option
checks: [{name: all-tests, cmd: python3 -m unittest -q}]   # run when the last step finishes
```

## Commands

| Command | What it does |
|---|---|
| `hank run spec.yml [--background]` | Start a task; prints the report at the end, or with `--background` the run id at once while the run goes on detached |
| `hank resume <id> [answer]` | Resume a task paused on a question (or with `--answer-file FILE`); `--background` as for run |
| `hank say <id> [text]` | Queue a note for a running task, or `--stop` to stop it (a resumable pause); refused once the run has ended |
| `hank verdict <id> pass\|fail [note]` | Record the foreman's verdict on a run after reviewing it |
| `hank report <id>` | Print the full report of a run (stdout) |
| `hank status <id>` | A snapshot of a run, with no model call: status, steps, minutes, tokens, the last steps and the question if it paused |
| `hank watch <id>` | Follow a running task; `--steps` also prints step events |
| `hank list` | List all runs with their status and title |
| `hank lesson <topic> <text...>` | Add a lesson for a topic (e.g. `video`, `3d`) to the system prompt |
| `hank stats [--json] [--card] [ids...]` | Numbers per run; `--card` prints one row per model |
| `hank cost [--since SINCE] [--until UNTIL] [--json] [paths...]` | Token usage in the foreman's session logs (each API call once); defaults to the newest Claude Code session of the current folder |
| `hank mcp` | An MCP server on stdio over these commands, for agents that call tools (see "Using Hank from your coding agent") |

## Using Hank from your coding agent

Install Hank first (see the Quickstart). The plugin then gives your agent two things: the skill, which says when to
delegate and how to write a spec, and the MCP server `hank mcp`, for agents that call tools rather than shell
commands. The same repository serves every agent below.

| agent | install | checked |
|---|---|---|
| Claude Code | `claude plugin install handy-hank --marketplace Fr3nky88/handy-hank` in a terminal; in a session, `/plugin marketplace add Fr3nky88/handy-hank`, then `/plugin install handy-hank@handy-hank` | used for every measurement in this README; a whole task run through `hank mcp`; the one-command install checked from a local copy |
| Codex CLI | `codex plugin marketplace add Fr3nky88/handy-hank`, then `codex plugin add handy-hank@handy-hank` | installed from a local copy; Codex 0.174 connects to `hank mcp`. With a local model Codex hides MCP tools behind its tool search, so the model used Hank through the CLI; not tried with an OpenAI model |
| GitHub Copilot CLI | `copilot plugin marketplace add Fr3nky88/handy-hank`, then `copilot plugin install handy-hank@handy-hank` | installed from a local copy: the skill and the MCP server are registered |
| Gemini CLI | `gemini extensions install https://github.com/Fr3nky88/handy-hank` | the extension validates |
| OpenCode | copy `skills/handy-hank` to `~/.config/opencode/skills/` and add the server below to `~/.config/opencode/opencode.json` | a whole task run through `hank mcp`, with a local model as OpenCode's own |
| any other agent | the CLI through its shell, or `hank mcp` as a stdio MCP server | |

OpenCode's MCP block:

```json
{"mcp": {"servers": {"hank": {"type": "local", "command": ["hank", "mcp"]}}}}
```

A call such as `hank_wait` can take minutes. The plugin asks for a 600-second timeout where the agent reads one; Codex
uses its own default of 60 seconds unless you set `tool_timeout_sec` under `[mcp_servers.hank]` in
`~/.codex/config.toml`.

The foreman writes the spec, reviews the report and records the verdict; Hank never decides what to do or whether it
is done.

## Security

The local model runs commands without a human approving each step, so the worst case must stay small: a mistake or a prompt injection can only touch the project. The sandbox (bubblewrap on Linux, sandbox-exec on macOS) applies this policy:

- **Writable** — the project folder, the run's tmp (mounted as `/tmp` on Linux; `$TMPDIR` on macOS, where `/tmp` is writable too), package caches (`~/.npm`, `~/.m2`, `~/.cache`, `~/.gradle`, `~/.cargo/registry`) and any `writable_dirs` from the spec
- **Read-only** — everything else, your home included: the model can read your files
- **Hidden** — credentials: `.ssh`, `.gnupg`, `.aws`, `.kube`, `.docker`, `.config/gh`, `.password-store` and `.local/share/keyrings` are masked, and `.git-credentials`, `.netrc`, `.claude/.credentials.json`, `.pgpass` and `.my.cnf` are bound to /dev/null
- **Blocked** — writes to git (no checkout, stash or reset of anyone's work; `commit: true` commits outside the sandbox) and Docker, unless `allow_docker: true` (the docker socket is masked otherwise)
- **Not isolated** — the network is open, and the task's commands inherit your environment variables, API keys included: start Hank from a shell without secrets you would not show the model. A hidden home and a clean environment are on the [roadmap](https://github.com/Fr3nky88/handy-hank/blob/main/docs/ROADMAP.md).

Set `sandbox: false` in the config only if you accept no isolation: every command then runs with your own permissions.

## Benchmarks

The bench is the local half of the evidence: six standard tasks in `bench/` (bugfix, feature, lint, api-change, data, video) plus harder ones, run by **Hank alone** — no foreman notes and no answers (a question or a pause would count as a failure), each run in a fresh work dir made by the task's `setup.sh`. Date: 2026-12-03. Model: inkling-2-mini (IQ3_S, LM Studio, Vulkan, 64k context, temperature 0.2, profile small, `send_reasoning` on), on one RX 6800 XT.

### Standard tasks

Each task's `check.sh` verifies more than the tests the model sees, with cases the tests do not try.

| task | what the model gets | result |
|---|---|---|
| bugfix | an invoicing package; a failing test of an invoice total with a refund | pass (3 runs) |
| feature | a word-count CLI; add `--stopwords FILE` with a test of it | pass (3 runs) |
| lint | a package with 29 ruff findings and two unformatted files | pass (3 runs) |
| api-change | an app written for geokit 1.x, with geokit 2.0 and its CHANGELOG in the repo | pass (3 runs) |
| data | a CSV of 61 orders: a Markdown table per month with a total and the best month, and a bar chart | pass (3 runs) |
| video | a 3 s 1280x720 title card on #1B2A4A with fades; `ffprobe` and raw frames checked | pass (3 runs) |

18/18 across the three runs of the easy six. The full set is 13 tasks; inkling passed 12/13 — the one failure is 3d-print, see below.

### Harder tasks

| task | what it checks | result (inkling-2-mini, one run each) |
|---|---|---|
| multifile-bug | a package of 6 modules; a booking test fails (a Sunday show priced as a weekday) | pass — 19 steps, 3.9 min |
| refactor | three readers with their own copy of the amount and date parsing: one shared module, the settings passed as parameters | pass — 23 steps, 8.2 min |
| web-page | a to-do list as a static page (ids and classes named, localStorage key and format given); checked in headless Chrome through playwright-core: adding, ticking, deleting, the count, two reloads, no console error or network request | pass — 11 steps, 3.3 min |
| research-offline | four questions about a fictional ferry (20 saved pages); answers in `answer.md`, each with its source page cited next to it | pass — 11 steps, 3.2 min |
| long-chain | a staged spec (3 steps of 2 functions each): parse an access log, count statuses and top paths, requests per UTC hour, a Markdown report in an exact form; checked per step | pass — 34 steps, 11.9 min |
| 3d-print-openscad | the same box with OpenSCAD instead of hand geometry: `make_box.py` writes `box.stl` and the checks verify it (bounding box, edges wound in opposite directions, no degenerate triangle) | pass — 33 steps, 9.3 min |
| 3d-print | a box with a lid lip: `make_box.py` writes `box.stl`; the checks verify the bounding box, every edge in exactly two triangles wound in opposite directions, no degenerate triangle, a positive volume within 1% of 14,988 mm3 and 13 rays along x, y and z | fail — four replies in a row cut at the reply cap (about 440 s each), no file written; over two runs it never wrote one (55 minutes) |

3D geometry is a measured limit of inkling-2-mini in this setup: on the hand-written box it reasons to the reply cap again and again without writing a file, while every other task passed. The same box with OpenSCAD passed in 9.3 minutes. The checks verify that the code works, not that it is well written — the foreman's review stays needed with small models.

### Other local models

One run per task, 2026-12-03 (spark ran all thirteen; minicpm and qwen ran the six easy ones only, because the full set took about five hours with spark):

| model | size, context | easy six | all thirteen | minutes, easy six | generated per request (median) | median model s | cut replies |
|---|---|---|---|---|---|---|---|
| inkling-2-mini (as above) | 128x1.8B MoE, IQ3_S, 64k | 18/18 (3 runs) | 12/13 | about 15 | 281 | 5.8 | 0 on the easy six |
| spark-x2.5-4b | 4.1B, F16, 64k | 4/6 | 6/13 | 147.5 | 2,034 | 10.0 | 12 on the easy six |
| minicpm5-2b | 2.6B, F16, 64k | 4/6 | not run | 16.0 | 239 | 3.5 | 0 |
| qwen3.8-27b-gsq-rco | 27B dense, IQ3_XXS, 32k then 24k | 4/6 at 32k, 6/6 with the two crashed tasks rerun at 24k | not run | 18.3 (5.2 for the reruns) | 379 | 8.7 | 0 |

spark per task (all thirteen): pass on api-change (28 steps, 20.5 min), bugfix (14, 7.9), data (18, 9.5), feature (25, 15.7), refactor (52, 35.0) and web-page (13, 7.1); a `model` pause on 3d-print (8.7 min), 3d-print-openscad (9.1), lint (31.9), long-chain (54.5), multifile-bug (21.5), research-offline (13.3) and video (62.0).

### The A/B: the paid foreman alone, with Hank, with a Haiku subagent

The question: does handing work to Hank save the paid foreman tokens, and against what? `bench/ab.py` runs Claude Code (`claude -p`, Opus 5.5) on the same task in three arms — **alone** (Opus does the work itself, no Agent tool), **Hank** (Opus gets a short guide to the hank CLI and no Agent tool) and **Haiku** (Opus may delegate to a subagent, model haiku). The tasks are 9: the 8 of the bench (bugfix, feature, data, api-change, lint, video, refactor, 3d-print) plus long-chain (a module of six functions with their tests, about 300 lines, a staged spec). Each cell runs in bubblewrap with a clean environment; checks run outside the sandbox after the session. Two settings: **fresh** (an empty conversation) and **full context** (every cell resumes a fork of one warm-up session that read 129k tokens of standard-library source; the warm-up's own usage is subtracted).

Usage is counted in tokens, as Claude Code reports it per model: prices change with the model and the plan, token
counts do not. Output tokens are the ones the foreman generates; input tokens are the ones it reads (cache reads, cache
writes and plain input), so every turn counts the whole conversation again.

| setting | arm | passed | Opus output tokens | Opus input tokens | turns | minutes |
|---|---|---|---|---|---|---|
| fresh | alone | 9/9 | 26,386 | 0.75M | 40 | 4.4 |
| fresh | Hank | 9/9 | 25,577 (-3%) | 1.41M (+88%) | 62 | 37.0 |
| fresh | Haiku | 9/9 | 22,716 (-14%) | 1.21M (+61%) | 51 | 8.9 |
| full | alone | 9/9 | 33,057 | 6.79M | 56 | 5.3 |
| full | Hank | 9/9 | 28,466 (-14%) | 7.37M (+9%) | 57 | 25.5 |
| full | Haiku | 9/9 | 27,195 (-18%) | 7.79M (+15%) | 57 | 9.0 |

The Haiku arm also used the subagent's own tokens (60,710 and 54,525 Haiku output tokens); Hank's tokens are local — 922k read and generated fresh, 685k in the full context.

What it shows:
- Delegating trades the foreman's output for input. With Hank the foreman generated 3% fewer tokens from a fresh session and 14% fewer deep in a long one, and read 88% and 9% more: the spec, the wait and the review take turns, and every turn rereads the conversation.
- Small changes do not pay: on a bug fix of a few lines the foreman generated 42% and 27% more tokens with Hank than alone, and read 82% and 68% more.
- It pays where the result is much longer than its description: on long-chain the foreman's output fell by 50% fresh and 51% in the full context (6,084 to 3,062 and 7,244 to 3,516 tokens), for 60% and 18% more input.
- A spec that spells the code out saves little: on refactor (specs describing each function) the foreman's output fell only 11% and 4%.
- Hank is the slowest arm: 5 to 8 times the foreman alone, 3 to 4 times the Haiku arm.
- Per-task figures are single runs and move a lot; read the totals, not the rows.

### Reproducing them

```sh
python3 bench/run.py --model <name>              # every task, with a model from your Hank config
python3 bench/run.py bugfix feature --repeat 2   # some tasks, twice each
python3 bench/ab.py bugfix --arms alone hank     # the A/B: runs Claude Code with your login, real usage
```

`bench/run.py` writes one JSONL row per run to `bench/results/<model>-<date>.jsonl`. `bench/ab.py` runs each cell in its own bubblewrap sandbox; its docstring and `docs/EVIDENCE.md` give the setup and the limits.

## How Hank was tuned

- It was developed and field-tested mostly with one small local model, inkling-2-mini (IQ3_S). Every number in this README comes from that model unless a table says otherwise.
- Only the `small` profile gets the HOW TO WORK lesson, the reading limits and the advice to stage specs.
- Every model uses the no-fail runs, stall detection, the dynamic budget, checkpoints, compaction, judge checks and the sandbox.
- The risk is overfitting to one model. inkling passed 12/13 of the full set (18/18 on the easy six); spark-x2.5-4b passed 6/13, minicpm5-2b 4/6 and qwen3.8-27b 6/6 on the easy six (see "Other models" above). Every one of spark's failures was the model reasoning up to the reply limit, not Hank, the spec or the sandbox.

## Limitations

From `docs/EVIDENCE.md` ("Where it struggles") and the limits of the A/B:
- **Linux and macOS.** macOS is checked in CI only, not in real runs; Windows only through WSL2, not tested.
- **Small tasks do not pay.** Delegating them saved the foreman few output tokens or none and made it read more (see the A/B), and Hank is 5 to 8 times slower.
- **Tuned on one model** (see "How Hank was tuned").
- **What small models get wrong:** 3D geometry by hand (inkling reasoned to the reply limit without writing a file, 55 minutes over two runs), holistic refactors, edits through bash scripts with quoting problems, long reasoning when confused.
- **The checks verify that the code works, not that it is well written.** Hank's code passed every check of the A/B but had more style issues than the foreman's own: review what you get.
- **The sandbox does not hide your home or your environment variables** (see Security).
- **One request at a time:** LM Studio served one request at a time here, so parallel runs queue.
- **The A/B's limits:** one run per cell, on small tasks; one foreman model and one local model; the warm-up context is source code read, not a real conversation. Per-task figures move a lot from run to run: read the totals, not the rows.

## Tips

- On LM Studio, `reasoning_effort: "none"` at the top level of a model's `extra_body` turns its reasoning off: none in two samples each for spark-x2.5-4b, minicpm5-2b and qwen3.8-27b, which still called the tool, with about 5x fewer tokens. "low", `chat_template_kwargs` and `think: false` did nothing measurable. Whether it helps on real tasks is not measured yet.

  ```yaml
  models:
    spark:
      model: spark-x2.5-4b
      extra_body: {reasoning_effort: "none"}
  ```

- If the server does not report the context size, Hank warns once and assumes 32k: set `context_tokens` to the size the model is loaded with.
- A community tip, not measured here: a q8_0 KV cache in LM Studio's load settings takes about half the memory of the default, which leaves room for a longer context.

## FAQ

**Does Hank save my foreman's tokens?** Where the result is much longer than its description, yes: on long-chain the foreman's output tokens fell by 50% fresh and 51% in the full context. On small tasks it saves few output tokens or none (-3% fresh, -14% deep in a long session) and the foreman reads more (+88% and +9%). Weigh the two by what each kind of token costs you; the README gives tokens, not money, because prices change with the model and the plan.

**Do I need a GPU?** You need a model server. Usually that is a local one on your GPU (LM Studio, llama.cpp, Ollama, vLLM), but any OpenAI-compatible endpoint works. The numbers here come from one RX 6800 XT with 16 GB.

**Can any coding agent use it?** Any shell-capable agent can drive the CLI; copying the skill to your skills folder (see "Using Hank from your coding agent") gives an agent that supports skills a short guide on when to delegate and how.

**What does Hank cost me in time?** It is the slowest arm: 5 to 8 times the foreman alone, 3 to 4 times the Haiku subagent (37.0 min vs 4.4 fresh; 25.5 vs 5.3 full).

**Is it safe?** Commands run in a sandbox (bubblewrap on Linux, sandbox-exec on macOS): writes outside the project are refused, git is read-only and credential files are hidden. The model can still read the rest of your home and your environment variables, and the network is open; see "Security". The checks prove that the work passes them, not that it is good: review what you get.

**Does it run on Windows?** Through WSL2, which is Linux: install Hank and bubblewrap inside it (`sudo apt install bubblewrap pipx`). A model server on the Windows side is reached from WSL at the host's address, or at `localhost` with WSL's mirrored networking. Not tested yet.

## Contributing

See [CONTRIBUTING.md](https://github.com/Fr3nky88/handy-hank/blob/main/CONTRIBUTING.md) — setup, rules, lessons, bug reports and a pull request checklist.

## License

MIT — see [LICENSE](https://github.com/Fr3nky88/handy-hank/blob/main/LICENSE).

## Acknowledgements

Ideas taken from, or tested against Hank's runs because of, other harnesses: OpenHands (stall detection and its thresholds), SWE-agent (a syntax check on edits; collapsing old tool outputs, on the [roadmap](https://github.com/Fr3nky88/handy-hank/blob/main/docs/ROADMAP.md)), Codex (a short final summary), Aider (whitespace-tolerant edits, tested and not needed) and mini-swe-agent (one action per reply, tested). The trajectories of Claude Opus and Haiku in Claude Code gave the working method of Hank's small-model lesson.
