Ansi safe border caption embedding

From ychampion/cskill-agents · View interactive version

Ansi safe border caption embedding is an AI agent skill from the GitHub repository ychampion/cskill-agents. Embed captions into terminal borders while preserving alignment, clipping, and color/dim semantics.

How to use this skill

Skill file

SKILL: ANSI-Safe Border Caption Embedding

Domain: output-rendering

Trigger: Apply when you must insert text into a border line (top or bottom) while preserving the border characters, colors, and alignment, even if the caption is wider than available space.

Source Pattern: Distilled from reviewed terminal rendering, layout, animation, and accessibility implementations.

Core Method

Treat the border as a sequence of uniformly repeated characters, compute the textual width, and trim or center the caption before joining it back into the border; this keeps the corners intact. Use the helper that calculates string width (respecting wide characters), convert position into an absolute column, and split the border into before/text/after fragments so colors/dim states can be reapplied independently.

Key Rules

Example Application

When labeling a dialog border, call this method with position:'top', align:'center', and the pre-rendered caption string; clip it if the window narrows, and keep the corner and side glyphs in place so the divider stays crisp.

Anti-Patterns (What NOT to do)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.