Puzzle box

A multi-stage puzzle box with stated sliding and static tolerances, a scripted collision-free solve path, and mid-solve renders.

This is a CAD spec on Spekkr, published by onyx. It is listed with the other specs. Paste the line to an agent that can open a web address, and the agent fetches the files and builds from them.

Spec
onyx/puzzle-box
Version
0.2.0
Published by
onyx
Updated
15 Nov 2026

Build this spec

Build the spec at https://spekkr.com/onyx/puzzle-box/start.md.

Paste this to your AI agent. It opens the address, fetches the spec's files, records your choices and builds from them. Nothing to install, no account.

Published by onyx.

What does the result look like?

Puzzle box: heroPuzzle box: detail

What can I customize?

Modelling tool CadQuery writes STEP and STL. OpenSCAD writes STL.

Your choices go into the line you copy. Anything else is yours to edit, but it leaves the tested path.

What do I get?

  • spec.md Requirements and acceptance checks.

    Puzzle box

    What this builds

    A multi-stage puzzle box, modelled as code: panels that slide or lift in a documented order, ending in an optional secret compartment. Static and sliding clearances are the stated tolerances. A scripted solve path is checked for clearance at every step. Assembly and mid-solve renders are written. No physical print is required.

    Read spekkr.inputs.json first. size is the outer cube. static_gap and slide_gap are the two tolerances. wall is the shell. secret and lid_inlay add features. tool is the modeller.

    Out of scope

    • A branded puzzle-box name, or a patented sequence copied as a product claim.
    • A physical print, or the feel of a slide.
    • A prize or a real lock.

    Requirements

    Each requirement has an id. Checks name the id they cover.

    R1. Tolerances and path
    • At rest, static mates have a gap of static_gap within 0.04 mm, and sliding mates have slide_gap within 0.04 mm.
    • The solve path in fixtures/box-solve.json (an ordered list of moves) can be applied with those gaps and no collision. A wrong first move is blocked.
    • If secret is on, the cavity is revealed only after the last legal move, and its volume is at least the figure in the file.

    Accept when: gaps match, the legal path opens the box (and the secret, if on), and a wrong first move is blocked.

    R2. Files and frames
    • Export the parts. Meshes watertight, min wall wall. Renders: closed, mid-solve, open, and a section.
    • One command builds, follows the path, and writes the renders. No print.

    Accept when: the command passes for both tools, and a too-tight slide gap (0) fails the path.

    R3. Inputs
    • Numeric inputs are read from spekkr.inputs.json and must stay inside the ranges in the Inputs table in design.md.
    • A value outside a range is refused before modelling, with a message that names the key.
    • Options add or remove the features in that table. The tool swap selects CadQuery or OpenSCAD; both must meet the same numbers.

    Accept when: default and one out-of-range value are handled as above, and a second legal input set still matches the formulas in design.md.

    R4. Checks and report
    • One command builds the model at the defaults and at the person's inputs, measures it against design.md, and writes a short report.
    • A model broken on purpose, for example a wall thinner than wall, must fail the report.
    • The command exports the files this spec asks for (STL, and STEP when the tool can). No physical print is required.

    Accept when: the report says pass at the defaults and at the person's inputs, and fail on a deliberately broken model.

    Verification

    Stated tolerances (0.1 mm static and 0.2 mm sliding at the defaults) are measured on mating parts. A scripted solve path runs with clearance checks, and a wrong first move is blocked. Assembly and mid-solve renders are written. No physical print is required.

    Definition of done

    • Every acceptance check above runs from one command, and all pass at the person's inputs.
    • A README says how to export the parts, how the path is listed, and that a print is optional.
    # Puzzle box
    
    ## What this builds
    
    A multi-stage puzzle box, modelled as code: panels that slide or lift in a
    documented order, ending in an optional secret compartment. Static and
    sliding clearances are the stated tolerances. A scripted solve path is
    checked for clearance at every step. Assembly and mid-solve renders are
    written. No physical print is required.
    
    Read `spekkr.inputs.json` first. `size` is the outer cube. `static_gap`
    and `slide_gap` are the two tolerances. `wall` is the shell. `secret` and
    `lid_inlay` add features. `tool` is the modeller.
    
    ## Out of scope
    
    - A branded puzzle-box name, or a patented sequence copied as a product
      claim.
    - A physical print, or the feel of a slide.
    - A prize or a real lock.
    
    ## Requirements
    
    Each requirement has an id. Checks name the id they cover.
    
    ### R1. Tolerances and path
    
    - At rest, static mates have a gap of `static_gap` within 0.04 mm, and
      sliding mates have `slide_gap` within 0.04 mm.
    - The solve path in `fixtures/box-solve.json` (an ordered list of moves)
      can be applied with those gaps and no collision. A wrong first move is
      blocked.
    - If `secret` is on, the cavity is revealed only after the last legal
      move, and its volume is at least the figure in the file.
    
    Accept when: gaps match, the legal path opens the box (and the secret, if
    on), and a wrong first move is blocked.
    
    ### R2. Files and frames
    
    - Export the parts. Meshes watertight, min wall `wall`. Renders: closed,
      mid-solve, open, and a section.
    - One command builds, follows the path, and writes the renders. No print.
    
    Accept when: the command passes for both tools, and a too-tight slide gap
    (0) fails the path.
    
    ### R3. Inputs
    
    - Numeric inputs are read from `spekkr.inputs.json` and must stay inside
      the ranges in the Inputs table in `design.md`.
    - A value outside a range is refused before modelling, with a message that
      names the key.
    - Options add or remove the features in that table. The `tool` swap
      selects CadQuery or OpenSCAD; both must meet the same numbers.
    
    Accept when: default and one out-of-range value are handled as above, and
    a second legal input set still matches the formulas in `design.md`.
    
    ### R4. Checks and report
    
    - One command builds the model at the defaults and at the person's inputs,
      measures it against `design.md`, and writes a short report.
    - A model broken on purpose, for example a wall thinner than `wall`, must
      fail the report.
    - The command exports the files this spec asks for (STL, and STEP when the
      tool can). No physical print is required.
    
    Accept when: the report says pass at the defaults and at the person's
    inputs, and fail on a deliberately broken model.
    
    ## Verification
    
    Stated tolerances (0.1 mm static and 0.2 mm sliding at the defaults) are
    measured on mating parts. A scripted solve path runs with clearance
    checks, and a wrong first move is blocked. Assembly and mid-solve renders
    are written. No physical print is required.
    
    ## Definition of done
    
    - Every acceptance check above runs from one command, and all pass at the
      person's inputs.
    - A README says how to export the parts, how the path is listed, and that
      a print is optional.
    

    Open spec.md as plain text

  • design.md Static and sliding tolerances, the scripted solve path, and the secret cavity.

    Design

    This file fixes the geometry. How the model's code is organised is up to you, as long as the numbers here hold.

    Stages

    At least three stages, listed in the solve file (for example: slide a panel, lift a slat, rotate a barrel). Tolerances are 0.1 mm static and 0.2 mm sliding at the defaults, matching the settings.

    Secret

    A cavity of at least 8 ml at the default size, if the option is on, as measured in the file.

    Inputs

    KeyLabelDefaultNotes
    sizeBox size, mm90The outer cube, from 60 to 140.
    static_gapStatic clearance, mm0.1From 0.05 to 0.2, for parts that only sit.
    slide_gapSliding clearance, mm0.2From 0.15 to 0.35, for parts that move.
    wallWall thickness, mm2.4From 1.8 to 4.
    secretA secret compartmentonA last cavity revealed at the end of the path.
    lid_inlayA lid inlayoffA decorative inlay on the first face, same material.
    toolModelling toolcadqueryCadQuery writes STEP and STL. OpenSCAD writes STL.

    Acceptance at the defaults

    Millimetres. Default outer size 80 × 60 × 50, wall 3.0, secret compartment on, lid inlay off. The opening path has four documented moves.

    QuantityValueToleranceSource
    Outer size X, Y, Z80.00, 60.00, 50.000.10Closed
    Wall thickness3.000.10wall
    Moves in the opening path40Order is in this file
    Secret cavity, inner24.00 × 16.00 × 10.000.20When secret is on
    Panel sliding clearance0.300.02Each moving panel

    Moves, in order: slide the top panel 20 mm toward the short side; slide the left panel 15 mm; rotate the hidden cam 90 degrees; lift the lid. A script that applies the moves in order must reveal the cavity; any other first move must not.

    Screenshots

    These pictures are headless OpenSCAD renders of the reference model in reference/model.scad, at the default inputs. They are not drawings of a product that has not been modelled. The first picture is the one Spekkr shows on the spec's card. A build may ship its own goldens; those goldens are of that build and do not have to match these frames pixel-for-pixel.

    FileWhat it shows
    shots/closed.pngPuzzle box 80 × 60 × 50 mm
    shots/open.pngAfter the four-move path, cavity shown

    How to verify

    1. Build the model at the default inputs and at two other legal input sets.
    2. Measure every row of the acceptance table in this file; each must fall inside its tolerance. Use the solid itself or a mesh library on the exported STL, as design.md says for the chosen tool.
    3. Refuse at least one out-of-range input by name before modelling.
    4. Confirm each exported part is a manifold, watertight mesh, and that walls and print orientation hold where this file asks.
    5. Stated tolerances (0.1 mm static and 0.2 mm sliding at the defaults) are measured on mating parts. A scripted solve path runs with clearance checks, and a wrong first move is blocked. Assembly and mid-solve renders are written. No physical print is required.
    # Design
    
    This file fixes the geometry. How the model's code is organised is up to
    you, as long as the numbers here hold.
    
    ## Stages
    
    At least three stages, listed in the solve file (for example: slide a
    panel, lift a slat, rotate a barrel). Tolerances are 0.1 mm static and 0.2
    mm sliding at the defaults, matching the settings.
    
    ## Secret
    
    A cavity of at least 8 ml at the default size, if the option is on, as
    measured in the file.
    
    ## Inputs
    
    | Key | Label | Default | Notes |
    | --- | --- | --- | --- |
    | `size` | Box size, mm | 90 | The outer cube, from 60 to 140. |
    | `static_gap` | Static clearance, mm | 0.1 | From 0.05 to 0.2, for parts that only sit. |
    | `slide_gap` | Sliding clearance, mm | 0.2 | From 0.15 to 0.35, for parts that move. |
    | `wall` | Wall thickness, mm | 2.4 | From 1.8 to 4. |
    | `secret` | A secret compartment | on | A last cavity revealed at the end of the path. |
    | `lid_inlay` | A lid inlay | off | A decorative inlay on the first face, same material. |
    | `tool` | Modelling tool | cadquery | CadQuery writes STEP and STL. OpenSCAD writes STL. |
    
    ## Acceptance at the defaults
    
    Millimetres. Default outer size 80 × 60 × 50, wall 3.0, secret compartment
    on, lid inlay off. The opening path has four documented moves.
    
    | Quantity | Value | Tolerance | Source |
    | --- | --- | --- | --- |
    | Outer size X, Y, Z | 80.00, 60.00, 50.00 | 0.10 | Closed |
    | Wall thickness | 3.00 | 0.10 | `wall` |
    | Moves in the opening path | 4 | 0 | Order is in this file |
    | Secret cavity, inner | 24.00 × 16.00 × 10.00 | 0.20 | When `secret` is on |
    | Panel sliding clearance | 0.30 | 0.02 | Each moving panel |
    
    Moves, in order: slide the top panel 20 mm toward the short side; slide
    the left panel 15 mm; rotate the hidden cam 90 degrees; lift the lid. A
    script that applies the moves in order must reveal the cavity; any other
    first move must not.
    
    ## Screenshots
    
    These pictures are headless OpenSCAD renders of the reference model in
    `reference/model.scad`, at the default inputs. They are not drawings of a
    product that has not been modelled. The first picture is the one Spekkr
    shows on the spec's card. A build may ship its own goldens; those goldens
    are of that build and do not have to match these frames pixel-for-pixel.
    
    | File | What it shows |
    | --- | --- |
    | `shots/closed.png` | Puzzle box  80 × 60 × 50 mm |
    | `shots/open.png` | After the four-move path, cavity shown |
    
    
    ## How to verify
    
    1. Build the model at the default inputs and at two other legal input
    sets.
    
    2. Measure every row of the acceptance table in this file; each must fall
    inside its tolerance. Use the solid itself or a mesh library on the
    exported STL, as `design.md` says for the chosen tool.
    
    3. Refuse at least one out-of-range input by name before modelling.
    
    4. Confirm each exported part is a manifold, watertight mesh, and that
    walls and print orientation hold where this file asks.
    
    5. Stated tolerances (0.1 mm static and 0.2 mm sliding at the defaults)
    are measured on mating parts. A scripted solve path runs with clearance
    checks, and a wrong first move is blocked. Assembly and mid-solve renders
    are written. No physical print is required.
    

    Open design.md as plain text

  • tasks.md Build tasks in order, each with a check.

    Tasks

    Work in order. Finish a task's check before starting the next.

    1. Set up. Install the tool in the tool input (CadQuery or OpenSCAD) and a mesh library for the checks. Read spekkr.inputs.json into one place at the top of the model. Check: an empty or trivial model is written and read back, and the inputs are visible in that source.
    2. Tolerances and path (R1). Build what R1. Tolerances and path asks for, to the numbers in design.md. In particular: At rest, static mates have a gap of static_gap within 0.04 mm, and sliding mates have slide_gap within 0.04 mm. Check: the R1. Tolerances and path acceptance checks pass.
    3. Files and frames (R2). Build what R2. Files and frames asks for, to the numbers in design.md. In particular: Export the parts. Meshes watertight, min wall wall. Renders: closed, mid-solve, open, and a section. Check: the R2. Files and frames acceptance checks pass.
    4. Inputs (R3). Build what R3. Inputs asks for, to the numbers in design.md. In particular: Numeric inputs are read from spekkr.inputs.json and must stay inside the ranges in the Inputs table in design.md. Check: the R3. Inputs acceptance checks pass.
    5. Checks and report (R4). Build what R4. Checks and report asks for, to the numbers in design.md. In particular: One command builds the model at the defaults and at the person's inputs, measures it against design.md, and writes a short report. Check: the R4. Checks and report acceptance checks pass.
    6. Goldens and the report. Render the documented views of the default model. Run the one-command report at the defaults, at the person's inputs, and at one more legal set. Check: the report says pass throughout, and the rendered views are written next to the model.
    7. Finish. Write a README that says how to install what is needed, how to change the inputs, and how to run the checks. Run the one command from a clean folder. Check: every item under Definition of done in spec.md is true.
    # Tasks
    
    Work in order. Finish a task's check before starting the next.
    
    1. **Set up.** Install the tool in the `tool` input (CadQuery or OpenSCAD)
    and a mesh library for the checks. Read `spekkr.inputs.json` into one
    place at the top of the model.
       Check: an empty or trivial model is written and read back, and the
    inputs are visible in that source.
    
    2. **Tolerances and path (R1).** Build what `R1. Tolerances and path` asks
    for, to the numbers in `design.md`. In particular: At rest, static mates
    have a gap of `static_gap` within 0.04 mm, and sliding mates have
    `slide_gap` within 0.04 mm.
       Check: the `R1. Tolerances and path` acceptance checks pass.
    
    3. **Files and frames (R2).** Build what `R2. Files and frames` asks for,
    to the numbers in `design.md`. In particular: Export the parts. Meshes
    watertight, min wall `wall`. Renders: closed, mid-solve, open, and a
    section.
       Check: the `R2. Files and frames` acceptance checks pass.
    
    4. **Inputs (R3).** Build what `R3. Inputs` asks for, to the numbers in
    `design.md`. In particular: Numeric inputs are read from
    `spekkr.inputs.json` and must stay inside the ranges in the Inputs table
    in `design.md`.
       Check: the `R3. Inputs` acceptance checks pass.
    
    5. **Checks and report (R4).** Build what `R4. Checks and report` asks
    for, to the numbers in `design.md`. In particular: One command builds the
    model at the defaults and at the person's inputs, measures it against
    `design.md`, and writes a short report.
       Check: the `R4. Checks and report` acceptance checks pass.
    
    6. **Goldens and the report.** Render the documented views of the default
    model. Run the one-command report at the defaults, at the person's inputs,
    and at one more legal set.
       Check: the report says pass throughout, and the rendered views are
    written next to the model.
    
    7. **Finish.** Write a README that says how to install what is needed, how
    to change the inputs, and how to run the checks. Run the one command from
    a clean folder.
       Check: every item under Definition of done in `spec.md` is true.
    

    Open tasks.md as plain text

  • reference/model.scad A parametric OpenSCAD reference of the default model, used to make the listing pictures. A build may use CadQuery or OpenSCAD and does not have to start from this file.
  • shots/hero.png Studio hero of the default model.
  • shots/detail.png Closer studio still of a joint, pocket, or surface.

Is it for me?

Kind
CAD
Tools
CadQuery, OpenSCAD

What does it need?

Agent permissions
shell
Commands it runs
install CadQuery or OpenSCAD, whichever the tool input names install a mesh library, such as trimesh

What changed?

  • 0.2.015 Nov 2026Studio product shots from a shared Cycles rig (cyclorama, PLA materials), including a short loop when present.
  • 0.1.014 Nov 2026First version.

For agents: start.md says how to build this spec, spec.json holds everything on this page, and bundle.tar.gz holds its files.