craftcms-claude-skills
AGENTS.md82 starsChanged 4 months agoMITView on GitHub
Six specialized sub-agents, each with a dedicated model and tool scope. Agents are invoked from within Claude Code to handle specific types of work. They load relevant skills automatically and enforce project conventions. Use agents when work is scoped and repeatable. A single conversation can delegate to multiple agents -- plan with the planner, build with the builder, review with the reviewer. For complex work (more than 3 steps), always plan first, then build. The planner's output feeds directly into…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,736 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository15 other files it gives its agents.
- project-template/CLAUDE.mdCLAUDE.md
- reference/CLAUDE.mdCLAUDE.md
- craft-cloudSkill
- craftcmsSkill
- craft-content-modelingSkill
- craft-garnishSkill
- craft-pestSkill
- craft-php-guidelinesSkill
- craft-plugin-releaseSkill
- craft-pluginsSkill
- craft-project-setupSkill
- craft-siteSkill
- craft-twig-guidelinesSkill
- ddevSkill
- servdSkill
The file
Show its rules and text
We split this agents.md into the rules it gives an agent
27 rules. About 0 are common, 18 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈18
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 7
Use agents when work is scoped and repeatable.
- Distinctive: line 25
Tools: Read, Grep, Glob (read-only)
- Distinctive: line 51
No step may require a later step to verify itself.
- Distinctive: line 68
Tools: Read, Write, Edit, Bash, Grep, Glob, TaskCreate, TaskUpdate, TaskList
- Very specific: line 92
When a plan has more than 3 steps, the builder creates a todo list before writing any code.
- Distinctive: line 99
No hardcoded site IDs
- Very specific: line 107
All query properties wired in beforePrepare()
- Distinctive: line 112
No improvised CP UI — copy the core/vendor idiom and cite the template matched
- Distinctive: line 117
After all gates pass, the builder does one sweep on files it just wrote (while context is fresh):
- Distinctive: line 119
Remove temporary debug variables
- Distinctive: line 121
Delete dead code and unused imports
- Distinctive: line 122
Verify section headers and PHPDocs
- Very specific: line 169
Write PHP plugin/module code (that's craft-feature-builder)
- Distinctive: line 171
Use macros for UI components
- Distinctive: line 186
Tools: Read, Write, Edit, Bash, Grep, Glob
- Very specific: line 204
Element not found?: Check site context -- queue workers run in primary site.
- Very specific: line 206
Migration failed?: Check for stale mutex locks in cache table.
- Very specific: line 207
Queue job failing silently?: Check ddev craft queue/info and Craft logs for TTR timeouts.
- Distinctive: line 212
Always writes a regression test before fixing
- Distinctive: line 214
Never fixes a symptom without finding the root cause
- Distinctive: line 237
Read each changed file thoroughly
- Distinctive: line 238
Check against the checklist
- Very specific: line 260
All query class properties wired in beforePrepare()
- Very specific: line 265
No synchronous cleanup in init()
- Very specific: line 298
Tools: Read, Grep, Glob, Bash (read-only — git diff/log/show/blame only)
- Distinctive: line 351
After building, get a second opinion.
- Distinctive: line 361
When something breaks, investigate before patching.
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agents
Six specialized sub-agents, each with a dedicated model and tool scope. Agents are invoked from within Claude Code to handle specific types of work. They load relevant skills automatically and enforce project conventions.
When to Use Agents
Use agents when work is scoped and repeatable. A single conversation can delegate to multiple agents -- plan with the planner, build with the builder, review with the reviewer.
| Situation | Agent |
| Breaking a feature into implementation steps | craft-planner |
| Building a new plugin feature (elements, services, controllers) | craft-feature-builder |
| Building site templates, components, or content architecture | craft-site-builder |
| Investigating a bug or unexpected behavior | craft-debugger |
| Reviewing code before merge | craft-code-reviewer |
| Deep review of a high-stakes change (release branch, security-sensitive code, migrations, multi-service flows) | craft-code-reviewer-deep |
For complex work (more than 3 steps), always plan first, then build. The planner's output feeds directly into the builder.
craft-planner
Model: Opus (complex reasoning)
Tools: Read, Grep, Glob (read-only)
Skills loaded: craftcms
Breaks large tasks into scoped implementation steps that can each be completed in a single session.
What it does
- Reads the high-level requirement
- Identifies all affected areas (elements, queries, services, controllers, migrations, templates, project config, tests)
- Maps dependencies -- what must be built first
- Breaks work into steps of roughly equal size
- Writes the plan to
docs/plans/{feature-name}.md
Plan format
Each step includes:
- Files to create or modify (exact paths)
- Dependencies on previous steps
- Which
ddev craft makecommand to scaffold with - A verification gate -- a runnable command with expected outcome (not "looks right")
- Estimated complexity: small (< 15 min), medium (15-30 min), large (30-45 min)
Rules
- Each step's verification gate must be a runnable command. "Check that it works" is not a gate --
ddev craft migrate/upsucceeds and shows the new table" is a gate. - Steps are ordered so each layer can be verified before the next depends on it: migrations before records, records before services, services before controllers.
- No step may require a later step to verify itself.
- Architectural decisions are surfaced as explicit decision points, not buried as assumptions.
- Multi-site implications and project config impacts are flagged.
- Auth level is asked upfront: public, any user, admin, or permission-gated.
Example delegation
Plan the implementation of a Job Listings custom element type with
department relations, salary range, and a full CP edit page.craft-feature-builder
Model: Opus (complex multi-file work)
Tools: Read, Write, Edit, Bash, Grep, Glob, TaskCreate, TaskUpdate, TaskList
Skills loaded: craftcms, craft-php-guidelines, craft-garnish
Builds production-quality plugin code following project architecture. Receives implementation plans and executes them layer by layer.
The Build-Verify Gate Pattern
This is the core discipline. Each layer must pass its gate before the next layer starts. The builder never writes five files and verifies at the end -- that compounds debugging complexity.
Gate order for plugin work:
- Migration --
ddev craft migrate/upsucceeds, schema exists - Record / Model -- class resolves,
ddev craftdoesn't throw on boot - Service -- minimal method callable via Craft CLI or Pest test
- Controller -- actual request (
curlor browser) returns expected response - CP templates -- edit/index pages render without Twig errors
- Tests --
ddev craft pest/testgreen - Simplification pass -- collapse nesting, remove debug artifacts, verify PHPDocs
- Final verification --
ddev composer check-cs+ddev composer phpstanclean
A gate is "I ran the thing and saw it work." If a gate fails, the builder stops and fixes before moving on. It never plasters over a failed gate.
Mandatory todo list
When a plan has more than 3 steps, the builder creates a todo list before writing any code. One todo per plan step. A step is marked completed only after its verification gate passes -- never batch-completed.
Prevention rules
The builder enforces these rules that the reviewer will flag if violated:
andWhere()notwhere()on element queries- No hardcoded site IDs
$allowAnonymouslists specific actions, never blankettrue- No
$e->getMessage()returned to anonymous users - Permission handles as class constants
- Cached badge counts in
getCpNavItem() Gc::EVENT_RUNfor cleanup, not synchronous hooks- Conditional asset bundle registration
- No
|rawon admin content in<style>/<script> - All query properties wired in
beforePrepare() - Twig extension functions return, not echo
addSelect()notselect(),site('*')in queue workersDb::parseParam()for user input- Idempotent migrations with
muteEvents - No improvised CP UI — copy the core/vendor idiom and cite the template matched
- Restructures re-verify standing behavioral decisions, not just routes/tests
Simplification pass
After all gates pass, the builder does one sweep on files it just wrote (while context is fresh):
- Collapse nesting with early returns
- Remove temporary debug variables
- Simplify conditionals (
matchoverswitch) - Delete dead code and unused imports
- Verify section headers and PHPDocs
- Re-run ECS and PHPStan
Example delegation
Build the Job Listings element type following the plan in docs/plans/job-listings.mdcraft-site-builder
Model: Opus (complex multi-file work)
Tools: Read, Write, Edit, Bash, Grep, Glob, TaskCreate, TaskUpdate, TaskList
Skills loaded: craft-site, craft-twig-guidelines, craft-content-modeling
Builds site templates, content architecture, and component systems following atomic design principles.
The Build-Verify Gate Pattern (Site Edition)
Adapted for site work, but the same discipline applies -- verify each layer before composing the next.
Gate order for site work:
- Content model -- sections, entry types, fields created. Verified in CP.
- Sample content -- at least one entry per type exists for rendering
- Atoms -- render standalone in a scratch template without errors
- Molecules -- render with real atom compositions, props flow correctly
- Organisms / layouts -- full-page render succeeds, no Twig errors
- Routes / views -- actual page load returns expected HTML
- Eager loading audit -- Elements Panel shows no N+1 on relational fields
- Responsive / a11y check -- after content renders correctly
What it does well
- Plans content models and presents them as decision tables before implementing
- Builds atoms before molecules before organisms (never top-down)
- Enforces
onlyon every{% include %} - Uses
.eagerly()on every relational field in loops - Applies atomic design naming (by visual treatment, not parent context)
- Uses
collect({})for props and class collections - Handles Matrix block rendering with
ignore missing
What it never does
- Install plugins without approval
- Write PHP plugin/module code (that's
craft-feature-builder) - Skip eager loading on relational fields
- Use macros for UI components
- Hardcode content that should come from fields
Example delegation
Build the blog listing and detail templates with a card component,
topic filtering, and pagination.craft-debugger
Model: Sonnet (focused, single-concern)
Tools: Read, Write, Edit, Bash, Grep, Glob
Skills loaded: craftcms, craft-php-guidelines
Systematic bug investigation with a hypothesis-driven approach.
Debugging workflow
- Reproduce -- understand the exact steps, read error logs and queue failures
- Hypothesize -- form 2-3 possible explanations before reading code
- Investigate -- read relevant code, check
storage/logs/, run targeted tests - Isolate -- write a minimal failing test that captures the bug
- Fix -- make the smallest change that fixes the issue
- Verify -- run ECS, PHPStan, and the full test suite
Craft-specific investigation points
The debugger knows where to look for common Craft issues:
- Element not found? Check site context -- queue workers run in primary site. Try
->site('*')->status(null). - Project config drift? Compare YAML with database via
ddev craft project-config/diff. - Migration failed? Check for stale mutex locks in
cachetable. - Queue job failing silently? Check
ddev craft queue/infoand Craft logs for TTR timeouts. - Element status wrong? Status is computed from dates/conditions, not stored -- check
getStatus().
Rules
- Always writes a regression test before fixing
- Explains reasoning at each step
- Never fixes a symptom without finding the root cause
- States what has been ruled out if the cause is not found
Example delegation
The sync queue job is failing silently on the staging server. No errors
in the queue log, but entries aren't being updated. Investigate.craft-code-reviewer
Model: Sonnet (focused, single-concern)
Tools: Read, Grep, Glob (read-only)
Skills loaded: craftcms, craft-php-guidelines, craft-garnish
Code review with a structured findings report. Read-only -- it never modifies files.
Review workflow
- Identify changed files via
git diff - Read each changed file thoroughly
- Check against the checklist
- Generate a findings report grouped by severity
Report format
- Critical (must fix before merge) -- security issues, data integrity risks, broken conventions
- Important (should fix) -- missing PHPDocs, incomplete
@throws, architectural violations - Suggestions (nice to have) -- naming improvements, simplification opportunities, test coverage gaps
The checklist
Security (5 checks):
$allowAnonymoususes specific action names, never blankettrue- Exception messages never returned to anonymous users
|rawin CP templates reviewed for XSS- Permission handles match between registration and checking
Db::parseParam()for user input
Query safety (5 checks):
6. addSelect() not select()
7. andWhere() not where()
8. No hardcoded site IDs
9. All query class properties wired in beforePrepare()
10. site('*') in queue workers
Performance (4 checks):
11. getCpNavItem() badge counts are cheap
12. No synchronous cleanup in init()
13. defineSources() uses aggregate queries
14. Asset bundles registered conditionally
Code quality (5 checks):
15. PHPDoc completeness on every class, method, property
16. Section headers present and correct
17. Early returns, match over switch
18. Twig extensions return (not echo), delegate to services
19. Migration safety: idempotent, muteEvents
CP JavaScript checks (when JS files are in scope)
- Classes extend
Garnish.Base - Listeners use
addListener(), not jQuery.on() - Non-button elements use
activateevent, notclick - Key codes use Garnish constants
- ESC handling through
uiLayerManager - Webpack uses externals for Garnish
destroy()callsthis.base()- Deprecated APIs flagged
Example delegation
Review the changes in the job-listings branch before I open a PR.craft-code-reviewer-deep
Model: Opus (xhigh effort)
Tools: Read, Grep, Glob, Bash (read-only — git diff/log/show/blame only)
Skills loaded: craftcms, craft-php-guidelines, craft-garnish, craft-twig-guidelines, craft-site
The deep-review counterpart to craft-code-reviewer. The standard reviewer (Sonnet) catches checklist violations per file; this one (Opus, xhigh) catches what surface pattern-matching misses. Use it when the extra scrutiny is worth the token cost — release branches, security-sensitive code, large architectural changes, migrations, multi-service flows. Use the standard reviewer for daily review.
Where it looks that the standard reviewer doesn't
- Cross-file data flow — traces request data controller → service → element → DB to catch multi-file authorization gaps and TOCTOU escalations.
- Untested paths — reads the test suite and identifies new branches, exception paths, and negative cases the diff doesn't cover.
- Architecture — whether the abstraction is right, whether a service should exist, whether a migration can roll back.
- Race conditions & transaction boundaries — read-then-write without locking, resaves inside loops without
muteEvents, single-worker assumptions in queue jobs. - N+1 at production scale — eager-loading gaps in services called from loops elsewhere, with the math run at real data volume.
- Semantic correctness — does the code do what was intended, including empty arrays, soft-deleted parents, disabled multi-site, drafts.
- Migration safety at scale — add-column on million-row tables, unbatched long migrations, index additions that lock.
- Plugin lifecycle correctness — settings that mutate mid-request, events wired after they fire, DB hits during plugin boot.
Discipline
It does not fabricate runtime bugs from generic framework intuition — claims about state staleness, DI timing, or cache lifecycle must trace through Craft's actual Yii2 source, or they're downgraded to "Verify". Depth means more accurate, not longer: a correct one-line finding beats a three-paragraph speculation.
Report format
Same severity grouping as the standard reviewer (Critical / Important / Suggestions), but each finding adds why it matters at depth — the subtle issue surface scanning would miss. Read-only; never modifies files.
Example delegation
Deep-review the release/1.6.0 branch before tagging — it touches migrations,
the asset filesystem, and the permission layer.Prevention/Detection Parity
The builder and reviewer are designed as complementary pairs. The builder's prevention rules map to the reviewer's checklist items. Everything the builder prevents, the reviewer detects -- and vice versa.
This means code built by the craft-feature-builder agent passes the craft-code-reviewer agent's checklist with zero findings if the builder followed its own rules. The overlap is intentional: if the builder misses something (it sometimes does), the reviewer catches it.
Agent Composition Patterns
Plan then build
The most common pattern. Plan first to break down complexity, then build layer by layer.
1. Delegate to craft-planner: "Plan the implementation of..."
2. Review the plan, adjust if needed
3. Delegate to craft-feature-builder: "Build following the plan in docs/plans/..."Build then review
After building, get a second opinion.
1. Delegate to craft-feature-builder: "Build the webhook controller..."
2. Delegate to craft-code-reviewer: "Review the changes in the webhook branch"
3. Fix any findings from the reviewDebug then fix
When something breaks, investigate before patching.
1. Delegate to craft-debugger: "The sync job is failing silently..."
2. Debugger identifies root cause and writes regression test
3. If fix is complex, delegate to craft-feature-builder for the implementationFull cycle
For significant features:
1. craft-planner -- break down the feature
2. craft-feature-builder -- implement layer by layer
3. craft-code-reviewer -- review before merge
4. craft-debugger -- investigate if anything breaks in stagingDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

