Skip to main content
skill CX Codex

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

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add dev-toolings/superpowers-symfony --skill twig-components -a claude-code
Open on GitHub

What 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.twig into a component with props and a slot.
  • Make the list search reactive with #[AsLiveComponent] and debounce the input.
  • Write a test for AlertComponent that covers mount and render with InteractsWithTwigComponents.

How to install twig-components

1Skills CLI (Vercel)

npx skills add dev-toolings/superpowers-symfony --skill twig-components -a claude-code

2Manually: put the files in place

~/.claude/skills/twig-components/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/twig-components/

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

Similar skills

All skills for Frontend and UI →

From the same set51

The whole set →
value-objects-and-dtos This skill guides Symfony work with immutable Value Objects and DTOs, covering constructor validation, value equality, and data crossing application boundaries. CX Codex +1 ★ 234repo stars effective-context effective-context is a Claude Code skill that teaches an agent to gather context for Symfony development: versions, error-path files, stack traces, and project constraints. CX Codex +1 ★ 234repo stars strategy-pattern Implements the Strategy pattern in Symfony using tagged services. Helps clean up branching logic when algorithms or providers vary at runtime. CX Codex +1 ★ 234repo stars executing-plans The executing-plans skill guides Claude Code through an approved implementation plan, with test-first steps and a separate commit for each one. Use it for multi-step work or to resume after an interruption. CX Codex +1 ★ 234repo stars cqrs-and-handlers cqrs-and-handlers implements CQRS in Symfony projects using separate Messenger buses for commands and queries. CX Codex +1 ★ 234repo stars daily-workflow The daily-workflow skill lays out a routine for Symfony work, from getting a project running to checking changes before a commit. Use it for migrations, debugging, and recurring maintenance. CX Codex +1 ★ 234repo stars bootstrap-check bootstrap-check runs a pass/fail check over a Symfony project's setup: .env, services, Doctrine mappings, routes. Each failure comes with the fix. CX Codex +1 ★ 234repo stars ports-and-adapters ports-and-adapters guides Claude Code in setting up Hexagonal Architecture in Symfony, isolating domain models from Doctrine, HTTP, and vendor SDKs. CX Codex +1 ★ 234repo stars

Project sponsors

Companies that keep this analytics open