Uuid v7 rfc 9562 generation
Skill kjuhwa/skills-hub/skills/architecture/uuid-v7-rfc-9562-generation
Generate RFC 9562 compliant UUIDv7 with millisecond timestamp prefix for sortabilityFrom its SKILL.md
npx -y skills add kjuhwa/skills-hub --skill uuid-v7-rfc-9562-generationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
1.4 KB, 285 tokens by cl100k_base, as published. Nobody here has run it
UUIDv7 (RFC 9562) generator
UUIDv7 puts a 48-bit millisecond timestamp in the high bits, the version nibble in bits 48–51, and random bits everywhere else. IDs generated at different times sort lexicographically by time — ideal for append-only logs, outbox tables, and file naming.
Mechanism
function uuidv7() {
const ms = Date.now();
const hex = ms.toString(16).padStart(12, '0');
const rnd = crypto.randomBytes(10);
rnd[0] = (rnd[0] & 0x0f) | 0x70; // version 7
rnd[2] = (rnd[2] & 0x3f) | 0x80; // variant 10
const r = rnd.toString('hex');
return `${hex.slice(0,8)}-${hex.slice(8,12)}-${r.slice(0,4)}-${r.slice(4,8)}-${r.slice(8,20)}`;
}
When to reuse
- Message/event IDs where chronological sort matters.
- Replacing
ULIDorDate.now()+noncead-hoc schemes. - Any ID space where a DB sequence is undesirable (distributed systems, file-based stores).
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.