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?
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: bubbletea-code-review3description: Reviews BubbleTea TUI code for proper Elm architecture, model/update/view patterns, and Lipgloss styling. Use when reviewing terminal UI code using charmbracelet/bubbletea. Use when this capability is needed.4---56# BubbleTea Code Review78## Quick Reference910| Issue Type | Reference |11|------------|-----------|12| Elm architecture, tea.Cmd as data | [references/elm-architecture.md](references/elm-architecture.md) |13| Model state, message handling | [references/model-update.md](references/model-update.md) |14| View rendering, Lipgloss styling | [references/view-styling.md](references/view-styling.md) |15| Component composition, Huh forms | [references/composition.md](references/composition.md) |16| Bubbles components (list, table, etc.) | [references/bubbles-components.md](references/bubbles-components.md) |1718## CRITICAL: Avoid False Positives1920**Read [elm-architecture.md](references/elm-architecture.md) first!** The most common review mistake is flagging correct patterns as bugs.2122### NOT Issues (Do NOT Flag These)2324| Pattern | Why It's Correct |25|---------|------------------|26| `return m, m.loadData()` | `tea.Cmd` is returned immediately; runtime executes async |27| Value receiver on `Update()` | Standard BubbleTea pattern; model returned by value |28| Nested `m.child, cmd = m.child.Update(msg)` | Normal component composition |29| Helper functions returning `tea.Cmd` | Creates command descriptor, no I/O in Update |30| `tea.Batch(cmd1, cmd2)` | Commands execute concurrently by runtime |3132### ACTUAL Issues (DO Flag These)3334| Pattern | Why It's Wrong |35|---------|----------------|36| `os.ReadFile()` in Update | Blocks UI thread |37| `http.Get()` in Update | Network I/O blocks |38| `time.Sleep()` in Update | Freezes UI |39| `<-channel` in Update (blocking) | May block indefinitely |40| `huh.Form.Run()` in Update | Blocking call |4142## Review Checklist4344### Architecture45- [ ] **No blocking I/O in Update()** (file, network, sleep)46- [ ] Helper functions returning `tea.Cmd` are NOT flagged as blocking47- [ ] Commands used for all async operations4849### Model & Update50- [ ] Model is immutable (Update returns new model, not mutates)51- [ ] Init returns proper initial command (or nil)52- [ ] Update handles all expected message types53- [ ] WindowSizeMsg handled for responsive layout54- [ ] tea.Batch used for multiple commands55- [ ] tea.Quit used correctly for exit5657### View & Styling58- [ ] View is a pure function (no side effects)59- [ ] Lipgloss styles defined once, not in View60- [ ] Key bindings use key.Matches with help.KeyMap6162### Components63- [ ] Sub-component updates propagated correctly64- [ ] Bubbles components initialized with dimensions65- [ ] Huh forms embedded via Update loop (not Run())6667## Critical Patterns6869### Model Must Be Immutable7071```go72// BAD - mutates model73func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {74 m.items = append(m.items, newItem) // mutation!75 return m, nil76}7778// GOOD - returns new model79func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {80 newItems := make([]Item, len(m.items)+1)81 copy(newItems, m.items)82 newItems[len(m.items)] = newItem83 m.items = newItems84 return m, nil85}86```8788### Commands for Async/IO8990```go91// BAD - blocking in Update92func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {93 data, _ := os.ReadFile("config.json") // blocks UI!94 m.config = parse(data)95 return m, nil96}9798// GOOD - use commands99func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {100 return m, loadConfigCmd()101}102103func loadConfigCmd() tea.Cmd {104 return func() tea.Msg {105 data, err := os.ReadFile("config.json")106 if err != nil {107 return errMsg{err}108 }109 return configLoadedMsg{parse(data)}110 }111}112```113114### Styles Defined Once115116```go117// BAD - creates new style each render118func (m Model) View() string {119 style := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("205"))120 return style.Render("Hello")121}122123// GOOD - define styles at package level or in model124var titleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("205"))125126func (m Model) View() string {127 return titleStyle.Render("Hello")128}129```130131## When to Load References132133- **First time reviewing BubbleTea** → [elm-architecture.md](references/elm-architecture.md) (prevents false positives)134- Reviewing Update function logic → [model-update.md](references/model-update.md)135- Reviewing View function, styling → [view-styling.md](references/view-styling.md)136- Reviewing component hierarchy → [composition.md](references/composition.md)137- Using Bubbles components → [bubbles-components.md](references/bubbles-components.md)138139## Review Questions1401411. Is Update() free of blocking I/O? (NOT: "is the cmd helper blocking?")1422. Is the model immutable in Update?1433. Are Lipgloss styles defined once, not in View?1444. Is WindowSizeMsg handled for resizing?1455. Are key bindings documented with help.KeyMap?1466. Are Bubbles components sized correctly?147148---149> Converted and distributed by [TomeVault](https://tomevault.io/claim/existential-birds) — claim your Tome and manage your conversions.150<!-- tomevault:4.0:skill_md:2026-04-11 -->