prefixed-ulids

Installation
SKILL.md

Prefixed ULID Primary Keys

This project uses Stripe-style prefixed ULIDs as the primary key for every Django model:

prd_01jq3v8f6a7b2c8d9e0f1g2h3j4k
ord_01jq3v8fgh7x2y5z9a1b2c3d4e5f

A 3-4 character prefix identifies the entity type, followed by an underscore and a lowercase ULID. ULIDs are 128-bit, lexicographically sortable by creation time, URL-safe, and collision-resistant.

Why

  • Debuggable. ord_01jq... in a log line tells you immediately it's an order — no need to cross-reference the column.
  • Safe to expose. Unlike auto-increment integers, prefixed ULIDs leak no ordering or volume information, and unlike opaque UUIDs they remain human-readable.
  • Time-sortable. ULIDs sort chronologically, so ORDER BY id doubles as ORDER BY created_at without a second index.
  • Type-safe across layers. Every ID is a str end-to-end — no UUID / str coercion at the service/API boundary.
  • No integer collisions. Exporting, importing, and sharding are all easier without monotonic counters.
Related skills

More from dvf/opinionated-django

Installs
10
GitHub Stars
105
First Seen
Apr 11, 2026