# Designing .NET CLI Output for AI Agents

> Source: <https://dev.to/rushuiguan/designing-net-cli-output-for-ai-agents-249o>
> Published: 2026-11-25 19:08:15+00:00

**Key takeaway:** Albatross.CommandLine v9 drops default console logging so JSON output pipes cleanly, and adds a CommandOutput envelope with command name, errors, exit code and log folder so agents can parse each command's outcome.

It’s been about a year since we released Albatross.CommandLine v8. We’ve used it in production across a number of projects, and reusable options have become one of the features we rely on most. Along the way, we added `Albatross.CommandLine.CodeAnalysis` to help developers catch issues at compile time. We also updated the source generator packaging so consuming projects automatically reference it as a development dependency.

With the release of `System.CommandLine` v3, we’ve released Albatross.CommandLine v9, targeting .NET 10 and .NET Standard 2.1. In my [previous article](https://dev.to/rushuiguan/systemcommandline-with-dependency-injection-a-complete-solution-128o), I wrote about how a command takes an input like `--instrument AAPL` and passes an `InstrumentSummary` to its handler. Much of the work in v9 focuses on the other end of that interaction. What should the command print when the caller is an AI agent?

As we use AI agents for more of our development work, verifying their changes becomes increasingly important. We also rely on agents to write and run integration tests, including tests that span multiple services. How do we make sure those tests exercise the behavior we care about?

Our systems use a service-oriented architecture, and we rely heavily on CLIs to test them. A CLI gives the agent a defined set of operations it can use to build a test. It can run one command, inspect the result, and use a value from that result in the next command. For that to work reliably, the agent needs to know what to expect from each command’s output.

The first change in v9 was to remove default console logging. If a command prints a price as JSON, I want to be able to pipe it straight into `ConvertFrom-Json`. One log message on standard output is enough to break that pipeline.

The second change was to introduce `Albatross.CommandLine.Outputs`. For a command that returns data, the output is straightforward. A price lookup can serialize the quote to JSON and print it directly.

An update is a little different. It might have no data to return, but the caller still needs to know how the operation went. The command can report that outcome using a `CommandOutput` envelope.

```
public record class CommandOutput {
    public required string Command { get; init; }
    public string? Message { get; set; }
    public IReadOnlyCollection<ErrorOutput>? Errors { get; set; }
    public required int ExitCode { get; init; }
    public string? LogFolder { get; set; }
}
```

Every envelope identifies the command and reports its exit code. When an operation fails, the agent can inspect `Errors` and, if it needs more detail, find the logs through `LogFolder`.

Suppose we ask an agent to verify that a price update works. It runs the update command, gets an exit code of `0`, and marks the test as passed. So far, all it has verified is that the command reported success.

I’d want the test to establish that the current price is `100`, update it to `105`, then read it back through the CLI and assert that it’s `105`. The starting value matters. If the price was already `105`, even a read-back assertion could pass when the update did nothing.

That’s how the two forms of output work together. The update envelope tells the agent how the operation went. The query result tells it what price the service now exposes. Consistent output makes those checks easy to write. Deciding which checks prove the behavior is still part of designing the test.

When you ask an AI agent to write an integration test, what do you specify up front, and what do you trust the agent to figure out?
