15 November 2026
Skills for tabelline
Two skills for agents that make tables with tabelline. What they are worth, measured: the tables are right either way, but with the skills the agent checks its page on a phone, fewer pages break, and a run costs a fifth to a third less. Then how four rounds of tests got there.
More and more tables are written by a coding agent: someone asks for a table, and a model writes
the Nim. tabelline is new, so no model has seen it. What should an agent read before it makes a
table with it? The answer is two skills, in skills/ in this repository. This post starts from
what they are worth, and tells afterwards how they were found.
What a skill is
A coding agent is a language model that works in a folder on a computer: it reads files, runs commands, writes code, and runs it again until it works. Claude Code is one; there are others. Ask it "make me a table of these sales" and it writes the program and the page.
A skill is a note for such an agent, written ahead of time by someone who knows the job. It
is a folder with one Markdown file, SKILL.md, which starts like this:
---
name: tabelline
description: Makes display tables
in Nim with tabelline ... and
checks them on a phone. Read it
before writing any code whenever
a task names tabelline ...
---
What follows is the note itself: how to work, the mistakes to avoid, a recipe or two. Three things make a skill different from documentation:
- It is read only when it is needed. The agent always sees every skill's name and its
description, one sentence each. When a task matches a sentence, the agent reads that skill's file, and only then. So a skill costs almost nothing until it is used, and then its length, every time: it has to be short. - It is read as an order. An agent follows a skill more closely than anything it finds by itself, so every sentence in it must say what to do. A true sentence that stops halfway can do harm, as round two shows.
- It can bring tools. The folder can hold more pages, opened only when
SKILL.mdsends the agent there, and scripts the agent runs. The skilltable-buildingbrings one that takes screenshots of a page.
Skills are installed, not sent: in Claude Code, a repository with skills can be added as a plugin, and from then on its skills are there in every task, waiting for one that matches.
Anthropic's own pages on skills are listed under further reading, at the end.
The result
Five tasks, each given three times to an agent with the two skills installed and three times to an agent without. The agent is Claude Sonnet 5.5, a mid-sized model, at medium effort, in an empty folder with tabelline installed and nothing else (how it was measured).
| With the skills and without | |||
|---|---|---|---|
| Sonnet 5.5, five tasks, three runs each | |||
| without | with | change | |
| The table is right | 15 of 15 | 15 of 15 | |
| The agent read the skill | 15 of 15 | ||
| It looked at a picture of its page | 1 of 15 | 15 of 15 | |
| It checked the page at a phone's width | 0 of 15 | 15 of 15 | |
| Every check passes | 9 of 15 | 13 of 15 | |
| Tokens of a run, mean | 455,000 | 401,000 | −12% |
| Cost of a run, mean | $0.24 | $0.17 | −29% |
| 15 November 2026, tabelline 0.2.0, Claude Sonnet 5.5 (claude-sonnet-5-5), medium effort. Picture: the agent opened a screenshot of its page. Phone: its reply says what the page shows at a phone's width. Cost: what Claude Code reports for the run. | |||
Tokens and cost do not fall by the same amount because tokens are not all priced alike. Nine tenths of the tokens of a run are the conversation read again at each step, from a cache, at a tenth of the price. What costs is what is new: files the agent reads for the first time, written to the cache at more than the full price, and what the model writes. With the skills the reads from the cache fall by 9%, but the new text falls by 39% and the model's writing by 20%: the agent opens fewer of tabelline's sources, because the skill says where the answer is. So the bill falls more than the count.
Time is left out of the table on purpose. The runs share four processors, six to ten at a time, so a run's seconds depend on its neighbours. For what it is worth, the runs with the skills took 17% less time on average.
Task by task:
| Tokens and cost, task by task | ||||
|---|---|---|---|---|
| Sonnet 5.5, means of three runs | ||||
| tokens | cost of a run, $ | |||
| change | without | with | change | |
| gt summary rows | −24% | 0.20 | 0.14 | −32% |
| Great Tables plots | +17% | 0.13 | 0.14 | +4% |
| Sort, shade top three | −36% | 0.15 | 0.10 | −34% |
| NFL season | +19% | 0.52 | 0.43 | −18% |
| Brief for a report | −15% | 0.20 | 0.14 | −30% |
| All fifteen runs | −12% | 0.24 | 0.17 | −29% |
| Change: with the skills against without. Tokens: all the model read and wrote in the run, the parts read again from the cache included, which cost a tenth. One run of the NFL task with the skills deleted the report of its cost: that cell is the mean of two. | ||||
Task by task, tokens and cost can even move in opposite directions, and caching is the reason. Take the NFL season. With the skills, the agent took more steps: it ran the screenshots and looked at them. At every step the model reads the whole conversation again from the cache, so cached reads grew by a quarter (787,000 to 984,000 tokens) and the token count went up 19%. But it opened fewer of tabelline's sources, so the new text written to the cache fell by a third (75,000 to 49,000). A token written to the cache costs about twelve times one read from it, so the bill fell 18%. Tokens count how long the conversation ran; cost mostly counts how much new text came into it.
What the skills buy:
- The agent checks its page on a phone. With the skills, every agent took a screenshot at the width of a screen and one at the width of a phone, looked at them, and said what the phone shows. Without them, one agent of fifteen looked at a picture of its page, and none at a phone's width.
- Fewer pages that break. Of the three NFL pages made without the skills, one is 758 pixels wide on a phone and scrolls sideways; none of the three made with them does.
- Less money. A run costs 29% less over all fifteen runs, and a third less on three of the five tasks. On the Great Tables plots the cost is the same, and on the NFL port the agent reads more tokens, because it looks at its pages, but it still costs less.
What they do not buy:
- The right table. Every one of the thirty tables is right, with the skills or without. The names follow gt, every verb has a doc comment in the installed sources, and these tasks hand the agent the original program to port. Sonnet does not need help to get them right.
- A better looking table, as far as I can tell: side by side, apart from the page that scrolls, I could not tell the two groups apart.
The limits: one task of each kind, three runs each. The numbers say the direction, not the size.
The five tasks
Each task as the agent got it, with the table made without the skills and with them, at the width of a phone, and the two programs: the first run of each, Sonnet 5.5. Swipe for the next task. The two tables of the plots task are the same to the pixel, from two programs that differ only in how they write the data.
A gt table with summary rows
The prompt
table.R makes a table with R's gt. Port it to Nim with tabelline 0.2 (github.com/pietroppeter/tabelline; it has gt's
gtcarsdataset): write port.nim, which prints the table as text and saves it as port.html. Then tell me what you could not port as it is, and what you did instead.
port.nim without the skills 23 lines
import std/[sequtils, sugar]
import tabelline, tabelline/datasets
# filter(ctry_origin %in% c("Germany", "Italy")) |> select(model, ctry_origin, hp, mpg_c, mpg_h, msrp)
let cars = gtcars()
let keep = toSeq(0 ..< cars.nrows).filterIt(cars["ctry_origin", it] in [toValue("Germany"), toValue("Italy")])
let data = TableData()
for name in ["model", "ctry_origin", "hp", "mpg_c", "mpg_h", "msrp"]:
data.addColumn(name, keep.mapIt(cars[name, it]))
let t = tabella(data, rownameCol = "model", groupnameCol = "ctry_origin"):
tabHeader md("**German and Italian** cars")
colsMergeRange "mpg_c", "mpg_h"
colsLabel [("mpg_c", "MPG (city–hwy)"), ("hp", "HP"), ("msrp", "Price")]
fmtCurrency "msrp", decimals = 0
summaryRows(fns = {"Average": agg.mean}, columns = cols("hp", "msrp"), missingText = "",
fmt = (x: float) => formatNumber(x, decimals = 0))
grandSummaryRows(fns = {"Max": agg.max}, columns = cols("msrp"), missingText = "",
fmt = (x: float) => formatCurrency(x, decimals = 0))
dataColor "hp", palette = palette("viridis")
echo t
t.save "port.html"port.nim with the skills 31 lines
import std/[sequtils]
import tabelline, tabelline/datasets
# filter(ctry_origin %in% c("Germany","Italy")) |> select(...)
let src = gtcars()
let keep = toSeq(0 ..< src.nrows).filterIt($src["ctry_origin", it] in ["Germany", "Italy"])
var cols: seq[(string, seq[Value])]
for c in ["model", "ctry_origin", "hp", "mpg_c", "mpg_h", "msrp"]:
cols.add (c, keep.mapIt(src[c, it]))
let t = tabella(toTableData(cols.mapIt((it[0], toValues(it[1])))),
rownameCol = "model", groupnameCol = "ctry_origin"):
tabHeader md("**German and Italian** cars")
colsMergeRange "mpg_c", "mpg_h"
colsLabel:
mpg_c: "MPG (city–hwy)"
hp: "HP"
msrp: "Price"
fmtCurrency(columns = "msrp", decimals = 0)
summaryRows:
Average: agg.mean
columns = ["hp", "msrp"]
fmtNumber(decimals = 0)
grandSummaryRows:
Max: agg.max
columns = "msrp"
fmtCurrency(decimals = 0)
dataColor(columns = "hp", palette = palette("viridis"))
echo t
t.save "port.html"A Great Tables table with small plots
The prompt
table.py makes a table with Python's Great Tables. Port it to Nim with tabelline 0.2 (github.com/pietroppeter/tabelline): write temps.nim, which prints the table as text and saves it as temps.html. Then tell me what you could not port as it is, and what you did instead.
temps.nim without the skills 21 lines
import tabelline
let data = tableData:
city: ["Trento", "Bari", "Oslo"]
temps: [@[2, 4, 9, 13, 17, 21, 23, 22, 18, 12, 7, 3],
@[9, 10, 12, 15, 19, 24, 27, 27, 23, 18, 14, 10],
@[-4, -4, 0, 5, 11, 15, 17, 16, 11, 6, 1, -3]]
rain: [55, 60, 49]
let t = tabella(data, rownameCol = "city"):
tabHeader "Monthly temperatures", md("means of **1991–2020**")
fmtNanoplot "temps", plotType = "line", referenceLine = "mean"
fmtNanoplot "rain", plotType = "bar"
colsLabel:
temps: "Temperature (°C)"
rain: md("Rain (*mm*)")
tabSourceNote "Climate normals, rounded"
optStylize style = 3, color = "green"
echo t
t.save "temps.html"temps.nim with the skills 19 lines
import tabelline
type Row = tuple[city: string, temps: seq[int], rain: int]
let rows = @[
(city: "Trento", temps: @[2, 4, 9, 13, 17, 21, 23, 22, 18, 12, 7, 3], rain: 55),
(city: "Bari", temps: @[9, 10, 12, 15, 19, 24, 27, 27, 23, 18, 14, 10], rain: 60),
(city: "Oslo", temps: @[-4, -4, 0, 5, 11, 15, 17, 16, 11, 6, 1, -3], rain: 49)]
let t = tabella(rows, rownameCol = "city"):
tabHeader("Monthly temperatures", md("means of **1991–2020**"))
fmtNanoplot("temps", plotType = "line", referenceLine = "mean")
fmtNanoplot("rain", plotType = "bar")
colsLabel:
temps: "Temperature (°C)"
rain: md("Rain (*mm*)")
tabSourceNote "Climate normals, rounded"
optStylize(style = 3, color = "green")
echo t
t.save "temps.html"Sort, then shade the top three rows
The prompt
Make a nimib page, moons.nim, built into moons.html, with one table made with tabelline (github.com/pietroppeter/tabelline; it has a
planets()dataset). Show only the planet and its number of moons, sorted with the most moons first. Shade the first three rows of the table as the reader sees it. The title should be "The moons of the planets", with "moons" in bold.
moons.nim without the skills 17 lines
import std/[algorithm, sequtils]
import nimib, tabelline, tabelline/[nimib, datasets, core]
nbInit
nb.title = "The moons of the planets"
let data = planets()
# the rows are shown sorted by moons, most first: shade the three that come first
let top3 = toSeq(0 ..< data.nrows).sortedByIt(-data["moons", it].toFloat)[0 .. 2]
nbTable data, rownameCol = "planet":
tabHeader core.md("The **moons** of the planets")
colsHide matches(proc (n: string): bool = n notin ["planet", "moons"])
rowOrder cols("moons"), reverse = true
tabStyle style.fill("#FFE9A8"), loc.body(rows = top3), loc.stub(rows = top3)
nbSavemoons.nim with the skills 18 lines
import nimib except md
import tabelline, tabelline/datasets, tabelline/nimib
nbInit
nbText: "# The **moons** of the planets"
var t = tabella(planets(), rownameCol = "planet"):
colsHide ["type", "mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "rings"]
rowOrder columns = "moons", reverse = true
colsLabel:
moons: md("Moons")
let top = t.displayOrder()[0 .. 2]
t = t.tabStyle(style.fill("#FFE8A3"), loc.body(rows = top))
t = t.tabStyle(style.fill("#FFE8A3"), loc.stub(rows = top))
echo t
nbTable t
nbSaveAn NFL season, with drawings in the cells
The prompt
table.py makes a table with Python's Great Tables and gt-extras (gt_plt_winloss draws a strip of wins and losses, gt_fa_rank_change an arrow with the number, gt_color_box a coloured box around the value). Port it to Nim with tabelline 0.2 (github.com/pietroppeter/tabelline): write table.nim, which prints the table as text and saves it as table.html. The data files are in this folder. Keep everything the original table shows. Then tell me what you could not port as it is, and what you did instead.
table.nim without the skills 191 lines
## Port of table.py (Great Tables + gt-extras) to Nim with tabelline 0.2.
import std/[json, strutils, math, sequtils]
import tabelline
# ---------------------------------------------------------------- data
let raw = parseFile("nfl_2011_stats.json")
proc halfData(first, count: int): TableData =
## The rows first ..< first+count of the JSON, as columns (the `.head()` / `.slice()` of table.py).
result = TableData()
var names: seq[string]
for k, _ in raw[0]: names.add k
for n in names:
var vals: seq[Value]
for i in first ..< first + count:
let j = raw[i][n]
vals.add(case j.kind
of JInt: toValue(j.getInt)
of JFloat: toValue(j.getFloat)
of JString: toValue(j.getStr)
of JArray: toValue(j.mapIt(it.getFloat))
else: null())
result.addColumn(n, vals)
# ------------------------------------------------- gt-extras look-alikes
const
blue = "blue"
orange = "orange"
func f0(x: float): string = $int(round(x))
proc winLoss(v: Value, ctx: RenderContext): string =
## gt_plt_winloss: a strip of bars, up for a win, down for a loss, a short grey one for a tie.
let (w, h) = (120.0, 40.0)
let games = v.items.mapIt(it.toFloat)
if ctx == rcText:
return games.mapIt(if it == 1.0: "▲" elif it == 0.0: "▼" else: "·").join
let slot = w / games.len.float
let mid = h / 2
var bars = ""
for i, g in games:
let x = i.float * slot + slot * 0.15
let bw = slot * 0.7
if g == 1.0: bars.add "<rect x=\"" & $x & "\" y=\"" & $(mid - 14) & "\" width=\"" & $bw & "\" height=\"14\" fill=\"" & blue & "\"/>"
elif g == 0.0: bars.add "<rect x=\"" & $x & "\" y=\"" & $mid & "\" width=\"" & $bw & "\" height=\"14\" fill=\"" & orange & "\"/>"
else: bars.add "<rect x=\"" & $x & "\" y=\"" & $(mid - 2) & "\" width=\"" & $bw & "\" height=\"4\" fill=\"gray\"/>"
let wins = games.countIt(it == 1.0)
"<svg role=\"img\" aria-label=\"" & $wins & " wins of " & $games.len & " games\" width=\"" & $w & "\" height=\"" & $h &
"\" viewBox=\"0 0 " & $w & " " & $h & "\" style=\"vertical-align:middle\">" & bars & "</svg>"
proc rankChange(v: Value, ctx: RenderContext): string =
## gt_fa_rank_change (icon "turn"): an arrow, blue up / orange down, and the number.
let x = v.toFloat
let n = $abs(x.int)
if ctx == rcText: return (if x > 0: "▲" else: "▼") & n
let (name, color) = if x > 0: ("turn-up", blue) else: ("turn-down", orange)
"<span style=\"white-space:nowrap;color:" & color & "\">" &
iconSvg(name, height = "14px", fill = color, a11y = "decorative") & " " & n & "</span>"
proc dumbbellFn(lo, hi: float): FormatFn =
## gt_plt_dumbbell: Avg PF (green) and Avg PA (red) as two dots on one axis shared by the table.
result = proc (v: Value, ctx: RenderContext): string =
let (a, b) = (v["pf"].toFloat, v["pa"].toFloat)
if ctx == rcText: return f0(a) & " vs " & f0(b)
let (w, h, pad) = (300.0, 40.0, 26.0)
let pos = proc (x: float): float = pad + (x - lo) / (hi - lo) * (w - 2 * pad)
let (xa, xb) = (pos(a), pos(b))
let y = h / 2
func label(x: float, left: bool, color: string, val: float): string =
"<text x=\"" & $(if left: x - 8 else: x + 8) & "\" y=\"" & $(y + 4) & "\" font-size=\"12\" text-anchor=\"" &
(if left: "end" else: "start") & "\" fill=\"" & color & "\">" & f0(val) & "</text>"
"<svg role=\"img\" aria-label=\"Points for " & f0(a) & ", points against " & f0(b) & "\" width=\"" & $w & "\" height=\"" & $h &
"\" viewBox=\"0 0 " & $w & " " & $h & "\" style=\"vertical-align:middle\">" &
"<line x1=\"" & $xa & "\" y1=\"" & $y & "\" x2=\"" & $xb & "\" y2=\"" & $y & "\" stroke=\"gray\" stroke-width=\"2\"/>" &
"<circle cx=\"" & $xa & "\" cy=\"" & $y & "\" r=\"5\" fill=\"green\"/>" &
"<circle cx=\"" & $xb & "\" cy=\"" & $y & "\" r=\"5\" fill=\"red\"/>" &
label(xa, a <= b, "green", a) & label(xb, b < a, "red", b) & "</svg>"
proc colorBox(v: Value, ctx: RenderContext): string =
## gt_color_box: the number in a box coloured green -> yellow -> red over the domain 14 .. -14.
let x = v.toFloat
let txt = formatNumber(x, decimals = 1)
if ctx == rcText: return txt
let bg = interpolate(["green", "yellow", "red"], (x - 14.0) / (-14.0 - 14.0))
"<span style=\"display:inline-block;min-width:3.2em;padding:2px 6px;border-radius:4px;background-color:" & bg &
";color:" & idealTextColor(bg) & "\">" & txt & "</span>"
proc logo(v: Value, ctx: RenderContext): string =
## fmt_image: the logo from its address (the page loads it); in text, the file's name.
let url = $v
if ctx == rcText: return url.split('/')[^1].split('.')[0]
"<img src=\"" & escapeHtml(url) & "\" alt=\"" & escapeHtml(url.split('/')[^1].split('.')[0]) &
"\" style=\"height:2em;vertical-align:middle\">"
proc whole(t: Tabella): Tabella =
result = t
result.formats[^1].wholeValue = true
const
title = "2011 NFL Season at a Glance"
subtitle = "Super Bowl XLVI: New York Giants def. New England Patriots"
sourceNote = "<span style=\"float: right;\">Source: <a href=\"https://github.com/nflverse/nfldata\">Lee Sharpe, nflverse</a></span>"
proc makeTable(first, count: int): Tabella =
var d = halfData(first, count)
# the dumbbell plot takes the place of Avg PF and reads Avg PA as well: put both in one record
var pfpa: seq[Value]
var lo, hi = NaN
for i in 0 ..< d.nrows:
let (a, b) = (d["Avg PF", i].toFloat, d["Avg PA", i].toFloat)
pfpa.add toValue((pf: a, pa: b))
for x in [a, b]:
if lo.isNaN or x < lo: lo = x
if hi.isNaN or x > hi: hi = x
let dd = TableData()
for c in d.columns:
dd.addColumn(c.name, if c.name == "Avg PF": pfpa else: c.values)
var t = initTabella(dd, rownameCol = "Team", groupnameCol = "team_division")
t = t.tabStubhead("Team")
t = t.tabSpanner("Scoring", ["Avg PF", "Avg PA", "Point Diff"])
t = t.tabSpanner("Season Trends", ["Games", "Streak"])
t = t.fmt("team_logo_espn", logo).whole
t = t.colsHide(cols("Wins", "team_conf", "team_name"))
t = t.colsAlign(alCenter, cols("Avg PF", "Avg PA", "Games"))
t = t.colsMoveToStart("team_logo_espn")
t = t.colsLabel("team_logo_espn", "")
t = t.fmt("Games", winLoss).whole
t = t.fmt("Streak", rankChange).whole
t = t.fmt("Avg PF", dumbbellFn(lo, hi)).whole
t = t.colsLabel("Avg PF", "Points For vs Points Against")
t = t.colsHide("Avg PA")
t = t.fmt("Point Diff", colorBox).whole
t = t.tabStyle(style.fill("lightgray"), loc.stub())
for (team, c) in [("NYG", "gold"), ("NE", "silver")]:
let st = style.fill(c, alpha = 0.3)
t = t.tabStyle(proc (r: Row): CellStyle = (if $r["Team"] == team: st else: CellStyle()),
loc.body(), loc.stub())
# gt_add_divider: a dark blue line on the right of Point Diff, label included
let div3 = style.borders({sRight}, "darkblue", weight = "3px")
t = t.tabStyle(div3, loc.body("Point Diff"), loc.columnLabels("Point Diff"))
# gt_theme_538
t = t.tabOptions(tableFontNames = "Arial, Helvetica, sans-serif", tableFontSize = "14px",
tableBackgroundColor = "#FFFFFF", tableBorderTopStyle = "none",
tableBorderBottomStyle = "none", columnLabelsBackgroundColor = "#FFFFFF",
columnLabelsFontWeight = "bold", columnLabelsTextTransform = "uppercase",
columnLabelsFontSize = "80%", columnLabelsBorderBottomColor = "#333333",
columnLabelsBorderBottomWidth = "3px", tableBodyHlinesColor = "#DDDDDD",
rowGroupBackgroundColor = "#F0F0F0", rowGroupFontWeight = "bold",
rowGroupBorderColor = "#DDDDDD",
headingAlign = "left", headingBorderBottomStyle = "none")
t
let t1 = makeTable(0, 16)
let t2 = makeTable(16, 16)
# ---------------------------------------------------------------- text
# gt_two_column_layout(table_header_from=1): one header, the two tables, the source note once.
echo title
echo subtitle
echo ""
echo t1
echo ""
echo t2
echo "Source: Lee Sharpe, nflverse (https://github.com/nflverse/nfldata)"
# ---------------------------------------------------------------- html
let page = """<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<title>""" & title & """</title>
<style>
body{margin:0;padding:24px;font-family:Arial,Helvetica,sans-serif}
.layout-head h1{font-size:125%;margin:0;font-weight:bold}
.layout-head p{font-size:85%;margin:4px 0 12px;color:#333}
.layout{display:flex;gap:24px;align-items:flex-start;flex-wrap:wrap}
.layout > div{flex:1 1 0;min-width:0;overflow-x:auto}
.layout-foot{text-align:right;font-size:90%;margin-top:8px}
</style></head>
<body>
<div class="layout-head"><h1>""" & title & "</h1><p>" & subtitle & """</p></div>
<div class="layout">
<div>
""" & t1.toHtml(withStyle = true) & """
</div>
<div>
""" & t2.toHtml(withStyle = false) & """
</div>
</div>
<div class="layout-foot">""" & sourceNote & """</div>
</body></html>
"""
writeFile("table.html", page)table.nim with the skills 163 lines
import std/[json, strutils, sequtils, math, os]
import tabelline
# ------------------------------------------------------------------ data
let rows = parseFile("nfl_2011_stats.json")
proc loadData(part: JsonNode): TableData =
## One column per key of the JSON records. "Avg PF" holds the pair [PF, PA]: the dumbbell draws both.
result = TableData()
for key in ["Team", "Record", "Wins", "Avg PF", "Avg PA", "Point Diff", "Games", "Streak",
"team_division", "team_conf", "team_name", "team_logo_espn"]:
var vs: seq[Value]
for r in part:
let x = r[key]
if key == "Avg PF":
vs.add toValue(@[x.getFloat, r["Avg PA"].getFloat]); continue
case x.kind
of JString: vs.add toValue(x.getStr)
of JInt: vs.add toValue(x.getInt)
of JFloat: vs.add toValue(x.getFloat)
of JArray: vs.add toValue(x.mapIt(it.getFloat))
else: vs.add null()
result.addColumn(key, vs)
proc floats(v: Value): seq[float] = v.items.mapIt(it.toFloat)
# ------------------------------------------------------------------ cells drawn by hand
proc fx(x: float): string = formatFloat(x, ffDecimal, 1)
proc winLoss(v: Value, ctx: RenderContext): string =
# gt_plt_winloss: win_color blue, loss_color orange, tie_color gray, 120 x 40
let g = v.floats
if ctx == rcText: return g.mapIt(if it == 1.0: "W" elif it == 0.0: "L" else: "T").join("")
const w = 120.0
const h = 40.0
let step = w / float(g.len)
let bw = step * 0.7
var s = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"120\" height=\"40\" viewBox=\"0 0 120 40\" role=\"img\" aria-label=\"win-loss record\">"
s.add "<line x1=\"0\" y1=\"20\" x2=\"120\" y2=\"20\" stroke=\"#bbbbbb\" stroke-width=\"0.5\"/>"
for i, r in g:
let x = float(i) * step + (step - bw) / 2
if r == 1.0: s.add "<rect x=\"" & fx(x) & "\" y=\"3\" width=\"" & fx(bw) & "\" height=\"16\" fill=\"blue\"/>"
elif r == 0.0: s.add "<rect x=\"" & fx(x) & "\" y=\"21\" width=\"" & fx(bw) & "\" height=\"16\" fill=\"orange\"/>"
else: s.add "<rect x=\"" & fx(x) & "\" y=\"17\" width=\"" & fx(bw) & "\" height=\"6\" fill=\"gray\"/>"
s & "</svg>"
proc rankChange(v: Value, ctx: RenderContext): string =
# gt_fa_rank_change, icon "turn": turn-up in blue for a positive streak, turn-down in orange
let n = v.i
if ctx == rcText: return (if n > 0: "▲ " else: "▼ ") & $abs(n)
let (_, icon) = findIcon(if n > 0: "fas fa-turn-up" else: "fas fa-turn-down")
let color = if n > 0: "blue" else: "orange"
"<span style=\"white-space:nowrap;color:" & color & ";display:inline-flex;align-items:center;gap:4px;\">" &
"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 " & $icon.width & " 512\" height=\"14\" width=\"" &
fx(14.0 * float(icon.width) / 512.0) & "\" fill=\"" & color & "\" aria-hidden=\"true\"><path d=\"" & icon.path &
"\"/></svg><span>" & $abs(n) & "</span></span>"
proc dumbbell(lo, hi: float): FormatFn =
# gt_plt_dumbbell: PF green, PA red, 300 x 40, 0 decimals; the scale is the table's own
result = proc (v: Value, ctx: RenderContext): string =
let pf = v.items[0].toFloat
let pa = v.items[1].toFloat
if ctx == rcText: return formatNumber(pf, decimals = 0) & " vs " & formatNumber(pa, decimals = 0)
const w = 300.0
let (l, r) = (20.0, w - 20.0)
proc px(x: float): float = l + (x - lo) / (hi - lo) * (r - l)
let (a, b) = (px(pf), px(pa))
"<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"300\" height=\"40\" viewBox=\"0 0 300 40\" role=\"img\" aria-label=\"" &
"points for " & formatNumber(pf, decimals = 0) & ", points against " & formatNumber(pa, decimals = 0) & "\">" &
"<line x1=\"" & fx(a) & "\" y1=\"22\" x2=\"" & fx(b) & "\" y2=\"22\" stroke=\"#aaaaaa\" stroke-width=\"3\"/>" &
"<circle cx=\"" & fx(a) & "\" cy=\"22\" r=\"5\" fill=\"green\"/><circle cx=\"" & fx(b) & "\" cy=\"22\" r=\"5\" fill=\"red\"/>" &
"<text x=\"" & fx(a) & "\" y=\"12\" font-size=\"12\" text-anchor=\"middle\" fill=\"green\">" & formatNumber(pf, decimals = 0) & "</text>" &
"<text x=\"" & fx(b) & "\" y=\"38\" font-size=\"12\" text-anchor=\"middle\" fill=\"red\">" & formatNumber(pa, decimals = 0) & "</text></svg>"
proc colorBox(v: Value, ctx: RenderContext): string =
# gt_color_box: palette green-yellow-red over the domain [14, -14] (14 is green)
let x = v.toFloat
let txt = formatNumber(x, decimals = 1)
if ctx == rcText: return txt
let fill = interpolate(["green", "yellow", "red"].mapIt(cssColor(it)), (14.0 - x) / 28.0)
"<div style=\"background-color:" & fill & ";color:" & idealTextColor(fill) &
";padding:2px 8px;border-radius:2px;text-align:center;font-weight:bold;\">" & txt & "</div>"
proc logo(v: Value, ctx: RenderContext): string =
if ctx == rcText: return ""
let url = v.s
let name = url.splitFile.name.toUpperAscii
"<img src=\"" & url & "\" alt=\"" & name & "\" style=\"height:2em;vertical-align:middle\">"
proc whole(t: sink Tabella): Tabella =
## the last format gets the whole list, not each item
result = t
result.formats[^1].wholeValue = true
# ------------------------------------------------------------------ the table
proc makeTable(part: JsonNode): Tabella =
let data = loadData(part)
var lo, hi = data["Avg PF"].values[0].items[0].toFloat
for v in data["Avg PF"].values:
for x in v.items:
lo = min(lo, x.toFloat); hi = max(hi, x.toFloat)
var t = tabella(data, rownameCol = "Team", groupnameCol = "team_division"):
tabStubhead "Team"
tabSpanner "Scoring", ["Avg PF", "Avg PA", "Point Diff"]
tabSpanner "Season Trends", ["Games", "Streak"]
colsHide ["Wins", "team_conf", "team_name", "Avg PA"]
colsMoveToStart "team_logo_espn"
colsLabel:
team_logo_espn: ""
"Avg PF": "Points For vs Points Against"
colsAlign alCenter, ["Games", "Streak"]
fmt "team_logo_espn", logo
fmt "Games", winLoss
whole()
fmt "Streak", rankChange
fmt "Avg PF", dumbbell(lo, hi)
whole()
fmt "Point Diff", colorBox
# stub fill, then the two highlighted teams (gt_highlight_rows: all cells, stub included)
t = t.tabStyle(style.fill("lightgray"), loc.stub())
for (team, colour) in [("NYG", "gold"), ("NE", "silver")]:
let sel = where($it["Team"] == team)
t = t.tabStyle(style.fill(colour, alpha = 0.3), loc.body(rows = sel), loc.stub(rows = sel))
# gt_add_divider: a dark blue 3px line at the right of Point Diff
t = t.tabStyle(style.borders({sRight}, color = "darkblue", weight = "3px"), loc.body(cols = "Point Diff"))
# gt_theme_538, as far as tabelline has it
t = t.tabOptions(
tableFontNames = "Chivo, Arial, Helvetica, sans-serif", tableFontSize = "14px",
tableBorderTopStyle = "none", tableBorderBottomStyle = "none",
headingAlign = "left", headingBorderBottomColor = "white",
headingTitleFontWeight = "bold", headingTitleFontSize = "150%",
columnLabelsBackgroundColor = "white", columnLabelsFontSize = "12px", columnLabelsFontWeight = "bold",
columnLabelsTextTransform = "uppercase", columnLabelsBorderBottomColor = "black",
columnLabelsBorderBottomWidth = "2px", dataRowPadding = "3px",
tableBodyHlinesColor = "#ededed", rowGroupFontWeight = "bold", rowGroupBorderColor = "black",
sourceNotesFontSize = "12px")
t
let h1 = rows.elems[0 ..< 16]
let h2 = rows.elems[16 ..< 32]
let title = "2011 NFL Season at a Glance"
let subtitle = "Super Bowl XLVI: New York Giants def. New England Patriots"
let note = html("<span style=\"float: right;\">Source: <a href=\"https://github.com/nflverse/nfldata\">Lee Sharpe, nflverse</a></span>")
let t1 = makeTable(%h1).tabSourceNote(note)
let t2 = makeTable(%h2).tabSourceNote(note)
# text
echo title
echo subtitle
echo ""
echo t1
echo t2
# page: one header, two tables side by side (gt_two_column_layout, header from table 1)
let page = "<!doctype html>\n<html lang=\"en\"><head><meta charset=\"utf-8\">" &
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><title>" & title & "</title>" &
tabellaStyle & "<style>body{margin:0;padding:24px;font-family:Chivo,Arial,Helvetica,sans-serif}" &
"h1{font-size:150%;margin:0 0 4px}p.sub{margin:0 0 16px;font-size:85%}" &
".two{display:flex;flex-wrap:wrap;gap:24px;align-items:flex-start}.two>div{flex:1 1 640px;min-width:0;overflow-x:auto}</style></head>\n<body>\n" &
"<h1>" & title & "</h1><p class=\"sub\">" & subtitle & "</p>\n<div class=\"two\"><div>" &
t1.toHtml(withStyle = false) & "</div><div>" & t2.toHtml(withStyle = false) & "</div></div>\n</body></html>\n"
writeFile("table.html", page)A brief: one table for a yearly report
The prompt
pizzaplace.csv has one row for each of 5,000 pizzas a pizzeria sold in 2015 (type, size, price). Make one table for the owner's yearly report that shows how the sales split by type and size, with tabelline 0.2 (github.com/pietroppeter/tabelline): write report.nim, which prints the table as text and saves it as report.html. Make it a table you would be proud to see printed in the report.
report.nim without the skills 48 lines
import std/[tables, strutils, algorithm, sequtils]
import tabelline
const sizes = ["S", "M", "L", "XL", "XXL"]
# count pizzas and revenue by (type, size)
var cnt: Table[(string, string), int]
var rev: Table[string, float]
var types: seq[string]
let raw = readCsv("pizzaplace.csv")
for i in 0 ..< raw.nrows:
let ty = $raw["type", i]
let sz = $raw["size", i]
if ty notin types: types.add ty
cnt.mgetOrPut((ty, sz), 0) += 1
rev.mgetOrPut(ty, 0.0) += raw["price", i].toFloat
# best-selling type first
proc total(ty: string): int = sizes.mapIt(cnt.getOrDefault((ty, it))).foldl(a + b)
types.sort(proc (a, b: string): int = cmp(total(b), total(a)))
var d = TableData()
d.addColumn("type", types.mapIt(toValue(it.capitalizeAscii)))
for s in sizes:
d.addColumn(s, types.mapIt(if cnt.hasKey((it, s)): toValue(cnt[(it, s)]) else: toValue(nil)))
d.addColumn("Revenue", types.mapIt(toValue(rev[it])))
let t = tabella(d, rownameCol = "type"):
tabHeader "Pizzas sold in 2015", "by type and size, with revenue"
tabStubhead "Type"
tabSpanner "Size", ["S", "M", "L", "XL", "XXL"]
summaryColumns:
Total: agg.sum
columns = cols("S", "M", "L", "XL", "XXL")
fmtInteger cols("S", "M", "L", "XL", "XXL", "Total")
fmtCurrency cols("Revenue"), currency = "USD", decimals = 0
dataColor cols("S", "M", "L", "XL", "XXL"), palette = palette("pastelli")
colsMove cols("Total"), after = "XXL"
colsAlign alRight
subMissing everything(), missingText = "–"
grandSummaryRows:
"All types": agg.sum
columns = cols("S", "M", "L", "XL", "XXL", "Total", "Revenue")
tabSourceNote "Source: pizzaplace.csv, 5,000 pizzas sold in 2015. – means none sold."
echo t
t.save "report.html"report.nim with the skills 40 lines
import std/[tables, sequtils, algorithm, strutils]
import tabelline
let sales = readCsv("pizzaplace.csv")
let sizes = ["S", "M", "L", "XL", "XXL"]
var count: CountTable[(string, string)]
var revenue: Table[string, float]
var total = 0.0
for i in 0 ..< sales.nrows:
let ty = $sales["type", i]
let p = sales["price", i].toFloat
count.inc((ty, $sales["size", i]))
revenue.mgetOrPut(ty, 0.0) += p
total += p
let types = toSeq(revenue.keys).sortedByIt(-revenue[it])
var columns = @[("type", toValues(types.mapIt(it.capitalizeAscii())))]
for s in sizes:
columns.add (s, toValues(types.mapIt(count.getOrDefault((it, s), 0))))
columns.add ("pizzas", toValues(types.mapIt(sizes.foldl(a + count.getOrDefault((it, b), 0), 0))))
columns.add ("revenue", toValues(types.mapIt(revenue[it])))
columns.add ("share", toValues(types.mapIt(revenue[it] / total)))
let t = tabella(toTableData(columns), rownameCol = "type"):
tabHeader md("**Pizza sales in 2015, by type and size**"), md("Number of pizzas sold; types ordered by revenue")
tabSpanner "Pizzas sold by size", sizes
colsLabel:
pizzas: "All sizes"
revenue: "Revenue, $"
share: "Share of revenue"
fmtNumber sizes, decimals = 0
fmtNumber "pizzas", decimals = 0
fmtNumber "revenue", decimals = 0
fmtPercent "share", decimals = 1
subZero sizes, zeroText = "–"
grandSummaryRows:
"All types": agg.sum
tabSourceNote "Source: pizzaplace.csv, one row per pizza sold (5,000 pizzas). Revenue assumes prices in US dollars."
echo t
t.save "report.html"The checks
Each task has six to eight checks, run on the files the agent leaves and on its last message. "The table is right" counts the checks on the table and its code; "every check passes" adds the ones on looking (the screenshots exist, the reply says what the phone shows) and on how the table goes in the page.
| The checks | ||
|---|---|---|
| what tools/skillevals.nim reads after each run | ||
| checks | what they check | |
| A gt table with summary rows | 8 | The page exists; three totals of the summary rows are right (601, 420, $1,416,362); a range is written 20–30; the code uses summaryRows; the cars the original leaves out are left out; the colours are viridis. |
| A Great Tables table with small plots | 7 | The page exists; six drawings; the reference line at the mean; the bold and the italic of the original (1991–2020, mm); optStylize; the source note. |
| Sort, then shade the top three rows | 7 | The page exists; moons in bold; the table goes in the page with nbTable; Saturn and Uranus shaded, Mercury, Venus and Earth not; the rows come from the sort (displayOrder or a sort), not written by hand. |
| An NFL season, with drawings in the cells | 7 | The page exists; the drawings are in the HTML; none is escaped into text; no size ends in a dot (width="120."); the spanner Season Trends; the format that may return HTML (RenderContext); the phone screenshot. |
| A brief: one table for a yearly report | 6 | The page exists; the wide and the phone screenshots; a total row; a title (tabHeader); the reply says what the phone shows. |
With the skills, 13 runs of 15 pass every check, and 9 without. The two that fail with the skills took the phone picture of the NFL page, looked at it and did not keep it. Without the skills, the six that fail are those of the two tasks that ask for the pictures. A check that passes does not make a good table, as round three shows: the checks catch what an agent got wrong before, and the pictures let the agent, and a person, see the rest.
A smaller model, and other libraries
A skill has no model of its own: it is read by the model of whoever uses it. So the same five tasks went to Claude Haiku 5.5, the small model, three runs each way.
| Haiku, with the skills and without | |||
|---|---|---|---|
| Haiku 5.5, five tasks, three runs each | |||
| without | with | change | |
| The table is right | 14 of 15 | 15 of 15 | |
| The agent read the skill | 15 of 15 | ||
| It looked at a picture of its page | 3 of 15 | 5 of 15 | |
| It checked the page at a phone's width | 0 of 15 | 10 of 15 | |
| Every check passes | 8 of 15 | 13 of 15 | |
| Tokens of a run, mean | 1,779,000 | 1,444,000 | −19% |
| Cost of a run, mean | $0.11 | $0.09 | −17% |
| 15 November 2026, tabelline 0.2.0, Claude Haiku 5.5 (claude-haiku-5-5), medium effort. | |||
| Tokens and cost, task by task | ||||
|---|---|---|---|---|
| Haiku 5.5, means of three runs | ||||
| tokens | cost of a run, $ | |||
| change | without | with | change | |
| gt summary rows | −16% | 0.024 | 0.021 | −12% |
| Great Tables plots | −17% | 0.016 | 0.014 | −10% |
| Sort, shade top three | −38% | 0.021 | 0.014 | −30% |
| NFL season | −22% | 0.473 | 0.369 | −22% |
| Brief for a report | −16% | 0.024 | 0.020 | −17% |
| All fifteen runs | −19% | 0.111 | 0.093 | −17% |
| Change: with the skills against without. Tokens: all the model read and wrote in the run, cached reads included. One run of the brief with the skills deleted the report of its cost: that cell is the mean of two. | ||||
Haiku got 29 tables of 30 right. The one it got wrong, without the skills, shades the three planets by name, so the shading does not follow the sort. That surprised me less once I read what the agents without the skills did:
- The answer is on the machine. Every run opened tabelline's installed sources, where each verb has a doc comment with an example. The names are gt's in camelCase, so a gt name finds the tabelline verb. For the NFL port, some runs even installed the Python original in their folder to read how it draws its charts.
- The tasks hand over the original. Four of the five give the gt or Great Tables program to port: the agent translates, it does not design. The fifth, the brief, is a plain cross table.
- Haiku reads more. It used about four times Sonnet's tokens (1.8 million a run, against 0.45), at a tenth of the price per token. It makes up for knowing less by reading more.
What the skills change on Haiku: a fifth less money and tokens, the one wrong table, and two of the three NFL pages without the skills that scroll sideways on any screen (1,344 and 1,286 pixels), against none with them. What they changed less than on Sonnet, at first, was looking: Haiku read the skill every time, and still looked at its screenshots in only five runs of fifteen. A small model follows the first steps of a skill and drops the later ones. Then the skill's description changed (see Round four): it now says first what the skill does, "makes display tables ... and checks them on a phone". Fifteen new Haiku runs with it looked in eleven, and thirteen passed every check, against twelve. They also cost a little more, $0.107 a run against $0.092: looking is work. Fifteen runs is a hint, not proof.
The skill table-building says it is for any library. The brief went to Sonnet in Python with
Great Tables and in R with gt, three runs each way, with the skill installed and not named.
| The brief in Python and in R | ||||
|---|---|---|---|---|
| Great Tables 1.1 and gt 1.4, three runs each | ||||
| Python | R | |||
| without | with | without | with | |
| The agent read the skill | 2 of 3 | 3 of 3 | ||
| It looked at a picture of its page | 3 of 3 | 3 of 3 | 3 of 3 | 3 of 3 |
| It checked the page at a phone's width | 0 of 3 | 2 of 3 | 0 of 3 | 3 of 3 |
| Cost of a run, mean | $0.08 | $0.09 | $0.12 | $0.13 |
| 15 November 2026, Claude Sonnet 5.5, medium effort. | ||||
For Python and R the skill is not useful, on this evidence. The agents look without being
told: every agent without the skill took a screenshot of its page. The skill adds a look at a
phone's width, five runs of six, for about a cent more, and none of the twelve pages, with it or
without, breaks on a phone. All twelve tables are right and look alike. Models know gt and Great
Tables well; what table-building brings to an agent that uses tabelline (the screenshot
script, the habit of looking) it does not bring to one that already knows its library.
What I make of it
Useful, but modest, and worth less than the work that went into them. Keep them, keep them small, and put the next effort into tabelline itself.
What they do well. They make the agent check its page at a phone's width, which without them it almost never does. That is the one thing good docs cannot give: it is a habit, not a fact, and it is what caught real defects (three of six NFL pages without the skills scroll sideways, none of six with them). And they cut the cost of a run by a fifth to a third, by telling the agent where the answer is instead of letting it search the sources.
What they do not do. They do not make tables more correct: on these tasks the agents got the table right anyway, Haiku too. The credit goes to tabelline: gt's names, a doc comment with an example on every verb, in the installed sources. That is the strongest finding of the whole exercise, and it is about the library, not the skills. They do not make tables better looking, as far as I could see. And on a small model they work less well: Haiku reads the skill every time, and dropped the step that looks in two runs of three, until the description named it (one run in four since).
How much to trust the numbers. Moderately. Five tasks, three runs each, two models. Every measurement found a fault in the one before (the repository's notes leaking into the agents, then the project's memory, a wrong count of "looked", a wrong install command), and this round may well have one more. The direction is credible; the percentages are not precise.
What next
In this order, each with what it would change:
- Decide what
table-buildingis for (S). Alone, in Python and R, it did not help; with tabelline, what made the difference (look at the page, at a phone's width, withlook.js) is now a step oftabelline, andtable-buildingloads in only some runs. Either fold the rest of it intotabellineand keep one skill, or keep it and find a task where it changes the result (a design task, below). Not worth making its first sentence stronger first: the one Python run that did not load it made a table as good as the others. - Make the look step stick on a small model (S). Naming the phone check in the description took Haiku from five runs of fifteen that looked to eleven. Try the step as the skill's first instruction too, and run the Haiku cases again, three runs more each to tell a real gain from luck.
- No new rule without an agent that fails without it. The tasks are now too easy to tell the two groups apart on correctness. A harder case needs a design task with no original to port: the brief is the only one, and it is a plain cross table. Candidates: a timetable from raw departures, a ranking with a chart per row from a long table, a report table from a messy spreadsheet.
- Fix in tabelline the seven traps from round three, now in the backlog, so the skill can lose the lines that work around them:
| Seven traps for tabelline to fix | ||
|---|---|---|
| size, and what agents (and the skill) do today | ||
| size | today | |
| An unknown palette name fails when the verb is called | S | palette("oranges") is accepted and fails only when the table is drawn. The skill says which names exist. |
| A format that sees its row | M | A drawing of two columns needs both packed in one cell as text first. The page on drawings shows how. |
fmt for a whole list | S | A cell with a list is formatted item by item, so a chart of the list gets one number. The page on drawings says to write the list as text. |
| A page of several tables | S | tabellaStyle once, then toHtml(withStyle = false) for each table, by hand. The skill gives the recipe. |
optCss says when it drops a rule | S | An @import in the CSS (a web font, say) is dropped without a word. The skill does not cover it yet. |
| api.md for agents | S | The index is 37 KB, more than one read, and style.text is under ### text. The skill says how to grep it. |
| A clearer error for a block of pairs | S | In colsLabel: a name with a space and no quotes gives a macro error that does not say to quote it. The skill says to. |
| From the agents' notes in round three. S: a small change, M: a medium one. | ||
- Run the eval at every release, as a check that nothing got worse, not as research: the same cases, both models, the same isolation, and the numbers next to these.
What the two skills are
tabellineholds what is specific to tabelline and is not in its docs: where the docs are and how to search them, how to work (one verb per line, print the table as text, write the page, look at it), the traps agents met, and two pages for hard tables, one on data made in code and one on drawings in cells.table-buildingholds what is true of any table, with any library: say what the table is for, shape the data first, build in the order of the parts, look at it, say what you checked. It comes withlook.js, the script that takes the two screenshots and measures what a program can measure.
Both are at the end of this post, as an agent reads them. In Claude Code they install as one
plugin, with two commands: the first adds this repository as a marketplace, the second installs
the plugin tabelline from it.
/plugin marketplace add pietroppeter/tabelline
/plugin install tabelline@tabelline
Any other agent can be pointed at the two SKILL.md files. The page For coding
agents has the same, and the README.
Why the skills live here
The skills began in another repository because they were an experiment. They move here for three reasons.
- They are tested against the same code. Every Nim example in a skill runs in tabelline's CI and must print what the skill shows. A change that alters an example fails until the skill is updated, in the same PR.
- They are found. Whoever finds tabelline finds its skills: in the README, in llms.txt, on the page For coding agents.
- Each trap is a bug report. A trap in a skill is a place where tabelline could be clearer. Seven of them are now in the backlog: an unknown palette name that fails only when the table is drawn, a format that cannot see its row, an index of api.md that is too long. When tabelline fixes one, the trap leaves the skill.
How it was measured
Each task is a folder in a skill's evals/: the prompt, the files the agent finds, and one small
file per check. A check is that a file exists, or that a pattern is, or is not, in a file or in
the agent's reply: the page has a summary row, the code takes the rows from the display order,
no drawing has a size that ends in a dot, the screenshots exist.
How the runs are kept apart from everything else, since an agent that knows the answer tests nothing:
- Every run is a new agent process (
claude -p), not a helper of the session that writes the skills, so it gets none of that conversation. - It starts in an empty folder outside any repository, with the task's files only, so it finds
no CLAUDE.md or AGENTS.md. User settings are left out (
--setting-sources local), and with them every installed plugin; no connector is given (--strict-mcp-config); the project's memory is switched off. - With the skills, the plugin is a copy of
skills/without theevals/folders, so the agent cannot read its checks. The prompt never names a skill: the agent loads it, or not, from its first sentence, as it would for a user. - Caches are per run, and the agents installed packages only in their own folder.
- What is not enforced is asked, then checked. The prompt tells the agent not to open the repository, the other runs or the book (which holds the answer to the NFL task). A script read every tool call of every run: none did.
- Both groups run at the same time on the same four CPUs, six to ten at once, so seconds depend on the neighbours: compare the two groups, not a time with another. Tokens and cost do not have this problem.
When a run ends, tools/skillevals.nim grades its folder.
A skill is worth keeping when the agent that has it does better, or does the same with less time and money.
How we got there
It took four rounds. The first three were measured in a simpler way, which the fourth shows was not good enough: the agent was told to read the skill, and it was a helper of the session that was working on tabelline, so it also carried this repository's notes for agents. Their numbers are kept as they were found.
Round one: a skill that copied the docs
The first skill was written for tabelline 0.1, on 10 November. It held the list of the verbs, a map from gt's and Great Tables' names to tabelline's, and three examples. Four tasks, one run each way:
| Round one: the 0.1 skill | ||
|---|---|---|
| four tasks, one run each | ||
| tasks passed | seconds, mean | |
| with the skill | 4 of 4 | 29 |
| without | 4 of 4 | 37 |
The agent without the skill passed everything. It read the sources that nimble had installed, where every verb has a doc comment, and it guessed the names, because they are gt's in camelCase. The skill saved eight seconds. Pietro's verdict: "0.1 skills did not add that much". The copy of the API in the skill would also go out of date at every release.
The lesson is about tabelline more than about skills: names that follow gt, and docs in the source, already do most of a skill's work.
Round two: send the agent to the docs
For 0.2 the skill was made small. What it copied moved to where it belongs, tabelline's own docs, in a form an agent reads well (PR #108):
- api.md: the whole Reference in one Markdown file. An agent
searches it for
fmt_numberand findsfmtNumber, with its signature and an example that ran. - llms.txt: a map of the site for models, with the plain-text files first.
The skill kept only what the docs do not say: where they are, how to work (write the table one
verb per line, print it as text with echo t, then write the page), one example, and the traps
agents had met.
The tasks got harder: a gt table with summary rows and merged columns, a Great Tables table with small plots in the cells, and a sort followed by "shade the top three rows". Each ran three times in three ways: with nothing, with a line saying where the docs are, and with the skill.
| Round two: three ways, three runs each | ||||||
|---|---|---|---|---|---|---|
| runs passed, and seconds on average | ||||||
| nothing | docs | skill | ||||
| passed | s | passed | s | passed | s | |
| gt port | 3 of 3 | 60 | 3 of 3 | 70 | 3 of 3 | 57 |
| Great Tables port | 3 of 3 | 73 | 3 of 3 | 70 | 3 of 3 | 66 |
| Top three rows | 2 of 3 | 257 | 2 of 3 | 92 | 0 of 3 | 100 |
| Top three rows, rule fixed | 3 of 3 | 38 | ||||
| 14 November 2026, tabelline 0.2.0. One run with nothing took 560 s on the third task; without it the mean is 106 s. | ||||||
The two ports passed every time, in every way. With the skill they used about a tenth fewer tokens. Ports of this size are no test of a skill any more.
The third task is where the skill did worse than nothing. In tabelline rows = [0] is the
first row of the data, not the first row shown, so after a sort it is the wrong row. The skill
warned about it in one sentence: rows count in data order, and "to mean rows by content, use
where". All three agents with the skill obeyed. Two wrote the names of the three planets in the
code. One wrote moons > 20. The page looked right and the checks passed, but the shading no
longer followed the sort: change the data and the wrong rows are shaded. The agents without the
skill had read the docs and found displayOrder, which gives the rows as they are shown.
The sentence was true. It was also incomplete, and an agent follows a skill more closely than
anything it finds by itself. The rule now says what to do: build the table, take
t.displayOrder()[0 .. 2], style those rows. The task gained a check that reads the code. Three
new runs passed, in 38 seconds.
A rule in a skill says what to do, not only what to avoid. And a check reads the code, not only the page.
Round three: hard tables
So far the tables were easy. Pietro asked how the skill should handle hard ones, and which examples to give it, since the book has some forty ported tables to choose from.
Choosing by taste would repeat round one. So six hard tasks went to agents, with the skill and without, and each agent also wrote notes for tabelline's maintainers: what it tried first, what failed, where it found the answer. The tasks:
- three tables with charts drawn in the cells and data shaped in code first: the Euro NCAP ranking, the lemurs, an NFL season (entries of Posit's Table Contest and a gt-extras example);
- a railway timetable, with twenty columns;
- a board of Super Bowl squares, which is a grid and not rows of data;
- a brief with no table to copy: "one table for the owner's yearly report", from 5,000 pizza orders.
All twelve programs compiled and ran. The notes say where the time went:
| Where twelve runs lost time | ||
|---|---|---|
| runs whose notes mention it, of 12 | ||
| runs | what happened | |
| Did not look at the page | 12 | Every agent searched the HTML for its styles. None took a screenshot. |
| Finding a name in the docs | 12 | The index of api.md was too long to print in one go, and style.text is filed under text. |
| Data made in code | 11 | tabelline does not group, join or pivot, by design. Each agent worked out alone how to build a table from columns it computed. |
| A drawing in a cell | 8 | fmt with a simple proc escapes HTML, so the cell shows <svg ...> as text. The proc that may return HTML takes a second argument. |
A number printed as 28. | 3 | Nim's {x:.0f} keeps the dot. With width="120." a drawing loses its size. |
| Counted in the agents' notes, 15 November 2026, tabelline 0.2.0. | ||
The first line is the one that matters. Here is the NFL table as one agent delivered it, with the skill of round two. Every check on its HTML passed.
- The title is there twice: once from the table and once written by hand above it.
- A column of addresses that should have been logos, or hidden.
- The table runs off the page: the last columns cannot be seen.
Another run drew its charts with width="120." and got rows 170 pixels tall around a small
drawing. No agent knew, because no agent looked. A person would have seen all of it in a second.
One skill or two
Pietro's question was whether to split the skill: one for building a table, one for tabelline's specifics. The findings split themselves in those two kinds, so the answer is two.
What is specific to tabelline goes in the skill tabelline:
- how to search api.md without printing it whole;
- a page on data made in code: read a cell, group, join, pivot and sort in plain Nim, then make the table's data, in one program of thirty lines;
- a page on drawings in cells: a
fmtproc that returns HTML, what it answers for the text output, two numbers in one cell, one scale for all rows, a size with no dot; - a table of seven kinds of hard table, each with the book chapter to read.
The two pages are separate files. An agent making a plain table never opens them. The book is not copied into the skill: the table links each chapter's source at the release's tag.
| Which chapter for which table | |
|---|---|
| the skill's index of the book | |
| read | |
| Charts or boxes drawn in cells | An NFL season, the lemurs |
| A timetable, or any table with twenty columns | SEPTA's timetable |
| A grid that is not rows of data | Super Bowl squares, the periodic table |
| A statistical summary by groups | A clinical table |
| Many summary rows | Summary lines |
| A ranking with pictures and a heavy style | Euro NCAP |
| Every style and option, one by one | Styling with gt |
What is true of any table, with any library, goes in a new skill, table-building. It has
five steps:
- Say what the table is for, in one sentence: who reads it and what they compare.
- Shape the data first, and check two or three numbers by hand.
- Build in the order of the parts: stub and groups, labels and spanners, formats, totals, title and notes, and emphasis last and little.
- Look at it.
- Say what you checked.
It does not change when tabelline does, and it was written to work for gt and Great Tables too (tested later: see the result).
Look at it
Step 4 is the reason the second skill exists. It comes with a script, look.js. The agent runs
it on its page and gets two screenshots, one 1100 pixels wide and one at the width of a phone,
and a list of what a program can measure: a page that scrolls sideways, cells that are cut, rows
far taller than the others, pictures that did not load. Then the agent reads the two pictures,
with a list of what only eyes find: a title shown twice, a drawing off its line, labels that wrap
into three lines, text on a colour it cannot be read on.
The same six tasks ran again, once each, with both skills. The book was held out this time: it holds the answers to five of the six, and an agent that reads the answer tests nothing. All six agents took the screenshots and read them. The same NFL table:
The agent that made the lemurs table wrote that the axes of its line charts had vanished, with
x1="48.", and that it found out "only by looking at the screenshot". The page on drawings warns
about that dot. The agent had read the warning, and wrote the dot anyway. Then it looked, saw it,
and fixed it.
A warning is read and forgotten. A picture of the result is not.
Two new eval cases keep this. One ports the NFL table and checks that the drawings are in the HTML and not escaped, that no size ends in a dot, and that the screenshots exist. One gives the pizza brief. The runs of the first half of this round fail them, and the runs of the second half pass.
Round four: measure it properly
Pietro asked what the final skills are worth, in numbers. Measuring it showed two faults, one in the method and one in the skills.
The method. In the first three rounds the agent "without the skill" was a helper started from the session that was working on tabelline. It had been given this repository's notes for agents, which say how tabelline's examples are written and where its docs are. So it was not without. And the agent "with the skill" was told to read it, which is not how a skill is used: a user installs it and the agent decides. The result at the top of this post comes from new agent processes, in a folder outside any repository, with the skills installed and not named.
The skills. In the first proper run, the skill tabelline loaded in all fifteen runs with
the skills. The skill table-building loaded only for the brief. For the other twelve, the
agent had read in tabelline a sentence that sent it to table-building for the look step,
and did not follow it: twelve agents of twelve did not look at their page. The step is now in
tabelline itself, as the third step of its way of working, with the command to run. The twelve
runs were made again: twelve of twelve looked.
The same tasks on Haiku, the small model, found one more: five runs of fifteen never opened the skill. Its first sentence now starts with "Read this first, before writing any code". Of nine new runs on the three tasks where it had been skipped, eight opened it.
Pietro asked whether a description that starts with an order is normal. It is common: Anthropic's guidance asks for what a skill does and when to use it, and its skill-creator for a description "a little bit pushy", because models skip skills more often than they read one too many. Ours gave the when and never the what, so it became "Makes display tables in Nim with tabelline ... and checks them on a phone", then the when. Fifteen Haiku runs with it: every one read the skill, and eleven looked at their page, against five.
An agent does what the skill it is reading says, not what another skill would say. Put the step where the agent already is.
Writing down how the runs were kept apart found one more fault, after Pietro asked: every agent, in both groups, had this project's memory in its prompt, a page of notes about tabelline and its docs. And "looked" had been counted from the screenshots left in the folder, so an agent that looked and deleted its pictures counted as not looking. The result at the top comes from all the runs made again, 72 of them, with the memory switched off and "looked" counted from the pictures the agent opened. Without the memory, agents without the skills looked more often than before, and the skills' advantage on the right table went away; the phone, the pages that break and the cost remained.
Write down how the experiment is isolated, and check each line against the transcripts. Two of the faults here were found that way.
What four rounds say
- Names that follow gt, and docs in the source, do most of the work. Put effort there first.
- A skill holds what the docs do not: how to work, the traps, a few recipes. It links the rest.
- Every rule says what to do. A true warning that stops halfway did more harm than no skill.
- Checks read the code and the page, and the hardest task is the only one that tests anything.
- Agents rarely check what they make on a phone, unless a skill gives them the tool and tells them to.
- Choose what goes in a skill from what agents wrote down, not from what seems useful.
- A pointer from one skill to another is not followed. Each skill holds its own steps.
- The sentence that says when to use a skill is an order, not a description: a small model skips a description.
- Measure with agents that know nothing: a new process, an empty folder, no memory, skills that load by themselves. A helper of the working session knows too much.
- Count what the agent did, from its transcript, not what it left behind.
Further reading
For a first skill, in the order I would read them:
- Equipping agents for the real world with Agent Skills, Anthropic's post that introduced skills: what they are and why an agent reads them in three steps (the name and description always, the file when a task matches, the other files only when sent there). Short, no code.
- Agent Skills: overview: the same ideas as reference, with the layout of a skill's folder.
- Skill authoring best practices: how to write one. The description says what the skill does and when to use it, in the third person, with the words a user would say; keep the file short and let it point to the rest; test it with the models that will use it. The most useful page of the four.
- Skills in Claude Code: where skills live, how plugins bring them, and what to do when a skill is not loaded when it should be, or is loaded when it should not.
- skill-creator, in Anthropic's repository of example skills: a skill for writing skills, with a loop of test prompts and evals like the one in this post. It is where the advice to make a description "a little bit pushy" comes from, because models tend to skip skills they would need.
What this post adds to them is mostly about testing: measure with agents that know nothing, count what they did from their transcripts, and keep a rule only when an agent fails without it.
How it is built
Everything is in skills/, at the root of the repository:
skills/tabelline/SKILL.md, withreferences/data.mdandreferences/cells.md, the two pages for hard tables;skills/table-building/SKILL.md, withscripts/look.js;evals/in each skill: one folder per task, with the prompt, the files the agent finds, and one small file per check.
.claude-plugin/ has two small JSON files that make the repository a plugin for Claude Code and
its own marketplace, so the two skills install in one line. Any other agent can be pointed at the
files.
Two tools keep the skills honest, both in Nim:
tools/skillexamples.nimfinds every Nim block in the skills that imports tabelline, runs it, and compares what it prints with the text block after it. It works like the tool that runs the examples of the specs, and CI runs it on every PR.tools/skillevals.nimgrades what an agent made against a task: it reads the checks of the task and says which pass. A check is that a file exists, or that a pattern is, or is not, in a file or in the agent's reply.
The two skills, as an agent reads them:
The skill tabelline 166 lines
---
name: tabelline
description: Makes display tables in Nim with tabelline (titles, stubs, row groups, spanners, formats, colours, summary rows, nanoplots) and checks them on a phone; says where its docs are and which traps agents met. Read it before writing any code whenever a task names tabelline, asks for a display table in Nim (in a program, a README or a nimib page), or ports a gt (R) or Great Tables (Python) table to Nim, even if the user never says "tabelline".
metadata:
status: draft
---
# tabelline
[tabelline](https://github.com/pietroppeter/tabelline) makes display tables in Nim after R's gt
and Python's Great Tables. This skill targets **0.2**. It holds only what tabelline's own docs do
not: where they are, how to work, and the traps agents met. Look names up there.
## Where the docs are
- **[llms.txt](https://pietroppeter.github.io/tabelline/llms.txt)**: the map, plain text.
- **[api.md](https://pietroppeter.github.io/tabelline/api.md)**: the whole API in one Markdown
file, about 8,000 lines: never print it whole. It opens with an index, one line per name with
gt's name (lines 13 to 445, too long for one read: take it in two halves, or grep it). Then
each name has an entry with its signatures, its doc comment and an example with what it prints.
- a tabelline name: `grep -n "^### fmtNumber" api.md`, then `sed -n` the forty lines after;
- a gt or Great Tables name: `grep -n "fmt_number" api.md`;
- `loc.body`, `style.text`, `agg.sum`: the entry is the last word, `### body`, `### text`;
- the names of `tabOptions` are the fields of `### TabOptions`; the values of an enum
(`alCenter`) are in its entry, `### Align`.
- Offline: the doc comments in the installed sources (`nimble path tabelline`) are the same text.
Most of gt and Great Tables is there in 0.2, under the same names in camelCase (`summary_rows`
is `summaryRows`, `cells_body()` is `loc.body()`, `cell_fill()` is `style.fill()`). Before
writing a workaround, grep api.md for the gt name. What is missing is in the feature map,
[gt.json](https://pietroppeter.github.io/tabelline/coverage/gt.json) (`status` not `done`).
## Install
Not in nimble's package list. From a folder that is not a nimble project (inside one, nimble
0.26 skips the package you name):
```sh
nimble install -y "https://github.com/pietroppeter/tabelline@#v0.2.0"
```
## Work like this
1. Write the table as a recipe, one verb per line, then `echo t` and run
(`nim r --hints:off t.nim`). Text shows the parts, groups, formats, summary rows and
nanoplots (as sparklines); not styles, colours or superscripts.
2. Then write what was asked: `t.save "t.html"` (a page), `t.toHtml`, `t.toMarkdown`, or
`nbTable t` in nimib, and grep the HTML for the colours and styles you set.
3. Then look at the page, every time, also for a small table. From this skill's folder:
`node ../table-building/scripts/look.js t.html` writes `t-wide.png` (1100px) and
`t-phone.png` (390px) and lists what it can measure. Read both pictures: a title shown twice,
a column that should be hidden, a drawing too big, a table cut at the edge of a phone. Fix
and look again. In your reply say what the phone shows, or that you could not look.
```nim
import tabelline, tabelline/datasets
let t = tabella(planets(), rownameCol = "planet", groupnameCol = "type"):
tabHeader md("The **planets**")
colsHide ["mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "rings"]
colsLabel:
moons: md("*moons*")
summaryRows:
total: agg.sum
columns = "moons"
echo t
```
```text
The planets
┌─────────┬───────┐
│ │ moons │
╞═════════╪═══════╡
│ Terrestrial │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Mercury │ 0 │
│ Venus │ 0 │
│ Earth │ 1 │
│ Mars │ 2 │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ total │ 3 │
├─────────┼───────┤
│ Gas giant │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Jupiter │ 95 │
│ Saturn │ 146 │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ total │ 241 │
├─────────┼───────┤
│ Ice giant │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Uranus │ 28 │
│ Neptune │ 16 │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ total │ 44 │
└─────────┴───────┘
```
## When the table is hard
Two things take most of the time in a hard table, and neither is a verb to look up. Read the
page before you start on one:
- **The data is made in code** (a group-by, a join, a pivot, a sort, a JSON file, anything the
Python did with Polars or the R with dplyr): [references/data.md](references/data.md).
- **A cell holds a drawing or HTML of your own** (a small chart, a coloured box, anything from
gt-extras): [references/cells.md](references/cells.md).
For a whole table like yours, the book ports real ones, with the original Python or R beside
the Nim. Read the one closest to your table (the Nim is after each `""":`); they shape their
data with nanuq, which you can replace with plain Nim:
| Your table | Read (under `https://raw.githubusercontent.com/pietroppeter/tabelline/v0.2.0/book/`) |
| --- | --- |
| charts or boxes drawn in cells | `extras/nfl_season.nim`, `contest/lemurs.nim` |
| a timetable, or any table with twenty columns | `blog/septa.nim` |
| a grid that is not rows of data (a calendar, a board, a periodic table) | `blog/superbowl.nim`, `contest/periodic_table.nim` |
| a statistical summary by groups (counts and percents, a clinical table) | `vignettes/case_study_clinical.nim` |
| many summary rows | `vignettes/summary_lines.nim` |
| a ranking with pictures, links and a heavy style | `contest/euroncap.nim` |
| every style and option, one by one | `contest/gt_styling.nim` |
For the order to build a table in, and what to look for in the pictures, read the skill
`table-building`.
## Traps agents met
- **`md` with nimib 0.4.3** (the released nimib): `import nimib` and tabelline give
`ambiguous call; both boost.md ... and core.md`. Write `import nimib except md`.
- **Rows are rows of the data, from 0, not rows as shown.** After `rowOrder`, `rows = [0]` is
still the first row of the data. For the first rows as shown, build the table, then take
`t.displayOrder()[0 .. 2]` and style those rows (`t = t.tabStyle(..., loc.body(rows = top))`),
so the shading follows the data; do not write the names or a threshold by hand. To mean rows by
content, `where(...)`.
- **A cell is a `Value`, not a string**: `where(it["planet"] in ["Saturn", "Jupiter"])` does not
compile; write `where($it["planet"] in ["Saturn", "Jupiter"])`. Comparisons with numbers and
strings work as they are (`it["moons"] > 20`, `it["type"] == "Ice giant"`).
- **A verb outside the recipe returns a new table**: `t.tabHeader("x")` alone changes nothing.
Inside the recipe every call is read as a verb, except `echo`, `discard` and asserts.
- **A list of pairs is a block in the recipe** (`colsLabel:`, `summaryRows:`, `colsWidth:`), one
pair per line, and there a `fmtNumber(decimals = 0)` line formats the summary cells.
- **`md` escapes HTML tags.** A `<span>` or an `<a>` in a title, a label or a note goes in
`html(...)`.
- **A palette is a name tabelline has, or colours.** `palette("oranges")` is not one and fails
when the table is drawn, with `not a colour: oranges`. Grep api.md for `### palette` for the
names, or give the colours: `palette = @["#FFF4E5", "#C2410C"]`.
- **Not in tabelline, write this instead**: a selector's negation is `everything() - sel`;
`system_fonts("industrial")` is `systemFonts("industrial")`; there is no `google_font()` (name
the font and a stack of the reader's own after it); a regular expression in `matches` is a proc
of the name.
- **A list of pairs as a block takes pairs written out.** A name with a space, or a label with
one, goes in quotes (`"Avg PF": "Points for"`, `"All types": agg.sum`). Pairs computed in a
loop are a `seq[(string, string)]` made before the recipe and given to the verb:
`colsWidth widths`.
- **`loc.body`, `loc.stub` and `loc.columnLabels` take `cols =`**, not `columns =` as the verbs do.
- **Several tables on one page**: `tabellaStyle` once, then each `t.toHtml(withStyle = false)`.
- **The first compile takes a minute or two**; later ones are fast.
- **Colours on a styled page**: `optCssTheme()` takes them from the page's CSS variables
(`--ink`, `--paper`, ...), so in a nimib page with a theme write no hex values.
## Before you finish
The program ran and you read `echo t`; the output asked for exists and holds the styles you set;
you ran `look.js` and read the wide and the phone picture (step 3), or said that you could not;
every feature of a gt or Great Tables table you could not port is named in your reply, after a
grep of api.md for its gt name.The skill table-building 77 lines
---
name: table-building
description: Use when building, porting or reviewing a display table that people will read (in a report, a page, a README or a slide), with any library (tabelline, gt, Great Tables, HTML by hand), to build it in order and check it by looking at it, even if the user only says "make a table".
metadata:
status: draft
---
# Building a table
How to get from data and an intent to a table worth printing, whatever draws it. The library's
own skill says which verbs to call (for tabelline, the skill `tabelline`); this one says in what
order to work and when the table is done.
It exists because of what agents did on six hard tables: every one compiled, every agent grepped
the HTML for its styles, none looked at the page. Two of the pages had a title shown twice, a
column cut off at the edge and rows 170px tall around a small drawing.
## 1. Say what the table is for
One sentence before any code: who reads it, and what they compare. "The owner sees which pizza
type earns most, and how sizes split." That sentence picks the rows (what is compared), the
order (by the measure that matters, not by the alphabet), and what can go.
When porting a table, the original has decided this already. List every thing it shows (each
column, group, total, note, colour, drawing) before you write, and tick the list at the end.
## 2. Shape the data first
One row for each thing compared, columns in the order they are read, sorted, already summed.
Print the data and check two or three numbers by hand against the source. A wrong join gives a
handsome table of wrong numbers.
## 3. Build in the order of the parts
Run the program after each step and read the text output.
1. **Stub and groups**: the names of the rows on the left, rows gathered under group labels.
2. **Column labels and spanners**: words a reader knows, not names from the data; the unit in
the label (`Price, EUR`), not repeated in every cell; a spanner over columns that belong
together.
3. **Formats**: numbers of a column with the same decimals, thousands separated, as few digits
as the comparison needs; dates as a reader writes them; a dash for what is missing.
4. **Totals**: a summary row or column only if the reader would add them up.
5. **Title and notes**: a title that says what is in the table, a subtitle for the period or
the unit, the source in a note.
6. **Emphasis, last and little**: colour for one thing only (the size of a number, or the row
to notice). Text on the left, numbers on the right, thin rules, no grid. These are Jon
Schwabish's [ten guidelines](https://doi.org/10.1017/bca.2020.11): space and light rules
over boxes, and nothing that does not carry data.
## 4. Look at it
A table is not done when it compiles. Write the HTML, then run `scripts/look.js` from this
skill's folder (here `$SKILL`):
```sh
node "$SKILL/scripts/look.js" table.html
```
It writes `table-wide.png` (1100px) and `table-phone.png` (390px) and lists what it can measure:
a page that scrolls sideways, cut cells, rows far taller than the rest, pictures that did not
load. Then **read both pictures** and look for what it cannot measure:
- a title or a label shown twice, or a column that should be hidden and is not;
- a drawing too big, too small, off its line, or not on the same scale from row to row;
- labels that wrap into three lines, numbers that do not line up, a column far too wide;
- colours you cannot read text on;
- on the phone, a table that is only its first two columns.
Fix, run again, look again, until a look finds nothing. If nothing here can take a screenshot,
say so in your reply: do not write that the table looks right.
## 5. Say what you checked
In the reply: what the table shows, which numbers you checked by hand, that you looked at it
wide and on a phone (or could not), and, for a port, each thing of the original that is missing
or different and what you did instead.The script look.js 80 lines
#!/usr/bin/env node
// Looks at a table the way a reader will: screenshots an HTML page wide (1100px) and on a phone
// (390px), and lists what a grep of the HTML cannot show.
// node look.js page.html [out-prefix] -> <prefix>-wide.png, <prefix>-phone.png, a report
// Needs Playwright (npm i playwright, or the one already installed). Read the PNGs afterwards:
// the report finds only some defects.
const path = require('path');
let chromium;
try { ({ chromium } = require('playwright')); } catch (e) {
console.error('look.js: Playwright is not installed. Install it (npm i playwright && npx playwright install chromium),\n' +
'or take the screenshots another way, e.g.\n' +
' chromium --headless --screenshot=wide.png --window-size=1100,1400 page.html\n' +
' chromium --headless --screenshot=phone.png --window-size=390,1400 page.html\n' +
'and read them. Do not skip the look.');
process.exit(2);
}
const file = process.argv[2];
if (!file) { console.error('usage: node look.js page.html [out-prefix]'); process.exit(2); }
const prefix = process.argv[3] || file.replace(/\.html?$/, '');
const maxHeight = 2400; // a screenshot taller than this is too small to read: the top is enough
async function look(browser, name, width) {
const page = await browser.newPage({ viewport: { width, height: 900 }, deviceScaleFactor: 1 });
const failed = [];
page.on('requestfailed', r => failed.push(r.url()));
await page.goto('file://' + path.resolve(file), { waitUntil: 'load' });
await page.waitForTimeout(500);
const r = await page.evaluate(() => {
const out = { tables: [], clipped: [], brokenImages: [], tallRows: [], emptyColumns: [] };
out.pageWidth = document.documentElement.scrollWidth;
out.pageHeight = document.documentElement.scrollHeight;
for (const img of document.images) if (!img.complete || img.naturalWidth === 0) out.brokenImages.push(img.src);
document.querySelectorAll('table').forEach((t, i) => {
const box = t.getBoundingClientRect();
const rows = [...t.querySelectorAll('tbody tr')];
const heights = rows.map(tr => tr.getBoundingClientRect().height).filter(h => h > 0).sort((a, b) => a - b);
const median = heights.length ? heights[heights.length >> 1] : 0;
// a table may scroll inside a box of its own: that is fine, a page that scrolls sideways is not
let scroller = t.parentElement;
while (scroller && scroller !== document.body && getComputedStyle(scroller).overflowX === 'visible') scroller = scroller.parentElement;
out.tables.push({ table: i + 1, width: Math.round(box.width), rows: rows.length,
medianRowHeight: Math.round(median), tallestRow: Math.round(heights[heights.length - 1] || 0),
scrollsInItsBox: !!scroller && scroller !== document.body });
rows.forEach((tr, j) => { const h = tr.getBoundingClientRect().height;
if (median > 0 && h > 3 * median && h > 90) out.tallRows.push(`table ${i + 1} row ${j + 1}: ${Math.round(h)}px (median ${Math.round(median)}px)`); });
t.querySelectorAll('th, td').forEach(c => {
if (c.scrollWidth > c.clientWidth + 2 && getComputedStyle(c).overflow !== 'visible')
out.clipped.push(`table ${i + 1}: "${(c.textContent || '').trim().slice(0, 30)}" is cut (${c.clientWidth}px of ${c.scrollWidth}px)`);
});
});
return out;
});
const shot = `${prefix}-${name}.png`;
await page.screenshot({ path: shot, clip: { x: 0, y: 0, width: Math.max(width, Math.min(r.pageWidth, 2 * width)), height: Math.min(r.pageHeight, maxHeight) } });
await page.close();
console.log(`\n== ${name} (${width}px): ${shot}${r.pageHeight > maxHeight ? ` (the top ${maxHeight}px of ${r.pageHeight}px)` : ''}`);
const problems = [];
if (r.pageWidth > width + 2) problems.push(`the page is ${r.pageWidth}px wide and scrolls sideways: ${name === 'phone' ? 'let the table scroll in its own box, or show fewer columns' : 'the table is too wide'}`);
for (const t of r.tables) console.log(` table ${t.table}: ${t.width}px wide, ${t.rows} rows, rows ${t.medianRowHeight}px (tallest ${t.tallestRow}px)${t.scrollsInItsBox ? ', scrolls inside its box' : ''}`);
if (r.tables.length === 0) problems.push('no <table> on the page');
for (const t of r.tables) {
if (t.medianRowHeight > 100) problems.push(`table ${t.table}: its rows are ${t.medianRowHeight}px tall: is a drawing or a picture in them larger than it should be?`);
if (t.width > width + 2 && name === 'wide') problems.push(`table ${t.table} is ${t.width}px wide: its last columns are out of view even on a wide screen`);
}
const remote = [...new Set([...r.brokenImages, ...failed])];
if (remote.length) problems.push(`${remote.length} image(s) or file(s) did not load (offline here, or a wrong address?): ${remote.slice(0, 3).join(', ')}${remote.length > 3 ? ', ...' : ''}`);
for (const p of r.tallRows.slice(0, 5)) problems.push('a row far taller than the others: ' + p);
for (const p of r.clipped.slice(0, 5)) problems.push(p);
if (problems.length) for (const p of problems) console.log(' ! ' + p); else console.log(' nothing found by the checks');
return problems.length;
}
(async () => {
const browser = await chromium.launch();
let n = 0;
n += await look(browser, 'wide', 1100);
n += await look(browser, 'phone', 390);
await browser.close();
console.log(`\nNow read ${prefix}-wide.png and ${prefix}-phone.png: the checks above do not see a title shown twice,\na drawing out of place, a label that wraps badly, or colours that cannot be read.`);
})().catch(e => { console.error('look.js: ' + e.message); process.exit(1); });