bubbletea
Skill1 starsChanged 6 months agoMITView on GitHub
Build terminal user interfaces with Go and Bubbletea framework. Use for creating TUI apps with the Elm architecture, dual-pane layouts, accordion modes, mouse/keyboard handling, Lipgloss styling, and reusable components. Includes production-ready templates, effects library, and battle-tested layout patterns from real projects.
7 other projects use a version of this, 2 of them edited.
Adopted by
Most recently taken up by
- devantler-tech/ksailedited, first seen Nov 7, 2026
- compozy/compozytheir own version, first seen Nov 7, 2026
- carapace-sh/carapace-bintheir own version, first seen Oct 8, 2026
- hmans/beanstheir own version, first seen Oct 8, 2026
- 1024XEngineer/bytemindtheir own version, first seen May 8, 2026
- FelipeAngeli/skillsedited, first seen Apr 10, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 2
- devantler-tech/ksail★ 16497% same
- FelipeAngeli/skills★ 295% same
Wrote their own version · 5
- compozy/compozy★ 2.9ksame name
- carapace-sh/carapace-bin★ 2ksame name
- hmans/beans★ 951same name
- pedronauck/skills★ 649same name
- 1024XEngineer/bytemind★ 43same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository6 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- coding-standardsSkill
- golang-patternsSkill
- golang-proSkill
- security-reviewSkill
- skillscopeSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. 0 are common, 15 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
15
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Use this skill when:
- Very specific: line 24
CRITICAL: Before implementing ANY layout, consult references/golden-rules.md for the 4 Golden Rules.
- Distinctive: line 29
Never Auto-Wrap in Bordered Panels: - Always truncate text explicitly
- Distinctive: line 30
Match Mouse Detection to Layout: - Use X coords for horizontal, Y coords for vertical
- Distinctive: line 41
All new projects follow this architecture:
- Very specific: line 58
Keep main.go minimal (entry point only, ~21 lines)
- Very specific: line 59
All types in types.go (structs, enums, constants)
- Distinctive: line 91
When implementing layouts, follow this sequence:
- Distinctive: line 147
Always check layout mode before processing mouse events:
- Distinctive: line 199
When panels don't align or render incorrectly:
- Distinctive: line 201
Check height accounting: - Verify contentHeight calculation subtracts all UI elements + borders
- Distinctive: line 202
Check text wrapping: - Ensure all strings are truncated to maxTextWidth
- Distinctive: line 203
Check mouse detection: - Verify X/Y coordinate usage matches layout orientation
- Distinctive: line 204
Check border consistency: - Use same border style for all panels
- Distinctive: line 210
All projects support YAML configuration with hot-reload:
- Distinctive: line 253
All reference files are loaded progressively as needed:
- Distinctive: line 270
Always: use weight-based sizing for flexible layouts
- Distinctive: line 277
Follow these patterns and you'll avoid 90% of TUI layout bugs.
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Bubbletea TUI Development
Production-ready skill for building beautiful terminal user interfaces with Go, Bubbletea, and Lipgloss.
When to Use This Skill
Use this skill when:
- Creating new TUI applications with Go
- Adding Bubbletea components to existing apps
- Fixing layout/rendering issues (borders, alignment, overflow)
- Implementing mouse/keyboard interactions
- Building dual-pane or multi-panel layouts
- Adding visual effects (metaballs, waves, rainbow text)
- Troubleshooting TUI rendering problems
Core Principles
CRITICAL: Before implementing ANY layout, consult references/golden-rules.md for the 4 Golden Rules. These rules prevent the most common and frustrating TUI layout bugs.
The 4 Golden Rules (Summary)
- Always Account for Borders - Subtract 2 from height calculations BEFORE rendering panels
- Never Auto-Wrap in Bordered Panels - Always truncate text explicitly
- Match Mouse Detection to Layout - Use X coords for horizontal, Y coords for vertical
- Use Weights, Not Pixels - Proportional layouts scale perfectly
Full details and examples in references/golden-rules.md.
Creating New Projects
This project includes a production-ready template system. When this skill is bundled with a new project (via new_project.sh), use the existing template structure as the starting point.
Project Structure
All new projects follow this architecture:
your-app/
├── main.go # Entry point (minimal, ~21 lines)
├── types.go # Type definitions, structs, enums
├── model.go # Model initialization & 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
└── .claude/skills/bubbletea/ # This skill (bundled)Architecture Guidelines
- Keep
main.gominimal (entry point only, ~21 lines) - All types in
types.go(structs, enums, constants) - Separate keyboard and mouse handling into dedicated files
- One file, one responsibility
- Maximum file size: 800 lines (ideally <500)
- Configuration via YAML with hot-reload support
Available Components
See references/components.md for the complete catalog of reusable components:
- Panel System: Single, dual-pane, multi-panel, tabbed layouts
- Lists: Simple list, filtered list, tree view
- Input: Text input, multiline, forms, autocomplete
- Dialogs: Confirm, input, progress, modal
- Menus: Context menu, command palette, menu bar
- Status: Status bar, title bar, breadcrumbs
- Preview: Text, markdown, syntax highlighting, images, hex
- Tables: Simple and interactive tables
Effects Library
Beautiful physics-based animations available in the template:
- 🔮 Metaballs - Lava lamp-style floating blobs
- 🌊 Wave Effects - Sine wave distortions
- 🌈 Rainbow Cycling - Animated color gradients
- 🎭 Layer Compositor - ANSI-aware multi-layer rendering
See references/effects.md for usage examples and integration patterns.
Layout Implementation Pattern
When implementing layouts, follow this sequence:
1. Calculate Available Space
func (m model) calculateLayout() (int, int) {
contentWidth := m.width
contentHeight := m.height
// Subtract UI elements
if m.config.UI.ShowTitle {
contentHeight -= 3 // title bar (3 lines)
}
if m.config.UI.ShowStatus {
contentHeight -= 1 // status bar
}
// CRITICAL: Account for panel borders
contentHeight -= 2 // top + bottom borders
return contentWidth, contentHeight
}2. Use Weight-Based Panel Sizing
// Calculate weights based on focus/accordion mode
leftWeight, rightWeight := 1, 1
if m.accordionMode && m.focusedPanel == "left" {
leftWeight = 2 // Focused panel gets 2x weight
}
// Calculate actual widths from weights
totalWeight := leftWeight + rightWeight
leftWidth := (availableWidth * leftWeight) / totalWeight
rightWidth := availableWidth - leftWidth3. Truncate Text to Prevent Wrapping
// Calculate max text width to prevent wrapping
maxTextWidth := panelWidth - 4 // -2 borders, -2 padding
// Truncate ALL text before rendering
title = truncateString(title, maxTextWidth)
subtitle = truncateString(subtitle, maxTextWidth)
func truncateString(s string, maxLen int) string {
if len(s) <= maxLen {
return s
}
return s[:maxLen-1] + "…"
}Mouse Interaction Pattern
Always check layout mode before processing mouse events:
func (m model) handleLeftClick(msg tea.MouseMsg) (tea.Model, tea.Cmd) {
if m.shouldUseVerticalStack() {
// Vertical stack mode: use Y coordinates
topHeight, _ := m.calculateVerticalStackLayout()
relY := msg.Y - contentStartY
if relY < topHeight {
m.focusedPanel = "left" // Top panel
} else {
m.focusedPanel = "right" // Bottom panel
}
} else {
// Side-by-side mode: use X coordinates
leftWidth, _ := m.calculateDualPaneLayout()
if msg.X < leftWidth {
m.focusedPanel = "left"
} else {
m.focusedPanel = "right"
}
}
return m, nil
}Common Pitfalls to Avoid
See references/troubleshooting.md for detailed solutions to common issues:
❌ DON'T: Set explicit Height() on bordered panels
// BAD: Can cause misalignment
panelStyle := lipgloss.NewStyle().
Border(border).
Height(height) // Don't do this!✅ DO: Fill content to exact height
// GOOD: Fill content lines to exact height
for len(lines) < innerHeight {
lines = append(lines, "")
}
panelStyle := lipgloss.NewStyle().Border(border)Testing and Debugging
When panels don't align or render incorrectly:
- Check height accounting - Verify contentHeight calculation subtracts all UI elements + borders
- Check text wrapping - Ensure all strings are truncated to maxTextWidth
- Check mouse detection - Verify X/Y coordinate usage matches layout orientation
- Check border consistency - Use same border style for all panels
See references/troubleshooting.md for the complete debugging decision tree.
Configuration System
All projects support YAML configuration with hot-reload:
theme: "dark"
keybindings: "default"
layout:
type: "dual_pane"
split_ratio: 0.5
accordion_mode: true
ui:
show_title: true
show_status: true
mouse_enabled: true
show_icons: trueConfiguration files are loaded from:
~/.config/your-app/config.yaml(user config)./config.yaml(local override)
Dependencies
Required:
github.com/charmbracelet/bubbletea
github.com/charmbracelet/lipgloss
github.com/charmbracelet/bubbles
gopkg.in/yaml.v3Optional (uncomment in go.mod as needed):
github.com/charmbracelet/glamour # Markdown rendering
github.com/charmbracelet/huh # Forms
github.com/alecthomas/chroma/v2 # Syntax highlighting
github.com/evertras/bubble-table # Interactive tables
github.com/koki-develop/go-fzf # Fuzzy finderReference Documentation
All reference files are loaded progressively as needed:
- golden-rules.md - Critical layout patterns and anti-patterns
- components.md - Complete catalog of reusable components
- troubleshooting.md - Common issues and debugging decision tree
- emoji-width-fix.md - Battle-tested solution for emoji alignment across terminals (xterm, WezTerm, Termux, Windows Terminal)
External Resources
Best Practices Summary
- Always consult golden-rules.md before implementing layouts
- Always use weight-based sizing for flexible layouts
- Always truncate text explicitly (never rely on auto-wrap)
- Always match mouse detection to layout orientation
- Always account for borders in height calculations
- Never set explicit Height() on bordered Lipgloss styles
- Never assume layout orientation in mouse handlers
Follow these patterns and you'll avoid 90% of TUI layout bugs.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

