Craftcms-claude-skills craft-site
Craft CMS 5 front-end Twig development — atomic design, template architecture, component patterns, Vite buildchain. Covers the full site template surface: atoms, molecules, organisms, props/extends/block pattern, layout chains, view routing, content builders, image presets, Tailwind named-key collections, multi-brand CSS tokens, JavaScript boundaries (Alpine/DataStar/Vue, tabs, accordions, interactive components), Vite asset loading, and front-end auth (login, registration, password reset, user profiles). Triggers on: {% include ... only %}, {% embed %}, _atoms/, _molecules/, _organisms/, _views/, _builders/, _boilerplate/, component--variant.twig, _component--props.twig, image presets, Tailwind class collections, collect({}), utilities prop, multi-brand theming, data-brand, hero sections, card components, content builders, Matrix block rendering, craft.vite.script, vite.php, vite.config.ts, nystudio107, buildchain, asset loading, per-page scripts, Blitz, static caching, page caching, dynamic caching with Sprig, ImageOptimize, Imager-X, responsive images, srcset, image transforms, SEOmatic, meta tags, OpenGraph, JSON-LD, Sprig, htmx, multi-language site, language switcher, hreflang, localization, Formie, form styling, login form, registration form, user authentication front-end, RSS feed, Atom feed, JSON Feed, XML sitemap, feed.xml, sitemap.xml, |rss, |atom, search page, search results, .search(), search index, search form, search configuration, headless, headless CMS, GraphQL queries, preview tokens, Next.js, Nuxt, Astro, consuming GraphQL API, front-end framework integration. Always use when creating, editing, or reviewing any Craft CMS front-end Twig template, component, layout, view, builder, buildchain configuration, or front-end auth flow — including plugin template integration (Blitz, SEOmatic, Sprig, Formie, Imager-X). Do NOT trigger for PHP plugin/module development or content modeling decisions.
git clone https://github.com/michtio/craftcms-claude-skills
T=$(mktemp -d) && git clone --depth=1 https://github.com/michtio/craftcms-claude-skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/craft-site" ~/.claude/skills/michtio-craftcms-claude-skills-craft-site && rm -rf "$T"
skills/craft-site/SKILL.mdCraft CMS 5 — Front-End Twig (Atomic Design)
Atomic design system patterns for Craft CMS 5 site templates. Vanilla Twig — no module dependency. Works with any Craft 5 project.
This skill is scoped to front-end template architecture — component design, routing, composition, theming, and buildchain. For extending Craft (plugins, modules, PHP), see the
craftcms skill.
Companion Skills — Always Load Together
When this skill triggers, also load:
— Twig coding standards: variable naming, null handling, whitespace control, include isolation, Craft helpers. Required for any Twig code.craft-twig-guidelines
— Sections, entry types, fields, Matrix, relations. Required when deciding what content to query or how templates access data.craft-content-modeling
— All commands run through DDEV. Required for running Vite, npm, and Craft CLI commands.ddev
Documentation
- Twig in Craft: https://craftcms.com/docs/5.x/development/twig.html
- Template tags: https://craftcms.com/docs/5.x/reference/twig/tags.html
- Template functions: https://craftcms.com/docs/5.x/reference/twig/functions.html
- Twig 3 docs: https://twig.symfony.com/doc/3.x/
Use
WebFetch on specific doc pages when a reference file doesn't cover enough detail.
Common Pitfalls (Cross-Cutting)
- Missing
ononly
— ambient variables leak in silently.{% include %} - Variant logic via conditionals (
) instead of extends/block.{% if variant == 'x' %} - Naming atoms by parent context (
) instead of visual treatment (hero-button
).button--primary
prop used as override — it's additive. Override via named-slot merge.utilities- Queries inside views — views receive data, they don't fetch it.
- Missing
on relation fields in views — causes N+1 queries..eagerly() - Missing
fallback in builders for unknown block types.devMode - Hardcoded Tailwind colors (
) instead of brand tokens (bg-yellow-600
).bg-brand-accent - Mixing buttons and links — buttons are actions (resolve to
,<a>
, or<button>
from props), links are navigation (always<span>
). Separate atom categories.<a> - Tracking/analytics inside components — decouple to data attributes at view/page level.
Reference Files
Read the relevant reference file(s) for your task. Multiple files often apply together.
Task examples:
- "Build a new card component" → read
+atomic-patterns.md
+composition-patterns.md
+component-inventory.mdtailwind-conventions.md - "Set up a new project's template structure" → read
+boilerplate-routing.mdcomponent-inventory.md - "Add a content builder for a Matrix field" → read
+boilerplate-routing.mdcomposition-patterns.md - "Handle responsive images" → read
+image-presets.mdplugins/image-optimize.md - "Add multi-brand theming" → read
tailwind-conventions.md - "Decide between Alpine and Vue for a feature" → read
javascript-boundaries.md - "Compose Tailwind classes without conflicts" → read
+tailwind-conventions.mdtwig-collections.md - "Understand atomic design methodology" → read
atomic-design.md - "Set up Vite + Tailwind in a new Craft project" → read
vite-buildchain.md - "Debug why assets aren't loading in production" → read
vite-buildchain.md - "Install GTM/analytics/CMP in a Craft project" → read
third-party-integration.md - "Configure SEOMatic for a section" → read
plugins/seomatic.md - "Set up Blitz caching with Cloudflare" → read
plugins/blitz.md - "Add a form to a page" → read
plugins/formie.md - "Configure CKEditor with nested entries" → read
plugins/ckeditor.md - "Build a navigation menu" → read
plugins/navigation.md - "Add a link field to a component" → read
plugins/hyper.md - "Set up redirects for a site" → read
plugins/retour.md - "Add recurring/repeating dates to entries" → read
plugins/timeloop.md - "Create a JSON API endpoint" → read
plugins/element-api.md - "Debug N+1 queries in templates" → read
plugins/elements-panel.md - "Run a security audit" → read
plugins/sherlock.md - "Embed a YouTube/Vimeo video as an asset" → read
plugins/embedded-assets.md - "Configure email delivery via SES" → read
+plugins/amazon-ses.mdthird-party-integration.md - "Build a language switcher" → read
multi-site-patterns.md - "Add login/registration to the front end" → read
auth-flows.md - "Build a user profile edit page" → read
auth-account.md - "Set up password reset flow" → read
auth-flows.md - "Set up hreflang tags" → read
multi-site-patterns.md - "Plan a multi-language site architecture" → read
multi-site-patterns.md - "Add live search without JavaScript" → read
plugins/sprig.md - "Build reactive filtering or load-more" → read
plugins/sprig.md - "Import data from an external feed" → read
plugins/feed-me.md - "Set up responsive images with Imager-X" → read
plugins/imager-x.md - "Build a search page" → read
search.md - "Configure search settings" → read
(Search Configuration)search.md - "Rebuild the search index" → read
(Rebuilding)search.md - "Create an RSS feed" → read
feeds.md - "Build an XML sitemap" → read
(XML Sitemap)feeds.md - "Create a JSON Feed" → read
(JSON Feed)feeds.md - "Set up a headless Craft CMS with Next.js" → read
headless.md - "Fix GraphQL preview tokens" → read
headless.md - "Consume Craft GraphQL API from a front-end framework" → read
headless.md
| Reference | Scope |
|---|---|
| Methodology: Brad Frost's atomic design principles, 5-to-3 tier compression, composability, context-agnostic naming, classification problem, decompose-downward workflow. Technology-independent. |
| Individual component construction: props/extends/block pattern, variant file mechanics, button/link/text/icon atom implementations |
| Component composition: molecule pattern, organism pattern, structural embed pattern, include/extends/embed decision table, calling conventions, creating new components |
| Classification methodology: decision tree, naming conventions, file naming, props design, scaffold guidelines, tier promotion, audit checklist |
| Template chain: layout hierarchy, Craft section template paths, global variables, routers, views, content builders, directory structure |
| Class composition: named-key collections, standard key names, prop, variant-based dark mode, spacing preference. Assumes Tailwind CSS — adapt patterns to your CSS framework. |
| Craft CMS Vite setup: nystudio107 plugin bridge, , , , conditional per-page loading, Tailwind v4 integration, DDEV configuration |
| Image handling: single atom with presets, srcset/sizes, ImageOptimize vs Craft Cloud, hosting strategies |
| JS decision tree: Twig → Alpine/DataStar → Vue, mount points, data handoff, coexistence rules |
| method reference: creating, accessing, transforming, filtering, sorting, slicing, arrow functions |
| Script loading order, CMP (UserCentrics/CookieBot), GTM/sGTM data layer, analytics (Fathom/Plausible), AWS SES transport, n8n webhooks, Blitz compatibility, full head template example |
| Language switchers, hreflang tags, site architectures (subfolder/domain/subdomain/multi-brand), cross-site queries, static translations, site-specific templates, multi-site forms, site detection |
| Front-end authentication forms: login, registration, password reset, set new password |
| Account management: edit profile, email verification, navigation partial, access control tags, user session helpers, GeneralConfig auth settings |
| Search: syntax, Twig queries, configuration, indexing, rebuilding, score and ranking |
| Feeds: RSS 2.0, Atom, JSON Feed, XML sitemap, custom routes, date filters |
| Headless & hybrid: headlessMode, GraphQL API, CORS, preview tokens, Next.js/Nuxt/Astro integration |
Plugin References
Detailed configuration, Twig API, and pitfalls for Craft plugins. Located in
references/plugins/.
| Reference | Plugin | Key Surface |
|---|---|---|
| SEOMatic (nystudio107) | Meta cascade, Twig get/set API, JSON-LD, custom element SEO bundles, sitemaps, GraphQL |
| Blitz (putyourlightson) | Refresh modes, Twig dynamic content, driver architecture (storage/purger/deployer), Nginx rewrite, Cloudflare integration |
| Formie (verbb) | Form rendering (one-line/granular), theme config for Tailwind, submission querying, hooks, integrations |
| ImageOptimize (nystudio107) | OptimizedImages field, / builders, loading strategies, transform methods, console commands |
| CKEditor (craftcms) | Toolbar config, nested entries with chunk rendering, HTML Purifier, custom styles, Redactor migration |
| Sprig (putyourlightson) | Reactive Twig components (htmx), live search, load more, pagination, filtering, form submissions without JS |
| Colour Swatches (craftpulse) | Palette config, multi-colour swatches, Tailwind class mapping, Twig model API |
| Password Policy (craftpulse) | Validation rules, HIBP check, retention/expiry, console commands, recommended settings |
| Hyper (verbb) | Link types, , , single/multi-link, element access, button atom integration |
| Retour (nystudio107) | Redirect types (exact/regex), 404 tracking, CSV import, auto slug-change redirects, config |
| Navigation (verbb) | Node querying, custom rendering, active states, custom fields on nodes, GraphQL |
| Typogrify (nystudio107) | , , , smart quotes, widow prevention |
| Cache Igniter (putyourlightson) | GlobalPing warmer, geographic locations, refresh delay, Blitz companion |
| Knock Knock (verbb) | Staging password protection, environment-aware config, URL exclusions |
| Timeloop (craftpulse) | Repeating date field, variable API, function, GraphQL, period frequencies |
| Element API (craftcms) | JSON API via config file, Fractal transformers, endpoint routing, pagination, caching |
| Elements Panel (putyourlightson) | Debug toolbar panels for element population counts, duplicate detection, eager-loading opportunities |
| Sherlock (putyourlightson) | Security scanning, HTTP headers, CMS config checks, scheduled scans, IP restriction, monitoring |
| Embedded Assets (spicyweb) | oEmbed as first-class assets, , iframe customization, GraphQL |
| Amazon SES (putyourlightson) | SES mail transport adapter, AWS credential config, SNS bounce tracking |
| Feed Me (craftcms) | Data import from XML/JSON/CSV, field mapping, duplicate handling, CLI automation |
| Imager-X (spacecrafttechnologies) | Advanced image transforms, batch generation, named presets, effects, optimizers, external storage |
Component System Conventions
One canonical component system across all projects. Atoms are context-agnostic — always named by visual treatment, never by parent. HTML element type is resolved from props (
url → <a>, type → <button>, fallback → <span>).
External link detection is derived from the URL, never passed as a prop. Components auto-apply
target="_blank", rel="noopener noreferrer", external icon, and sr-only text when a URL is external.
FontAwesome is the universal icon system. Icons are passed as FA class strings.
Visual variants use extends/block — base template defines structure, variant overrides classes. Never use conditional logic to switch between variant styles. For structural skeletons with content slots, use
{% embed %} — see composition-patterns.md.
Image handling uses a single atom with config-driven presets, not separate variant files per context.
CSS & Theming Conventions
This skill assumes Tailwind CSS for class composition examples. Adapt patterns to your CSS framework — the architectural principles (named keys, additive utilities, semantic tokens) are framework-agnostic.
Class collections use named keys per style concern — this is the primary mechanism for preventing conflicts. The
utilities prop is additive (extending), not overriding. Override specific concerns via named-slot merge.
Multi-brand theming uses CSS custom properties activated by
data-brand="{{ currentSite.handle }}" on <html>. Components reference semantic Tailwind classes (bg-brand-accent) resolved via CSS variables. Template-level brand overrides only exist when the HTML structure itself differs between brands — not for color/font/spacing differences.
Token naming follows three layers: primitives (
--brand-{color}-{shade}), semantics (--brand-{purpose}), and framework mapping (--color-brand-{purpose}).
Tailwind v4 cascade layers don't fix class conflicts within the same utilities layer. Named-key collections remain necessary.
Routing Conventions
PHP handles data, Twig handles presentation. Views receive data through includes — they never query it themselves.
collect() is used for both props and class building. The full Collection API is available in Twig via Craft.
The JS boundary follows a decision tree: Twig is the default → Alpine/DataStar for UI state → Vue for application state.