naming-conventions
它能做什么
这项技能检查 CSS 类名,并建议统一的命名规则,例如 BEM。适用于希望样式易于查找和修改的前端开发者和团队。
适用场景
- ✓当你请智能体整理或统一 CSS 类名的时候。
- ✓当很难看出某个类名的作用,而且各组件之间的样式不断冲突的时候。
- ✓当你开始新项目,希望从一开始就有清晰的命名约定的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/naming-conventions/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的 CSS 类名很乱。请帮我用 BEM 这样统一的规则重新命名。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会检查样式表中的类名,并将其改写为块、元素和修饰符的形式。它会让名称保持 kebab-case 格式,并把工具类与组件样式分开。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Use consistent CSS naming conventions
Without a naming convention, class names become a guessing game — does .active mean the nav item is active, the button is pressed, or a form field has focus? With BEM or a similar methodology, .button--active is unambiguous. This reduces the time spent searching for existing styles and prevents accidental style conflicts.
Quick Reference
- BEM (Block__Element--Modifier) is the most widely adopted naming convention
- Consistent naming lets you understand a class's purpose without reading its styles
- Namespace utility classes and JS hooks separately from component styles
- Use kebab-case for class names (not camelCase or snake_case)
Check
Audit the class names in this CSS file. Are they consistently named? Do they follow a clear convention? Are there any ambiguous names that could conflict?
Fix
Rename classes to follow BEM methodology: Block, Block__Element, Block--Modifier pattern.
Explain
Explain BEM naming convention, why naming conventions matter, and how to apply BEM to a real component.
Code Review
Review stylesheets, component styles, and responsive states related to Use consistent CSS naming conventions. Flag exact selectors, declarations, or breakpoints that violate the rule in the rendered UI.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/css/naming-conventions
常见问题
什么是 BEM?
BEM 代表 Block、Element 和 Modifier(块、元素和修饰符),它让类名有清晰的结构,例如 button--active。
为什么使用 kebab-case?
这项技能推荐它,而不是 camelCase 或 snake_case,以保持类名统一。
JavaScript 钩子需要单独的名称吗?
需要。这项技能建议把 JavaScript 钩子放在自己的命名空间中,与组件样式分开。
详情
作者的原始描述
Use when reviewing stylesheets, component styles, and responsive behavior related to Use consistent CSS naming conventions. Check the rendered layout across breakpoints and interaction states before proposing a fix.
热度
- GitHub 星标
- 75k
- 排名
- #2946
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。