# Compact cargo output


# Compact cargo output

A long `cargo build` or `cargo test` can hand an agent thousands of tokens of
compiling lines, warnings, and progress bars - enough that reading a single task
output can eat most of a session's context window. banish compacts that output
before it reaches Claude Code, Cursor, or any MCP agent, keeping the errors and
the final status and dropping the rest.

## The problem - cargo output is verbose

`cargo build` prints a Compiling line for every crate in the graph, then a stream
of warnings, then the final result. On a cold build of a real project that is
hundreds of lines the model does not need in order to know what happened. When an
agent reads that from a background task, the whole log can be pulled into context
in one shot.

## Before and after with banish

banish runs the real command and pipes the output through the cargo filter:

| Command | Raw tokens | Compacted | Saved |
| --- | --- | --- | --- |
| cargo build (33 crates) | 265 | 17 | 94 percent |

The filter drops the per-crate Compiling and Downloading lines and keeps the last
few lines - the Finished line on success, or the error summary when the build
fails. See the full spread across commands on the [benchmarks](/docs/reference/benchmarks)
page, measured on a fixed corpus you can reproduce with `banish bench`.

## How the cargo filter works

The cargo filter ships with banish out of the box. It compacts `cargo build`,
`cargo test`, and `cargo clippy`. On `cargo test` it keeps the lines that matter -
errors, warnings, the test result, and panics - and drops the passing noise. If a
filter fails, banish returns the raw output rather than swallowing it. See
[built-in filters](/docs/reference/built-in-filters) for the full set.

## Write your own for another command

The same approach works for any noisy command. The [.bsh language](/docs/concepts/bsh-language)
lets you define a filter in about ten lines - no recompile. To start compacting
cargo output in your own agent, [set up an agent](/docs/getting-started/set-up-an-agent).
