The 4 Golden Rules
These four rules prevent 90% of TUI layout bugs. They were discovered the hard way across six projects and hundreds of debugging hours.
leftWeight=2, rightWeight=1 beats leftWidth=80. Hardcoded widths break when the terminal resizes.Architecture Pattern
Every Bubbletea project follows this file structure. Separation of concerns keeps each file under 300 lines and makes it easy for Claude to navigate.
your-app/ ========= | +-- main.go Entry point (~21 lines) | +-- types.go Type definitions, structs, enums | +-- model.go Model init & layout calculation | +-- update.go Message dispatcher | +-- update_keyboard.go Keyboard handling | +-- update_mouse.go Mouse handling | +-- view.go View rendering & layouts | +-- styles.go Lipgloss style definitions | +-- config.go Configuration management
Component Catalog
20+ ready-to-use components across 8 categories. Each one is documented with full code examples and integration patterns.
Effects Library
Visual effects for terminal UIs. These run entirely in ANSI text, no graphics libraries needed.
Key Patterns
Battle-tested code patterns extracted from 6+ production projects.
leftWeight, rightWeight := 1, 1 if m.accordionMode && m.focusedPanel == "left" { leftWeight = 2 } totalWeight := leftWeight + rightWeight leftWidth := (availableWidth * leftWeight) / totalWeight
// Never auto-wrap -- always truncate explicitly maxTextWidth := panelWidth - 4 // -2 borders, -2 padding title = truncateString(title, maxTextWidth)
// BAD: Can cause misalignment panelStyle := lipgloss.NewStyle().Border(border).Height(height) // GOOD: Fill content to exact height, then wrap with border for len(lines) < innerHeight { lines = append(lines, "") } panelStyle := lipgloss.NewStyle().Border(border)
War Story: Emoji Width Fix
Reference Files
Five files that make up the complete skill. Bundled as a Go module, included in every new TUI project.
By the Numbers
The Story
This skill captures everything learned building six Go TUI projects in rapid succession -- TFE, TUIClassics, TUITemplate, CellBlocksTUI, Tmuxplexer, and ai-kanban-board -- between October and December 2025.
The 4 Golden Rules alone would have saved weeks of debugging if known from the start. Every project hit the same border-height trap, the same text-wrapping overflow, the same mouse-coordinate mismatch. By the third project, the patterns were clear. By the sixth, they were codified.
The emoji width fix took days of testing across xterm, WezTerm, Termux, and Windows Terminal. Each emulator had its own opinion about how wide an emoji should be. The solution is ugly but it works everywhere.
Now it is bundled as a Go module that gets included in every new TUI project, so Claude starts with all this knowledge on day one. No more rediscovering the border height trap. No more debugging why clicks register in the wrong panel. The field guide is written.