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.
npx agentmods add skills/garrettw/php-arch-skills/persistence-patternsnpx skills add garrettw/php-arch-skills --skill persistence-patternsgit clone --depth 1 https://github.com/garrettw/php-arch-skillsWrote 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.
[](https://agentmods.dev/skills/garrettw/php-arch-skills/persistence-patterns)<a href="https://agentmods.dev/skills/garrettw/php-arch-skills/persistence-patterns"><img src="https://agentmods.dev/badge/skills/garrettw/php-arch-skills/persistence-patterns.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00057 | $0.02228 |
| Opus 5 | $0.00028 | $0.01114 |
| Sonnet 5 | $0.00011 | $0.00446 |
| Haiku 4.5 | $0.00006 | $0.00223 |
Grade A, and why
persistence-patterns 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 4d 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.
How it starts
The opening of the file, as written. The whole thing — 98 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Persistence, Mappers & Repositories in PHP
When to Use Rich Persistence vs. Simple ORM
Rich persistence (Mapper + Repository) is only worth the ceremony when the application has complex invariants or needs to swap storage. Use simple ORM for straightforward CRUD.
| Use Rich Persistence (Mapper + Repository) | Use Simple ORM (Entity + Query Builder) |
|---|---|
| Complex business invariants to protect | Single-table CRUD with few rules |
| Need to swap storage implementation | Fixed database schema |
| Tests must run without DB for domain logic | Schema changes hand-in-hand with feature |
| Long-lived system, evolving requirements | Prototype, MVP, throwaway code |
A library or package that simply exposes data objects should not include mappers or repository interfaces.
Data Source Spectrum & Gateway vs Repository
Persistence structure is a separate axis from domain-logic style. There is a progression of increasing separation between business logic and storage: Table Data Gateway → Row Data Gateway → Active Record → Data Mapper (see data-source-patterns.md for the spectrum, philosophy, and Gateway-vs-Repository distinction). The lightest end (Table Data Gateway) is one class per table that fetches/persists rows and nothing more; the heavy end (Data Mapper) fully isolates domain objects from the database. Active Record sits in the middle: one object per row that also carries its business behavior and knows how to persist itself. It is outstanding for CRUD-heavy apps with modest rules and small teams that value rapid iteration, but becomes a liability as the domain grows richer and more interconnected — the class drifts from representing the business to representing the ORM. Recognize when it has outgrown its limits and move persistence/mapping out into a Data Mapper. At the heavy end, Data Mapper fully isolates domain objects from the database (only the Mapper bridges the two); it is the preferred persistence model for complex enterprise software (DDD, Hexagonal/Onion/Clean, CQRS writes) because it keeps database concerns out of the domain. Its value is not easy database swaps — it is persistence ignorance for a rich domain model — and the extra indirection is only justified when a rich domain would otherwise be compromised by persistence concerns.
What ships with it
9 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
- references/active-record.md 2.3 KB
- references/data-mapper.md 3.7 KB
- references/data-source-patterns.md 5.0 KB
- references/decision-flowchart.md 4.2 KB
- references/orm-architecture-patterns.md 5.1 KB
- references/orm-patterns.md 6.1 KB
- references/row-data-gateway.md 1.5 KB
- references/table-data-gateway.md 2.2 KB
- references/transaction-boundaries.md 3.6 KB
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.
- 4d ago First seen · 98 lines · 57 tokens per session scan A 8616ffc1def1
persistence-patterns is a skill published in the GitHub repository garrettw/php-arch-skills (11 stars, last pushed 1mo ago), licensed MPL-2.0. It adds 57 tokens to every session and 2,228 once invoked, about $0.0003 per session on Opus 5. 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.
Other skills, from other repositories
bun-api
Bun runtime API reference for TypeScript scripts. Covers Bun.file(), Bun.write(), Bun.$() shell, Bun.spawn(), Bun.Glob, Bun.env, bun:sqlite, Bun.sql() for PostgreSQL/MySQL via DATABASEURL, Bun.s3 for S3-compatible storage, Bun.redis for Redis/Valkey, Bun.Archive for tarballs, Bun.Image image processing, Bun.WebView…
migration-planner
Plans a safe, incremental migration (framework, database, service, or platform) with rollback points and a dual-running strategy. Use when replacing something that's already in production and can't just be swapped in one step.
database-architect
Reviews database schemas, relationships, indexes, constraints, and data modeling decisions. Use when designing a new schema or reviewing an existing one for correctness and scalability.
performance-auditor
Looks for performance bottlenecks across frontend rendering, backend logic, database access, and network usage. Use when something is slow or before it needs to scale.
multi-tenant-data-partitioner
Architects database multi-tenancy models (Shared DB/Schema vs Separate Schema vs Separate Database) and tenant routing.
cache-strategy-planner
Designs multi-tier caching architectures (CDN, Redis, memory), invalidation policies, and stampede mitigations.