<h1 align="center">Contraption</h1>
<p align="center"><b>Describe a chore. Claude builds a Rube Goldberg machine that actually works.</b><br>
A Claude Code skill. Every machine runs in real physics, and ships only once it finishes<br>40 out of 40 runs with every part nudged.</p>
<p align="center">
<a href="https://code.claude.com/docs/en/skills"><img src="https://img.shields.io/badge/Claude_Code-skill-262a44?style=flat-square&logo=claude&logoColor=white" alt="Claude Code skill"></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-262a44?style=flat-square" alt="MIT license"></a>
<a href="#requirements"><img src="https://img.shields.io/badge/node-%E2%89%A5%2018-262a44?style=flat-square&logo=nodedotjs&logoColor=white" alt="Node 18 or later"></a>
<a href="#requirements"><img src="https://img.shields.io/badge/dependencies-0-262a44?style=flat-square" alt="No dependencies"></a>
<a href="https://github.com/0xpratzyy/contraption/actions/workflows/ci.yml"><img src="https://github.com/0xpratzyy/contraption/actions/workflows/ci.yml/badge.svg" alt="CI: every machine, 40 nudged runs"></a>
</p>
<p align="center">
<a href="https://0xpratzyy.github.io/contraption/"><img src="https://img.shields.io/badge/Run_the_machines-live_gallery-f7cf2e?style=for-the-badge&labelColor=262a44" alt="Run the machines in the live gallery"></a>
<a href="#quick-start"><img src="https://img.shields.io/badge/Install-npx_skills_add-f4aec3?style=for-the-badge&labelColor=262a44" alt="Install with npx skills add"></a>
</p>
<p align="center">
<a href="#quick-start">Quick start</a> ·
<a href="#the-machines">The machines</a> ·
<a href="#how-a-machine-gets-made">How it works</a> ·
<a href="#the-look">The look</a> ·
<a href="#install">Install</a> ·
<a href="#run-it-yourself">Run it yourself</a> ·
<a href="#limits">Limits</a>
</p>
<p align="center">
<a href="https://0xpratzyy.github.io/contraption/#chai"><img src=".github/assets/hero.gif" width="100%" alt="A white pegboard with yellow plastic ramps. A chrome marble rolls down a zig-zag, knocks over seven white dominoes of growing size, the last one tips a pink see-saw into a chrome toaster, the toast lands on a big red button, the button's cable drops a hammer onto a chrome teapot, and the teapot pours chai into a glass."></a>
</p>
<p align="center"><sub><b>Nº 01, For the Pouring of Chai.</b> A marble, seven dominoes, a see-saw, a toaster, a big red button, a hammer and a teapot: eight stages, 19.0 seconds, 40 of 40 drops in the glass. Recorded frame by frame from the same physics that passed verification.</sub></p>
---
Ask for a chore and Claude invents a chain of 6 to 10 stages that ends with the chore done, the long way round. It mounts every part on a pegboard, runs the machine in Box2D physics, moves whatever jams, then runs it 40 more times with every part nudged a few centimetres and tilted a little. A machine ships only if all 40 runs finish, with every stage firing in order.
Then it puts the machine in a gallery you can play: run it, slow it down, follow the action, or drag a part somewhere else before you press Run and watch it fail.
## Quick start
```sh
npx skills add 0xpratzyy/contraption -g -a claude-code
```
Then, in Claude Code:
```text
/contraption a machine that waters my plants
```
Claude copies the kit into `./contraption`, builds the machine stage by stage, proves it, and opens it on `localhost:4173`. No API keys and nothing to `npm install`: the physics engine is vendored.
## The machines
<table>
<tr>
<td width="50%"><a href="https://0xpratzyy.github.io/contraption/#chai"><img src=".github/assets/chai.webp" alt="A chrome teapot on a yellow stand tips over and pours a stream of chai into a glass on a yellow shelf. A hammer hangs above it, a toaster and a red BREW button sit on a shelf to the left."></a></td>
<td width="50%"><a href="https://0xpratzyy.github.io/contraption/#deploy"><img src=".github/assets/deploy.webp" alt="A blue toy release train has rolled down a long rail onto a red DEPLOY button. Next to it a stack of dark server racks is on fire."></a></td>
</tr>
<tr>
<td><sub><b>Nº 01 · For the Pouring of Chai</b><br>Marble zig-zag, dominoes in ascending order of self-importance, a see-saw, a toaster, BREW, a hammer, a teapot. 8 stages, 19.0 s.</sub></td>
<td><sub><b>Nº 02 · Deploy to Production on a Friday</b><br>A coffee mug, a rubber duck, a flaky CI pipeline of pegs, code review (a funnel), the release train, DEPLOY, servers on fire. 7 stages, 9.1 s.</sub></td>
</tr>
<tr>
<td><a href="https://0xpratzyy.github.io/contraption/#balloon"><img src=".github/assets/balloon.webp" alt="Confetti bursts where a red balloon was, above a cactus in a terracotta pot on a pink see-saw. A navy bowling ball rests at the bottom of a yellow staircase."></a></td>
<td><a href="https://0xpratzyy.github.io/contraption/#snooze"><img src=".github/assets/snooze.webp" alt="A pink alarm clock with chrome bells falls off a yellow nightstand onto a WAKE button, while a chrome hammer and a steel ball wait on a ramp to the right."></a></td>
</tr>
<tr>
<td><sub><b>Nº 03 · Pop One Balloon (Maximum Effort)</b><br>A wrecking ball, ten dominoes, a marble taking the stairs, a bowling ball, a cactus on a see-saw. 7 stages, 11.5 s.</sub></td>
<td><sub><b>Nº 04 · Snooze the Alarm (Without Getting Up)</b><br>A ringing alarm walks itself off the nightstand onto WAKE, a steel ball, a reluctant hammer, lights out. 7 stages, 11.3 s.</sub></td>
</tr>
<tr>
<td><a href="https://0xpratzyy.github.io/contraption/#kibble"><img src=".github/assets/kibble.webp" alt="A ginger cat leans into a steel bowl full of kibble, hearts rising above her, as a kraft paper sack of kibble tips over on its stand. A grey clockwork mouse sits on the bench to the right."></a></td>
<td><a href="https://0xpratzyy.github.io/contraption/#chai"><img src=".github/assets/pour.webp" alt="Close-up, animated: the toast lands on the button, the hammer swings down, the chrome teapot tips and pours a stream of chai into the glass until it is full."></a></td>
</tr>
<tr>
<td><sub><b>Nº 05 · Feed the Cat (She Insists)</b><br>The cat sits on FOOD, her yarn takes the long way down, a scratching post, PLAY, a wrecking ball, a clockwork mouse runs into the kibble sack. 9 stages, 14.2 s.</sub></td>
<td><sub><b>The payoff, up close.</b> The stream is drawn through the drops the physics is actually pouring, and the glass fills with every one that lands.</sub></td>
</tr>
</table>
Nº 05 was the skill's first blind test: a fresh Claude session with no memory of the other four got only `SKILL.md` and the kit, was asked for "a machine that feeds my cat", added the cat, the bowl and the kibble sack to the kit itself, and reached 40/40. What it tripped over is now in `SKILL.md`.
## How a machine gets made
1. **Pick the payoff.** What does "done" look like on screen? Chai in a glass, a balloon popped, a cat eating. The last stage is the punchline.
2. **Invent the chain.** 6 to 10 stages that escalate (marble, then dominoes, then a giant domino) and change the kind of motion (roll, topple, swing, fly, pour, pop). Every stage causes the next one physically, or through a visible wire.
3. **Build forward.** Claude places two or three stages, runs them, reads where things really end up, and puts the next stage there, not where it hoped things would go.
4. **Prove it.** `scripts/verify.js` runs the machine, then reruns it 40 times with every part shifted up to 3 cm, lifted up to 8 mm, tilted up to 0.6° and made up to 3% heavier or lighter. A run fails if it stalls, or if any stage comes true before the one ahead of it. The machine ships at 40/40.
5. **Show it.** Captions, a follow camera that holds on the payoff, and a readout of true numbers: how long it took and what landed where.
## The look
<p align="center"><img src=".github/assets/finishes.webp" width="100%" alt="The same moment of the chai machine in three finishes: on a dark green board with a teal teapot and a tape label; on a light painted board with a white porcelain teapot; and on a white pegboard with a chrome teapot, a pink handle, a yellow shelf and navy shadows."></p>
<p align="center"><sub>One moment, three finishes: <code>ink</code>, <code>paper</code> and <code>toy</code> (the default). Same machine, same physics.</sub></p>
Machines are drawn as toys on a white pegboard: glossy plastic in yellow, pink and white, chrome for anything metal, lit from the top left, with hard navy shadows falling down and right. Each machine keeps one or two colours of its own (the chai, a red button, a rubber duck, a balloon, a ginger cat). A card frames the board: the machine's number and title on top, the current stage and a live readout of time, stage and speed below, and a numbered pin wherever a stage fired.
Painters paint with material roles (`wood`, `metal`, `housing`, `pivot` and so on), never raw colours, so a part Claude adds for a new chore comes out in the same finish as everything else. A machine can ask for `style: 'paper'` or `style: 'ink'`, and `?style=` in the gallery's URL switches any machine.
## Install
| How | Command | Installs to |
|---|---|---|
| **skills CLI**, for you | `npx skills add 0xpratzyy/contraption -g -a claude-code` | `~/.claude/skills/contraption` |
| **skills CLI**, for one project | `npx skills add 0xpratzyy/contraption -a claude-code` | `.claude/skills/contraption` |
| **git**, for you | `git clone https://github.com/0xpratzyy/contraption.git ~/.claude/skills/contraption` | `~/.claude/skills/contraption` |
| **git**, for one project | `git clone https://github.com/0xpratzyy/contraption.git .claude/skills/contraption` | `.claude/skills/contraption` |
Then ask for a machine. You don't have to type `/contraption`: Claude also loads the skill when you ask for a Rube Goldberg machine, a chain-reaction contraption, or the most overkill way to do something.
```text
/contraption a machine that turns off the lights when I leave
/contraption the most overkill way to water one plant
/contraption ring a bell when the kettle boils, with at least one domino
```
## Run it yourself
```sh
git clone https://github.com/0xpratzyy/contraption.git && cd contraption
node scripts/serve.js # the gallery, on http://localhost:4173
node scripts/verify.js machines/chai.js --runs 40 # baseline run plus 40 nudged runs
node scripts/verify.js machines/chai.js --trace marble # where the marble actually goes
```
In the gallery, `#deploy` opens a machine, `?style=paper` or `?style=ink` changes the finish, `?t=12.5&pause` stops at a moment, and `?cam=whole` keeps the whole board in view.
## How it works
- [`SKILL.md`](SKILL.md) is what Claude reads: the workflow, the parts catalogue, the triggers and actions, how captions steer the camera, the failure modes it has learned to design around, and how to paint new parts.
- [`kit/engine.js`](kit/engine.js) builds a Box2D world from a machine file and fires its stages in causal order. The same file runs in Node and in the browser, so the machine that passed verification is the machine you watch.
- [`kit/paper.js`](kit/paper.js) draws the board in the `toy` and `paper` finishes; [`kit/render.js`](kit/render.js) draws the original `ink` one. [`kit/audio.js`](kit/audio.js) synthesises every clack, ding and pop from the collision that caused it.
- [`scripts/verify.js`](scripts/verify.js) is the proof: stage timings, traces, contact logs and the 40-run jitter test. CI runs it on every machine on every push.
- [`machines/`](machines) holds the five machines, each a plain JavaScript module of parts, wires and stages.
## Requirements
Node.js 18 or later, and a browser to watch the machine run. Nothing else: the physics engine ([planck.js](https://github.com/piqnt/planck.js), a JavaScript port of Box2D) is vendored in `kit/vendor/`.
## Limits
- Machines are 2D, seen from the front. Depth, shading and shadows are drawn, not simulated.
- Liquids and kibble are many small balls, so a pour is grainy up close in the physics, even if the stream on screen is smooth.
- A new machine takes Claude several build-and-verify passes, and a chain that depends on a precise bounce may never reach 40/40. When that happens the skill tells Claude to change the design, not the random seed.
- Keep runs under about 25 seconds: the follow camera and the gallery are tuned for that.
## License
MIT. planck.js is MIT (Erin Catto, Ali Shakiba); see [`kit/vendor/PLANCK-LICENSE.txt`](kit/vendor/PLANCK-LICENSE.txt).