How to Message-format=short as defaut and better for Ai

I want to use
cargo build --message-format=short or
cargo check --message-format=short
as default setting

Might be worth filing a feature request (couldn't find one) for a CARGO_MESSAGE_FORMAT environment variable and/or a configuration option under [term] (which'd be the two most obvious places to put global configuration of the message format IMO).

Understand Better + Faster

Cursor and Other VibeCoding IDE use cargo build in the terminal , but the default message is format for humanreading ,

  1. it take more tokens
  2. it is hard to understand for Ai , for example

For human

  warning: unused variable: `x`
  |       --> src\main.rs:6:9
  | 6 |  let x : i32 =2 ; 
  |            ^ help: if this is intentional, prefix it with an underscore: `_x` 
  |       = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

For Ai

warning: unused variable: `x` --> src\main.rs:6:9  | 6 |     let x : i32  =2 ;   |         ^ help: if this is intentional, prefix it with an underscore: `_x`  |  = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

there are many useless words like | ^ --> and many space

So it is hard to understanding and take more tokens

1 Like

@jofas here is another related topic for user who post a similar question

1 Like

Wouldn't it just be easier to make a development related build script and instruct the model to run them to get processed output in the way you want? That way you can have full control over what you want.

VibeCoding consumes a large number of tokens and has a substantial context capacity. However, AI often forgets user instructions in the later stages of work.

  1. I've tried different AI-powered VibeCoding IDEs, and they all tend to forget my guidance.
  2. Writing a personal development script is essentially a custom configuration. It would be much better if it could be standardized.

Interesting. That would be something I would like as a feature for humans to be honest. I actually never thought about just setting default terminal feature flags for cargo globally, and I didn't even know about the --message-format=short till now, it's actually much better to quickly check outputs while working. And being able to set it globally would be helpful. If there's demand for pure machine use, it might be worth considering a dedicated --message-format=machine that outputs compact JSON like this:

cargo test --message-format=json 2>/dev/null | jq -c 'select(.reason == "compiler-message") | .message | {level, message, file: .spans[0].file_name, line: .spans[0].line_start, col: .spans[0].column_start}'

{"level":"error","message":"unresolved import `procenv::ConfigBuilder`","file":"crates/procenv/examples/error_demo.rs","line":13,"col":15}
{"level":"error","message":"failed to resolve: could not find `serde` in `procenv`","file":"crates/procenv/examples/error_demo.rs","line":47,"col":26}
{"level":"error","message":"failed to resolve: could not find `serde` in `procenv`","file":"crates/procenv/examples/error_demo.rs","line":57,"col":35}
{"level":"error","message":"cannot find attribute `serde` in this scope","file":"crates/procenv/examples/error_demo.rs","line":48,"col":3}
{"level":"error","message":"cannot find attribute `serde` in this scope","file":"crates/procenv/examples/error_demo.rs","line":53,"col":7}