pydantic

pydantic is a cursor rule for Cursor from julien777z/agent-sync-action. It costs 0 tokens per session (1,044 once invoked), scanned A, original, MIT.

A project-specific rule file about Pydantic, a Python library commonly used for validating and describing data. The available information does not state its actual rules.

In plain words
What is it for?
It is for applying the project's Pydantic-related rules during development.
Why use it?
It may standardize how the project uses Pydantic, but the description is too thin to say which issues it prevents.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit It is for applying the project's Pydantic-related rules during development.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/julien777z/agent-sync-action/pydantic
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.

Clone the repo
git clone --depth 1 https://github.com/julien777z/agent-sync-action

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pydantic

README.md
[![agentmods](https://agentmods.dev/badge/rules/julien777z/agent-sync-action/pydantic/github.svg)](https://agentmods.dev/rules/julien777z/agent-sync-action/pydantic)
Your own site
<a href="https://agentmods.dev/rules/julien777z/agent-sync-action/pydantic"><img src="https://agentmods.dev/badge/rules/julien777z/agent-sync-action/pydantic/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pydantic

Your own site · 80×15
<a href="https://agentmods.dev/rules/julien777z/agent-sync-action/pydantic"><img src="https://agentmods.dev/badge/rules/julien777z/agent-sync-action/pydantic.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,044 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00000 $0.01044
Opus 5.5 $0.00000 $0.00418
Sonnet 5.5 $0.00000 $0.00209
Haiku 4.5 $0.00000 $0.00104

Measured 5d ago against content hash 1abbea915b40, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

pydantic scanned grade A with 0 findings 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 5d ago.

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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/pydantic.mdc · 118 lines

How it starts

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

Pydantic Rules

Model Design

  • Never use @dataclass decorator from dataclasses module.

  • Use Pydantic BaseModel for all class definitions that hold data.

  • Do not use NamedTuple for application or script data models; use an explicit BaseModel subclass instead.

  • Pydantic provides validation, serialization, and type coercion out of the box.

  • Expose zero-argument boolean accessors as @property instead of methods when they describe model state or capability.

  • Prefer property names such as can_access_xyz over can_access_xyz().

class AccessPolicy(BaseModel):
    role: str

    @property
    def can_access_admin(self) -> bool:
        return self.role == "admin"


policy = AccessPolicy(role="member")

if not policy.can_access_admin:
    raise PermissionError("Admin access required")
  • Never use Protocol for data models that hold data.

  • Use Protocol only for structural typing of interfaces (callbacks, duck typing).

  • Use Self return type for class methods.

Validation and Configuration

  • Use model_config = ConfigDict(...) for model configuration.
  • Use model_dump() instead of deprecated dict().
  • Use model_validator decorator for custom validation.
  • Do not add field_validator or model_validator just to coerce enum strings that should be represented by the enum itself; update the enum values to match the real contract instead.
  • Do not define __init__ on BaseModel subclasses; use fields, validators, model_post_init, or factory/class methods instead.
  • Never use pydantic.create_model; define an explicit BaseModel subclass instead. If create_model feels necessary, the design is probably too dynamic or too clever; refactor toward a named model class.
from enum import StrEnum

from pydantic import BaseModel, field_validator


class ShirtSize(StrEnum):
    SMALL = "small"
    LARGE = "large"

# Bad: validator added only to paper over the wrong enum values
class TShirtOrderBad(BaseModel):
    size: ShirtSize

    @field_validator("size", mode="before")
    @classmethod
    def validate_size(cls, value: str) -> str:
        return value.upper()

Read the full file on GitHub · 118 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. 5d ago Changed · +117 lines · -9 tokens per session 1abbea915b40
  2. 2mo ago First seen · 1 lines · 9 tokens per session scan A 1db166dd622d

Subscribe to this mod's changes

pydantic is a cursor rule published in the GitHub repository julien777z/agent-sync-action (9 stars, last pushed 3d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,044 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.