Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

prefixed-ulids带前缀的 ulids

Agent Skill

prefixed-ulids 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

240

周安装

10

GitHub Stars

101

下载量

80
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:prefixed-ulids(带前缀的 ulids)
来源仓库:https://github.com/dvf/opinionated-django
仓库路径:skills/prefixed-ulids
安装命令:
npx skills add https://github.com/dvf/opinionated-django --skill prefixed-ulids
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dvf/opinionated-django --skill prefixed-ulids

简介

带前缀的 ulids 技能用于查找、检索和筛选相关信息,支持关键词和场景匹配。

  • 适用于 Codex、Claude、Cursor、Gemini CLI 等宿主环境。
  • 通过 GitHub 安装,使用 npx skills add 命令添加指定仓库的技能。
  • 需确认权限范围和维护状态,注意可能触发联网或文件读写操作。
  • prefixed-ulids 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

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.

The Generator

Put this in src/project/ids.py:

from ulid import ULID

def prefixed_ulid(prefix: str) -> str:
    return f"{prefix}_{str(ULID()).lower()}"

def _make_generator(prefix: str):
    def generate() -> str:
        return prefixed_ulid(prefix)

    generate.__name__ = f"generate_{prefix}_id"
    generate.__qualname__ = f"generate_{prefix}_id"
    return generate

Then register a generator per aggregate root:

generate_prd_id = _make_generator("prd")
generate_ord_id = _make_generator("ord")
generate_itm_id = _make_generator("itm")

The __name__ / __qualname__ rewrite matters: Django migrations serialize the default callable's fully qualified name, so each generator needs a distinct identity or the autodetector will get confused.

Choosing a Prefix

  • 3 to 4 lowercase letters — short enough to stay readable in logs
  • Must be unique across the whole project
  • Prefer mnemonic, not cryptic: ord for order, inv for invoice, prd for product, usr for user
  • Avoid collisions with existing prefixes — grep src/project/ids.py before inventing a new one
  • Never rename a prefix once it's in production; the prefix is part of the ID

Using it in a Model

from typing import ClassVar

from django.db import models

from project.ids import generate_prd_id

class Product(models.Model):
    __prefix__: ClassVar[str] = "prd"
    id = models.CharField(
        max_length=64,
        primary_key=True,
        default=generate_prd_id,
        editable=False,
    )
    name = models.CharField(max_length=255)

    def __str__(self) -> str:
        return self.name

Rules:

  • CharField(max_length=64) — ULID is 26 chars, prefix + separator adds up to ~10, 64 leaves headroom.
  • primary_key=True and editable=False.
  • The default is the generator function (no parentheses) so Django calls it per row.
  • __prefix__: ClassVar[str] mirrors the generator's prefix — makes the mapping discoverable from the model class alone, and lets tests assert on it.
  • Never override save() to generate the ID; the default handles it.

Using it Across the Stack

Once IDs are strings at the ORM layer, they stay strings everywhere else:

  • DTOs (Pydantic): id: str — never UUID.
  • Repository params: def get(self, product_id: str) -> ProductDTO:...
  • API path params (django-ninja): def get_product(request, product_id: str):...
  • Celery task args: pass the string ID, never a model instance.
  • Tests: assert on the prefix, e.g. assert dto.id.startswith("prd_").

The prefix is also a cheap sanity check on every boundary: if an ID ever shows up without its prefix, something has stripped or regenerated it incorrectly.

Migrating an Existing Table

If the table already has integer or UUID primary keys, don't try to change them in place. Instead:

  1. Add a new CharField column with the prefixed ULID default, nullable at first.
  2. Backfill with a data migration that assigns prefixed_ulid("prd") to every existing row.
  3. Add unique=True and make it non-nullable in a follow-up migration.
  4. Swap it to primary_key=True only after every foreign key has been migrated to reference the new column — this usually means a multi-release cutover.

Prefer doing this on a new table where possible; in-place primary-key swaps in production are a lot of work for limited benefit.

Verify

  • Every model has __prefix__ and a CharField primary key using a generate_*_id default.
  • Every generate_*_id in src/project/ids.py has a unique prefix.
  • No model uses UUIDField, AutoField, or BigAutoField for its primary key.
  • No DTO field, service argument, or API path param types an ID as UUID — they're all str.
uv run ruff check src
uv run pyrefly check src
uv run pytest

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.02%
按下载量换算28

Claude

31.77%
按下载量换算25

Cursor

20.71%
按下载量换算17

Gemini CLI

8.99%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills