Golem cli structured output

From golemcloud/golem · View interactive version

Golem cli structured output is an AI agent skill from the GitHub repository golemcloud/golem. Understanding and parsing Golem CLI structured output. Use when using --format json, --format yaml, --format toon, discovering $type schemas with golem output-schema, or writing agents/tools that parse CLI output.

How to use this skill

Skill file

Golem CLI Structured Output

Both golem and golem-cli can emit machine-readable structured output. Use this skill when building scripts, coding agents, test harnesses, or tools that parse CLI output.

Formats

Use the global --format flag before the command:

golem --format json agent list
golem --format yaml component list
golem --format toon agent stream <AGENT_ID>

For automation, prefer --format json unless you specifically need YAML or TOON.

Human logs, prompts, progress, and diagnostics are written to stderr in structured formats. Parse stdout as the structured payload.

Secret And Masking Behavior

Most secret-bearing structured outputs are masked by default. Pass the global --show-secrets flag only when you intentionally need the raw values.

api-token.new is an explicit exception: golem api-token new intentionally emits the newly generated token secret once, including in structured formats such as --format json, because the secret cannot be retrieved later. Store that output securely.

Plugin parameter values are masked by sensitive-looking parameter names. When a plugin parameter carries a secret, use a parameter name containing words such as secret, token, password, or key so CLI outputs mask it by default.

`$type` Discriminator

Every structured output document has a top-level $type field. Branch on $type before reading command-specific fields.

Example:

{
  "$type": "agent.list",
  "agents": [],
  "cursor": null
}

$type values are stable output type identifiers. They often resemble CLI command/action paths, but they are not guaranteed to be literal command paths. Use schema metadata such as x-golem-command and, when present, x-golem-commands to understand which CLI command or commands can emit a type. A type that no CLI command emits names the golem mcp serve tool that returns it in x-golem-mcp-tool instead, such as agent.oplog-export of the tool agent_oplog_export.

Naming examples:

Discover Output Schemas

golem output-schema is raw tooling output, not a normal structured CLI result. In text mode it prints compact single-line JSON. Use the global --format flag to request another raw schema format such as pretty-json, yaml, pretty-yaml, or toon.

List known output type names:

golem output-schema --types

Print a focused schema for one output type:

golem output-schema --type agent.invoke

Print a focused schema bundle for multiple output types:

golem output-schema --type agent.oplog --type agent.stream

Print the full raw schema only when broad cross-output context is needed:

golem output-schema

--type returns a pruned JSON Schema containing the selected output definitions and only the referenced definitions needed by those types. This is usually the best schema input for coding agents because it keeps context small.

Single Documents, Streams, And Multi-Document Commands

Most structured commands emit exactly one document to stdout.

Some commands emit a finite set of structured documents during one command run. Different $types may appear conditionally, and not every possible document appears every time. For example, golem deploy may emit deploy.diff, deploy.plan, deploy.environment-setup-plan, deploy.environment-tool-grants, and/or deploy.deployment, followed by a final deploy success document. Another example: golem agent oplog --obfuscate emits one agent.oplog-export-header first, one agent.oplog-export-entry per oplog entry in index order, and one agent.oplog-export-coverage last; a sequence without the coverage document is from a failed export. The schemas mark these types multi-document.

Some commands emit a stream of documents:

| Command | $type | Shape |

|---------|---------|-------|

| agent stream | agent.stream | One document per stream event |

| agent oplog | agent.oplog | One document per oplog entry, without --obfuscate |

agent oplog --page reads one page instead and emits one agent.oplog-page document. Its entries are the agent.oplog documents of the page, and its cursor, when present, is passed back as --cursor to read the next page. A page can be empty and still have a cursor.

For compact --format json, each streamed document is emitted as one JSON line. Parse stdout line by line. For pretty-json, YAML, and TOON, parse stdout as a sequence or framed stream, not as one JSON object or array.

Structured stream output may be empty if there are no events or entries.

Focused schemas include x-golem-output-mode metadata:

| Mode | Meaning |

|------|---------|

| single | One structured document on success |

| stream | Multiple documents of the same event/entry type; parse until EOF or interruption |

| multi-document | Finite command-bounded output; multiple $types may appear conditionally |

TOON Frames

When using --format toon, each structured document is framed:

@toon
<one TOON document>
@end

Parse stdout by splitting on exact @toon and @end marker lines.

Text-Only Interactive Output

Some interactive terminal modes are text-only. For example, agent list --refresh continuously redraws the terminal and cannot be combined with structured formats such as --format json, --format yaml, or --format toon.

Practical Parsing Guidance

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.