Use Rivex from an AI agent.

A coding agent can run the rivex CLI the way you do, and harden each Dockerfile it creates or changes.

What the agent needs.

  • The rivex CLI on the PATH of the machine the agent works on. Install the CLI shows how. Rivex is in early access: Getting started says how to get an account.
  • An API key in the RIVEX_API_KEY variable of the agent's environment. Create an API key shows how to get one.

Set the key in the environment the agent starts its commands from, for example the shell profile of the account it runs as. Replace <your-api-key> with your key:

export RIVEX_API_KEY='<your-api-key>'

Put the key only there, never in the instruction file or a prompt: the agent reads those, and they often end up in a repository or a log. The CLI reads the key from the variable by itself, so it never appears in a command the agent runs.

The agent can instead keep its key in a file passed with --env-file: see Keep the key in a file. Run chmod 600 on it, keep it outside the repository, and never name it in the instruction file.

Tell the agent to harden its Dockerfiles.

Add these lines to the file your agent reads its instructions from, such as AGENTS.md, CLAUDE.md or .cursorrules:

After you create or change a Dockerfile, run `rivex harden --fail-on high -o Dockerfile Dockerfile`. If it exits non-zero, read the findings on standard error, fix them, and run it again. Commit the hardened Dockerfile.

When the Dockerfile is not at the top of the project, put its path in both places.

-o Dockerfile replaces the Dockerfile with the hardened one. The CLI reads the file before it writes the result, so both can be the same file. The hardened file is written even when the command fails on a finding, so the next run starts from it. --fail-on high fails on high and critical findings. For another threshold, use critical, medium or low.

What the agent sees.

The command never waits for input. With -o, standard output stays empty; without it, the hardened Dockerfile goes there. Standard error lists the findings, one per line with its severity, rule and message, then the status of the build verification, the SBOM and the attestation.

The exit code tells the agent what to do next:

  • 0: the Dockerfile was hardened, and no finding met --fail-on.
  • 1: the input is wrong, for example a missing Dockerfile or a bad flag value.
  • 2: the API gave no usable answer, for example no connection or a timeout. Running it again later can help.
  • 3: the API answered with an error, for example because the key is missing or wrong. Running it again does not help until the key is fixed.
  • 4: a finding met --fail-on. The hardened file is written: fix the findings and run it again.

Turn off build verification for the agent.

By hand, rivex harden builds the hardened Dockerfile in a sandbox when the server verifies builds. Each build uses one of the month's verified builds of your plan, 5 for a personal workspace, and can take a few minutes. An agent runs the command again after each fix, so it would spend a build every time and use them up in a single session.

Turn verification off for the agent in its environment, next to the key:

export RIVEX_VERIFY_BUILD=false

Or put it in the command of the instruction line instead:

rivex harden --verify-build=false --fail-on high -o Dockerfile Dockerfile

Standard error then says Build verification: not run — skipped for this run., and the exit code does not change. Your CI pipeline, or a run by hand, can still verify the build once the agent is done.

To keep verification on for the agent, leave both out. For a Dockerfile that copies project files with COPY or ADD, also add --build-context . to the command and run it from the project folder, so the sandbox has the files. Verify the build with your project files has the details.

Check the result.

rivex verify checks on your machine, with no API key, that a Dockerfile is the one Rivex hardened and signed. It needs the attestation that rivex harden --attestation-out attestation.sigstore.json saves when the server signs the result. Check a Dockerfile against its attestation shows the command, and Check hardened Dockerfiles in CI runs it on every change.