
Rust Tui Ratatui
- 6 installs
- 5 repo stars
- Updated August 5, 2026
- bjornmelin/dev-skills
Rust-tui-ratatui is a Claude Code skill for building Rust terminal UIs with Ratatui, crossterm event loops, and testable rendering.
About
Rust-tui-ratatui is a Claude Code skill for building Rust terminal user interfaces with Ratatui. It covers widgets and layouts, crossterm or termion event loops, async input, app state machines, keybindings, terminal UX, and snapshot tests. A developer uses it when building interactive TUIs that need persistent terminal state, keeping rendering pure and treating terminal cleanup as reliability-critical.
- Builds terminal UIs with Ratatui widgets, layouts, and event loops
- Uses an app/event/action/update/render architecture with clear state ownership
- Covers snapshot tests, keybinding tests, and reliable terminal cleanup
Rust Tui Ratatui by the numbers
- 6 all-time installs (skills.sh)
- Ranked #90 of 121 Rust skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
rust-tui-ratatui capabilities & compatibility
Free; uses the Rust toolchain and cargo.
- Capabilities
- terminal ui · tui testing · rust backend
- Use cases
- frontend · ui design · testing
- Pricing
- Free
What rust-tui-ratatui says it does
Build terminal applications with clear state ownership, predictable rendering, responsive input, and testable UI contracts.
Treat terminal cleanup as reliability-critical. Restore raw mode and alternate screen on all normal and error exits.
Use an app/event/action/update/render shape for nontrivial TUIs.
npx skills add https://github.com/bjornmelin/dev-skills --skill rust-tui-ratatuiAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 6 |
|---|---|
| repo stars | ★ 5 |
| Last updated | August 5, 2026 |
| Repository | bjornmelin/dev-skills ↗ |
What it does
Build interactive Rust terminal UIs with Ratatui, clear state ownership, and testable rendering.
Who is it for?
Ratatui widgets and layouts, event loops, app state machines, keybindings, terminal UX, and snapshot tests.
Skip if: Non-TUI Rust work or plain CLIs with only occasional prompts, which route to rust-cli-clap.
When should I use this skill?
Building terminal UIs, ratatui widgets/layouts, crossterm event loops, async input, or TUI snapshot tests.
What you get
Terminal applications with clear state ownership, predictable rendering, responsive input, and testable UI contracts.
- Ratatui widgets and layouts
- event loop and state machine
- render and keybinding tests
By the numbers
- 5-point operating model
- 3 reference guides
Files
Rust TUI Ratatui
Build terminal applications with clear state ownership, predictable rendering, responsive input, and testable UI contracts.
Operating Model
1. Identify whether the app is a true TUI, a CLI with occasional prompts, or a daemon dashboard. Use Ratatui only when persistent terminal state and interactive views are justified. 2. Keep rendering pure: widgets read immutable view models and write to frames. Event handlers mutate application state through explicit actions. 3. Use an app/event/action/update/render shape for nontrivial TUIs. Avoid spreading terminal I/O across widgets. 4. Treat terminal cleanup as reliability-critical. Restore raw mode and alternate screen on all normal and error exits. 5. Preserve accessibility of terminal UX: discoverable keybindings, no required color-only state, clear focus, and deterministic fallback for narrow terminals.
Reference Map
references/ratatui-app-architecture.mdfor app structure, state machines, view models, layout, widgets, and theme ownership.references/events-async-terminal.mdfor crossterm, async tasks, cancellation, terminal restoration, and resize handling.references/testing-ux.mdfor buffer assertions, insta snapshots, keybinding tests, and performance checks.
Defaults
- Prefer
ratatuiwithcrosstermunless the repository has an established backend. - Use typed actions/events instead of pushing raw key events through business logic.
- Keep long-running work in tasks; never block the render/input loop on network or disk-heavy operations.
- Use bounded channels and cancellation tokens for background work.
- Use
unicode-widthor Ratatui text primitives for display width. Do not assume byte length equals terminal width.
Verification
Use focused tests for state transitions and rendering:
cargo fmt --all --check
cargo test --all-targets
cargo clippy --all-targets --all-features -- -D warningsAdd render snapshots for stable screens, action/update tests for key flows, and at least one terminal cleanup path test when introducing a new event loop abstraction.
display_name: Rust TUI Ratatui
short_description: Rust terminal UI architecture.
default_prompt: Use $rust-tui-ratatui to design, implement, test, or review Rust terminal UIs with Ratatui.
policy:
allow_implicit_invocation: true
metadata:
skill_category: rust
primary_domains:
- tui
- ratatui
- crossterm
- terminal-ui
[
{
"query": "Build a ratatui dashboard with tabs, async refresh, and keybindings.",
"should_trigger": true,
"reason": "Ratatui dashboard architecture is the direct trigger."
},
{
"query": "Review this crossterm event loop for terminal cleanup and resize handling.",
"should_trigger": true,
"reason": "Terminal event loop reliability belongs to this skill."
},
{
"query": "Add insta snapshots for Ratatui buffers and test focus movement.",
"should_trigger": true,
"reason": "TUI rendering tests are in scope."
},
{
"query": "Add a clap subcommand that prints JSON.",
"should_trigger": false,
"reason": "CLI parser and stdout contracts belong to rust-cli-clap."
},
{
"query": "Configure a Tauri capability for filesystem access.",
"should_trigger": false,
"reason": "Tauri capability work belongs to rust-tauri-apps."
},
{
"query": "Design an Axum REST API with request tracing.",
"should_trigger": false,
"reason": "HTTP service work belongs to rust-web-services."
}
]
Events, Async, and Terminal Safety
Event Loop
Use one clear owner for terminal setup and teardown:
- enter alternate screen
- enable raw mode
- install panic/error restoration if needed
- run loop
- restore terminal on every exit path
Avoid early returns between setup and cleanup unless guarded by RAII.
Async Work
Do not block the input/render loop. For async applications:
- Use
tokiotasks for network or disk-heavy operations. - Send task results back as typed events.
- Use bounded channels to avoid unbounded memory growth.
- Use cancellation tokens for work tied to a screen or query.
- Debounce high-frequency inputs such as search.
Ticks and Rendering
Render on meaningful changes where possible. If using ticks, keep the interval intentional and cheap.
Handle resize events explicitly. Recompute layouts and clamp focus/scroll state after size changes.
Error Handling
Terminal restoration is more important than pretty errors. Restore first, then report.
Use domain errors for recoverable failures and keep fatal terminal/runtime errors rare and well explained.
Ratatui App Architecture
Structure
For nontrivial TUIs, use explicit layers:
App: owns durable state and mode.Event: external input such as keys, resize, ticks, task results.ActionorMessage: semantic intent.update: transforms state from actions.view model: computed display data.render: pure frame drawing from state/view model.
This keeps business behavior testable without a terminal and keeps widgets free of hidden side effects.
State and Modes
Represent major screens and modal flows with enums. Avoid boolean clusters such as is_searching, is_editing, is_help_open when only one mode can be active.
Keep focus explicit. For tables/lists, centralize selection state and clamp it after data changes.
Layout
- Use named layout helpers for reused regions.
- Define minimum supported dimensions and fallback views.
- Prefer predictable split constraints over chains of magic percentages.
- Keep theme/style ownership in one module or struct.
Widgets
Custom widgets should be small and deterministic:
- Inputs: immutable state/view model.
- Outputs: draw calls only.
- No direct I/O.
- No spawning tasks.
- No mutation outside documented state objects.
When a widget becomes complex, split data preparation from drawing rather than introducing mutable global UI state.
Domain Integration
Keep domain operations behind services or command objects. The TUI should request work and receive results, not own database clients, HTTP retry policy, or file scanners directly inside render/update functions.
Testing and UX
Tests
Use state/update tests for most behavior:
- keybinding maps to action
- action mutates state
- selection/focus clamps after data changes
- modal transitions are legal
- task results update visible state
Use render tests for stable screens. Ratatui buffers can be compared directly or snapshot-tested with insta after normalizing dynamic content.
Keybindings
- Keep global keys small and documented in-app.
- Avoid conflicting mode-specific keys.
- Provide an obvious quit path.
- Do not require mouse support for primary workflows.
Terminal UX
- Support narrow terminals with fallback layouts.
- Avoid color-only state.
- Preserve scroll position when refreshing data if the selected item still exists.
- Keep loading, empty, and error states first-class.
Performance
Large lists need virtualization or bounded rendering. Avoid reformatting thousands of rows every frame. Precompute expensive strings when data changes, not while drawing.
Related skills
FAQ
What architecture does rust-tui-ratatui use?
An app/event/action/update/render shape for nontrivial TUIs, keeping rendering pure and mutating state through explicit actions.
Why is terminal cleanup emphasized?
It is reliability-critical: raw mode and the alternate screen must be restored on all normal and error exits.