Skip to content

docs: add a skill for AI coding agents, compile-checked in CI - #272

Merged
vyncint merged 2 commits into
mainfrom
docs/agent-skill
Sep 5, 2026
Merged

docs: add a skill for AI coding agents, compile-checked in CI#272
vyncint merged 2 commits into
mainfrom
docs/agent-skill

Conversation

@vyncint

@vyncint vyncint commented Sep 5, 2026

Copy link
Copy Markdown
Owner

A skill for coding agents (Claude Code, Cursor, Copilot) that write tests with termlens, at skills/termlens/SKILL.md, plus a CI guard that compiles every Rust block in it against the crate.

What is in the skill

  • The model in sixty seconds, then twelve golden rules — each with the reason, not just the instruction: no sleep (and send_after as the one sanctioned delay), snapshot_after for whole-screen snapshots, one predicate per instant, bin! for own binaries, the 2..=1000 geometry floor and ceiling, the two coordinate orders, finish the process and assert !alternate_screen(), wait_frame only for applications that emit synchronized updates, termlens::Result<()> tests, snapshot the Screen not its text, the hermetic environment, cells and wide characters.
  • Four recipes, each a complete integration test: CLI --help snapshot with exit code; ratatui navigation and clean quit; overriding size, environment and deadline; targeted find/cell/style/rect_text/cursor assertions including CJK.
  • A failure-triage table quoting the crate's actual error strings, an API cheat sheet, a pitfalls table ("you are about to write X → write Y"), an insta pairing section and a finishing checklist.

What was measured before writing it

  • ratatui 0.30.2 + crossterm emits no DEC 2026 synchronized updates (repaints() stays 0 after a draw), so the skill sends agents to snapshot_after, and names the exact timeout message wait_frame produces otherwise.
  • The four recipes were extracted mechanically from the skill and run against a real ratatui 0.30.2 binary named myapp (list with highlight, j/k/q, --help, NO_COLOR): 5 tests, green 7 runs in a row, snapshots stable.
  • The instant-exit --help case ran 100 times with both wait orders on an idle machine with no loss; the skill still recommends waiting on the last line first, and says why (the macOS teardown race under load, from DESIGN §2).
  • A fresh claude -p session in this checkout reports the skill available and quotes its description, so the .claude/skills/termlens symlink is discovered.

The guard

.github/scripts/check-skill-snippets.sh writes each ```rust block to a scratch consumer owning a stub myapp and runs cargo check --tests; on failure it prints which snippet is which line of the skill. Verified to fail on a renamed method. New skill job, in required-green. It compiles and does not run — the stub is fn main() {}.

Not done, deliberately

  • No ratatui fixture in this repository (the binary the recipes ran against lives outside it); the guard therefore compiles rather than runs the recipes.
  • The skill installs as a single file, so there is no references/ split; at 450 lines it is dense on purpose.
  • Nothing in the skill references this repository's issue tracker or planning documents.

Coding agents write terminal tests badly in predictable ways: a sleep where
a wait belongs, a whole-screen snapshot taken mid-repaint, a 1x1 terminal,
a (row, col) handed to a method that wants (col, row), wait_frame against
an application that never emits synchronized updates, a bare program name
under env_clear. skills/termlens/SKILL.md is the counter to each — the
model in sixty seconds, twelve golden rules with the reason behind each, a
setup section, four copy-paste recipes (a CLI --help snapshot, a ratatui
navigation flow, overriding size and environment, targeted cell and style
assertions), a failure-triage table quoting the crate's actual messages,
an API cheat sheet, a pitfalls table and a finishing checklist. Written
against 0.9.0.

Every rule with a measurable claim was measured: stock ratatui 0.30.2 with
crossterm emits no DEC 2026 updates (repaints() stays 0), so the skill
sends agents to snapshot_after rather than wait_frame; the recipes ran
green seven times in a row against a real ratatui binary named myapp; the
instant-exit --help case ran 100 times with both wait orders; and a fresh
Claude Code session in this checkout discovers the skill through the
.claude/skills/termlens link. The README gains the one-line install and
CONTRIBUTING's layout names the directory. The skill deliberately does not
reference this repository's internal issue tracker or planning documents.

Signed-off-by: Vyncint Ng <vyncint@icloud.com>
The skill is what an agent copies from, so a recipe that stops compiling
teaches the wrong API to everyone who installed it. The README's example is
already compile-checked for the same reason; the skill's four recipes get
the same guard. check-skill-snippets.sh extracts every block tagged exactly
```rust into a scratch consumer that owns a stub `myapp` binary — the shape
the recipes are written for, so termlens::bin!("myapp") resolves at compile
time — and runs cargo check --tests against the crate in the checkout. A
failure prints which snippet maps to which line of the skill.

It compiles and does not run: the stub is fn main() {}, and the recipes'
runtime claims were exercised against a real ratatui application when the
skill was written. Verified to fail on a renamed method. The job joins
required-green; it is a script step, so CONTRIBUTING §1's cargo list is
unchanged and gates-listed still passes.

Signed-off-by: Vyncint Ng <vyncint@icloud.com>
@vyncint
vyncint merged commit d1b2933 into main Sep 5, 2026
13 checks passed
@vyncint
vyncint deleted the docs/agent-skill branch September 5, 2026 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant