gap-free-sequences

Generate gap-free business numbers via atomic SQL UPSERT within database transactions.

59|14|Updated Mar 1, 2026
One-click install
npx skills add https://github.com/vobase/vobase --skill gap-free-sequences
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: gap-free-sequences
Source: https://github.com/vobase/vobase/tree/main/packages/cli/skills/gap-free-sequences
Command: npx skills add https://github.com/vobase/vobase --skill gap-free-sequences

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Generating human-readable business numbers without gaps or duplicates under concurrent writes is difficult when numbering logic runs outside the database or outside the write transaction. This Skill centralizes sequence allocation so financial and compliance documents receive deterministic, auditable numbers that remain consistent after rollbacks and concurrent operations.

Core Features & Use Cases

  • Atomic, gap-free allocation: Uses a centralized sequences table and an atomic SQL UPSERT to allocate monotonic numbers per prefix.
  • Transaction safety: Designed to be called with the transaction handle so number allocation and record insertion are atomic and rollback-safe.
  • Flexible formatting: Supports pad length, separator, and optional year prefix while keeping the counter keyed by prefix.
  • Use cases: Invoice, order, shipment, purchase order numbering, compliance documents, and automated test validations for concurrency and rollback scenarios.

Quick Start

Generate a gap-free invoice number for prefix INV inside the same transaction and persist it with the invoice record.

Frequently Asked Questions about gap-free-sequences

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

FAQPage Schema
How do I generate gap-free invoice numbers in SQLite under concurrent writes?▼

Gap-free invoice numbers are generated using an atomic SQL UPSERT on a per-prefix sequences table, ensuring monotonic, unique allocation even during concurrent database writes.

How does transaction-safe sequence numbering prevent duplicate business numbers?▼

Transaction-safe sequence numbering prevents duplicates by passing the transaction handle so number allocation and record insertion are atomic, rolling back together if the transaction fails.

Can I format sequence numbers with a year prefix and custom pad length for compliance documents?▼

Yes, sequence numbers support flexible formatting including custom pad length, separators, and an optional year prefix while keeping the underlying counter keyed by the specified prefix.

What's the best way to prevent sequence gaps when database transactions roll back?▼

The best way to prevent sequence gaps during rollbacks is to allocate numbers inside the same database transaction using an atomic UPSERT, ensuring failed operations do not consume sequence values.

Does this gap-free sequence generation work for orders and shipments or only invoices?▼

Gap-free sequence generation works for any transactional document requiring uniqueness, including order, shipment, and purchase order numbering, as well as compliance document tracking.