Skip to content
Skill

Craft twig guidelines

Gives agents the Twig coding conventions and Craft helpers for Craft CMS 5 templates

Craft twig guidelines is an open-source agent skill for developer tools. It is available on Claude Code.

Scripts
shell
Platforms
Claude Code
GitHub stars
91
Last commit
License
MIT
Listing updated

Similar skills

About Craft twig guidelines

This skill sets out coding standards for Twig templates in Craft CMS 5 projects, covering atomic components, views, layouts and partials. It guides naming, null handling with the null-coalescing operators, whitespace control, isolating included partials, and writing component file headers. It also explains which Craft Twig helpers to prefer, such as tag(), attr(), svg() and collect(), and how to build class strings from named keys instead of string concatenation.

The skill ships a reference set that the agent reads on demand: core conventions with correct and wrong examples, a guide to Craft helper functions, and notes for upgrading to Craft 5.12. A short bash script reports the project's Craft version when the skill loads, so version-specific advice matches the site. It also lists common pitfalls, such as snake_case variables, missing include scoping and hardcoded colours.

Using it assumes a Craft CMS 5 project with Twig templates. Template architecture, routing and content modelling are handled by companion skills, and PHP standards by a separate PHP guidelines skill.

When your agent uses it

Twig coding standards and conventions for Craft CMS 5 templates. ALWAYS load this skill when writing, editing, or reviewing any .twig file in a Craft CMS project, even for small edits. Covers: variable naming (camelCase, no abbreviations), null handling (?? operator, ??? with empty-coalesce plugin), whitespace control ({%- trimming, NOT {%- minify -%}), include isolation (always 'only'), Craft Twig helpers ({% tag %}, tag(), attr(), |attr, |parseAttr, |append, svg()), collect() for props and class collections, .implode(), ========= comment headers on component files, and pitfalls (snake_case, macros as components, hardcoded colors).

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 5 files (40 KB) on GitHub on 3 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Check another skill before you install it.

Install

This skill ships in the craftcms-claude-skills plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

/plugin marketplace add michtio/craftcms-claude-skills
/plugin install craftcms-claude-skills@craftcms-claude-skills

Or copy only this skill to ~/.claude/skills/craft-twig-guidelines:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michtio/craftcms-claude-skills.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/craft-twig-guidelines &&
cp -R "$tmp/skills/craft-twig-guidelines" ~/.claude/skills/craft-twig-guidelines &&
rm -rf "$tmp"

For one project only, put the folder in .claude/skills/craft-twig-guidelines inside it instead.

Claude Code docs on skills

Copy the skill folder to ~/.agents/skills/craft-twig-guidelines to use it in every repository:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michtio/craftcms-claude-skills.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/craft-twig-guidelines &&
cp -R "$tmp/skills/craft-twig-guidelines" ~/.agents/skills/craft-twig-guidelines &&
rm -rf "$tmp"

For one repository only, put the folder in .agents/skills/craft-twig-guidelines inside it instead.

Codex docs on skills

Copy the skill folder to ~/.cursor/skills/craft-twig-guidelines to use it in every project:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michtio/craftcms-claude-skills.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/craft-twig-guidelines &&
cp -R "$tmp/skills/craft-twig-guidelines" ~/.cursor/skills/craft-twig-guidelines &&
rm -rf "$tmp"

For one project only, put the folder in .cursor/skills/craft-twig-guidelines inside it instead.

Cursor docs on skills

Run in a terminal (add --scope workspace to install it for the current workspace only):

gemini skills install https://github.com/michtio/craftcms-claude-skills.git --path skills/craft-twig-guidelines

Or copy the folder to ~/.gemini/skills/craft-twig-guidelines yourself.

Gemini CLI docs on skills

For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/craft-twig-guidelines:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michtio/craftcms-claude-skills.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/craft-twig-guidelines &&
cp -R "$tmp/skills/craft-twig-guidelines" ~/.copilot/skills/craft-twig-guidelines &&
rm -rf "$tmp"

For one project only, put the folder in .github/skills/craft-twig-guidelines inside it instead.

VS Code docs on skills

Get the folder:

git clone --depth 1 https://github.com/michtio/craftcms-claude-skills.git

Then copy craftcms-claude-skills/skills/craft-twig-guidelines into your agent's skills folder as craft-twig-guidelines. Agents that support SKILL.md read one folder per skill.

The SKILL.md format

What it does

Naming and null handling
Covers camelCase variable names, avoiding abbreviations, and when to use the null-coalescing operators.
Include isolation rules
Requires the only keyword on includes and renders so components do not depend on parent variables.
Craft Twig helpers
Explains tag(), attr(), svg() and collect() usage for polymorphic elements and class strings.
Whitespace control
Shows where to trim output whitespace and why the minify tag is deprecated.
Component file headers
Defines a standard comment header format for component, view and layout files.
Version-specific upgrade notes
Lists behaviour changes and deprecations for Craft 5.10 through 5.12 and Twig 3.29 to 3.31.

Good for

  • Review a Twig component for snake_case variables and missing include scoping
  • Refactor class string concatenation into collect() with named keys
  • Write a Craft Twig partial with proper whitespace control and a comment header
  • Check a template for hardcoded colours and replace them with theme classes
  • Upgrade a Twig template to use heading() or render() on Craft 5.12

Craft twig guidelines FAQ

What does the skill need to run?

It runs a bash script that reads the project's Craft version, so it needs a shell and a Craft CMS 5 project.

When does Craft twig guidelines trigger?

It is meant to load whenever a .twig file is written, edited or reviewed in a Craft CMS project, even for small edits.

Does Craft twig guidelines cover template architecture or PHP?

No. Architecture and routing are covered by the craft-site skill, content modelling by craft-content-modeling, and PHP by craft-php-guidelines.

How do I install Craft twig guidelines in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/craft-twig-guidelines to use it in all your projects, or to .claude/skills/craft-twig-guidelines in one project. Or install the craftcms-claude-skills plugin, which includes it: /plugin marketplace add michtio/craftcms-claude-skills, then /plugin install craftcms-claude-skills@craftcms-claude-skills.

Does Craft twig guidelines run scripts?

Yes. It runs shell scripts. No network calls were found in its scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Craft twig guidelines?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

What are the best alternatives to Craft twig guidelines?

The closest alternatives to Craft twig guidelines are Craft site, Craft php guidelines, Craftcms, Craft garnish and Craft content modeling.

Where this comes from

  • Description: from the skill's own SKILL.md.

More from michtio/craftcms-claude-skills

  1. Gives agents a safe Pest workflow for testing Craft CMS 5 plugins without touching live

    • Open source
    • 91 GitHub stars
    • Developer tools
  2. Guides an agent through Craft Cloud config, deploys, caching, and Cloud-specific limits

    • Open source
    • 91 GitHub stars
    • Databases
  3. Guides Craft CMS 5 content architecture: sections, entry types, fields, Matrix

    • Open source
    • 91 GitHub stars
    • Developer tools
  4. Deploys and runs Craft CMS on fortrabbit managed PHP hosting with safe git workflows

    • Open source
    • 91 GitHub stars
    • Developer tools
  5. Guides agents writing Craft CMS control panel JavaScript with the Garnish UI toolkit

    • Open source
    • 91 GitHub stars
    • Developer tools
  6. Runs one approved Craft CMS slice through outside builders under locked test gates

    • Open source
    • 91 GitHub stars
    • Developer tools