leafygreen-authoring
Skill273 starsChanged 7 months agoApache-2.0View on GitHub
Auto-invoked when writing or editing React components (.tsx/.ts) in a project that has @leafygreen-ui packages in package.json. Provides component mapping, import conventions, design token usage, and Figma MCP auto-install workflow.
- Installs packages
In this repository3 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/generate-pull-request-details.mdcCursor rule
- setup-leafygreenSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 7 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
When a user asks to add any UI element — in plain language, from a Figma design, or anywhere else — always check if a LeafyGreen component …
- Distinctive: line 53
If a package is not yet installed, install it before writing the component code:
- Distinctive: line 60
Always use named imports for LG components:
- Very specific: line 71
Always use design tokens from @leafygreen-ui/tokens for colors — never hard-coded hex values.
- Distinctive: line 85
When implementing a design from the Figma MCP, the component descriptions include the LeafyGreen package name, e.g.:
- Distinctive: line 96
Never substitute plain HTML for a LeafyGreen component that is called out in the design spec
- Very specific: line 103
Ask before creating new folders outside of src/components/
- Distinctive: line 107
Always define prop types explicitly using TypeScript interfaces
- Very specific: line 108
Do not use any as a type
- Distinctive: line 112
Keep components focused. If a component is doing more than one thing, split it.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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
LeafyGreen Authoring Conventions
Apply these conventions whenever writing or editing React components in a project that uses @leafygreen-ui/* packages.
Always prefer LeafyGreen components over plain HTML
When a user asks to add any UI element — in plain language, from a Figma design, or anywhere else — always check if a LeafyGreen component exists for it first. Never use a plain HTML element (<button>, <input>, <select>, etc.) when an @leafygreen-ui equivalent is available.
Common mappings:
| User asks for… | Use |
| Button, CTA | @leafygreen-ui/button → Button |
| Text input, text field | @leafygreen-ui/text-input → TextInput |
| Dropdown, select | @leafygreen-ui/select → Select, Option |
| Searchable dropdown | @leafygreen-ui/combobox → Combobox |
| Search box | @leafygreen-ui/search-input → SearchInput |
| Number field | @leafygreen-ui/number-input → NumberInput |
| Checkbox | @leafygreen-ui/checkbox → Checkbox |
| Radio button | @leafygreen-ui/radio-group → RadioGroup, Radio |
| Toggle, switch | @leafygreen-ui/toggle → Toggle |
| Icon button | @leafygreen-ui/icon-button → IconButton |
| Icon | @leafygreen-ui/icon → Icon |
| Heading, body text, label | @leafygreen-ui/typography → H1–H3, Body, Label, Subtitle |
| Modal, dialog | @leafygreen-ui/modal → Modal |
| Tooltip | @leafygreen-ui/tooltip → Tooltip |
| Tabs | @leafygreen-ui/tabs → Tabs, Tab |
| Table | @leafygreen-ui/table → Table, Row, Cell |
| Badge, tag, chip | @leafygreen-ui/badge → Badge |
| Banner, alert | @leafygreen-ui/banner → Banner |
| Toast, notification | @leafygreen-ui/toast → Toast |
| Menu, context menu | @leafygreen-ui/menu → Menu, MenuItem |
| Card | @leafygreen-ui/card → Card |
| Code block | @leafygreen-ui/code → Code |
| Logo / logomark | @leafygreen-ui/logo → MongoDBLogoMark, MongoDBLogo |
| Stepper, progress steps | @leafygreen-ui/stepper → Stepper, Step |
| Pipeline | @leafygreen-ui/pipeline → Pipeline, Stage |
If a package is not yet installed, install it before writing the component code:
npm install @leafygreen-ui/[package-name]Component imports
Always use named imports for LG components:
import { H1, Body, Subtitle } from '@leafygreen-ui/typography'
import { Button } from '@leafygreen-ui/button'
import Icon from '@leafygreen-ui/icon' // default import
import { MongoDBLogoMark } from '@leafygreen-ui/logo'Styling approach
Always use design tokens from @leafygreen-ui/tokens for colors — never hard-coded hex values. Tokens are the single source of truth for color in the design system and automatically resolve to the correct value for dark or light mode.
import { palette } from '@leafygreen-ui/tokens'
// Correct: use a token
color: palette.gray.dark2
// Avoid: hard-coded hex
color: '#3D4F58'Figma MCP → auto-install missing packages
When implementing a design from the Figma MCP, the component descriptions include the LeafyGreen package name, e.g.:
⚛️ React name: @leafygreen-ui/text-input
⚛️ React name: @leafygreen-ui/selectBefore writing any component code:
- Scan all
⚛️ React name:entries in the Figma design context - Cross-check each
@leafygreen-ui/*package againstpackage.json - Install any that are missing:
npm install @leafygreen-ui/[package-name] - Never substitute plain HTML for a LeafyGreen component that is called out in the design spec
File structure
- New components go in
src/components/[ComponentName].tsx - One component per file
- Name files and components in PascalCase:
ProjectCard.tsx, notproject-card.tsx - Ask before creating new folders outside of
src/components/
TypeScript
- Always define prop types explicitly using TypeScript interfaces
- Do not use
anyas a type
General
- Keep components focused. If a component is doing more than one thing, split it.
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.

