bem-structure

Enforce BEM naming and component structure in CSS projects.

6|1|Updated Feb 4, 2026
One-click install
npx skills add https://github.com/RoleModel/rolemodel-skills --skill bem-structure
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bem-structure
Source: https://github.com/RoleModel/rolemodel-skills/tree/main/skills/bem-structure
Command: npx skills add https://github.com/RoleModel/rolemodel-skills --skill bem-structure

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides expert guidance for writing, refactoring, and structuring CSS using BEM (Block Element Modifier) methodology to ensure consistency, readability, and maintainability across large front-end codebases.

Core Features & Use Cases

  • Enforces explicit BEM naming conventions (Block, Element, Modifier) for predictable, scalable class structures.
  • Guides component organization and Optics design system integration to avoid duplicating existing components.
  • Use Case: when refactoring legacy CSS or introducing new UI blocks, apply the guidelines to keep styles maintainable and aligned with design tokens.

Quick Start

Create a new component following BEM: define a Block class (for example, .card), add Element classes using __ notation (e.g., .card__title, .card__body), and apply Modifiers with -- (e.g., .card--featured). When extending components, reuse existing Optics components whenever possible.

Frequently Asked Questions about bem-structure

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is BEM naming convention in CSS and when should I use it?

BEM (Block Element Modifier) is a CSS naming methodology that enforces consistent class structures using Block, Element, and Modifier rules. Use BEM during CSS reviews or when creating new UI components to ensure scalability and maintainability across large frontend codebases.

How do I structure CSS classes using BEM for a new UI component?

To structure CSS with BEM, define a Block class like .card, add Element classes using __ notation like .card__title, and apply Modifiers with -- like .card--featured. Always use flat class selectors to maintain predictable and readable component structures.

Can I use BEM methodology to refactor legacy CSS?

Yes, you can apply BEM guidelines during refactoring sessions to restructure legacy CSS. By enforcing explicit Block, Element, and Modifier naming rules, you can transform unstructured styles into maintainable components aligned with the Optics design system.

Does BEM naming work with the Optics design system?

BEM naming integrates directly with the Optics design system to prevent component duplication. When extending UI blocks, the methodology guides you to reuse existing Optics components whenever possible, ensuring alignment with established design tokens and maintaining structural consistency.

Why use flat class selectors in BEM instead of nested CSS selectors?

Flat class selectors are required in BEM to maintain predictable and scalable class structures. By avoiding nested selectors, you ensure explicit Block, Element, and Modifier naming rules are followed, which keeps large frontend codebases readable and maintainable during CSS reviews.