Free to LearnCourse directory ↗

INTERACTIVE STUDIO · 5 STEPS

Time-travel debugger

A vase breaks in your game. Rewind to find the bump, then try a fix on a copy.

Rewind the Crash

The vase broke. Choose how far to rewind the recording.

My attempts

    Build your own debugger

    Build a debugger with Node.js and a coding agent. Replay the same moves, find the last change and try a fix on a copy.

    Download the five-rung Node project →

    Three Ways In · Layer 3 of 3 · Node.js 22+ · Zero Dependencies

    Build With Your Coding Agent — 5 Rungs + Planted Traps

    Build a deterministic record-and-replay debugger with your coding agent across five rungs: immutable register/memory snapshots, nondeterministic input tape replay, pre-mutation write watchpoints, backward last-writer binary search, and bounded checkpoint ring eviction. Each rung gives you an architect prompt for Claude Code, Codex, or Cursor, a planted bug that unguided agents write, and a deterministic test suite that catches it.

    1. Isolated state snapshots: Deep register and linear-memory snapshot/restore with zero shared typed-array views — Planted trap: Copying { ...state, regs: this.regs } by reference so stepping forward mutates saved history.
    2. Deterministic I/O tape: Recording external random/clock answers by call ordinal and replaying them identically — Planted trap: Indexing recorded answers by instruction count instead of event ordinal when a branch path shifts.
    3. Pre-write watchpoint: Halting execution immediately before a watched address changes so caller state is intact — Planted trap: Stepping the write first and stopping one instruction too late after the old value is gone.
    4. Reverse last-writer search: Finding the exact latest instruction before stop that wrote the bad value at addr — Planted trap: Returning the first write to addr instead of the last write preceding the crash.
    5. Bounded checkpoint ring: Evicting old snapshots while preserving every I/O tape entry needed from the oldest kept save — Planted trap: Trimming external I/O tape entries relative to step zero instead of the oldest surviving snapshot.
    unzip agent-track.zip && cd time-travel-debugger/agent-track
    node --test test/*.test.mjs
    mkdir -p my-debugger && cp -n src/starter.mjs my-debugger/engine.mjs
    TTD_IMPL=./my-debugger/engine.mjs node --test test/rung-01.test.mjs

    Download 5-Rung Agent Track (agent-track.zip) Read AGENT-TRACK.md on GitHub Open agent-track/README.md on GitHub

    Start here

    Explore how replay works in a longer run. Pick a step in the picture below. Gold marks a saved copy. The debugger loads it and runs forward to the step you picked.

    Listen to the guided replay walkthrough →

    The full course · 13 units

    Write a debugger for a small JavaScript machine, then use it on a compiled game. You’ll use ES modules (JavaScript files that share code) and WebAssembly (compiled instructions the game runs).

    Start with Node.js on your computer. The first check tells you which methods to build.

    git clone https://github.com/itsHabib/free-to-learn.git
    cd free-to-learn
    git checkout 7dba0d743224c10a707307769782b0db3f9a2a1a
    cd courses/time-travel-debugger
    node lab.mjs start project
    node lab.mjs check project 01 --help-used none

    Finish with six replay-budgeted bug investigations: each asks you to find a bad write within a fixed number of replayed instructions. Keep your fixes, first attempts and help records in the project folder.

    Open the 13-unit course on GitHub → · Download the 13-unit course ZIP