Scroll to navigation

HAX(1) User Commands HAX(1)

NAME

hax - minimalist terminal-native coding agent

SYNOPSIS

hax [options] [prompt...]
hax {-p|--json} [options] [prompt]
hax {-c|--resume[=ID]} [options] [prompt]

DESCRIPTION

hax is a single small binary that acts as a coding agent in the terminal. It talks to OpenAI, Anthropic, OpenRouter and compatible providers, to a ChatGPT/codex account, or to local models through llama.cpp and ollama. Unlike a web chat it runs in the native terminal scrollback, keeps the working directory as the unit of context, reads and edits files, and runs commands as a subprocess.

It extends through configuration, markdown files and subprocesses rather than a plugin runtime. There are no MCP marketplaces, no IDE panels, and no per-command permission prompts.

With no arguments hax starts an interactive REPL. In one-shot mode the final answer goes to standard output, while the provider banner, usage statistics, errors and the resume hint go to standard error, so hax -p is safe to pipe without losing diagnostics.

hax is not a security boundary. It executes shell commands on the model's behalf without per-command approval. Use operating-system-level isolation for untrusted work.

OPTIONS

Run non-interactively to completion and print the final assistant message to standard output. The prompt is taken from the positional arguments, joined with spaces, or from standard input when no argument is given and standard input is not a terminal.
One-shot mode that implies -p, writing the run's session records to standard output as JSON Lines, one record per line, closed by a result record carrying the outcome, final text, usage and session id. The standard error banner and statistics are omitted; errors and warnings still go there.
Resume the most recent conversation recorded for the current directory.
Resume a past conversation in the current directory, restoring the provider, model, effort and preset it last used. Without an argument a picker is shown, which requires a terminal; with an id, or a unique prefix of one, the run continues without prompting. A command line selection flag overrides the restored choice and is recorded in the resumed session.
Do not record this conversation. Nothing is left to resume afterwards, and prompts are not added to the Ctrl-R recall. Earlier sessions and prompts stay readable.
Send only the prompt text: no base system prompt, no environment section, no AGENTS.md, no skills and no tools. Useful as a barebones chat interface.
Run without project and delegation context: no AGENTS.md, no skills, no subagent section. The environment section, the tools and the base system prompt remain, unlike --raw.
Select the backend for this run. One of codex, openai, anthropic, openrouter, opencode-zen, opencode-go, llamacpp, ollama, or a provider defined in the configuration file.
Select the model for this run.
Select the reasoning effort for this run, where the provider supports it.
Apply the named preset, a presets.NAME selection from the configuration file. A preset is applied first and explicit provider, model and effort flags are layered over it.
Show usage information and exit.
Show the version and exit.

The four selection flags apply to the current process only, are not persisted, and take priority over every other source. Settings are resolved in this order, first defined value winning:

current-process override → resumed conversation → environment → state file → configuration file → built-in default

INTERACTIVE COMMANDS

Type /help inside the REPL for the authoritative live list.

/new [preset]
Start a fresh conversation, optionally with a preset. /clear is an alias.
/resume
Pick a past session for this directory.
/fork [n]
Create a new session branching before an earlier prompt. /fork 0 clones the current tip. Prefer it over /undo when trying an alternative, since the original session stays intact.
/undo [n]
Permanently truncate this session before an earlier prompt. It rewrites both the conversation memory and the session file, and has no redo.
/provider
Choose a provider, model and effort.
/model
Choose a model and effort for the current provider.
/effort
Choose the reasoning effort, where supported.
/preset [name]
Apply a configuration-defined preset.
/preset-save name [tint]
Save the current provider, model and effort as a preset.
/config [key [value]]
Show the resolved value, source and description of each setting, or set one for this process. Provider, model, effort and preset have their own commands, and API keys are only ever reported as set or unset.
/compact [focus]
Summarize older context, optionally emphasising something the summary must preserve.
/copy
Copy the most recent assistant response.
/tasks [kill id... | kill all ]
List background tasks, or stop them.
/session
Show the current session and local usage totals.
/usage
Query provider account or subscription usage, where supported.
/login [provider]
Log in to a provider account with a hax-managed token, for ChatGPT/codex.
/logout [provider]
Revoke and remove a hax-managed login.

KEYS

Submit. At a paused, empty prompt, continue without adding a message. Shift-Enter inserts a newline when the terminal sends LF for it.
Recall the previous or next prompt. Ctrl-R searches the persistent prompt history.
Pause after the current step so the conversation can be steered. Esc twice interrupts the model or a running tool immediately.
Clear the current prompt; twice on an empty prompt quits. Ctrl-D quits on an empty prompt.
Clear the screen and redraw the prompt.
Edit the prompt in $EDITOR.
Open the rendered conversation in $PAGER. This is the best view for reviewing what happened.
Open the model-facing transcript in $PAGER: the system prompt, tool schemas, tool calls and results, and post-compaction context.
Paste a clipboard image, or clipboard text when no image is available.
@ + Tab
Choose a project file with fzf(1) and insert its path. The model reads the file only if it needs to.

CONFIGURATION

Configuration is optional: the interactive pickers work without a file and remember provider and model choices. See config.json below for the settings reference.

Files

hax follows the XDG Base Directory specification. These are the paths used when the corresponding XDG_CONFIG_HOME, XDG_STATE_HOME or XDG_CACHE_HOME variable is unset.

~/.config/hax/config.json
Durable, user-owned configuration: defaults, provider definitions, presets and behaviour changes. Suitable for a dotfiles repository, provided secrets stay in environment variables. Plain JSON without comments; dotted keys are normally nested objects.
~/.config/hax/AGENTS.md
Global project instructions, loaded before any repository instructions.
~/.config/hax/skills/ , ~/.agents/skills/
Skill directories containing a SKILL.md per skill. <dir>/.agents/skills/ is searched first, from the current directory up to the repository root, so a nearer directory shadows a wider one. A skill should explain when and how to use a CLI or a repeatable workflow; project policy belongs in AGENTS.md.
Discovered from the repository root down to the current directory, so narrower rules follow broader ones. Outside Git, only ./AGENTS.md is considered. This is the place for build, test, lint and formatting commands, where important modules live, and what must not change.
~/.local/state/hax/state.json
Remembered interactive selections, written by hax. Do not edit by hand.
~/.local/state/hax/sessions/<encoded-cwd>/
Sessions and prompt history, as JSONL, scoped to the current directory. Sessions inactive for 30 days are removed by default; the session_retention_days setting changes that, and 0 keeps them indefinitely. The format is documented in sessions.md.
~/.cache/hax/catalog.json
Model metadata cache.

Environment

Override the provider, model, effort or preset for this run. Useful for per-shell and automated use; they override saved interactive choices.
Replace the base system prompt.
Set by hax itself in delegated subagent processes.
Byte threshold above which command output is streamed progressively instead of being returned as one record.
Used by Ctrl-G, Ctrl-O and Ctrl-T. The two pagers default to less -R when PAGER is unset.
Disable colour output.

External programs

All of these are optional; each feature degrades gracefully without it.

The @ file picker.
Repository context in prompts, and a faster @ candidate list.
The transcript pager.
Clipboard and image paste on Wayland and X11. Without them, hax falls back to the terminal's own OSC 52 support.

PROVIDERS

Run /login inside hax.
Set OPENAI_API_KEY.
Set ANTHROPIC_API_KEY.
Set OPENROUTER_API_KEY.
Set OPENCODE_API_KEY.
Run llama-server.
Run ollama serve.

Any OpenAI-compatible endpoint can be added as a custom provider through the providers block of config.json.

EXIT STATUS

0
The run finished.
1
The run failed.
130
A one-shot run was interrupted by SIGINT or SIGTERM. Completed work is saved and the session stays resumable. A second signal kills the process.

In one-shot mode SIGUSR1 pauses cleanly at the next turn boundary instead, and reports the outcome as paused.

EXAMPLES

Start a conversation in the current repository:

hax

Run a single task and capture only the answer:

answer=$(hax -p "summarize the public API")

Keep diagnostics out of the captured result:

hax -p "produce JSON only" >result.json 2>run.log

Observe a run as it happens:

hax --json "fix the failing test" | jq 'select(.kind == "tool_call" or .type == "result")'

Continue yesterday's conversation here, on a different model:

hax --resume --model=other-model

Ask a plain model question with no tools and no project context:

hax -p --raw "explain this error message"

SEE ALSO

git(1), fzf(1), less(1), ollama(1)

The full manual ships alongside the binary as README.md, CHANGELOG.md and the docs directory, including configuration.md, providers.md, sessions.md and usage.md.

Project homepage: https://usehax.dev

AUTHOR

Oleksandr Chekhovskyi and contributors.

2026-09-23 hax 0.5.0