Claude
Skills
Sign in
โ† Back

cat:render-box

Included with Lifetime
$97 forever

Render boxes and tables with proper emoji-aware alignment using box-drawing characters

Image & Video

What this skill does


# Render Box

## Purpose

Render boxes, tables, and bordered displays with proper emoji-aware alignment. LLMs cannot reliably
calculate character-level padding for Unicode text (see M142), so this skill delegates width
calculation to bash scripts that use Python's `unicodedata` module.

## When to Use

**MANDATORY** when rendering any bordered output containing emojis:
- Status boxes with emoji indicators (โœ…, โš , ๐Ÿ”„)
- Tables with emoji columns
- Checkpoint displays
- Progress displays with emoji prefixes

**Not needed** for:
- Plain markdown tables without emojis
- Unbordered lists with emojis
- Simple text output

## Prerequisites

The box rendering library is located in the plugin:
- `${CLAUDE_PLUGIN_ROOT}/scripts/lib/box.sh` - Core rendering functions
- `${CLAUDE_PLUGIN_ROOT}/scripts/pad-box-lines.sh` - Line padding with emoji widths
- `${CLAUDE_PLUGIN_ROOT}/emoji-widths.json` - Terminal-specific emoji width data

## Box Types

### 1. Simple Box

For status displays, checkpoints, and messages.

```bash
source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/box.sh"

box_init 72  # Set box width (default 74)
box_top "โœ… CHECKPOINT: Task Complete"
box_empty
box_line "  Task: fix-subagent-token-measurement"
box_line "  Status: Complete"
box_empty
box_divider
box_line "  Tokens: 45,000 (22% of context)"
box_empty
box_bottom
```

**Output:**
```
โ•ญโ”€โ”€โ”€ โœ… CHECKPOINT: Task Complete โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚                                                                    โ”‚
โ”‚  Task: fix-subagent-token-measurement                              โ”‚
โ”‚  Status: Complete                                                  โ”‚
โ”‚                                                                    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Tokens: 45,000 (22% of context)                                   โ”‚
โ”‚                                                                    โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
```

### 2. Table with Headers

For data with multiple columns. Build rows as TSV, then render with column alignment.
Use rounded corners for consistency with box displays.

```bash
source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/box.sh"

# Define column widths (adjust based on content)
COL1_W=17  # Type
COL2_W=32  # Description
COL3_W=8   # Tokens
COL4_W=15  # Context
COL5_W=10  # Duration

# Helper to pad cell content
pad_cell() {
    local content="$1"
    local width="$2"
    local display_w=$(display_width "$content")
    local padding=$((width - display_w))
    printf '%s%*s' "$content" "$padding" ""
}

# Render header (rounded top corners)
echo "โ•ญ$(dashes $COL1_W)โ”ฌ$(dashes $COL2_W)โ”ฌ$(dashes $COL3_W)โ”ฌ$(dashes $COL4_W)โ”ฌ$(dashes $COL5_W)โ•ฎ"
echo "โ”‚$(pad_cell " Type" $COL1_W)โ”‚$(pad_cell " Description" $COL2_W)โ”‚$(pad_cell " Tokens" $COL3_W)โ”‚$(pad_cell " Context" $COL4_W)โ”‚$(pad_cell " Duration" $COL5_W)โ”‚"
echo "โ”œ$(dashes $COL1_W)โ”ผ$(dashes $COL2_W)โ”ผ$(dashes $COL3_W)โ”ผ$(dashes $COL4_W)โ”ผ$(dashes $COL5_W)โ”ค"

# Render data rows
echo "โ”‚$(pad_cell " Explore" $COL1_W)โ”‚$(pad_cell " Explore codebase" $COL2_W)โ”‚$(pad_cell " 68.4k" $COL3_W)โ”‚$(pad_cell " 34% โœ“ OK" $COL4_W)โ”‚$(pad_cell " 1m 7s" $COL5_W)โ”‚"
echo "โ”‚$(pad_cell " general-purpose" $COL1_W)โ”‚$(pad_cell " Implement refactor" $COL2_W)โ”‚$(pad_cell " 170.0k" $COL3_W)โ”‚$(pad_cell " 85% โš  EXCEEDED" $COL4_W)โ”‚$(pad_cell " 3m 12s" $COL5_W)โ”‚"

# Render footer (rounded bottom corners)
echo "โ•ฐ$(dashes $COL1_W)โ”ด$(dashes $COL2_W)โ”ด$(dashes $COL3_W)โ”ด$(dashes $COL4_W)โ”ด$(dashes $COL5_W)โ•ฏ"
```

**Output:**
```
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Type            โ”‚ Description                    โ”‚ Tokens โ”‚ Context       โ”‚ Duration โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Explore         โ”‚ Explore codebase               โ”‚ 68.4k  โ”‚ 34% โœ“ OK      โ”‚ 1m 7s    โ”‚
โ”‚ general-purpose โ”‚ Implement refactor             โ”‚ 170.0k โ”‚ 85% โš  EXCEEDEDโ”‚ 3m 12s   โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
```

### 3. Nested Box

For hierarchical displays like project status.

```bash
source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/box.sh"

box_init 72
box_top "๐Ÿ—บ๏ธ PROJECT STATUS"
box_empty

# Use inner_* functions for nested boxes
inner_top "๐Ÿ“ฆ v1.0: Initial Release"
inner_line "โ˜‘๏ธ v1.1: Core features (5/5)"
inner_line "๐Ÿ”„ **v1.2: Current** (3/5)"
inner_line "   ๐Ÿ”ณ pending-task-1"
inner_line "   ๐Ÿ”ณ pending-task-2"
inner_bottom

box_empty
box_bottom
```

## Key Functions

| Function | Purpose |
|----------|---------|
| `box_init WIDTH` | Initialize box width (default 74) |
| `box_top "TITLE"` | Top border with optional title |
| `box_bottom` | Bottom border |
| `box_line "CONTENT"` | Content line with borders |
| `box_empty` | Empty line with borders |
| `box_divider` | Horizontal divider |
| `display_width "TEXT"` | Calculate emoji-aware display width |
| `pad "TEXT" WIDTH` | Pad text to exact display width |
| `dashes COUNT` | Generate COUNT dash characters |
| `inner_top "TITLE"` | Nested box top border |
| `inner_line "CONTENT"` | Nested box content line |
| `inner_bottom` | Nested box bottom border |
| `progress_bar PCT [WIDTH]` | Generate progress bar string |

## Box-Drawing Characters

| Character | Name | Usage |
|-----------|------|-------|
| `โ”€` | Horizontal | Borders, dividers |
| `โ”‚` | Vertical | Side borders, column separators |
| `โ•ญ` `โ•ฎ` | Rounded top | Top corners (ALL boxes and tables) |
| `โ•ฐ` `โ•ฏ` | Rounded bottom | Bottom corners (ALL boxes and tables) |
| `โ”œ` `โ”ค` | T-junction | Row dividers |
| `โ”ฌ` `โ”ด` | T-junction | Column headers/footers |
| `โ”ผ` | Cross | Grid intersections |
| `โ–ˆ` `โ–‘` | Block | Progress bars |

**Note:** Use rounded corners (`โ•ญโ•ฎโ•ฐโ•ฏ`) for all boxes and tables for visual consistency.
Square corners (`โ”Œโ”โ””โ”˜`) are deprecated.

## Anti-Patterns

### Never calculate padding manually

```bash
# โŒ WRONG - LLMs cannot reliably calculate emoji widths
printf "โ”‚ %-20s โ”‚\n" "โœ… Task complete"

# โœ… CORRECT - Use display_width function
source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/box.sh"
box_line "  โœ… Task complete"
```

### Never use markdown tables with emojis

```markdown
<!-- โŒ WRONG - Emojis break column alignment -->
| Status | Task |
|--------|------|
| โœ… | Complete |
| โš  | Warning |
```

Use box-drawing tables instead (see Table with Headers above).

### Never hardcode emoji widths

```bash
# โŒ WRONG - Emoji widths vary by terminal
EMOJI_WIDTH=2

# โœ… CORRECT - Use display_width function
WIDTH=$(display_width "โœ…")
```

## Related Skills

- `cat:token-report` - Uses render-box for subagent token tables
- `cat:status` - Uses render-box for project status display
- `cat:shrink-doc` - Uses render-box for validation tables

## Related References

- `display-standards.md` - Visual formatting guidelines
- `M142` - Learning about LLM padding calculation limitations
Files: 1
Size: 8.0 KB
Complexity: 10/100
Category: Image & Video

Related in Image & Video