> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/gum/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/gum/using-gum-with-ai/ai/gumcli-for-agents.md).

# GumCli for Agents

[GumCli](/gum/cli/cli.md) (`gumcli`) is a cross-platform command-line tool for working with Gum projects without opening the editor. Because it is scriptable, has machine-readable output, and reports meaningful exit codes, it is the primary way an AI agent acts on a Gum project and verifies its own work.

This page is a recipe-oriented tour from an agent-workflow angle. For the full reference on each command, follow the links into the [CLI](/gum/cli/cli.md) section.

## Installation

`gumcli` installs as a .NET global tool:

```
dotnet tool install -g GumCli
```

## Why it works well for agents

* **Machine-readable output** — command results (JSON, file paths, summaries) go to **stdout**, while banners and progress chatter go to **stderr**. An agent can consume stdout directly, for example `gumcli check MyProject.gumx --json`.
* **Meaningful exit codes** — `0` for success, `1` for errors found, `2` for a project that could not be loaded or invalid arguments. An agent can branch on the exit code instead of parsing prose.
* **No editor required** — everything runs headless, so it fits an automated edit → validate → verify loop.

## The agent loop

A typical agent workflow for building or modifying a Gum UI follows three stages.

### 1. Generate code

If the project uses code generation, initialize the settings once, then generate strongly-typed C# for the project's screens and components. This eliminates magic strings and lets the agent reference UI elements by name.

* [`codegen-init`](/gum/cli/cli/codegen-init.md) — write the code-generation settings into the project.
* [`codegen`](/gum/cli/cli/codegen.md) — generate C# for the project's elements. Pass `--prune` to also delete generated files left behind by elements that were deleted or renamed.

### 2. Validate

After editing project XML — whether by hand, with custom tooling, or via an assistant — validate it before trusting it. `check` catches the silent mistakes that are easy for an agent to make, such as misspelled element names that Gum would otherwise drop without error.

* [`check`](/gum/cli/cli/check.md) — validate a project and report errors. A non-zero exit code tells the agent to stop and fix the problem before continuing.

### 3. Verify visually

Generated code that compiles is not proof the UI looks right. Rendering the result to an image gives the agent something concrete to inspect — and, with a multimodal model, to actually "see."

* [`screenshot`](/gum/cli/cli/screenshot.md) — render a Screen or Component to a PNG. An agent can open the PNG to confirm the layout matches intent.
* [`diff-screenshots`](/gum/cli/cli/diff-screenshots.md) — render every Screen and Component via both `monogame` and `raylib` and report any mismatch, so a raylib-specific rendering bug doesn't slip through if the project targets both.
* [`svg`](/gum/cli/cli/svg.md) — render to SVG when a vector format is preferred.

## Supporting commands

* [`new`](/gum/cli/cli/new.md) — scaffold a new Gum project.
* [`fonts`](/gum/cli/cli/fonts.md) — generate missing bitmap font files referenced by the project.
* [`pack`](/gum/cli/cli/pack.md) — bundle a project into a single `.gumpkg` file.

{% hint style="info" %}
Pair `gumcli` with the [MCP Documentation Server](/gum/using-gum-with-ai/ai/mcp-server.md) so your assistant can look up how a command or property works while it drives the project, and with the [AI Skills](/gum/using-gum-with-ai/ai/ai-skills.md) so it understands the file formats it is editing.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flatredball.com/gum/using-gum-with-ai/ai/gumcli-for-agents.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
