
The Ankusa posts open with pencil figures: a wall with one slot in What Ankusa Refuses Before It Reads the Body, a strapped block of cells in Earning the 201. I wanted each one to look like a page from the notebook of an engineer of Agner Krarup Erlang’s time: graphite on cream squared paper, construction lines left in, a formula, and one mark in blue pencil.
The figures do not diagram the system. They need not mean anything exactly, as long as they look as if they do: batching is a bundle of square cells with a strap round it.
The pencil, the paper and the renderer behind them are now public as pencil-figure, an Agent Skill under the MIT license. It is the third skill behind this blog’s figures, after the diagram skill and animated-flow-gif. The figure at the top is one of three I drew with it once it was out.
Three trials
I installed the skill from the public repo and followed its SKILL.md the way an agent would, for three ideas that have nothing to do with Ankusa. I logged every render of a draft and what the renderer printed. One trial found a bug in the skill, so the commit I ended on, and the one this blog pins, is e5ff651.
| Figure | Sheet | Renders until accepted | First render | JPEG |
|---|---|---|---|---|
| Trammel | 1200 by 630 | 3 | Refused: the note ran off the sheet | 0.35 MB |
| Float valve | 960 by 720 | 2 | Refused: the note ran off the sheet | 0.33 MB |
| Escapement | 960 by 720 | 2 | Wrote the JPEG, then never exited | 0.31 MB |
A trammel for the skill itself
The idea is a small mechanism that draws an exact curve, which is what the skill does. The object is the trammel of Archimedes: two sliders in slots that cross at right angles, and a rod through both. A point on the rod traces an ellipse whose semi-axes are its distances to the two pivots, so PA = b, PB = a is true of the drawing. The ellipse is the blue mark, and the sheet is a share card.
The first render stopped on the note:
render: scene-trammel.mjs: labels collide
"the rod draws the curve" runs off the sheet
I had put it at x 820. The script face is wider than I guessed: at 22.5 units the note is 381 units long and ended at 1202, past the edge of a sheet 1200 wide. I moved the formula and the note to the top right, and the second render passed. Looking at it, I moved the mechanism to the middle of the sheet, drew the rod’s second position as a dashed bar in place of a single dashed line, and lightened the plate’s hatching. The third render is the figure at the top.
A float valve for backpressure
The idea is a full buffer slowing its own producer. The object is a cistern with a float valve: as the water rises, the float lifts a lever that closes the inlet, so the tank throttles its own supply. The inflow falls as the level h nears the shut-off level H, hence q = k (H − h). The lever and its float are the blue mark.

The first render failed the same way:
render: scene-float-valve.mjs: labels collide
"the tank closes its own inlet" runs off the sheet
I had left the note where the starter puts its own, at x 612. The starter’s note, one strap for the lot, is 253 units long. Mine is 351 and ended at 963 on a sheet 960 wide. Moved to x 480, the second render was the one I kept.
An escapement for rate limiting
The idea is one unit of work per tick, however hard the source pushes. The object is an anchor escapement: the weight drives the escape wheel, and the anchor lets the wheel advance a fixed amount with each swing of the pendulum, so a heavier weight does not make the clock run faster. I used the proportions that article gives for a 30-tooth wheel: the pallets span 7½ teeth, and the anchor’s pivot sits √2 wheel radii above the wheel’s centre. The anchor is the blue mark.

The first render wrote the JPEG and then never exited. Run again under timeout, it printed its summary line and was still running when timeout killed it at 100 seconds:
/tmp/pencil-trial/escapement.jpg: 1440x1080 from a 960x720 sheet, 310,877 bytes
After that every render hung the same way, the starter included. ps showed five Chrome renderer helpers whose parent was now PID 1, still running. The renderer stopped Chrome with a SIGTERM to the browser process alone. Killing Chrome does not kill its helpers. They outlived the browser and held open a pipe they had inherited from it, so Node waited on that pipe.
The bug was in the skill, so I fixed it there. Chrome now starts as the leader of its own process group, and the renderer kills the whole group and closes the pipes once it has the image. A new test runs a fake Chrome that leaves a sleep holding its stderr: the old code was still waiting when timeout killed it at 12 seconds, and the fix exits in one. It shipped as 1.0.1. After reinstalling, the same render took 0.75 seconds.
In the drawing itself, the 12° pitch mark sat against the teeth and the pendulum’s swing arc barely showed. I moved the pitch arc out, widened the swing, enlarged the pallets and moved the formula to the empty lower right, and the next render was the one I kept.
What a scene is
A scene is a small JavaScript module with three exports:
export const seed = 202; // a whole number; fixes every wobble, smudge and fox mark
export const size = [1200, 630]; // optional; 960 by 720 when absent
export default function draw(s, kit) { /* draw on the sheet s */ }
s is the sheet. kit holds the pencil grades and the geometry helpers: points, splines, clipping for a detail circle, isometric piles of cells. A scene imports nothing and writes nothing.
| Grade | For |
|---|---|
HARD | Construction: axes, projection lines, arcs that locate things. Pale, and runs well past both ends. |
FINE | Lines between cells, hatching, dimension and centre lines |
SOFT | Outlines of solids, dark and gone over twice |
ACCENT with BLUE | The one blue mark |
Every stroke is a filled ribbon whose width follows a pressure noise and tapers at both ends. The lettering is traced by the same pencil from the single-stroke Hershey fonts, taken from hersheytext and bundled with the skill, so there is nothing to install. The seed fixes every wobble, so a re-run draws the same figure.
One command draws the scene and writes the JPEG:
node ~/.agents/skills/pencil-figure/scripts/render.mjs scene.mjs hero.jpg
It drives headless Chrome over the DevTools protocol with no npm dependencies. Writing .svg in place of .jpg skips the browser, which is a quick way to check a scene for collisions.
What the renderer refuses
It exits 1 with the reason, and writes nothing, when:
- The module is not a scene: it does not load, has no whole-number
seedor no default export function, or itssizeis outside 480 to 1440. drawthrows. The message names the line in the scene.- Lettering is below the sheet’s floor, the sheet width over 60. That is 16 units on the default sheet, about 12px in this blog’s 754px column.
- Text uses a character the faces lack. Beyond ASCII and Greek there are
· − × ° ′ √ ≤. - A label touches a stroke or another label, or comes within 12 units of the sheet edge. Each one is named, with the place.
A page screenshot of the SVG is not stable. Screenshots of the same page alternate between two rasterizations of the SVG filters, which would churn the committed files on every re-export. The renderer draws the SVG onto a canvas on the CPU, with the GPU off, and a re-run writes the same bytes.
The figures are JPEGs because the paper grain is noise in every pixel: about 3 MB per figure as a PNG, about 0.3 MB as a JPEG.
Other sheets
The default sheet is 960 by 720 units and exports at 1.5x, 1440 by 1080. export const size = [1200, 630] makes a share card, like the trammel at the top, which exports at 1800 by 945. Sides run from 480 to 1440. The pencil and the 24-unit squares are the same on every sheet, so a bigger sheet is a bigger page, and the lettering floor rises with its width: 20 units on the share card. For more pixels, --scale takes 0.5 to 4.
Installing it
The skills CLI installs it for any agent that loads Agent Skills:
npx skills add jamescarr/pencil-figure
In Claude Code it also installs as a plugin, with claude plugin marketplace add jamescarr/pencil-figure and then claude plugin install pencil-figure@jamescarr-pencil-figure. I install it for Oh My Pi at a pinned commit, so an update is a change I make on purpose:
npx -y skills@1.9.1 add jamescarr/pencil-figure@e5ff651ef04ec7819d94ccb905e69f5e72bf0198 --skill pencil-figure -g -a pi -y
It needs Node 22 or later, and for a JPEG a Chrome, Chromium, Brave or Edge. It needs no network.
How I use it for this blog
diagrams/README.md pins the skill by commit. make diagrams renders every diagrams/<series>/sketch/scene-*.mjs into static/images/. The JPEGs are committed, because the deploy workflow runs Hugo and nothing else. The ten Ankusa scenes are the skill’s bundled examples, and rendered with the published skill they came out byte for byte the same as the JPEGs already committed.
The README has the full usage, and examples/ holds the ten scenes behind the Ankusa figures.