Prisma ORM Agent Rules

A contract-first data access layer with typed query builders and structured schema artifacts.

Overview

Prisma ORM starts from contracts and gives newcomers a modular path through the codebase. Canonical skills and rules stay separate from tool-specific links, type-safety rules are explicit, and specialized work points to playbooks and architecture docs.

Documents

├── 
├──  · symlink → AGENTS.md
├── .agents
│   ├── rules
│   │   ├── 
│   │   ├── 
│   │   ├── 
│   │   ├── 
│   │   └── 
│   └── skills
│       └── publish-npm-version
│           └── SKILL.md · unavailable at this commit
├── docs
│   ├── architecture docs
│   │   ├── adrs
│   │   │   └── Architecture Decision Records
│   │   ├── patterns
│   │   │   ├── 
│   │   │   ├── 
│   │   │   ├── 
│   │   │   └── 
│   │   └── subsystems
│   │       └── Subsystem architecture guides
│   ├── onboarding
│   │   ├── 
│   │   ├── 
│   │   ├── 
│   │   ├── 
│   │   ├── 
│   │   └── 
│   ├── oss
│   │   └── 
│   ├── reference
│   │   └── 
│   ├── 
│   ├── 
│   ├── 
│   └── 
├── projects
│   └── 
└── skills-contrib
    ├── *
    │   └── SKILL.mdCanonical contributor skills
    └── no-bare-casts
        └── 

Techniques in this file

01 / Pointing at the source of truth

Name the tracked source behind each tool-facing mirror

Skills live under skills-contrib and rules under .agents/rules. Tool-specific directories are generated or symlinked presentations; editing canonical paths keeps Git diffs aligned with the tracked files.

Source excerpt starting at line 33.
The repo keeps a single canonical home for each kind of agent surface, with presentation symlinks that satisfy the paths each harness expects.

02 / Ratchets

Enforce a direction of travel for unsafe casts

Production casts use named utilities with a reason rather than bare as. The file identifies a plugin and CI ratchet that prevent per-PR increases while preserving explicit exceptions for tests and as const.

Source excerpt starting at line 67.
- No bare `as` in production code. Use `blindCast<T, "Reason">` or `castAs<T>` from `@internal/utils/casts`; see the `no-bare-casts` skill for the decision tree. `as const` and test files are exempt. The `no-bare-cast` plugin + CI ratchet enforce no per-PR cast increases.

03 / Architecture as narrative

Describe the contract flow from authoring to execution

The guide follows schema authoring through emitted JSON and declaration files, validation, and typed DSL use. It separates structured artifacts from executable runtime generation.

Source excerpt starting at line 86.
1. **Authoring**: Write `schema.psl` or use TypeScript builders → canonicalized Contract IR2. **Emission**: Emitter validates and generates `contract.json` + `contract.d.ts`3. **Hydration**: the client factory (or a family `ContractSerializer`) validates `contract.json` into the typed contract4. **Usage**: DSL functions (`sql()`, `schema()`) accept the contract and propagate types

04 / Router files

Route routine work through modular onboarding

Setup, repository layering, conventions, testing, and common tasks each have a separate document. Day-to-day changes are directed to a playbook instead of duplicating every procedure in the root.

Source excerpt starting at line 113.
- Day-to-day playbook (add SQL operation, split monolith, fix import violation, etc.): [Common Tasks Playbook](docs/onboarding/Common-Tasks-Playbook.md)

Ideas for your repo

  1. Distinguish canonical tracked guidance from generated tool-facing paths.
  2. Attach a measurable direction to an incremental safety policy.
  3. Explain how generated artifacts participate in the runtime contract.
  4. Keep common task procedures in a linked playbook.
Sponsored byModem

Give your agents the whole story.

These instructions explain how to work in Prisma ORM. Modem shows your agents what customers said, who is affected, and what changed.

See how Modem works