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 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/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.
<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="Reviewed on agentmods" width="80" 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.1 | $0.00058 | $0.02285 |
| Opus 5.5 | $0.00023 | $0.00914 |
| Sonnet 5.5 | $0.00012 | $0.00457 |
| Haiku 4.5 | $0.00006 | $0.00229 |
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 15d 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 — 101 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 that persistence concerns would otherwise compromise. Easy storage swaps are rarely the real benefit (see data-mapper.md). 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 |
| Domain must stay free of persistence code | The schema is the model |
| 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. Pick the lightest one that fits the area: a Table Data Gateway for rows with no behavior, Active Record for CRUD-heavy areas with modest rules, and a Data Mapper when a rich domain model must stay free of persistence concerns. Avoid Row Data Gateway in new code. data-source-patterns.md is the full treatment of the spectrum, its philosophy, and when Active Record has outgrown its limits.
The distinction between a Gateway and a Repository is subtle but critical:
- A Gateway thinks in tables: "How do I fetch rows from this table?" It returns rows/recordsets and uses persistence language.
- A Repository thinks in business concepts: "How do I retrieve domain objects?" It returns domain objects in the ubiquitous language.
What ships with it
10 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 2.5 KB
- references/orm-architecture-patterns.md 5.3 KB
- references/orm-patterns.md 6.2 KB
- references/performance-and-caching.md 3.1 KB
- references/row-data-gateway.md 1.5 KB
- references/table-data-gateway.md 2.2 KB
- references/transaction-boundaries.md 4.4 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.
- 15d ago Changed · +1 tokens per session 7dbb35b802bf
- 18d ago Changed · +2 lines 9c0cf4a6ee1b
- 19d ago Changed · -3 lines 6e91d8ce1d0c
- 20d ago Changed · +4 lines 3fc4806a3ba5
- 3mo 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 (17 stars, last pushed 2d ago), licensed MPL-2.0. It adds 58 tokens to every session and 2,285 once invoked, about $0.0002 per session on Opus 5.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.
persistence-patterns compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| persistence-patternsgarrettw/php-arch-skills | Skill | 17 | 2d ago | MPL-2.0 | A | 58 | Claude Code, Codex |
| cqrs-event-sourcing-designercodebygarv/Ai-skills | Skill | 28 | 3mo ago | MIT | A | 30 | Claude Code, Codex |
| architecture-paradigm-cqrs-esathola/claude-night-market | Skill | 358 | yesterday | MIT | A | 33 | Claude Code |
| bitrix-performancebxmaximum/bitrix-framework-skills | Skill | 78 | yesterday | MIT | A | 51 | Claude Code, Codex |
| bitrix-postgresqlbxmaximum/bitrix-framework-skills | Skill | 78 | yesterday | MIT | A | 51 | Claude Code, Codex |
| doctrine-batch-processingdev-toolings/superpowers-symfony | Skill | 236 | 22d ago | MIT | A | 29 | Claude Code |
| doctrine-eventsdev-toolings/superpowers-symfony | Skill | 236 | 22d ago | MIT | A | 32 | Claude Code |