twig-components — Claude Code skill: reusable Twig components
twig-components turns repeated Twig markup into Symfony UX components with props, slots and CVA variants. Handy once the same template chunk starts getting copied around.
MIT ★ 234 updated 2026-10-05
npx skills add dev-toolings/superpowers-symfony --skill twig-components -a claude-codeWhat twig-components does
The skill walks the agent through Symfony UX Twig Components. It picks the shape first: an anonymous template, a class marked #[AsTwigComponent], or a reactive #[AsLiveComponent]. Props are declared as public mutable properties, and anything derived goes into mount(). Content arrives through blocks used as slots.
Reactive state carries #[LiveProp(writable: true)], and typing gets debounced. Component tests use InteractsWithTwigComponents and cover mount plus render.
One guardrail bites in real code: public props can't be readonly, since they are assigned after the object exists. Services go in as private readonly instead. The skill holds only Read, Glob and Grep, so it inspects and searches your project — writing the files is your job.
What it helps with
- pull a repeated Twig block into a component with props and slots
- add a reactive search box with Live Components
- cover a component's mount and render with a test
- split button variants through CVA instead of template copies
- grep templates for markup that keeps getting duplicated
Example prompts for the agent
- Move the product card out of
templates/product/show.html.twiginto a component with props and a slot. - Make the list search reactive with
#[AsLiveComponent]and debounce the input. - Write a test for
AlertComponentthat covers mount and render withInteractsWithTwigComponents.
How to install twig-components
1Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill twig-components -a claude-code2Manually: put the files in place
~/.claude/skills/twig-components/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/twig-components/
1Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill twig-components -a codex2Manually: put the files in place
.agents/skills/twig-components/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill twig-components -a cursor2Manually: put the files in place
.cursor/skills/twig-components/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install dev-toolings/superpowers-symfony content/skills/twig-components2Manually: put the files in place
.github/skills/twig-components/SKILL.md1Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill twig-components -a gemini-cli2Platform CLI
gemini skills install https://github.com/dev-toolings/superpowers-symfony --path content/skills/twig-componentsManually: put the files in place
.devin/skills/twig-components/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about twig-components
How do I install twig-components in Claude Code?
Run npx skills add dev-toolings/superpowers-symfony --skill twig-components -a claude-code. The skill ends up at ~/.claude/skills/twig-components/SKILL.md.
What is twig-components for?
It guides the agent through splitting Symfony templates into components: choosing the component kind, declaring props and slots, adding reactive state and a test.
Why can't public props be readonly?
They get assigned after the object is created, and readonly forbids that, so the component fails. Inject services as private readonly and leave props mutable.
Source text
SKILL.md · MIT
--- name: twig-components description: Build reusable UI components with Symfony UX Twig Components (props, slots, anonymous components, CVA) for clean templates capabilities: [read, search] tags: [architecture, ui] # projected by `bun run build` — do not edit by hand allowed-tools: - Read - Glob - Grep --- # Twig Components (Symfony) ## Use when - Extracting a repeated piece of Twig into a reusable component. - Building a component with props, slots, computed logic, or CVA variants. - Making a component reactive with Live Components (search, counters, forms). ## Default workflow 1. Choose the kind: anonymous (template only), class-based `#[AsTwigComponent]`, or `#[AsLiveComponent]`. 2. Declare props as public mutable properties; use `mount()` for derived values. 3. Expose content injection through blocks (slots) rather than more props. 4. For Live Components, mark writable state with `#[LiveProp(writable: true)]` and debounce user input. 5. Test the PHP class with `InteractsWithTwigComponents`. ## Guardrails - Never make public props `readonly`: they are assigned after instantiation. - Inject services as `private readonly`, never as public props. - Only mark a `LiveProp` writable when the browser must change it. - Keep one responsibility per component. ## Progressive disclosure - Use this file for execution posture and risk controls. - Open references when deep implementation details are needed. ## Output contract - Component classes and templates, with their props and slots. - Live state and actions, when the component is reactive. - A component test for mount and render. ## References - `reference.md`
© dev-toolings · MIT · dev-toolings/superpowers-symfony