principle-enforce-where-it-is-stored
Apply when more than one client (a web app, an API caller, an agent or MCP tool, an import job) can write the same data, or when a client fills in or corrects a field before sending it. The system that stores the data enforces its rules for every writer; a client that covers for a missing server rule hides the gap.
- License 许可
- MIT
- 最近更新
- 2026-11-11
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- principle-enforce-where-it-is-stored
- description
- Apply when more than one client (a web app, an API caller, an agent or MCP tool, an import job) can write the same data, or when a client fills in or corrects a field before sending it. The system that stores the data enforces its rules for every writer; a client that covers for a missing server rule hides the gap.
- user-invocable
- false
03 SKILL.md 正文
Enforce Where It Is Stored
The rule for what a record may hold lives where the record is stored: the API that writes it, and the database constraint beneath it. Every writer passes through that rule. The web app, an agent's tool, a script, and an import job are all just clients.
Why: when each client carries its own copy of the rule, the copies drift, and the next client to arrive (an agent, an integration, another environment) writes rows the others never would. A client that pads a field ("send 0 so the server doesn't break") makes the missing server rule invisible until a client that does not pad it shows up.
The pattern:
- Validate every write body on the server, against the same schema whichever client sent it. Reject what breaks a rule; do not store it and hope a reader copes.
- Back the invariants that matter with database constraints, so a path that skips the API still cannot store a broken row.
- Treat client-side checks as feedback, not enforcement. Instant feedback in the browser can share the server's code, but the server decides.
- When a client works around a server gap, fix the server, then delete the workaround.
- The server makes identity and entitlement. A row's id, its owner (user id,
sub, organization), a billing or payment-provider id, a storage key, and what the customer paid for come from the server or from the provider's own record, never from a request body. Refuse a body that names one. A client that may choose an id may choose another row's id.
The tests:
- "If a new client sent the minimal body the API accepts, would the stored row still be valid?"
- "Is this client changing data to suit the server? If so, the rule belongs on the server."
- Send each create once with every required field left out in turn. Each answer is a 400 that names the field, never a 500 from a database constraint.
Builds on Boundary Discipline: this names which boundary owns a rule when several clients share one store.
04 同仓库更多 Skills
why
Use for 'why does X work this way', 'why we picked Y', design rationale, regressions, postmortems, or data-backed thresholds. Discovers available MCPs and queries each evidence category (source control, issue tracker, long-form docs, real-time chat, infrastructure observability, error tracking, product analytics warehouse) in parallel, then returns a cited read on decisions and tradeoffs. Use how for runtime behavior.
what-did-i-get-done
Summarize authored commits over a user-specified time period into a concise update
unslop
Cut AI tells from any writing.
typescript-best-practices
TypeScript best practices. Use when reading or editing any .ts or .tsx file.
thermo-nuclear-code-quality-review
Run an extremely strict maintainability review for abstraction quality, giant files, and spaghetti-condition growth. Use for a thermo-nuclear code quality review, thermonuclear review, deep code quality audit, or especially harsh maintainability review.
technical-writing
Layered technical-writing standard: Diátaxis structure, Google developer style sentences, STE instruction rules, Global English syntax. Use for /technical-writing or when writing or reviewing docs, RFCs, readmes, PR descriptions, or commit messages.