sqlite-single-writer

Serialize cross-process SQLite writes using a lock file and WAL mode.

3|1|Updated Dec 23, 2025
One-click install
npx skills add https://github.com/marcus/marcus-skills --skill sqlite-single-writer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sqlite-single-writer
Source: https://github.com/marcus/marcus-skills/tree/main/skills/sqlite-single-writer
Command: npx skills add https://github.com/marcus/marcus-skills --skill sqlite-single-writer

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

SQLite allows only one writer at a time across processes. When multiple processes attempt to write concurrently, you get SQLITE_BUSY errors. This skill provides a cross-process locking pattern that serializes writes using a separate lock file, WAL mode, timeout handling, and crash-safe release.

Core Features & Use Cases

  • Cross-process write serialization using a dedicated lock file (db.lock) to coordinate access.
  • Write-Ahead Logging (WAL) mode enables concurrent reads while writes are serialized.
  • Timed lock acquisition with exponential backoff and diagnostic timeout messages when contention occurs.
  • Automatic lock release on process crash and crash-recovery hints for debugging.

Quick Start

Wrap all write operations with the provided WriteLocker to serialize access.

Frequently Asked Questions about sqlite-single-writer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent SQLITE_BUSY errors during concurrent multi-process writes?

To resolve SQLITE_BUSY errors, you serialize cross-process SQLite writes using a dedicated lock file alongside WAL mode to coordinate access and allow concurrent reads while writes wait their turn.

How does a lock file coordinate SQLite write contention across processes?

A separate lock file coordinates SQLite write contention by acting as an inter-process mutex, ensuring only one process writes at a time while WAL mode maintains read access for others.

What happens when a process crashes while holding the SQLite write lock?

The locking pattern provides crash-safe release, automatically freeing the lock file if a process terminates unexpectedly, and includes crash-recovery hints to aid debugging.

Can I use timeout and backoff mechanisms for SQLite inter-process locking?

Yes, the mechanism uses timed lock acquisition with exponential backoff, providing diagnostic timeout messages when write contention occurs so processes can wait safely before aborting.

When should I use a separate lock file instead of SQLite's internal locking?

Use a separate lock file for CLI tools, local apps, or agent systems performing concurrent writes, as it adds timeout-driven control and crash-safe release beyond standard SQLite locking.

Does enabling WAL mode remove the need for cross-process write serialization?

No, WAL mode allows concurrent reads but still permits only one writer, so cross-process write serialization via a lock file remains necessary to prevent timeout errors.