pydantic-resolve-3step

A three-stage development method for Python projects built with pydantic-resolve, starting with agreed data models and ending with application interfaces. It uses an ER diagram, which shows database entities and their relationships, plus ORM models that represent database records in code.

In plain words
What is it for?
Use it to plan and build projects with database models, entity data objects, GraphQL, REST, MCP, and use-case response assembly.
Why use it?
It separates requirements, data structure, business methods, and interface assembly so the project can grow in defined phases. Each phase has acceptance checks and pauses for user confirmation before the next one begins.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/klr-pattern/pydantic-resolve/skill
Any agent
npx skills add KLR-Pattern/pydantic-resolve --skill skill
Clone the repo
git clone --depth 1 https://github.com/KLR-Pattern/pydantic-resolve

Made for: Claude Code, Codex.

Per session 56 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 7,002 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00056 $0.07002
Opus 5 $0.00028 $0.03501
Sonnet 5 $0.00011 $0.01400
Haiku 4.5 $0.00006 $0.00700

Measured 3d ago against content hash 3be76d898294, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

pydantic-resolve-3step scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

The scan reads SKILL.md. This mod also ships 20 executable files (template/src/__init__.py, template/src/database.py, template/src/db.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

| 1 | REST 端点返回的响应字段符合 DTO 定义(FK 隐藏、关系字段包含) | curl GET endpoint |
skill/SKILL.md · 593 lines

How it starts

The opening of the file, as written. The whole thing — 593 lines — stays where its author put it; the contents beside it link to each section on GitHub.

pydantic-resolve 三阶段开发模式

基于 pydantic-resolve 的渐进式开发方法论。项目在一个 src/ 目录下逐步演进,每个阶段在上一阶段基础上新增代码。

Phase 职责 产出
Phase 0 需求确认 实体 + 关系 + 聚合根 + 用例方法(与用户反复确认)
Phase 1 Schema + ER Diagram + mock seed ORM models + Entity DTOs + build_relationship + Voyager
Phase 2 方法实现 + GraphQL service//methods.py + QueryConfig/MutationConfig + GraphQL
Phase 3 UseCase 响应组装 + MCP + REST DefineSubset + AutoLoad + UseCaseService + REST + MCP

核心原则

  • 需求确认是 Phase 0,必须反复与用户确认后才能进入 Phase 1(详见下方「Phase 0: 需求确认」)
  • 非功能模块与业务模块解耦,业务概念不侵入基础设施层
  • 每个 Phase 采用 V 型验收:先定义验收标准(V 降),再实现,最后回查验收(V 升)
  • 每个 Phase 实现完成后必须暂停,展示验收结果,等用户确认后再进入下一阶段
  • Phase 间递进:同一项目目录下逐步丰富,只新增不修改已有代码

V 型验收模型(贯穿所有 Phase)

每个 Phase 的结构统一为三段:

┌──────────────────────────────────────────────┐
│ V 降:定义验收标准                              │
│   "在当前 Phase 开始之前,先定义什么算做完。"      │
│   写入 spec/<phase>.md 的"验收标准"部分            │
└──────────────────────────────────────────────┘
                      ↓
              ┌───────────────┐
              │   实现 Phase   │
              └───────────────┘
                      ↓
┌──────────────────────────────────────────────┐
│ V 升:逐条回查验收                             │
│   "一条一条对照验收标准,通过才可继续。"           │
│   用户逐条确认 → 写入 spec/<phase>.md             │
└──────────────────────────────────────────────┘

验收标准必须是可观察、可操作的——不写"代码健壮",写"GraphiQL 中执行 X query 返回 Y"。

Phase 0: 需求确认(必做)

在写任何代码之前,必须与用户逐项确认以下内容。每一项都需要用户明确认可后才算完成。

Step 0-1: 术语与实体定义

逐一列出所有业务实体,每个实体说明:

  • 业务含义(一句话,团队无歧义)
  • 核心字段(名称 + 类型 + 语义说明,不需要穷举,但关键属性不能遗漏)
  • 字段约束(唯一、非空、枚举值、联合唯一等)

用表格形式呈现,方便用户逐行确认。

Step 0-2: 实体关系

用文本 ER 图展示实体间关系,每条关系标明:

  • 方向(1:N / N:1 / M:N)
  • 业务含义(如「Sprint 包含多条 Task」)
  • 是否需要中间实体
User ──1:N──→ Task
Sprint ──1:N──→ Task
Task ──N:1──→ User (owner)

必须与用户确认关系方向和基数是否正确。

Step 0-3: 聚合根

明确哪个(或哪些)实体是聚合根。聚合根决定:

  • 主要的业务入口(从哪个实体开始查询)
  • @query / @mutation 挂在哪些实体上
  • Phase 3 的 service 划分依据

Read the full file on GitHub · 593 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 593 lines · 56 tokens per session scan A 3be76d898294

Subscribe to this mod's changes

pydantic-resolve-3step is a skill published in the GitHub repository KLR-Pattern/pydantic-resolve (326 stars, last pushed 26d ago), licensed MIT. It adds 56 tokens to every session and 7,002 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

fastcrud

Use when building or modifying CRUD endpoints with FastCRUD (the fastcrud PyPI package) in a FastAPI project — covers FastCRUD, crudrouter, EndpointCreator, FilterConfig, JoinConfig, auto-relationship detection, the filter operator syntax (gte, in, ilike, etc.), cursor pagination, soft delete, and how to avoid N+1…

benavlabs/fastcrud · 147 tokens

payload

Use when working with Payload projects (payload.config.ts, collections, fields, hooks, access control, Payload API). Use when debugging validation errors, security issues, relationship queries, transactions, or hook behavior.

payloadcms/payload · 43 tokens

datamodel-code-generator

Use this skill when the user wants Python data models, Pydantic models, dataclasses, TypedDicts, msgspec structs, or type-safe Python classes generated from OpenAPI, AsyncAPI, JSON Schema, GraphQL, JSON/YAML/CSV sample data, MCP tool schemas, Protocol Buffers, XML Schema, Apache Avro, or existing Python model objects.…

koxudaxi/datamodel-code-generator · 147 tokens

mysql reporter

生成 MySQL 查询报表并生成可视化图表。当用户需要查询 MySQL 数据库并以报表形式展示结果时使用此技能,包括:统计销售数据、分析用户行为、生成业务报表、查询业务指标等。.

xerrors/Yuxi · 55 tokens

alembic-migration

Create, review, and apply database schema changes with Alembic. Use whenever a SQLAlchemy model is added or changed, a column/index/constraint needs to change, or a data backfill is required — anything that alters the PostgreSQL schema.

vstorm-co/full-stack-ai-agent-template · 56 tokens

add-graphjin-database

Use when adding a new GraphJin database, warehouse, or CQL/NoSQL backend; building a simulator because no live service is available; wiring a dialect, discovery, tests, scripts, README/CONFIG/FEATURES, or website database support surfaces.

dosco/graphjin · 60 tokens