prototype
MAmattpocock/skills288k10,178 new stars in the last 7 days
Also available at https://sacred.computer/llm/skills/port-sacred-terminal-ui-to-python/SKILL.md
Take a React Window*.tsx (or any sacred component) and produce a terminal CLI screen written in Python that uses Simulacrum's Python mirror in scripts/python/sacred_cli/. Simulacrum is the sacred CLI framework — the JavaScript half lives in scripts/cli/lib/, the Python half is a one-to-one snake_case mirror.
See
components/AGENTS.mdfor the canonical catalog of every sacred React component (props, theming tokens, CLI primitive equivalent). Read it before identifying which React surface you are porting from.
Use this skill whenever you want a Python CLI version of an existing sacred React surface. Sacred ships a Python port of the layout primitives (one-to-one with the JavaScript framework) so the same React component can render identically from either runtime.
A single .py file under scripts/python/templates/ that:
python3 shebang and if __name__ == "__main__": entry point.sacred_cli (the package lives in scripts/python/sacred_cli/).create_app(build=build).start() with a build(page, inner_w, selected_row) function that returns list[str].Read these files before starting:
scripts/python/templates/template.py — canonical example (run with npm run cli:python)scripts/python/sacred_cli/__init__.py — public surface re-exportsscripts/python/sacred_cli/ansi.py — ANSI escapes, hex helpers, padding, gradient textscripts/python/sacred_cli/window.py — window frame (margin + window bg + shadow)scripts/python/sacred_cli/card.py — box-drawing card borders and word wrapscripts/python/sacred_cli/table.py — format_row, kv_table, kv_table_gradientscripts/python/sacred_cli/button.py — button, button_rowscripts/python/sacred_cli/app.py — lifecycle: alt screen, raw mode, resize, paging, selectionscripts/cli/colors.json — sacred-themed color palette (the Python ANSI module loads this same JSON)The Python port mirrors the JavaScript framework one-to-one but uses snake_case:
| JavaScript | Python |
|---|---|
cardTop(title, innerW) | card_top(title, inner_w) |
cardRow(content, innerW) | card_row(content, inner_w) |
cardSelectRow(content, innerW, selected) | card_select_row(content, inner_w, selected) |
cardHeaderRow(content, innerW) | card_header_row(content, inner_w) |
cardBot(innerW) | card_bot(inner_w) |
formatRow(vals, colSpec, innerW) | format_row(vals, col_spec, inner_w) |
kvTable(pairs) | kv_table(pairs) |
kvTableGradient(pairs) | kv_table_gradient(pairs) |
buttonRow(left, right, innerW) | button_row(left, right, inner_w) |
wordWrap(text, maxW) | word_wrap(text, max_w) |
createApp({ build }) | create_app(build=build) |
button(hotkey, label) and the COLORS dict keep the same names because they have no JS-specific casing.
COL_SPEC = [
{"width": 14, "align": "left"},
{"width": 12, "align": "left", "grow": True},
{"width": 8, "align": "right", "status": True, "gap": 2},
]
Status coloring: ACTIVE/OPEN/APPROVED → bold green; CLOSED/PAID/SUSPENDED → gray. The framework handles this automatically when status: True.
<ASCIICanvas> (CLI is static)..py file."grow": True.build(page, inner_w, selected_row). Append card_top → rows → card_bot for each section. End with button_row(...).npm run cli:python. Verify margins, shadow, and inner padding match the React component.interactive={"count": 5, "on_select": fn, "persist": True} to create_app and use card_select_row(content, inner_w, i == selected_row).total_pages=N (or a callable) and slice your data by page inside build.#!/usr/bin/env python3.# NOTE(your_github_username): ....UPPER_SNAKE_CASE.2026-04-08T09:00:00).$18,920.50).scripts/cli/colors.json via sacred_cli.COLORS.termios raw mode. Windows users need a msvcrt shim that the sacred port does not currently provide.After writing the file:
npm test # JS framework unit tests + Python parity suite
npm run cli:python # your screen renders, ESC quits cleanly
If you see garbled output, your terminal probably does not support 24-bit true color — the sacred palette assumes \x1b[38;2;R;G;Bm works.
The Python framework is a one-to-one mirror of the JavaScript framework. The two runtimes are locked into byte-identical output by a parity test suite under scripts/python/sacred_cli/__tests__/:
npm run test:python # only the Python suite
npm test # JS suite + Python suite (chained)
npm run test:python first regenerates the reference fixture (scripts/python/sacred_cli/__tests__/fixtures/reference.json) via tsx scripts/cli/lib/__tests__/dump_reference.ts, then runs python3 -m unittest discover against sacred_cli/__tests__. The fixture is checked into the repo so the Python test never has to shell out — regeneration is just a guard against stale snapshots.
If python3 is not on PATH, the runner prints a warning and exits 0. Sacred contributors on minimal containers can still run npm test without installing Python.
A failing parity test almost always means a TS module was changed without porting the change to its Python mirror. To fix:
test_format_row_status).scripts/cli/lib/table.ts) and the Python mirror (scripts/python/sacred_cli/table.py) side-by-side.npm test. The fixture is regenerated automatically — no manual step needed.If you genuinely need to update the contract on both sides, edit the TS module first, then run npm test to see what the parity fixture now looks like, and only then port the new behavior into Python. Never edit the fixture JSON by hand.
The unit tests under scripts/python/sacred_cli/__tests__/ (one file per module: test_ansi.py, test_window.py, test_card.py, test_table.py, test_button.py) mirror the JS tests in scripts/cli/lib/__tests__/. When you add a new JS test, add the equivalent Python test in the same file so the assertion sets stay synchronized.
MAmattpocock/skills288k10,178 new stars in the last 7 days
AFaffaan-m/ECC278k4,046 new stars in the last 7 days
FIfirecrawl/firecrawl191k2,010 new stars in the last 7 days
Set visual direction and typography for UI, avoiding templated defaults.
ANanthropics/skills181k1,119 new stars in the last 7 days
ANanthropics/skills181k1,119 new stars in the last 7 days
Build complex HTML artifacts with React, Tailwind CSS, state management and routing.
ANanthropics/skills181k1,119 new stars in the last 7 days