postgres-nanoid
CommunityPrefix-safe Nanoid IDs for PostgreSQL.
Authorazlekov
Version1.0.0
Installs0
System Documentation
What problem does it solve?
PostgreSQL often stores internal UUIDs that should not be exposed in public APIs or URLs. This skill provides a standardized approach to generate and use prefixed Nanoid identifiers (public_id) that map to internal keys while remaining URL-safe and human-friendly.
Core Features & Use Cases
- Hybrid ID pattern: internal UUIDs use for database references; public_id uses nanoid with a prefix for API responses and external links.
- Prefix conventions: consistent 17-character random suffix after a short, readable prefix (e.g., usr_, ord_, prd_).
- Use cases: API responses, URL slugs, data exports, and safe migrations to add public_id columns.
- Migration guidance: add public_id column with default nanoid(prefix_), backfill existing rows, and enforce format with CHECK constraints and indexing.
Quick Start
- Create the nanoid helper function in your database (or apply the provided migration).
- Generate a sample prefixed ID: SELECT nanoid('usr_');
- Use as a default for a column: ALTER TABLE public.orders ADD COLUMN public_id TEXT DEFAULT nanoid('ord_');
- Validate format with a regex and create an index for efficient lookups.
Dependency Matrix
Required Modules
None requiredComponents
references
💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: postgres-nanoid Download link: https://github.com/azlekov/my-claude-code/archive/main.zip#postgres-nanoid Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.