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

transaction-correctness — Claude Code skill: WAL & ACID in Turso

Explains how transactions work in Turso: WAL mechanics, checkpointing, crash recovery, and concurrency rules.

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

What transaction-correctness does

The skill breaks down how Turso handles reads and writes through WAL (Write-Ahead Logging): writer appends frames to .db-wal, reader sees a consistent snapshot at its read mark, checkpoint moves changes back to .db. It covers four checkpoint types — PASSIVE, FULL, RESTART, TRUNCATE — and concurrency rules: one writer, readers don't block the writer.

Turso skips the .db-shm file and uses in-memory structures: frame_cache hashmap, atomic read marks, and locks. The skill references wal.rs and pager.rs, shows the split between connection-private state (Pager, WalFile) and shared state (WalFileShared, DatabaseStorage). This is the foundation if you're fixing Turso's transaction layer or debugging race conditions.

Requires the Turso repository — the skill relies on specific codebase files.

What it helps with

  • understand WAL mechanics in Turso
  • learn crash recovery process
  • study concurrency rules for database access
  • debug transactional logic
  • grasp Pager and WalFile architecture

Example prompts for the agent

  • explain how checkpointing works in Turso
  • show the difference between PASSIVE and FULL checkpoint
  • how does a reader see a consistent snapshot

How to install transaction-correctness

1Skills CLI (Vercel)

npx skills add tursodatabase/turso --skill transaction-correctness -a claude-code

2Manually: put the files in place

~/.claude/skills/transaction-correctness/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/transaction-correctness/

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 differential-fuzzer tursodatabase This skill guides Turso differential fuzzer runs and investigates differences against SQLite. Use it when generated SQL may expose correctness bugs. Claude Code CX Codex Cursor +1 1,200installs

Similar

shap K-Dense-AI Guides AI agents in explaining and auditing machine learning predictions with SHAP. Useful for selecting explainers, checking additivity, and rendering attribution plots. Claude Code CX Codex Cursor +1 2,000installs networkx K-Dense-AI Build, analyse and visualise Python graphs with NetworkX. Use it for routes, centrality, communities and graph file formats. Claude Code CX Codex Cursor +1 2,000installs polars K-Dense-AI The skill gives agents reference material on Polars, the Python DataFrame library with lazy evaluation and an expression-based API for ETL and pandas migration. Claude Code CX Codex Cursor +1 2,000installs rag-architect https://github.com/Jeffallan Designs production RAG systems: chunks documents, generates embeddings, configures vector stores, builds hybrid search pipelines, and evaluates retrieval quality. Claude Code CX Codex Cursor +1 4,700installs pyopenms K-Dense-AI Processes mass spectrometry data for proteomics and metabolomics using pyOpenMS. It detects features, identifies peptides, and generates multi-sample quantification matrices. Claude Code CX Codex Cursor +1 1,900installs polars-bio K-Dense-AI Genomic interval arithmetic on Polars DataFrames, plus readers and writers for formats from BED to CRAM. Built for coordinate-aware joins in a Python pipeline. Claude Code CX Codex Cursor +1 1,900installs xlsx official anthropics Creates, reads, edits, and converts spreadsheet files. Use it when the requested deliverable is an Excel workbook or another tabular file. Claude Code Claude.ai 187,223installs google-agents-cli-observability official Google This skill guides you through tracing and monitoring AI agents, including ADK agents. Use it when you need to inspect agent execution or monitor a deployed agent. Claude Code CX Codex Cursor +1 509,900installs

Questions about transaction-correctness

How to install transaction-correctness in Claude Code?

Run npx skills add tursodatabase/turso --skill transaction-correctness -a claude-code. The skill file will appear in ~/.claude/skills/transaction-correctness/SKILL.md.

What does transaction-correctness do?

It explains how transactions work in Turso: WAL mechanics, checkpointing, crash recovery, and concurrency rules for database access.

How is Turso different from standard SQLite?

Turso does not use the .db-shm file — instead it uses an in-memory WAL index with a frame_cache hashmap and atomic read marks, because multi-process access is not supported.

Source text

SKILL.md · MIT
---
name: transaction-correctness
description: How WAL mechanics, checkpointing, concurrency rules, recovery work in tursodb
---
# Transaction Correctness Guide

Turso uses WAL (Write-Ahead Logging) mode exclusively.

Files: `.db`, `.db-wal` (no `.db-shm` - Turso uses in-memory WAL index)

## WAL Mechanics

### Write Path
1. Writer appends frames (page data) to WAL file (sequential I/O)
2. COMMIT = frame with non-zero db_size in header (marks transaction end)
3. Original DB unchanged until checkpoint

### Read Path
1. Reader acquires read mark (mxFrame = last valid commit frame)
2. For each page: check WAL up to mxFrame, fall back to main DB
3. Reader sees consistent snapshot at its read mark

### Checkpointing
Transfers WAL content back to main DB.

```
WAL grows → checkpoint triggered (default: 1000 pages) → pages copied to DB → WAL reused
```

Checkpoint types:
- **PASSIVE**: Non-blocking, stops at pages needed by active readers
- **FULL**: Waits for readers, checkpoints everything
- **RESTART**: Like FULL, also resets WAL to beginning
- **TRUNCATE**: Like RESTART, also truncates WAL file to zero length

### WAL-Index
SQLite uses a shared memory file (`-shm`) for WAL index. **Turso does not** - it uses in-memory data structures (`frame_cache` hashmap, atomic read marks) since multi-process access is not supported.

## Concurrency Rules

- One writer at a time
- Readers don't block writer, writer doesn't block readers
- Checkpoint must stop at pages needed by active readers

## Recovery

On crash:
1. First connection acquires exclusive lock
2. Replays valid commits from WAL
3. Releases lock, normal operation resumes

## Turso Implementation

Key files:
- [WAL implementation](../../../core/storage/wal.rs) - WAL implementation
- [Page management, transactions](../../../core/storage/pager.rs)

### Connection-Private vs Shared

**Per-Connection (private):**
- `Pager` - page cache, dirty pages, savepoints, commit state
- `WalFile` - connection's snapshot view:
  - `max_frame` / `min_frame` - frame range for this connection's snapshot
  - `max_frame_read_lock_index` - which read lock slot this connection holds
  - `last_checksum` - rolling checksum state

**Shared across connections:**
- `WalFileShared` - global WAL state:
  - `frame_cache` - page-to-frame index (replaces `.shm` file)
  - `max_frame` / `nbackfills` - global WAL progress
  - `read_locks[5]` - read mark slots (TursoRwLock with embedded frame values)
  - `write_lock` - exclusive writer lock
  - `checkpoint_lock` - checkpoint serialization
  - `file` - WAL file handle
- `DatabaseStorage` - main `.db` file
- `BufferPool` - shared memory allocation

## Correctness Invariants

1. **Durability**: COMMIT record must be fsynced before returning success
2. **Atomicity**: Partial transactions never visible to readers
3. **Isolation**: Each reader sees consistent snapshot
4. **No lost updates**: Checkpoint can't overwrite uncommitted changes

## References

- [SQLite WAL](https://sqlite.org/wal.html)
- [WAL File Format](https://sqlite.org/walformat.html)

© 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