agentleFS
chrisrowechrisrowe/craftcms-claude-skills/skills/craft-content-modeling/SKILL.md

craft-content-modeling

Skill2 starsChanged 8 months agoMITView on GitHub

Craft CMS 5 content modeling — sections, entry types, fields, Matrix, relations, project config, and content architecture strategy. Covers everything editors and developers need to structure content in Craft. Triggers on: section types (single, channel, structure), entry types, field types, field layout, Matrix configuration, nested entries, relatedTo, eager loading, .with(), .eagerly(), categories, tags, globals, global sets, preloadSingles, propagation, multi-site content, URI format, project config, YAML, content architecture, content strategy, taxonomy, asset volumes, filesystems, image transforms, user groups, permissions, entries-as-taxonomy, entrify. Always use when planning content architecture, creating sections/fields, configuring Matrix, setting up relations, or making content modeling decisions.

1 other project uses a version of this, 1 of them edited.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 1

    1. michtio/craftcms-claude-skills★ 8217% same

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository7 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 4 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use web_fetch on specific doc pages when a reference file doesn't cover enough detail.

    line 27
  2. Distinctive:

    Read the relevant reference file(s) for your task.

    line 107
  3. Very specific:

    All schema changes (sections, entry types, fields, volumes, transforms, sites, plugins, permissions) are stored as YAML in config/project/.

    line 153
  4. Very specific:

    Run ddev craft up (applies migrations + project config)

    line 162
  5. Distinctive:

    Never manually edit YAML — let Craft manage it

    line 166
  6. Very specific:

    Always set allowAdminChanges => false in production

    line 167
  7. Distinctive:

    Use UIDs (not IDs) — they're stable across environments

    line 168
  8. Very specific:

    After resolving Git merge conflicts in YAML: ddev craft project-config/touch then ddev craft project-config/apply

    line 169
  9. Very specific:

    Use $ENV_VAR syntax in YAML for environment-specific values

    line 170
  10. Distinctive:

    Always add the Alternative Text field layout element to asset volumes for accessibility.

    line 191

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Craft CMS 5 — Content Modeling

How to structure content in Craft CMS 5. Sections, entry types, fields, Matrix, relations, asset management, and strategic patterns for real projects.

This skill covers content architecture — what goes in the CP, how it's organized, and how templates access it. For extending Craft with PHP (plugins, modules, custom element types), see the craftcms skill. For Twig template patterns, see craft-site and craft-twig-guidelines.

Documentation

Use web_fetch on specific doc pages when a reference file doesn't cover enough detail.

The Craft 5 Mental Model

Everything is an entry. Entry types are global (shared across sections and Matrix fields). Fields come from a global pool. Categories, tags, and globals are being phased out — use entries instead.

Three decisions define your content architecture:

  1. Which section type organizes the content (Single, Channel, Structure)
  2. Which entry types define its shape (global, reusable across contexts)
  3. Which relation strategy connects content together (Entries fields, Matrix, or both)

Section Type Decision

NeedSection TypeURI Example
One-off page (homepage, about, contact)Single__home__, about
Site-wide settings (footer, header config)Single (no URI, preloadSingles)—
Flat collection (blog, news, events)Channelblog/{slug}
Hierarchical pages (docs, services)Structure{parent.uri}/{slug}
Taxonomy (topics, categories)Structure (replaces categories)topics/{slug}
Flat tagsChannel (replaces tags)—

Singles replace globals

Set preloadSingles => true in config/general.php to access singles as global Twig variables by handle — identical to the old globals behavior but with drafts, revisions, live preview, and scheduling.

{# With preloadSingles enabled #}
{{ siteSettings.footerText }}
{{ siteSettings.socialLinks.all() }}

Caveat: Singles always propagate to all sites. This is hard-coded.

Structure queries for navigation

{% set topLevel = craft.entries.section('pages').level(1).all() %}
{% set children = craft.entries.descendantOf(entry).descendantDist(1).all() %}
{% set breadcrumbs = craft.entries.ancestorOf(entry).all() %}
{% set siblings = craft.entries.siblingOf(entry).all() %}

Entry Types in Craft 5

Entry types are defined globally (Settings → Entry Types), then attached to sections and Matrix fields. One entry type can serve multiple contexts.

Key implications:

  • Changing an entry type's field layout affects every section and Matrix field using it
  • Fields come from the global pool — same field definition reused everywhere
  • Local name/handle overrides per context available (5.6.0+)
  • The global pool demands careful field naming — use specific handles

Reserved handles (will collide with native attributes)

title, slug, id, uid, dateCreated, dateUpdated, status, url, uri, enabled, archived, siteId, level, lft, rgt, root, postDate, expiryDate

Common Pitfalls

  • Over-using Matrix — if content needs its own URL, independent querying, or permissions, it should be a separate section with an Entries relation field, not a Matrix block.
  • Vague field handles — image, text, link collide fast in the global pool. Use blogFeaturedImage, serviceDescription, ctaLink.
  • Not planning multi-site from the start — propagation method, field translation methods, and site settings must be configured before content exists. Changing propagation later resaves all entries.
  • Using categories/tags in new projects — they're deprecated. Use Structure sections (hierarchical taxonomy) and Channel sections (flat taxonomy) with Entries fields.
  • Forgetting preloadSingles — without it, singles aren't available as global variables and you need explicit queries.
  • Matrix for everything — 15+ entry types in one Matrix field is a red flag. Deeply nested Matrix hits max_input_vars limits and degrades CP performance.
  • Not using .eagerly() — every relational field access inside a loop should use .eagerly() to prevent N+1 queries.
  • Editing project config YAML manually — let Craft manage config/project/. Use php craft project-config/rebuild to regenerate from DB if needed.
  • Using database IDs in URI formats — IDs differ across environments. Use {slug}, {canonicalUid}, or custom fields.
  • Not setting allowAdminChanges => false in production — without this, production schema changes won't sync back to dev.

Reference Files

Read the relevant reference file(s) for your task.

Task examples:

  • "Plan a blog content architecture" → read content-patterns.md
  • "Which field type should I use for X?" → read field-types.md
  • "Set up relatedTo queries" → read relations-and-eager-loading.md
  • "Configure Matrix with nested entries" → read field-types.md (Matrix section)
  • "Plan a multi-site content model" → read content-patterns.md + propagation in SKILL.md
  • "Understand project config workflow" → this SKILL.md covers the essentials
ReferenceScope
references/field-types.mdAll 26 built-in field types: settings, Twig access patterns, query syntax, gotchas. Matrix configuration, view modes, nesting.
references/relations-and-eager-loading.mdrelatedTo() shapes (4 forms), .with() eager loading, .eagerly() lazy eager loading, nested eager loading, native eager-loadable attributes.
references/content-patterns.mdStrategic patterns for blog, portfolio, multi-site corporate, e-commerce. Section/field/relation architecture per pattern. Categories-to-entries migration.

Propagation Methods (Multi-Site)

Available for channels and structures. Singles always propagate to all sites.

MethodBehavior
Only save to site created inEntries exist in one site only
Same site groupEntries propagate within the same site group
Same languageEntries propagate to sites sharing the same language
All enabled sitesEntries exist in all enabled sites (default)
Let each entry choosePer-entry control via Status sidebar

Matrix fields have their own propagation method, independent of the section's.

Field Translation Methods

Per-field setting controlling how values behave across sites:

MethodBehavior
Not translatableSame value across all sites
Per siteIndependent value per site
Per site groupShared within site group, independent across groups
Per languageShared across sites with same language
CustomUser-defined grouping key

Configure translation methods before populating content.

Project Config Essentials

All schema changes (sections, entry types, fields, volumes, transforms, sites, plugins, permissions) are stored as YAML in config/project/.

Workflow

  1. Make CP changes in development environment
  2. YAML auto-updates in config/project/
  3. Commit to Git
  4. Deploy to staging/production
  5. Run ddev craft up (applies migrations + project config)

Rules

  • Never manually edit YAML — let Craft manage it
  • Always set allowAdminChanges => false in production
  • Use UIDs (not IDs) — they're stable across environments
  • After resolving Git merge conflicts in YAML: ddev craft project-config/touch then ddev craft project-config/apply
  • Use $ENV_VAR syntax in YAML for environment-specific values

Asset Volumes and Transforms

Volumes define content organization. Filesystems define storage (local, S3, Google Cloud, Azure). Multiple volumes can share one filesystem.

Image Transforms

{# Named transform (defined in Settings → Assets → Image Transforms) #}
<img src="{{ asset.getUrl('thumb') }}" alt="{{ asset.alt }}">

{# Ad-hoc transform #}
{% set transform = { width: 300, height: 200, mode: 'crop', format: 'webp' } %}
<img src="{{ asset.getUrl(transform) }}" alt="{{ asset.alt }}">

{# Srcset #}
{{ asset.getImg({ width: 300 }, ['1.5x', '2x', '3x']) }}

Always add the Alternative Text field layout element to asset volumes for accessibility.

Download now (ZIP)

Does 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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.