name: bubbletea-code-review
description: Reviews BubbleTea TUI code for proper Elm architecture, model/update/view patterns, and Lipgloss styling. Use when reviewing terminal UI code using charmbracelet/bubbletea.
BubbleTea Code Review
Quick Reference
| Issue Type |
Reference |
| Elm architecture, tea.Cmd as data |
references/elm-architecture.md |
| Model state, message handling |
references/model-update.md |
| View rendering, Lipgloss styling |
references/view-styling.md |
| Component composition, Huh forms |
references/composition.md |
| Bubbles components (list, table, etc.) |
references/bubbles-components.md |
CRITICAL: Avoid False Positives
Read elm-architecture.md first! The most common review mistake is flagging correct patterns as bugs.
NOT Issues (Do NOT Flag These)
| Pattern |
Why It's Correct |
return m, m.loadData() |
tea.Cmd is returned immediately; runtime executes async |
Value receiver on Update() |
Standard BubbleTea pattern; model returned by value |
Nested m.child, cmd = m.child.Update(msg) |
Normal component composition |
Helper functions returning tea.Cmd |
Creates command descriptor, no I/O in Update |
tea.Batch(cmd1, cmd2) |
Commands execute concurrently by runtime |
ACTUAL Issues (DO Flag These)
| Pattern |
Why It's Wrong |
os.ReadFile() in Update |
Blocks UI thread |
http.Get() in Update |
Network I/O blocks |
time.Sleep() in Update |
Freezes UI |
<-channel in Update (blocking) |
May block indefinitely |
huh.Form.Run() in Update |
Blocking call |
Review Checklist
Architecture
Model & Update
View & Styling
Components
Critical Patterns
Model Must Be Immutable
// BAD - mutates model
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.items = append(m.items, newItem) // mutation!
return m, nil
}
// GOOD - returns new model
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
newItems := make([]Item, len(m.items)+1)
copy(newItems, m.items)
newItems[len(m.items)] = newItem
m.items = newItems
return m, nil
}
Commands for Async/IO
// BAD - blocking in Update
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
data, _ := os.ReadFile("config.json") // blocks UI!
m.config = parse(data)
return m, nil
}
// GOOD - use commands
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, loadConfigCmd()
}
func loadConfigCmd() tea.Cmd {
return func() tea.Msg {
data, err := os.ReadFile("config.json")
if err != nil {
return errMsg{err}
}
return configLoadedMsg{parse(data)}
}
}
Styles Defined Once
// BAD - creates new style each render
func (m Model) View() string {
style := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("205"))
return style.Render("Hello")
}
// GOOD - define styles at package level or in model
var titleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("205"))
func (m Model) View() string {
return titleStyle.Render("Hello")
}
When to Load References
- First time reviewing BubbleTea ? elm-architecture.md (prevents false positives)
- Reviewing Update function logic ? model-update.md
- Reviewing View function, styling ? view-styling.md
- Reviewing component hierarchy ? composition.md
- Using Bubbles components ? bubbles-components.md
Review Questions
- Is Update() free of blocking I/O? (NOT: "is the cmd helper blocking?")
- Is the model immutable in Update?
- Are Lipgloss styles defined once, not in View?
- Is WindowSizeMsg handled for resizing?
- Are key bindings documented with help.KeyMap?
- Are Bubbles components sized correctly?
Source: 1024XEngineer/bytemind — distributed by TomeVault.
1---2name: 1024xengineer-bytemind-bytemind3description: ---4---5---6name: bubbletea-code-review7description: Reviews BubbleTea TUI code for proper Elm architecture, model/update/view patterns, and Lipgloss styling. Use when reviewing terminal UI code using charmbracelet/bubbletea.8---910# BubbleTea Code Review1112## Quick Reference1314| Issue Type | Reference |15|------------|-----------|16| Elm architecture, tea.Cmd as data | [references/elm-architecture.md](references/elm-architecture.md) |17| Model state, message handling | [references/model-update.md](references/model-update.md) |18| View rendering, Lipgloss styling | [references/view-styling.md](references/view-styling.md) |19| Component composition, Huh forms | [references/composition.md](references/composition.md) |20| Bubbles components (list, table, etc.) | [references/bubbles-components.md](references/bubbles-components.md) |2122## CRITICAL: Avoid False Positives2324**Read [elm-architecture.md](references/elm-architecture.md) first!** The most common review mistake is flagging correct patterns as bugs.2526### NOT Issues (Do NOT Flag These)2728| Pattern | Why It's Correct |29|---------|------------------|30| `return m, m.loadData()` | `tea.Cmd` is returned immediately; runtime executes async |31| Value receiver on `Update()` | Standard BubbleTea pattern; model returned by value |32| Nested `m.child, cmd = m.child.Update(msg)` | Normal component composition |33| Helper functions returning `tea.Cmd` | Creates command descriptor, no I/O in Update |34| `tea.Batch(cmd1, cmd2)` | Commands execute concurrently by runtime |3536### ACTUAL Issues (DO Flag These)3738| Pattern | Why It's Wrong |39|---------|----------------|40| `os.ReadFile()` in Update | Blocks UI thread |41| `http.Get()` in Update | Network I/O blocks |42| `time.Sleep()` in Update | Freezes UI |43| `<-channel` in Update (blocking) | May block indefinitely |44| `huh.Form.Run()` in Update | Blocking call |4546## Review Checklist4748### Architecture49- [ ] **No blocking I/O in Update()** (file, network, sleep)50- [ ] Helper functions returning `tea.Cmd` are NOT flagged as blocking51- [ ] Commands used for all async operations5253### Model & Update54- [ ] Model is immutable (Update returns new model, not mutates)55- [ ] Init returns proper initial command (or nil)56- [ ] Update handles all expected message types57- [ ] WindowSizeMsg handled for responsive layout58- [ ] tea.Batch used for multiple commands59- [ ] tea.Quit used correctly for exit6061### View & Styling62- [ ] View is a pure function (no side effects)63- [ ] Lipgloss styles defined once, not in View64- [ ] Key bindings use key.Matches with help.KeyMap6566### Components67- [ ] Sub-component updates propagated correctly68- [ ] Bubbles components initialized with dimensions69- [ ] Huh forms embedded via Update loop (not Run())7071## Critical Patterns7273### Model Must Be Immutable7475```go76// BAD - mutates model77func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {78 m.items = append(m.items, newItem) // mutation!79 return m, nil80}8182// GOOD - returns new model83func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {84 newItems := make([]Item, len(m.items)+1)85 copy(newItems, m.items)86 newItems[len(m.items)] = newItem87 m.items = newItems88 return m, nil89}90```9192### Commands for Async/IO9394```go95// BAD - blocking in Update96func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {97 data, _ := os.ReadFile("config.json") // blocks UI!98 m.config = parse(data)99 return m, nil100}101102// GOOD - use commands103func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {104 return m, loadConfigCmd()105}106107func loadConfigCmd() tea.Cmd {108 return func() tea.Msg {109 data, err := os.ReadFile("config.json")110 if err != nil {111 return errMsg{err}112 }113 return configLoadedMsg{parse(data)}114 }115}116```117118### Styles Defined Once119120```go121// BAD - creates new style each render122func (m Model) View() string {123 style := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("205"))124 return style.Render("Hello")125}126127// GOOD - define styles at package level or in model128var titleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("205"))129130func (m Model) View() string {131 return titleStyle.Render("Hello")132}133```134135## When to Load References136137- **First time reviewing BubbleTea** ? [elm-architecture.md](references/elm-architecture.md) (prevents false positives)138- Reviewing Update function logic ? [model-update.md](references/model-update.md)139- Reviewing View function, styling ? [view-styling.md](references/view-styling.md)140- Reviewing component hierarchy ? [composition.md](references/composition.md)141- Using Bubbles components ? [bubbles-components.md](references/bubbles-components.md)142143## Review Questions1441451. Is Update() free of blocking I/O? (NOT: "is the cmd helper blocking?")1462. Is the model immutable in Update?1473. Are Lipgloss styles defined once, not in View?1484. Is WindowSizeMsg handled for resizing?1495. Are key bindings documented with help.KeyMap?1506. Are Bubbles components sized correctly?151152---153> Source: [1024XEngineer/bytemind](https://github.com/1024XEngineer/bytemind) — distributed by [TomeVault](https://tomevault.io).154<!-- tomevault:4.0:skill_md:2026-06-19 -->