Skip to main content

Command line

The hackagent command runs red-team campaigns against AI agents from your terminal. You describe a run in a campaign file, check it, run it, and read the results, on your own machine or recorded on the HackAgent platform. The same command serves the web dashboard and runs the campaigns you queue from it.

Install it​

Install the hackagent package, or download a standalone binary, as Installation describes. The base install has every command on this page except two that need an extra: hackagent web needs hackagent[web], and the terminal app needs hackagent[tui].

Check it works:

hackagent --version
hackagent doctor

hackagent doctor reports the config file, the local database, the storage backend, whether an API key is set, and optional dependencies such as Graphviz. It changes nothing.

The commands​

Run hackagent with no command to open the terminal app. Every other command is listed in Commands, with all its options.

CommandWhat you use it for
hackagent campaignValidate and run campaign files, list the attacks, print the campaign JSON Schema. See Running campaigns.
hackagent examplesList the bundled example campaigns, copy one to edit, or run one.
hackagent datasetsBrowse the dataset presets and print sample goals from one.
hackagent resultsSummarize recent results, or show one result in detail.
hackagent webServe the dashboard from this machine. See The dashboard server.
hackagent runRun a campaign queued from the dashboard on this machine. See Running queued runs.
hackagent configShow, set, validate, import and reset settings. See Configuration.
hackagent initAnswer a few questions and save a config file.
hackagent doctorCheck your setup.
hackagent tuiOpen the terminal app, which builds, checks and runs a campaign.
hackagent versionPrint the version and the config file path.

Options such as --backend and --config-file belong to hackagent itself, so they go before the command: hackagent --backend remote results summary. Configuration lists them.

Typical workflows​

Validate and run a campaign on your machine​

Nothing leaves your machine except the calls to the models the campaign names. Start from an example, check it, then run it:

hackagent examples list
hackagent examples copy h4rm3l-demo # writes h4rm3l-demo.yaml here
hackagent campaign validate h4rm3l-demo.yaml
hackagent campaign run h4rm3l-demo.yaml
hackagent results summary

Each run writes its files under ./logs/runs/<run id>/ and its results to the local database. Running campaigns explains the output, the exit codes and the run-time options; Your first campaign walks through writing one from scratch.

Record runs on the HackAgent platform​

Put your API key in the environment, never in a file:

export HACKAGENT_API_KEY="your_api_key"

A campaign is recorded on the platform when its execution.storage says so. Its api_key names the variable:

execution:
storage:
backend: remote
api_key: "${HACKAGENT_API_KEY}"
hackagent campaign run campaign.yaml

To read the platform's results instead of the local ones, select the remote backend once, or for one command:

hackagent config set --backend remote # saved in the config file
hackagent --backend remote results summary # this command only

Configuration explains what each backend changes.

Open the dashboard​

pip install 'hackagent[web]'
hackagent web

With the default local backend, the dashboard shows the runs in your local database. With the remote backend, it shows your platform data. Either way it listens on this machine only. The dashboard server covers the modes and options; the Dashboard guide covers the pages themselves.

Run a campaign queued from the dashboard​

On the HackAgent platform you can queue a run for "a local machine". The run waits until a machine with your API key claims it:

export HACKAGENT_API_KEY="your_api_key"
hackagent run # lists the queued runs and asks which one
hackagent run <run id> # runs that one

The campaign runs here, with your model keys, and the dashboard follows it live. See Running queued runs.

Where to go next​

  • Configuration: the config file, environment variables, backends, CA bundles and proxies.
  • Campaign files: every field of the campaign format.
  • Troubleshooting: common errors, what causes them, and how to fix them.