guigui-gui/guigui/using-guigui
Claude Code and agent skill by guigui-gui/guigui
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Use this skill when writing or modifying GUI code with the Guigui framework (github.com/guigui-gui/guigui): creating or editing a widget, composing a layout, wiring buttons / text inputs / lists, passing shared state down the widget tree, handling pointer or keyboard input, or figuring out why a change to a field does not show up on screen. Covers the widget lifecycle (Build / Layout / Measure / Draw / input), LinearLayout sizing, Env-based dependency injection, the event-key callback pattern, dynamic child lists, and when state changes trigger a rebuild. Not for general Ebitengine rendering questions that do not involve Guigui widgets.
Install
npx vskill@latest install guigui-gui/guigui/using-guiguiSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as guigui-gui/guigui/using-guigui.
Using Guigui
Guigui is an immediate-mode-inspired GUI framework for Go on top of Ebitengine. "Inspired" is the key word: widgets are retained Go structs that you own and keep across ticks, but their child tree and presentation are reconstructed by re-running Build whenever relevant state changes — the way Compose or SwiftUI re-run a view function. You hold the state in struct fields; the framework decides when to rebuild, lay out, and redraw.
Read this whole file before writing widget code; the lifecycle rules below are the part people get wrong.
Freshness. Verified against Guigui at commitc1ffb301(2026-07-10).Guigui is alpha and its API may change — if anything here disagrees with thesource, the source wins: trust*.goin the module root and the programsunderexample/over this file, and update this skill when you find drift.
The mental model
- A widget is a struct that embeds
guigui.DefaultWidgetand overrides the
methods it needs. DefaultWidget supplies no-op defaults for every method, so override only what matters.
- A widget must work from its zero value — declare children as plain
(non-pointer) fields and reference them as &w.child. Do not allocate them in a constructor; var w Foo must already be usable.
- The framework runs two decoupled cycles. Each tick (Ebitengine's
Update,
at the app's TPS — 60×/sec by default, or whatever TPS is configured) first settles the tree: it may run Build (reconstruct the child tree), Layout (position the children), and the `Handle*Input` methods before calling Tick exactly once. A state change during input can cause another Build/Layout pass in the same tick before Tick runs. Rely only on these guarantees: Build precedes Layout within a pass, input sees the current layout, and Tick runs once, after input handling. Do not assume a fixed count of Build or Layout passes per tick. Each frame (Ebitengine's Draw, at the display's refresh rate) does Draw. Ticks and frames are not one-to-one — there may be more or fewer frames than ticks — so put per-step logic in Tick, never in Draw.
- You never invoke a widget's framework-driven methods (
Build,Layout,
Tick, Draw, the Handle*Input methods, Env, …) yourself — you set fields and register handlers, and the framework calls back. The one exception is `Measure`: a parent or composite widget calls a child's Measure directly to size it (it is what LinearLayout and the shared layout() helper do).
Minimal application
guigui.Run(root, *RunOptions) starts the app. RunOptions carries Title, WindowSize / WindowMinSize / WindowMaxSize, WindowFloating, AppScale, and an optional RunGameOptions passed through to Ebitengine.
The Widget interface
Embed guigui.DefaultWidget, then override as needed:
| Method | Signature | Override when | |
|---|---|---|---|
Build | Build(*Context, *ChildAdder) error | Almost always — declare and configure children. | |
Layout | Layout(*Context, *WidgetBounds, *ChildLayouter) | You have children to position (i.e. almost always). | |
Measure | Measure(*Context, Constraints) image.Point | The widget has an intrinsic preferred size (list rows, leaf widgets). | |
HandlePointingInput | HandlePointingInput(*Context, *WidgetBounds) HandleInputResult | Custom mouse/touch handling. | |
HandleButtonInput | HandleButtonInput(*Context, *WidgetBounds) HandleInputResult | Custom keyboard/gamepad handling — only delivered under focus/receptiveness conditions (see "Handling input directly"). | |
Env | Env(*Context, EnvKey, *EnvSource) (any, bool) | The widget provides shared values to descendants. | |
WriteStateKey | WriteStateKey(*Context, *StateKeyWriter) | State changes outside input/events must trigger a rebuild (see below). | |
Tick | Tick(*Context, *WidgetBounds) error | Per-tick updates (animation, timers); runs at the app's TPS. | |
Draw | Draw(*Context, *WidgetBounds, *ebiten.Image) | Custom rendering (most widgets compose children instead). | |
CursorShape | CursorShape(*Context, *WidgetBounds) (ebiten.CursorShapeType, bool) | The widget wants a non-default cursor. |
Build vs. Layout — the rule that matters most
- `Build` runs before any bounds are known. Use it to add children
(adder.AddWidget(&w.child)) and to push current state into them (SetText, SetEnabled, registering handlers). Build is re-run on every rebuild, so it must be idempotent — write it as "given my current state, configure my children," not "do this once."
- Conventional order inside `Build`: add first, configure second. Call all
the adder.AddWidget(...) you need, then push state into the children with Set* / On*. Configuring a child you did not add is harmless, so you do not need to guard every setter behind the same condition as its AddWidget — unconditionally configuring for simplicity is fine and idiomatic.
- Only add children you actually use this rebuild. Skip the
AddWidgetfor a
child that is not currently shown (e.g. the contents of a closed popup, a collapsed panel, a hidden tab). A widget that is not added is not laid out, drawn, or sent input, which is cheaper than adding it and hiding it. popup is the canonical example — it only adds its background/shadow/content while it is opening or open, yet still runs their setters unconditionally afterward.
- `Layout` runs after `Build`, with bounds known. Use it only to position
children via layouter.LayoutWidget(child, bounds) or a layout helper. Do not read bounds in Build; do not configure widget content in Layout.
widgetBounds.Bounds() gives this widget's own rectangle inside Layout, input, Tick, and Draw. A WidgetBounds only ever describes the widget it was handed to — there is no API to ask it for another widget's bounds. If a parent needs to size or place a child relative to a sibling, drive that from the layout (LinearLayout / layouter), not by trying to read the sibling's rectangle.
widgetBounds.VisibleBounds() gives the part left after ancestor clipping. Use Bounds() for layout coordinates and VisibleBounds() to cull custom drawing. For ordinary cursor hit testing, use widgetBounds.IsHitAtCursor(); it accounts for clipping and higher-layer occlusion. Use VisibleBounds() geometrically only for an additional custom-shape check or a point other than the cursor. In Draw, dst is a clipped subimage whose coordinates are still screen coordinates, so draw at Bounds().Min (or other screen-space coordinates), not at an assumed (0, 0) origin.
Layout with LinearLayout
LinearLayout is the workhorse. Build a slice of LinearLayoutItem, then call LayoutWidgets. Reuse the backing slice across ticks with slices.Delete(s, 0, len(s)) to avoid per-tick allocation (the framework calls Layout often).
Sizing per item (LinearLayoutItem.Size):
guigui.FixedSize(px)— exact pixel length along the layout direction.guigui.FlexibleSize(weight)— shares the leftover space proportionally to
the weight (after fixed/intrinsic items are placed). A bare LinearLayoutItem{Size: guigui.FlexibleSize(1)} with no Widget is a spacer.
- Zero `Size{}` — the item is sized by the widget's own
Measure
(intrinsic size).
Nesting: an item can carry a sub-layout instead of a widget via LinearLayoutItem{Size: ..., Layout: &subLayout} where subLayout is another guigui.LinearLayout. The cross-axis always fills the available extent.
Size things in multiples of basicwidget.UnitSize(context) rather than raw pixels so layouts scale correctly on Hi-DPI and at different app scales.
Share one layout between Layout and Measure
A composite widget usually needs the same LinearLayout in two places: Layout feeds it to LayoutWidgets, and Measure asks it for a size. Build it once in an unexported helper — conventionally named layout — and call that helper from both. The structure then has a single source of truth, and Measure can never drift from what Layout actually does:
LinearLayout is a plain value, so returning one by value is cheap; the helper still reuses the items slice across ticks as before.
Composition and built-in widgets
Compose by embedding child widgets as fields and adding them in Build. The basicwidget package provides the standard catalog — Background, Button, Text, TextInput, NumberInput, Checkbox, Toggle, RadioButton, Slider, Select/Combobox, List[T], Table[T], Panel, Popup, PopupMenu, ContextMenuArea[T], SegmentedControl, Form, Image, Divider, Expander, and more. Configure them with their Set* methods in Build and subscribe to their On* callbacks.
For button actions, default to OnDown; reach for OnUp only when release semantics genuinely matter.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/using-guigui/SKILL.md
Popularity
- Repository stars
- 486
- Repository forks
- 18
- 7-day trend score
- 31
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/guigui-gui/guigui/using-guigui)