bem-css
Skill1 starsChanged 7 days agoMITView on GitHub
Implement and review CSS with the BEM methodology. Use when writing CSS, styling a component, refactoring selectors, naming blocks, elements, or modifiers, or reviewing a stylesheet for BEM violations. Not for general visual design, HTML architecture, JavaScript behavior, or framework-specific decisions unless they directly affect CSS class names.
In this repository5 other files it gives its agents.
- chrome-validationSkill
- cleaner-commitsSkill
- create-better-skillSkill
- jest-coverageSkill
- web-accessibilitySkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
21 rules. About 0 are common, 14 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈14
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 18
Read repository instructions and inspect nearby CSS before choosing names.
- Distinctive: line 20
After editing, run the narrowest available formatter, linter, typecheck, or test for the touched CSS.
- Very specific: line 31
Use names that describe the entity's role, not its appearance or DOM tag.
- Distinctive: line 33
Do not create a selector for every nested DOM node.
- Distinctive: line 37
Follow these rules unless the project explicitly documents a compatible exception:
- Distinctive: line 39
Use class selectors for blocks, elements, and modifiers.
- Distinctive: line 40
Do not use IDs or tag selectors to style BEM entities.
- Very specific: line 41
Prefer one simple class per rule: .card, .card__title, .card_featured.
- Very specific: line 42
Avoid combining classes such as .button.button_active.
- Very specific: line 43
Avoid descendant selectors such as .page .card__title and .card .card__title.
- Very specific: line 44
Keep nesting minimal. Nest only when a block state, theme, or modifier must change a related element, for example .button_hovered …
- Very specific: line 45
Do not combine a tag and class, such as button.button.
- Very specific: line 46
Do not style a block based on where it happens to be rendered.
- Distinctive: line 48
Keep specificity low and predictable.
- Distinctive: line 52
Use modifiers to express appearance, state, or behavior that varies while the entity remains the same.
- Distinctive: line 65
Use a mix when one node participates in more than one independent block or when a parent must supply external geometry.
- Distinctive: line 67
Do not merge unrelated blocks merely because they share a color, size, or isolated declaration.
- Distinctive: line 71
When the project already organizes styles by component, keep each block's base styles, elements, and modifiers together or in the project's …
- Distinctive: line 81
Follow the project's build system and naming syntax when it differs.
- Distinctive: line 85
Check every touched selector and report the exact selector when a rule fails:
- Distinctive: line 102
When a project convention conflicts with the methodology, preserve the project convention if it is intentional, call out the tradeoff, and …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
BEM CSS
Implement and review CSS as independent, reusable BEM blocks. Use the BEM CSS methodology as the authority when project conventions do not specify a compatible rule.
Start
- Determine the mode: implement, refactor, or review. For a combined request, review the existing selectors before changing them.
- Identify the target files, the block or component being changed, its elements, its modifiers, and any existing naming convention.
- Read repository instructions and inspect nearby CSS before choosing names. Preserve an established project prefix or syntax when it remains BEM-compatible.
- State the proposed selectors and affected files. Ask for confirmation before editing files.
- After editing, run the narrowest available formatter, linter, typecheck, or test for the touched CSS. If no executable check exists, inspect the diff and report that limitation.
Model the component
Describe the component in BEM entities before writing selectors:
- Block: an independent component or reusable concept, such as
.cardor.menu. - Element: a meaningful part of its block, written
.block__element, such as.card__title. - Modifier: a boolean or key-value variation of a block or element, written
.block_modifieror.block_key_value, such as.card_featuredor.button_size_large. - Mix: multiple independent BEM entities on one DOM node when each owns a separate responsibility, such as
button card__action.
Use names that describe the entity's role, not its appearance or DOM tag. Prefer .card__title over .card__blue-text, and .button_size_large over .button_24px.
Do not create a selector for every nested DOM node. Create an element only when the part has a meaningful role within the block. If a nested part is independently reusable, make it a block and use a mix where needed.
Write selectors
Follow these rules unless the project explicitly documents a compatible exception:
- Use class selectors for blocks, elements, and modifiers.
- Do not use IDs or tag selectors to style BEM entities.
- Prefer one simple class per rule:
.card,.card__title,.card_featured. - Avoid combining classes such as
.button.button_active; a modifier should remain independently overridable. - Avoid descendant selectors such as
.page .card__titleand.card .card__title. Put the relationship in the element class or use a state/theme rule only when the relationship is essential. - Keep nesting minimal. Nest only when a block state, theme, or modifier must change a related element, for example
.button_hovered .button__text. - Do not combine a tag and class, such as
button.button; this increases specificity and makes modifiers harder to override. - Do not style a block based on where it happens to be rendered. Put external geometry and positioning on the parent element or a mix, for example
.header__button, not.header .button.
Keep specificity low and predictable. When a variation is likely to change, add or adjust a modifier instead of changing the base block or adding a contextual override.
Use modifiers and mixes
Use modifiers to express appearance, state, or behavior that varies while the entity remains the same. Keep the base block responsible for stable internal styling and put the variation in the modifier:
.button {
font-family: inherit;
border: 1px solid currentColor;
}
.button_size_large {
min-block-size: 3rem;
}Use a mix when one node participates in more than one independent block or when a parent must supply external geometry. Keep responsibilities separate so mixed blocks do not define the same property and depend on source order.
Do not merge unrelated blocks merely because they share a color, size, or isolated declaration. Share behavior through a meaningful block or mix only when the components are functionally related.
Organize files
When the project already organizes styles by component, keep each block's base styles, elements, and modifiers together or in the project's established BEM structure. Do not introduce a new file layout for a small change.
For a new structure, prefer a block directory with focused files:
button/
button.css
_size/button_size_large.cssFollow the project's build system and naming syntax when it differs. A flat stylesheet is acceptable when that is the repository convention; preserve the same entity boundaries in the selectors.
Review checklist
Check every touched selector and report the exact selector when a rule fails:
- The name identifies a block, element, modifier, or mix clearly.
- Elements belong to the correct block and are not chained (
.a__b__c). - Modifiers extend an entity without replacing its base class.
- Blocks remain reusable outside their current parent.
- External margin, positioning, and layout belong to the parent element or a mix.
- IDs, tag selectors, unnecessary combined selectors, and deep contextual nesting are absent.
- Specificity is low enough that modifiers can override base styles without escalation.
- Mixed blocks do not overlap in responsibility for the same property.
- New variation is represented by a modifier or a new block instead of a contextual exception.
- The change preserves the repository's formatter, linter, cascade, and build conventions.
Boundaries
Handle CSS and CSS-adjacent class naming only when it is needed to implement or review the BEM change. Do not redesign the visual system, rewrite HTML structure, change JavaScript behavior, migrate a framework, or impose a new file architecture unless the user explicitly asks for that work. If the existing markup prevents a correct BEM implementation, explain the smallest required markup change and ask before making it.
When a project convention conflicts with the methodology, preserve the project convention if it is intentional, call out the tradeoff, and avoid silently rewriting unrelated selectors.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

