Gum docs writing

From vchelaru/Gum · View interactive version

Gum docs writing is an AI agent skill from the GitHub repository vchelaru/Gum. Writing Gum docs in GitBook markdown. Triggers: editing docs/, SUMMARY.md, GitBook hints/figures, cross-page links, doc images.

How to use this skill

Skill file

Gum Docs Writing Reference

Readers Are People With Little Attention

Docs are for people who want to get something done and will not read more than they must. Skills are for agents, who read fast, so a skill can hold many details as long as it does not overload context. Both stay short, for different reasons.

For every sentence, section and screenshot, ask: is this absolutely critical for getting the task done? If not, cut it. Detail the tool, a warning message or the code already shows is not critical.

Write the page, then cut it in half before committing: a property page says what it does in one or two sentences and when to change it in one, and repeats nothing the tool already shows in a label, tooltip or subtext. If a sentence would not change what the reader does, delete it.

XML doc comments in the C# runtimes are docs too, with the same readers. Say what the member does and its one precondition; do not add advice about other members.

Before You Write and Before You Commit

  1. Before writing prose: read the page you are editing and one or two sibling pages in the same folder, and match their sentence length and voice.
  2. Before committing: re-read every new paragraph against those pages and the Prose Style and Tone and Style sections below. Cut explanation the neighbors would not include.

Organize by Functionality, Not API Type

A page's home is the functional section a user browses when they have the problem it solves, not a type-indexed folder chosen because that's where the class lives. A new feature's primary explanation goes in its task-based section (e.g. cursor hit-testing for scaled/render-target rendering under events-and-interactivity/); the gum-code-reference/<Type>/ folders hold only terse per-member stubs that link back to it.

Verify Behavior Claims Before Writing Them

Before writing a claim like "X isn't available on backend Y" or "X requires package Z," verify it against the relevant domain skill (e.g. gum-runtime-fonts, gum-kernsmith-integrations, gum-cross-platform-unification) or source — this skill covers GitBook mechanics only, not product behavior. A missing per-platform package is not proof of a capability gap: the platform may get the capability another way (Silk.NET has no KernSmith package because it renders through SkiaSharp, which rasterizes fonts natively — parity, not a gap).

Keep Interfaces Out of Docs

Docs teach the normal path through GumService and the concrete classes. IGumService and the other interfaces are explained once, in docs/code/gum-code-reference/gumservice-gumui/README.md. Mention an interface elsewhere only when the concrete member returns null or cannot be used (for example GumUI.Cursor while a custom cursor is installed).

File Location and SUMMARY.md

All docs live under docs/. docs/SUMMARY.md is the master table of contents — GitBook navigation is built entirely from it. A file not listed in SUMMARY.md is unreachable from the nav even if it exists on disk.

Every new file must be added to SUMMARY.md with a 2-space indent per nesting level:

* [Section](gum-tool/section/README.md)
  * [Page Title](gum-tool/section/page.md)
    * [Sub-page](gum-tool/section/sub/page.md)

Paths in SUMMARY.md are relative to docs/.

README.md as Section Landing Pages

A README.md inside a folder is the section's landing page. In SUMMARY.md, link it as folder/README.md. Sub-pages of that section are indented under it.

Image Paths

All images live in docs/.gitbook/assets/. Reference them using a depth-relative path from the page file:

Image filename convention: date-time prefix like 15_06 10 06.png (day_hour minute second) or 08_14 21 31.gif. Spaces in filenames require wrapping the path in <> angle brackets in standard Markdown image syntax: ![](<../../../.gitbook/assets/15_06 10 06.png>). In <figure> tags the src attribute handles spaces without angle brackets.

Take starting screenshots without being asked. When a docs change describes something visible in the Gum tool or in a rendered result, take the screenshots yourself, cropped tight, named by the convention above, and wrapped in the same <figure> markup as neighboring pages. Pages under docs/gum-tool/ use the editor: dark theme, only the canvas with its checker background, nothing selected unless the page is about the tool UI. Pages under docs/code/ use a render of the running game or a sample, not the editor. Skip red arrows. A new image on a page that already has images copies their setup exactly: open the existing images first, then match the objects and their roles (which object carries the property, which is the background), the sizes, layout and background, and whatever tool chrome they show or hide (outlines, selection, rulers). Change only the value the new section is about, and never add an object the existing images don't have. Before sending, put the new image next to an existing one from the page and check they look like one set.

Some images use a generic image (N).png naming pattern with numeric suffixes like image (13) (1).png — these are GitBook-uploaded files; don't rename them.

GitBook-Specific Syntax

Hint blocks — must always have a closing {% endhint %} tag or the page breaks:

{% hint style="info" %}
Content here.
{% endhint %}

{% hint style="warning" %}
Content here.
{% endhint %}

Figure blocks — used for images with captions. Always include alt attribute and <figcaption>:

<figure><img src="../../../.gitbook/assets/filename.png" alt=""><figcaption><p>Caption text</p></figcaption></figure>

For inline images without captions, use standard Markdown: ![](<path>).

HTML entities — &#x20; (space) and &#x64; (d) appear in GitBook-generated content for spacing and special characters. Do not strip them; GitBook uses them intentionally.

Cards for listing subpages — GitBook auto-lists subpages only on a page with no content, so a landing page that has intro text needs an explicit list. A Cards table in raw HTML renders correctly (see adding-initializing-gum/README.md). The second cell's href is the page path relative to the file, and GitBook fills in the card title from the first cell:

<table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>Card title</td><td><a href="page.md">page.md</a></td></tr></tbody></table>

Previewing Docs Changes

Every PR that touches docs/ gets two GitBook checks. Run gh pr checks <number> and open the GitBook (./docs) - docs.flatredball.com/gum/ link for a live preview of the rendered site, or the GitBook (./docs) link for the diff in the GitBook editor. Check the preview before reporting a docs change as done, since GitBook-specific markup (cards, hints, tabs) can only be confirmed there.

Internal Links

Always use relative paths — no absolute URLs. Link to a section landing page using its README.md:

[Container](../container/README.md)

Do not use anchor-only links to other files (e.g., [foo](other-file.md#section) is fine, but [foo](#section) only works within the same page).

Tool Docs vs Code Docs

The docs have two top-level sections — Gum Tool (docs/gum-tool/) and Code (docs/code/). These must never be mixed:

When writing a tool doc page (e.g., a property page under gum-elements/), focus entirely on the tool experience: what the property does visually, where it appears in the UI, and screenshots showing the effect. Do not add code examples showing how to set the property in C#. Conversely, code doc pages should not walk through the tool's UI.

Per-runtime supported-file facts live on the one code page docs/code/files-and-fonts/supported-files.md; tool pages describe what the tool supports, and a code page never links to a tool page for runtime facts.

Decide the page's home before writing: if the feature is something the tool ships or edits (built-in shaders, templates, Forms themes, variables and their rows), its main page is a tool page; the code page covers only the generic runtime API that any user-supplied asset uses, and never describes a tool-shipped asset or says "ships with Gum". Check every new section against this split before presenting it.

Cross-Cutting Topics (Binding, Localization, Theming)

Some features cut across many controls — binding, localization, theming, code generation — and individual controls have control-specific behaviors that intersect with them. For example, TextBox.Text can be bound to a numeric ViewModel property and the binding implicitly converts string ↔ number; ListBox interacts with BindingContext differently than other controls; localized labels behave differently in PasswordBox.

The convention for these:

The control-page note exists so that a reader troubleshooting "why doesn't my int binding take" while reading the TextBox page finds what they need without bouncing around. The feature-page section exists so that a reader learning the binding system isn't surprised later. Both audiences are real; the split avoids both blind spots without duplicating content.

Date-Specific Content Goes in Hint Blocks

Anything that is only true relative to a release date — "as of <month> <year>", "before <date>", "in <version> X changed" — must live in a {% hint %} block, not in the body paragraphs of a section. Phrase the surrounding prose in terms of current behavior so it stays correct after the dated note is removed.

Why: dated notes eventually become noise once enough time has passed (everyone reading the docs is on the new behavior). Keeping them in hint blocks gives a single, visually obvious anchor to delete later instead of forcing the author to re-read every paragraph hunting for embedded dates.

Pattern:

The Font Generator project property controls ... There are two options:

* **KernSmith** — ... This is the default for new projects.
* **BMFont** — ... a separate external tool.

{% hint style="info" %}
**As of May 2026:** New projects default to **KernSmith**. Before this, the default was **BMFont**. Existing projects keep their current setting.
{% endhint %}

Not this — date leaks into body bullets, so removing the dated context later means rewriting prose:

* **KernSmith** — ... Default for new projects starting in May 2026.
* **BMFont** — ... Was the default before May 2026.

This applies to: "as of <date>", "starting in <date>", "before <date>", "in version X", "the May 2026 release", and any "what changed in <release>" section heading. When in doubt: if deleting the sentence later would leave the surrounding paragraph still accurate, it's safe in the body; if deleting it would leave a contradiction or dangling reference, lift it into a hint.

Flag Release Status for New Features

Before documenting a new feature or behavior, ask the user whether it has already shipped, is out in preview, or hasn't shipped yet — they usually know offhand, which is faster than investigating. Only investigate yourself when they don't know: walk the feature's commits with git merge-base --is-ancestor <commit> <sha> against the commit each candidate NuGet build was made from, then confirm against the live NuGet feed.

"Shipped" means published to NuGet (stable or preview), not merged to main. Runtime NuGet packages publish on a separate, manually-triggered workflow (dotnet-nuget.yaml) from the Tool's near-daily GitHub Releases (build-and-release.yml) — a feature on main, or even bundled into a dated Tool release, can sit unpublished to NuGet for days.

Then flag accordingly in a {% hint style="info" %} block (same pattern as dated content above):

Monthly Migration Pages

A docs/gum-tool/upgrading/migrating-to-<year>-<month>.md page needs What Changed at a Glance only when one point is critical and wide-reaching, such as a hard break most readers hit (migrating-to-2026-october.md is the model). Otherwise leave the section out: the ### headings under Breaking Changes and Migrations already list each change, so a summary of them adds nothing. Never use a stock lead-in over a bullet list ("Two changes need your attention:").

Each entry lists only what a user must do after upgrading. Leave out descriptions of internal or generated-code changes that need no action, and leave out additions: new members, new APIs and new options are release-notes material, never a migration entry. Before keeping a section, ask what the reader would do differently; if nothing, delete it.

Prose Style: Clarity Beats Brevity

Cut length that adds reading, never length that adds understanding. Density and clarity are separate axes, and a longer sentence that lands the first time beats a compressed one the reader has to decode. Trimming a page is not the same as making it clearer, and a reader who has to re-read a sentence has not been saved anything.

Three habits that cost words without buying understanding:

Read-aloud test. If a clause repeats the clause before it, or the sentence runs out of breath, rewrite it. Do not shorten it.

❌ "Set text.Font to a path ending in .ttf to bypass family name resolution and route the value through the file backed rasterization path rather than the operating system font lookup. This happens automatically, and there is nothing to enable."

✅ "Gum loads a Font value ending in .ttf as a font file rather than looking it up as an installed font family. It decides this from the extension alone, so there is no setting to turn on."

Run this as a pass before committing, not only while drafting. The mechanical rules on this page (em dashes, {% endhint %} pairs, placement comments, SUMMARY indentation) can be grepped, and the prose rules cannot, so they are the half that silently gets skipped. Re-read every new or edited paragraph against the three habits above and against the passive-voice rule under Tone and Style.

Tone and Style

Code Sample Placement Comments

Every \\\csharp` block must have a placement comment as its first line so readers and agents know where the code belongs.

| Comment | Meaning |

|---|---|

| // Initialize | Runs once right after GumUI.Initialize. Use this by default. |

| // Update | Code that runs each frame in the update loop. |

| // Draw | Code that runs each frame in the draw loop. |

| // Class scope | Field or property declarations at class level. |

| // In CustomInitialize | Code specifically in a generated partial CustomInitialize() method. |

When to omit the comment:

Mixed-scope snippets get one marker per part, with no class wrapper and no method signatures:

// Class scope
int clickCount;

// Initialize
var button = new Button();
button.Click += (_, _) => clickCount++;

// Update
GumUI.Update(gameTime);

Runtime-Neutral Snippets

Snippets outside MonoGame-only pages show no Game class, no override methods and no GumUI.Initialize call; they start after Gum is initialized and use the markers above. The markers are defined for readers in docs/code/getting-started/setup/adding-initializing-gum/README.md. Per-frame calls are written GumUI.Update(gameTime); and GumUI.Draw();. A page that needs a Gum project loaded links to getting-started/setup/loading-a-gum-project-.gumx.md (or reads ObjectFinder.Self.GumProjectSave) instead of showing the load call. Host setup never gets per-runtime tabs; it lives only on the runtime setup pages.

A page may stay MonoGame-only when it is a runtime setup page or uses MonoGame-only types (SpriteBatch, GraphicsDevice, RenderTarget2D, GumBatch, Window). Its title, intro or the line before the sample says so.

Irreducible per-platform syntax → tabs, don't ask. First try to collapse a sample to a single platform-neutral form. When an API genuinely differs per runtime (for example opening bundled content with TitleContainer), wrap just those blocks in GitBook {% tabs %} with one {% tab %} per platform (e.g. MonoGame / Raylib). This is the standard, expected treatment for irreducible divergence; use it without asking. Keep the surrounding prose shared above/below the tabs — only the code that truly differs goes inside. Don't assume a member's type differs per backend from memory (e.g. KeyCombo.PushedKey, KeyEventArgs.Key) — check current source, since Gum has been steadily unifying input types onto Gum.Forms.Input.Keys across backends.

Runtime Setup Pages

Each page in docs/code/getting-started/setup/adding-initializing-gum/ has the same shape, with monogame-kni-fna/README.md as the model: a Starting From a New Project section on platforms gumcli new --platform supports, a complete program that builds with only the base package and loads no .gumj, then an Optional Extras table (package plus the one Use*() line per extra) and a Loading Your Gum Project section (the .gumj Initialize line plus the csproj copy rule). Never put optional Use*() calls or a .gumj path in the complete program, since a reader who skipped a package must still get a build that runs.

XnaFiddle Links

For adding or updating XnaFiddle interactive links, see xnafiddle.md.

Code Sample Rules

Gotchas

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.