tui-ui
Use when building or fixing a full-screen terminal program: panes, lists, forms, dashboards, a picker, keybindings, focus, resize, the alternate screen and plain mode. Triggers: build a TUI, ratatui TUI, Bubble Tea TUI, Lip Gloss TUI, Ink TUI, Textual TUI, TUI keybinding bar, TUI help screen, TUI alt screen, terminal left in raw mode, terminal layout breaks when I resize, TUI too small, TUI redraw flicker, TUI screen reader plain mode, udelej TUI, klavesove zkratky v TUI, rozlozeni v terminalu. A command that prints and exits (streams, colour, exit codes, errors, progress, help, signals, pipes, secrets) is cli-ui.
- License 许可
- GPL-3.0
- 最近更新
- 2026-11-13
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- tui-ui
- description
- Use when building or fixing a full-screen terminal program: panes, lists, forms, dashboards, a picker, keybindings, focus, resize, the alternate screen and plain mode. Triggers: build a TUI, ratatui TUI, Bubble Tea TUI, Lip Gloss TUI, Ink TUI, Textual TUI, TUI keybinding bar, TUI help screen, TUI alt screen, terminal left in raw mode, terminal layout breaks when I resize, TUI too small, TUI redraw flicker, TUI screen reader plain mode, udelej TUI, klavesove zkratky v TUI, rozlozeni v terminalu. A command that prints and exits (streams, colour, exit codes, errors, progress, help, signals, pipes, secrets) is cli-ui.
03 SKILL.md 正文
Full-screen terminal programs
A TUI owns the screen, the keyboard and the terminal's modes until it exits. It has no hover, no pixels, no compositor, and a reader the screen cannot show it to: a screen reader, a log, a pipe, a shell it must leave intact. Unaided, an agent computes layout from a constant, prints a debug line in the middle of a frame, forgets to restore raw mode on a panic, and lists keys the screen does not honour. This skill is the rules for the author who ships such programs. It does not cover a command that prints and exits (cli-ui), and the rules there (colour order, secrets, exit codes) apply to a TUI's plain mode and to its first and last second.
Why: ui-design (tokens), a11y-audit (criteria), ux-audit (feedback, interruption), animate and animation-vocabulary (motion values). Here: how a program that owns the screen behaves. Measure it headless (below); a screenshot of a terminal proves little.
Framework
Read the manifest first: a framework already in it wins. A TUI is a loop of input, event, state, update, layout and render; the framework gives it, so do not fight its idiom.
- Go: Bubble Tea (Model, Update, View) with Lip Gloss for styles, Bubbles for list, table, input and spinner, Huh for forms.
- Rust: Ratatui with Crossterm;
Table,ListandBlock, stateful widgets for selection. - TypeScript: Ink (React for the terminal) with
@inkjs/ui(its<Spinner>). Ink 7 and later has an option for the alternate screen (inline by default); Ink 8 has no mouse or focus reports and reads the size fromuseWindowSize(), notstdout.columns. - Python: Textual (retained widgets, CSS), with Rich for styled plain output.
A display-width helper is already a dependency of the framework; use it, add no second one.
One architecture, kept apart
- Rendering is a pure function of state and terminal size. I/O is a command or effect (a Bubble
Tea
Cmd, a Ratatui channel and task), never a call inside update or draw, because a blocking call freezes input. - Layout is computed in draw from the real area, never in the key handler and never from a constant. Budget every pane's outer, inner and text width as integers that sum to the parent before writing code: a row of W+1 cells wraps, pushes the top row off and tears the frame, so every row is exactly W cells and the frame exactly H rows.
- Logs go to a file or the framework's log channel. A print during a raw-mode or alternate-screen session corrupts the frame.
The screen buffer and the terminal's modes
- A summon-choose-exit tool (a picker) runs inline: chrome on stderr or
/dev/tty, the chosen answer on stdout, so$(picker)works. Requiring stdout to be a TTY would refuse its own use. A long-lived session takes the alternate screen. On exit, erase the UI or leave a one-line receipt, never a half-drawn frame. - State the terminal contract: a TTY, a minimum grid of your own choosing (design for 80x24
first), and a fallback for each enhancement (truecolor to 256 to 16 to mono, mouse, hyperlinks,
bracketed paste). Unicode is likely, not certain: keep an ASCII twin for every glyph and let the
user force it (
--ascii). No emoji in chrome. - Restore on every exit: raw mode, alternate screen, cursor (cli-ui), mouse reporting; on normal
exit, error, panic and signal (a
Dropguard, adefer, a handler registered once at the process boundary). When the framework owns signals, do not add a second handler beside it. A shell left in raw mode is the worst failure a user meets. - Running an editor, a shell or a child is a pause, not an exit: stop input, restore the terminal, wait, re-enter the modes, reload what the child may have changed, force a full redraw. Never final-unmount an app that must resume. Ctrl-Z suspend has no meaning on Windows.
- Ask for the light or dark background (OSC 11 query with a capped wait, since some terminals never answer, or the framework's request), use the default palette until it answers, and offer a theme override. Never assume dark.
Layout by width, and resize
- Write the floor plan per screen: what happens at 80x24, at a 60-column split and below the minimum, which pane wins, what hides, what truncates, and when "terminal too small" appears. A multi-column layout always has a single-pane fallback. A review that cannot name the floor is unfinished.
- Keep width and height in state and recompute from them on each resize event. Coalesce events only if layout is expensive enough that dragging the window stutters. Cap content width on a huge terminal; prose measure about 72 to 100 cells.
- Truncate with cli-ui's Width rule. Centre only a splash, an empty state or a dialog.
- Right-to-left text goes in its own field; terminals disagree on bidi, so never reverse by hand.
Keys
- One key table per state. The footer hint and the
?help screen are both derived from it, so neither can name a key that does nothing here; a test presses every advertised key. - Everything works by keyboard; the mouse only adds and never gates, and the selection bypass is
documented. Ctrl-C quits even with a text field focused;
qquits only when no field has focus; Esc backs up one level and closes overlays, and never discards typed text without asking. Ctrl-S and Ctrl-Q reach a raw-mode app as plain keys, so binding them is allowed. Handle a lone Esc (tmux delays it). - Exactly one focus is visible, in the same cells whether focused or not, with a cue besides colour. The focused row is always on screen.
- Pasted text is data, never keystrokes. Enable bracketed paste (mode 2004) on free-text fields; a single-line field keeps the first line of a multi-line paste or refuses it, never submits it, because a pasted newline can run as Enter.
- Validate a field on blur or submit, not on each keystroke.
- Apply ux-audit's reversibility rule on screen; focus an irreversible action's confirm on Cancel. The question's wording, the default No and the typed name for data loss are cli-ui's.
Look and states
- Start monochrome. Colour roles and the 16-colour rule are cli-ui's; here each colour has one job (status, active, data); borders only to group, spacing before lines. A glyph marking every row marks nothing.
- Design the empty, loading and error views as states with a next action, never as a crash.
- Waits: the thresholds are cli-ui's Progress. On screen the indicator is a row in the frame, never a print into it. Esc cancels an in-flight request. Loading text names the work, and an error names the cause and remedy (cli-ui's Messages).
- Motion in a terminal is a redraw, not a composite: animate's curves, durations and property rules do not apply. No animation on a keyboard action. A spinner or loop is stepped, never carries information alone, and stops when motion is off (cli-ui). One frame clock for the app; an idle screen does not tick and a spinner steps every second frame, because the cost is bytes written per redraw. Redraw only what changed.
- Depth is one step of background shade or a rule line, never transparency; hierarchy is bold, dim and case, never colour alone. The font is the person's.
- Stress it: an environment variable (
APP_DATA=worst,empty,one) swaps the data source where rows load, andAPP_VARIANT=2picks a design variant there; one binary prints each, nothing is edited. Check the narrow 60-to-80-column band and below the application's minimum (gfargovisual-patterns.md). Width and table folding follow cli-ui.
Plain mode
Every action is reachable in a linear mode, chosen by a flag or an environment variable
(--plain, ACCESSIBLE=1), never by guessing a screen reader. In it: no alternate screen, status
lines appended instead of repainted, menu choices numbered, each line labelled by kind, and meaning
never carried by position. Streams, the colour carrier and table folding are cli-ui's. Why:
screen readers read a TUI poorly, and this mode is the practical help.
Prove it headless
Drive state transitions, event to action, and a frame at a pinned size and colour profile (80x24,
60 columns and the minimum) with scripted keys (Down Down Enter) and an injected clock, with no
TTY, so CI runs it. Snapshot per size, not once.
Red flags
- Layout from a constant, or in the key handler: move it to draw, from the real area.
- A print, a log call or a library that writes to stdout while the screen is owned: send it to a file.
- No restore on panic or signal: add the guard, because the shell stays raw.
- A footer that lists keys by hand: derive it from the key table.
- A mouse-only action, or an action missing from plain mode: add the keyboard path.
- Rows of W+1 cells or a spinner on an idle screen: fix each, they tear the frame. Text-width defects follow cli-ui's Width rule.
- A confirm on every delete: offer undo and confirm only the irreversible.
Say it in the reply
- The framework and why, the buffer (inline or alternate) and what is restored on exit.
- The floor plan: what 80x24, a narrow split and below-minimum do.
- The key table and where the footer and help read it from.
- What plain mode prints, from a run. Anything unverified: a terminal or size you did not run in.
Sources: gfargo/tui-design-skill (MIT), pageton/tui-design-skill (MIT), jrschumacher/skill-bubbletea-tui (MIT), clig.dev (CC-BY-SA-4.0, paraphrased).
04 同仓库更多 Skills
worktrunk
Use when working with git worktrees or wt (worktrunk): creating, switching, merging or removing a branch workspace, configuring wt (project or personal config, workflow hooks around switch, commit and merge, commit-message generation, hook approvals), or a wt command that failed. Triggers: make a worktree for this branch, wt merge, wt remove, configure wt, .config/wt.toml, run tests before merge, install deps when a worktree is created, wt hook, wt switch does not cd, nastav wt, wt nefunguje.
web-ladder
Use when a task needs something the internet holds: look something up, search the web, find which page answers a question, read a page, check a library's current docs, a page that needs a browser or shows a captcha. Runs one research loop: searxng search, keywords, cases, search again up to three times, Context7 for a library, Tavily when the keywords will not come, one page in a browser, the person on a wall. Triggers: look this up, search the web, find out online, read this page, check the docs, the page is blocked, captcha, najdi na webu, otevri tu stranku. A multi-round question goes to the qsm-web:web-research agent; one tool's commands are its own skill (searxng, browserbox, opensrc).
searxng
Use when running a web search through the person's own SearXNG instance with qsm-web searxng: choosing a search profile or engines, the instance, time range or language, reading its JSON, a suspended engine. Triggers: search with searxng, qsm-web searxng, search profile, niche search, academic search, IT search, vyhledavaci profil, searxng is down, which engines. The research loop around it is the web-ladder skill.
opensrc
Use when the source code of an open-source library or repository is needed on disk to read: the docs are silent, the behaviour must be checked in code, the version the project pins. Runs qsm-web opensrc get with a package spec or a repository address. Triggers: get the source of this package, clone this library, read the library's code, qsm-web opensrc, stahni zdrojak knihovny. Library docs are the Context7 skill; the research loop is the web-ladder skill.
browserbox
Use when one page needs a real browser through qsm-web browserbox: content built by script, a page that blocks plain fetching, a captcha to solve or hand to the person, a scripted sequence of clicks, a login the person is present for. Triggers: open it in a browser, the page is empty without JavaScript, captcha, take over the browser, run these steps on the page, log in to this site, browserbox. When to reach for a browser at all is the web-ladder skill.
usage
Use when the user wants a review of how they use Claude Code, or setup hands over after a first install: review my Claude Code usage, audit my setup, what does my setup cost, where did my tokens go, clean up my Claude Code, usage report, zkontroluj moje pouzivani. One walkthrough of four stages (machine, work, habits, extensions), questions after each, then one plan. A question about one topic (which hooks are slow) goes to that topic's skill; this session's tokens alone is `/qsm-usage`.