> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zocomputer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate diagram

> Generate a block diagram, using D2.

{/* Tool: generate_d2_diagram */}

D2 is a domain-specific language for diagramming ([https://d2lang.com](https://d2lang.com)). Use this whenever a diagram would clarify the USER's request. Provide raw D2 text only—no markdown fences, comments, or extra prose. Input is saved as `<file_stem>.d2` in the conversation workspace and rendered to `<file_stem>.png` under Images/, which is returned to the USER.

## Parameters

<ParamField path="code" type="string" required={true}>
  Valid D2 source (required, plain text).
</ParamField>

<ParamField path="file_stem" type="string" required={true}>
  Base filename for both `.d2` and `.png`.
</ParamField>

<ParamField path="output_dir" type="string" default={""}>
  Optional absolute directory for the PNG (defaults to `/home/workspace/Images`).
</ParamField>
