Rich
Use when CLI needs better structure, readability, feedback.
Boundary
Use for terminal presentation and interaction design.
- pair with
python when implementing CLI in Python
- keep logging policy, valid, domain behavior outside this skill
- use for how output rendered, not what system means
Reference Map
references/console.md -- console setup, panels, tables, rules, markup, output boundaries
references/progress.md -- status, progress bars, live updates, final summaries
references/logging.md -- RichHandler, tracebacks, stderr, failure presentation
Assets
assets/main.py -- runnable CLI example with table, status, progress, error output
Output Boundaries
- use
Console for user-facing output
- use
logging for operational events
- keep stdout clean when output may be piped or parsed
- send human-readable errors to console configured with
stderr=True
- do not mix
print() with Rich output
Console Setup
from rich.console import Console
console = Console()
error_console = Console(stderr=True)
Keep near CLI entrypoint, not scattered ad hoc console instances.
Common Primitives
Tables
Use Table for compact comparison, status, inventory output.
- keep column names short
- align numbers and durations consistently
- avoid overly wide tables that wrap unpredictably
Panels and Rules
Use Panel and Rule to separate sections only when it improves scanning.
- prefer one or two strong separators over heavy framing everywhere
- do not turn every message into panel
Status and Progress
- use
track() for single simple loop
- use
Progress() when multiple tasks or richer status needed
- keep task labels short and specific
- progress should describe meaningful work, not every tiny function call
Syntax and JSON
- use
Syntax when showing code snippets
- use
JSON when pretty-printing structured payloads for humans
- avoid syntax highlighting for machine-oriented logs or giant payload dumps
Logging and Tracebacks
Use RichHandler when logs part of interactive CLI experience.
from rich.logging import RichHandler
logging.basicConfig(
level="INFO",
format="%(message)s",
handlers=[RichHandler(rich_tracebacks=True)],
)
- keep log messages concise
- prefer structured fields in logs; use Rich for rendering, not hiding detail
- enable rich tracebacks for local CLI tools and developer workflows
Live Output
Use Live when screen should update in place:
- dashboards
- job runners
- multi-step setup flows
- streaming status views
Prefer Live only when evolving state matters. Static output usually easier to debug and copy.
Markup Guardrails
- prefer Rich markup over raw ANSI escapes
- escape or disable markup for untrusted user content
- keep styles purposeful; too much color hurts readability
- use color to signal meaning, not decoration
Good CLI Defaults
- success output short and calm
- failures explicit and actionable
- progress output transient where possible
- final summaries compact
- important identifiers copyable without stripping decorations
1---2name: rich3description: Terminal UX with Rich -- console setup, tables, panels, progress, logging, tracebacks, live updates. Load when building polished CLI output.4---56# Rich78Use when CLI needs better structure, readability, feedback.910## Boundary1112Use for terminal presentation and interaction design.1314- pair with `python` when implementing CLI in Python15- keep logging policy, valid, domain behavior outside this skill16- use for how output rendered, not what system means1718## Reference Map1920- `references/console.md` -- console setup, panels, tables, rules, markup, output boundaries21- `references/progress.md` -- status, progress bars, live updates, final summaries22- `references/logging.md` -- `RichHandler`, tracebacks, stderr, failure presentation2324## Assets2526- `assets/main.py` -- runnable CLI example with table, status, progress, error output2728## Output Boundaries2930- use `Console` for user-facing output31- use `logging` for operational events32- keep stdout clean when output may be piped or parsed33- send human-readable errors to console configured with `stderr=True`34- do not mix `print()` with Rich output3536## Console Setup3738```python39from rich.console import Console4041console = Console()42error_console = Console(stderr=True)43```4445Keep near CLI entrypoint, not scattered ad hoc console instances.4647## Common Primitives4849### Tables5051Use `Table` for compact comparison, status, inventory output.5253- keep column names short54- align numbers and durations consistently55- avoid overly wide tables that wrap unpredictably5657### Panels and Rules5859Use `Panel` and `Rule` to separate sections only when it improves scanning.6061- prefer one or two strong separators over heavy framing everywhere62- do not turn every message into panel6364### Status and Progress6566- use `track()` for single simple loop67- use `Progress()` when multiple tasks or richer status needed68- keep task labels short and specific69- progress should describe meaningful work, not every tiny function call7071### Syntax and JSON7273- use `Syntax` when showing code snippets74- use `JSON` when pretty-printing structured payloads for humans75- avoid syntax highlighting for machine-oriented logs or giant payload dumps7677## Logging and Tracebacks7879Use `RichHandler` when logs part of interactive CLI experience.8081```python82from rich.logging import RichHandler8384logging.basicConfig(85 level="INFO",86 format="%(message)s",87 handlers=[RichHandler(rich_tracebacks=True)],88)89```9091- keep log messages concise92- prefer structured fields in logs; use Rich for rendering, not hiding detail93- enable rich tracebacks for local CLI tools and developer workflows9495## Live Output9697Use `Live` when screen should update in place:9899- dashboards100- job runners101- multi-step setup flows102- streaming status views103104Prefer `Live` only when evolving state matters. Static output usually easier to debug and copy.105106## Markup Guardrails107108- prefer Rich markup over raw ANSI escapes109- escape or disable markup for untrusted user content110- keep styles purposeful; too much color hurts readability111- use color to signal meaning, not decoration112113## Good CLI Defaults114115- success output short and calm116- failures explicit and actionable117- progress output transient where possible118- final summaries compact119- important identifiers copyable without stripping decorations