icons — rule for Claude Code and Codex: icon imports and styling
This rule enforces icon imports from your project's configured library and removes manual sizing from components. Use it to keep all icons consistent across the codebase.
LicenseRef-Proprietary ★ 7,523 updated 2026-10-29
.claude/rules/icons.mdWhat icons does
The rule sets three constraints. First: import icons from the library specified in your project's iconLibrary field. If it says lucide, use lucide-react; if tabler, use @tabler/icons-react. Never default to lucide-react without checking.
Second: add data-icon="inline-start" (before text) or data-icon="inline-end" (after text) to icons inside buttons and other components. Skip sizing classes like mr-2 size-4 — the component handles those via CSS.
Third: pass icons as React components, not string keys. Instead of a lookup table with icon="check", pass icon={CheckIcon}. This keeps types tight and prevents mapping mistakes.
What it helps with
- pick the correct icon package from project config and import from it
- place an icon in a button without extra sizing classes
- pass an icon to a component as a type-safe React component
- ensure all icons have consistent sizes and spacing
Example prompts for the agent
- Check the project's
iconLibraryand importCheckIconfromlucide-reactif it's set tolucide - Add an icon to a button with
data-icon="inline-start"withoutclassName="size-4" - Pass
icon={AlertIcon}toStatusBadgeinstead of the stringicon="alert"
How to install icons
Manually: put the files in place
.claude/rules/icons.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/icons.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/icons.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/icons.mdManually: put the files in place
.clinerules/icons.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about icons
How do I install the icons rule in Claude Code?
Create .claude/rules/icons.md in your project root or copy it there if it already exists. Claude Code loads all rules from this folder on startup.
What does the icons rule do?
It enforces using your project's iconLibrary for all imports, removes manual sizing on component icons, and requires passing icons as React components instead of string keys.
Why can't I add size-4 or similar classes to icons inside Button?
The Button component already controls icon size through CSS. Extra classes override the styles and break the design.