Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

differential-fuzzer — Claude Code skill: install and usage

This skill guides Turso differential fuzzer runs and investigates differences against SQLite. Use it when generated SQL may expose correctness bugs.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add tursodatabase/turso --skill differential-fuzzer -a claude-code
Open on GitHub

What differential-fuzzer does

The skill documents a fuzzer that runs generated SQL statements against Turso and SQLite, then compares their results. It catches row-set and schema differences, plus cases where one engine accepts a statement and the other returns an error.

The fuzzer lives in testing/differential-oracle/fuzzer/. It runs through cargo and supports a fixed seed, profiles, verbose output, and retained database files. Run artifacts go to simulator-output/, including minimized.sql, test.sql, and schema.json.

The instructions require loading the Debugging skill when using this tool. That matters because reproductions using aux must go through differential_probe: the tursodb shell cannot attach :memory: as aux. After reducing a failure, turn its kernel into a permanent *.sqltest regression.

What it helps with

  • compare Turso and SQLite results for generated SQL
  • replay a failure with its seed and profile
  • inspect a reduced case in minimized.sql
  • check a divergence with differential_probe
  • create a *.sqltest regression from a failure kernel

Example prompts for the agent

  • Run `differential_fuzzer` with `--seed 12345` and retain the database files.
  • Inspect `simulator-output/minimized.sql` with `differential_probe`.
  • Run the fuzzer in `loop 50` mode with verbose output.

How to install differential-fuzzer

1Skills CLI (Vercel)

npx skills add tursodatabase/turso --skill differential-fuzzer -a claude-code

2Manually: put the files in place

~/.claude/skills/differential-fuzzer/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/differential-fuzzer/

From the same set10

The whole set →
code-quality tursodatabase Correctness rules, Rust patterns, and anti-over-engineering guidance for coding agents working in your repo. Claude Code CX Codex Cursor +1 1,800installs storage-format tursodatabase A reference for the SQLite file format: header, pages, B-trees, cells, overflow, freelist, tied to Turso's storage code. Claude Code CX Codex Cursor +1 1,300installs testing tursodatabase Skill teaches you to write tests for SQL and Rust: choose between .sqltest, TCL and integration formats, run test suites with the right commands. Claude Code CX Codex Cursor +1 1,300installs async-io-model tursodatabase Teaches the agent Turso's cooperative async I/O patterns: explicit state machines, IOResult, and avoiding re-entrancy bugs. Claude Code CX Codex Cursor +1 1,300installs debugging tursodatabase A skill for tracking down tursodb bugs: compare bytecode against SQLite, turn on trace logs, run ThreadSanitizer, replay a seed and measure stack use. Claude Code CX Codex Cursor +1 1,300installs index-knowledge tursodatabase Skill automatically creates hierarchical AGENTS.md documentation for a codebase. Analyzes project structure, scores directory complexity, and generates files with instructions for AI agents. Claude Code CX Codex Cursor +1 1,300installs mvcc tursodatabase Architectural reference for experimental MVCC in Turso: row versioning, snapshot isolation, and known memory limits. Useful when working on database internals. Claude Code CX Codex Cursor +1 1,200installs transaction-correctness tursodatabase Explains how transactions work in Turso: WAL mechanics, checkpointing, crash recovery, and concurrency rules. Claude Code CX Codex Cursor +1 1,200installs

Similar

quality-playbook official Andrew Stellman This skill explores a codebase, derives requirements, reviews implementation, and audits it against specifications. Use it when you need findings tied to tests and verified TDD patches. GitHub Copilot 1,600installs setup-browser-cookies garrytan This skill transfers cookies from your local Chromium browser into a headless browsing session. Use it to test authenticated sites without re-entering credentials each run. Claude Code CX Codex Cursor +1 342installs code-review agno-team Automated code inspection for style violations, bugs, and best-practice gaps. The skill runs linting, identifies issues, and delivers structured feedback with severity levels. Claude Code CX Codex Cursor +1 472installs angular-architect https://github.com/Jeffallan An Angular 17+ specialist skill for Claude Code and other AI editors: standalone components with signals, NgRx stores, lazy routing and bundle checks. Claude Code CX Codex Cursor +1 4,800installs secure-workflow-guide trailofbits Guides smart contracts through Trail of Bits' 5-step security audit on check-in or before deployment. It runs static analysis, generates visual charts, and prepares fuzzing tests. Claude Code CX Codex Cursor +1 7,400installs scrutinize thananon An outsider-perspective review skill for plans, pull requests, and diffs. It challenges intent first, traces execution paths beyond the diff, and flags structural flaws. Claude Code CX Codex Cursor +1 5,200installs improve-codebase-architecture Matt Pocock This skill scans a codebase for architectural friction, then builds a visual HTML report with refactoring candidates. Use it before a deeper architecture review. Claude Code 1,163,035installs design-taste-frontend Leonxlnx This skill directs the design of public pages and work screens, then checks the result in a browser through screenshots. Use it when an interface feels generic or unfinished. Claude Code CX Codex Cursor +1 673,100installs

Questions about differential-fuzzer

How do I install differential-fuzzer in Claude Code?

Run npx skills add tursodatabase/turso --skill differential-fuzzer -a claude-code, then run npx skills add tursodatabase/turso --skill differential-fuzzer -a claude-code again. The skill file is at ~/.claude/skills/differential-fuzzer/SKILL.md.

What does differential-fuzzer do?

It generates SQL statements, executes them on Turso and SQLite, and reports result or schema divergences. Failures produce artifacts that can be replayed.

Why should an `aux` reproduction use `differential_probe`?

The tursodb shell cannot attach :memory: as aux. differential_probe runs each script statement against both engines and marks divergences.

Source text

SKILL.md · MIT
---
name: differential-fuzzer
description: Information about the differential fuzzer tool, how to run it and use it catch bugs in Turso. Always load this skill when running this tool
---

# Differential Fuzzer

Always load [Debugging skill for reference](../debugging/)

The differential fuzzer compares Turso results against SQLite for generated SQL statements to find correctness bugs.

## Location

`testing/differential-oracle/fuzzer/`

## Running the Fuzzer

### Single Run

```bash
# Basic run (100 statements, random seed)
cargo run --bin differential_fuzzer

# With specific seed for reproducibility
cargo run --bin differential_fuzzer -- --seed 12345

# More statements with verbose output
cargo run --bin differential_fuzzer -- -n 1000 --verbose

# Keep database files after run (for debugging)
cargo run --bin differential_fuzzer -- --seed 12345 --keep-files

# All options
cargo run --bin differential_fuzzer -- \
  --seed <SEED>           # Deterministic seed
  -n <NUM>                # Number of statements (default: 100)
  -t <NUM>                # Number of tables (default: 2)
  -c <NUM>                # Columns per table (default: 5)
  --verbose               # Print each SQL statement
  --keep-files            # Persist .db files to disk
```

### Continuous Fuzzing (Loop Mode)

```bash
# Run forever with random seeds
cargo run --bin differential_fuzzer -- loop

# Run 50 iterations
cargo run --bin differential_fuzzer -- loop 50
```

### Docker Runner (CI/Production)

```bash
# Build and run from repo root
docker build -f testing/differential-oracle/fuzzer/docker-runner/Dockerfile -t fuzzer .
docker run -e GITHUB_TOKEN=xxx -e SLACK_WEBHOOK_URL=xxx fuzzer
```

Environment variables for docker-runner:
- `TIME_LIMIT_MINUTES` - Total runtime (default: 1440 = 24h)
- `PER_RUN_TIMEOUT_SECONDS` - Per-run timeout (default: 1200 = 20min)
- `NUM_STATEMENTS` - Statements per run (default: 1000)
- `LOG_TO_STDOUT` - Print fuzzer output (default: false)
- `GITHUB_TOKEN` - For auto-filing issues
- `SLACK_WEBHOOK_URL` - For notifications

## Output Files

All output goes to `simulator-output/` directory:

| File | Description |
|------|-------------|
| `test.sql` | All executed SQL statements. Failed statements prefixed with `-- FAILED:`, errors with `-- ERROR:` |
| `schema.json` | Database schema at end of run (or at failure) |
| `test.db` | Turso database file (only with `--keep-files`) |
| `test-sqlite.db` | SQLite database file (only with `--keep-files`) |

## Reproducing Errors

Always follow these steps

1. **Find the seed and profile** in the error output:
   ```
   INFO: Starting differential_fuzzer with config: SimConfig { seed: 12345, ..., weight_profile: Writes }
   ```

2. **Re-run with that seed and profile** (a seed only replays under the same profile):
   ```bash
   cargo run --bin differential_fuzzer -- --seed 12345 --profile writes --verbose --keep-files
   ```

3. **Read the minimized reproduction first.** On an oracle failure the fuzzer
   writes these files to `simulator-output/`:
   - `minimized.sql` - a shrunken state script plus the shrunken failing
     statement, produced automatically. Start here.
   - `turso-state.sql` / `sqlite-state.sql` - each engine's full state as a
     replayable script, when you need more than the minimized version kept.
   - `test.sql` - every executed statement (the failing one is marked
     `-- FAILED:`). The minimizer falls back to replaying this history when
     the failure depends on how the state was built, not just its contents.
   - `schema.json` - table structure at failure time.

4. **Probe the reproduction with `differential_probe`.** It runs a
   statement-per-line script on Turso and SQLite side by side, prints both
   outcomes for every statement, marks divergences, and compares the final
   table contents. Exit code 1 means something diverged.
   ```bash
   cargo run -q -p differential-fuzzer --bin differential_probe -- \
       simulator-output/minimized.sql
   ```
   Use it instead of piping SQL into the two shells: the tursodb shell cannot
   `ATTACH ':memory:' AS aux`, so fuzzer reproductions with an `aux` schema
   only run correctly through the probe. Reading from stdin also works:
   `echo "SELECT ~X'96';" | cargo run -q -p differential-fuzzer --bin differential_probe`.

5. **Bisect by editing the script.** Copy `minimized.sql`, simplify one thing
   at a time (replace an expression with a constant, drop a column, drop a
   state line), and re-run the probe after each edit. The divergence marker
   tells you immediately whether the edit kept the bug. This loop usually
   ends at a one-line kernel you can hand to `EXPLAIN` on both engines.

6. **Create a permanent `*.sqltest` regression** from the kernel before the
   fix is complete. Preserve only the schema, data, statements, and assertions
   required to expose the bug. The seed and minimized fuzzer artifact are
   debugging aids, not substitutes for this regression. Use a Rust test only
   when the behavior cannot be expressed in `.sqltest`, and always load the
   [Debugging skill for reference](../debugging/).

## Understanding Failures

### Oracle Failure Types

1. **Row set mismatch** - Turso returned different rows than SQLite
2. **Turso errored but SQLite succeeded** - Turso rejected valid SQL
3. **SQLite errored but Turso succeeded** - Turso accepted invalid SQL
4. **Schema mismatch** - Tables/columns differ after DDL

### Warning (non-fatal)

- **Unordered LIMIT mismatch** - LIMIT without ORDER BY may return different valid rows

## Key Source Files

| File | Purpose |
|------|---------|
| `main.rs` | CLI parsing, entry point |
| `runner.rs` | Main simulation loop, executes statements on both DBs |
| `oracle.rs` | Compares Turso vs SQLite results |
| `schema.rs` | Introspects schema from both databases |
| `memory/` | In-memory IO for deterministic simulation |

## Tracing

Set `RUST_LOG` for more detailed output:

```bash
RUST_LOG=debug cargo run --bin differential_fuzzer -- --seed 12345
```

© tursodatabase · MIT · tursodatabase/turso

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor