no-contract-data-patching-in-tests

no-contract-data-patching-in-tests is a cursor rule for Cursor from prisma/orm. It costs 0 tokens per session (822 once invoked), scanned A, original, Apache-2.0.

A testing rule for contract-based software that forbids hand-writing or modifying the raw data structures used to represent contracts.

In plain words
What is it for?
Use it when testing contracts: use fixtures produced by the real system or create them through a user-facing builder or authoring interface.
Why use it?
Hand-built test data can stop matching real contracts while tests continue to pass, making the tests unreliable.

Cursor rule for Cursor ✓ vendor

Written for Cursor: a Cursor rule (.mdc). Also seen: installed under .agents/ (shared by several agents).

Good fit Use it when testing contracts: use fixtures produced by the real system or create them through a user-facing builder or authoring interface.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/prisma/orm/no-contract-data-patching-in-tests
About the project

Prisma ORM is a Node.js and TypeScript database toolkit that lets applications work with databases through a programming interface instead of writing every query directly in SQL. Developers use it with databases including PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB, and CockroachDB. The catalogue add-ons provide agent rules, skills, hooks, agents, and other workflows for using Prisma.

prisma/orm · 47,667 stars · on GitHub · prisma.io

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/prisma/orm

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 no-contract-data-patching-in-tests

README.md
[![agentmods](https://agentmods.dev/badge/rules/prisma/orm/no-contract-data-patching-in-tests/github.svg)](https://agentmods.dev/rules/prisma/orm/no-contract-data-patching-in-tests)
Your own site
<a href="https://agentmods.dev/rules/prisma/orm/no-contract-data-patching-in-tests"><img src="https://agentmods.dev/badge/rules/prisma/orm/no-contract-data-patching-in-tests/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 no-contract-data-patching-in-tests

Your own site · 80×15
<a href="https://agentmods.dev/rules/prisma/orm/no-contract-data-patching-in-tests"><img src="https://agentmods.dev/badge/rules/prisma/orm/no-contract-data-patching-in-tests.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 822 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.00822
Opus 5.5 $0.00000 $0.00329
Sonnet 5.5 $0.00000 $0.00164
Haiku 4.5 $0.00000 $0.00082

Measured 2mo ago against content hash de74833197ce, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

no-contract-data-patching-in-tests 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 2mo 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.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

.agents/rules/no-contract-data-patching-in-tests.mdc · 71 lines

How it starts

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

No Contract Data Patching in Tests

Rule

Never, under any circumstances, patch or hand-author raw contract data structures in tests. This is a HARD rule — hard as obsidian — not a guideline, suggestion, or default you may trade away under time pressure. Use real emitted fixtures. If a test really has to generate a contract at runtime, it may only generate it from a high-level representation made with a user-facing authoring surface (contract builder DSL, PSL) — never by writing, or worse, patching, the raw contract data structure.

A hand-built object literal that "happens" to match the contract shape is not a contract — it is a bag of random data that incidentally coincides with a real contract today and will diverge tomorrow given the velocity of this repo. Tests built on it are vacuous.

No cast-smuggling

Constructing a contract value at runtime and forcing it through the type system with as unknown as FrameworkContract<...>, as unknown as Contract, blindCast/castAs, or any equivalent escape is strictly forbidden — that cast is the tell that you are hand-authoring raw contract data. Do not refactor unrelated as casts to blindCast/castAs to slip such a value past review. There is no acceptable variant of this workaround.

If you cannot satisfy this rule

Stop. A workaround is never acceptable — it invalidates the rest of the work and is treated as a total failure of the task, not a partial success.

  • Working unattended: stop and fix whatever prevents you from satisfying the rule (e.g. add the missing emitted fixture, or extend the authoring surface) before continuing.
  • Working interactively: stop and flag it to the operator.

Why

Patched contracts drift from anything the emitter can produce: they skip authoring-time validation, encode shapes no user can reach, and silently keep passing when the real contract format changes. Tests then assert behavior for contracts that cannot exist.

Don't

// ❌ WRONG: spreading/overriding raw contract internals
const contract = withPatchedDomainModels(getTestContract(), (models) => ({
  ...models,
  Project: {
    ...project,
    relations: {
      ...project.relations,
      related: { ...related, through: { ...related.through, targetColumns: ['tenant_id'] } },
    },
  },
}));

Read the full file on GitHub · 71 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. 2mo ago First seen · 71 lines · 0 tokens per session scan A de74833197ce

Subscribe to this mod's changes

no-contract-data-patching-in-tests is a cursor rule published in the GitHub repository prisma/orm (47,667 stars, last pushed yesterday), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 822 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-30.