leafygreen-ui
Copilot instructions273 starsChanged 7 months agoApache-2.0View on GitHub
This document provides comprehensive guidance for coding agents working on the LeafyGreen UI design system repository. Following these instructions will minimize build failures, validation errors, and rejected pull requests. LeafyGreen UI is MongoDB's React component library and design system consisting of: Refer to package.json for the required Node and pnpm versions. MUST use pnpm, not npm or yarn Follow this workflow for all development tasks: Each package supports these scripts (defined in individual package.json): The CI/CD system runs validations on…
In this repository3 other files it gives its agents.
- .cursor/rules/generate-pull-request-details.mdcCursor rule
- leafygreen-authoringSkill
- setup-leafygreenSkill
The file
We split this copilot-instructions.md into the rules it gives an agent
10 rules. About 0 are common, 6 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 32
MUST use pnpm, not npm or yarn
- Distinctive: line 36
Follow this workflow for all development tasks:
- Distinctive: line 44
ALWAYS run this before any development work
- Very specific: line 49
Add/update tests in .spec.tsx files
- Very specific: line 50
Update stories in .stories.tsx files
- Very specific: line 79
CRITICAL: Always use pnpm run fix instead of manual formatting fixes
- Distinctive: line 83
All checks must pass in CI
- Distinctive: line 85
Update documentation as needed
- Distinctive: line 122
Test setup with Jest/React Testing Library
- Very specific: line 148
Use workspace:^ for internal dependencies (Example: "@leafygreen-ui/palette": "workspace:^")
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions 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 UI - Copilot Instructions
This document provides comprehensive guidance for coding agents working on the LeafyGreen UI design system repository. Following these instructions will minimize build failures, validation errors, and rejected pull requests.
Repository Overview
LeafyGreen UI is MongoDB's React component library and design system consisting of:
- 100+ workspace packages across 5 scopes:
@leafygreen-ui,@lg-charts,@lg-chat,@lg-mcp, and@lg-tools - Languages/Frameworks: TypeScript, React 18, Emotion (CSS-in-JS), Storybook
- Build System: Turbo monorepo with pnpm workspaces
Project Structure
leafygreen-ui/
├── packages/ # @leafygreen-ui core components (button, modal, etc.)
├── charts/ # @lg-charts data visualization components
├── chat/ # @lg-chat conversational UI components
├── mcp/ # @lg-mcp MCP (Model Context Protocol) components and hooks
├── tools/ # @lg-tools build system, CLI, linting, etc.
├── stories/ # Storybook files unrelated to a specific component
└── scripts/ # Repository maintenance scriptsBuild System & Development Commands
Required Environment
Refer to package.json for the required Node and pnpm versions.
MUST use pnpm, not npm or yarn
Development Workflow & Commands
Follow this workflow for all development tasks:
Initial Setup (required after clone or when switching branches):
pnpm run init # Installs dependencies and builds all packages- ALWAYS run this before any development work
Making Changes:
- Edit component files in
src/ - Add/update tests in
.spec.tsxfiles - Update stories in
.stories.tsxfiles
- Edit component files in
Development Commands:
# Build all packages (uses Turbo, typically 6-10 seconds with cache) pnpm build # Start Storybook for development pnpm start # Starts on port 9001 # Run tests pnpm test # All tests pnpm run test --filter="@leafygreen-ui/*" # Specific scope # Linting pnpm lint # Check only pnpm run fix # Auto-fix issuesBefore Committing:
pnpm build # Ensure builds pass pnpm lint # Check for issues pnpm test # Run test suite pnpm changeset # Document changes for release- CRITICAL: Always use
pnpm run fixinstead of manual formatting fixes - Runs ESLint, Prettier, and npmPkgJsonLint
- CRITICAL: Always use
- PR Submission:
- All checks must pass in CI
- Include meaningful test coverage
- Update documentation as needed
Package-Level Commands
Each package supports these scripts (defined in individual package.json):
{
"scripts": {
"build": "lg-build bundle",
"tsc": "lg-build tsc",
"docs": "lg-build docs"
}
}Validation Pipeline
The CI/CD system runs validations on every PR
For regular PRs, refer to .github/workflows/pr.yml
PR Requirements
Refer to .github/pull_request_template.md for PR requirements
Package Development Guidelines
Creating New Components
pnpm create-package my-new-componentThis scaffolds:
- Package structure with TypeScript configs
- Test setup with Jest/React Testing Library
- Storybook stories
- Build configuration
Package Structure
Each package follows this structure:
packages/component-name/
├── src/
│ ├── Component/
│ │ ├── Component.tsx
│ │ ├── Component.styles.ts
│ │ ├── Component.spec.tsx
│ │ └── index.ts
│ ├── Component.stories.tsx
│ ├── index.ts
│ └── types.ts
├── package.json
├── README.md
└── CHANGELOG.mdWorkspace Dependencies
- Use
workspace:^for internal dependencies (Example:"@leafygreen-ui/palette": "workspace:^") - External dependencies use specific versions with caret
^version notation. - External dependencies in
@lg-tools/*packages use explicit dependency versions (with no caret^or tilde~)
TypeScript Configuration
- Extends
@lg-tools/build/config/package.tsconfig.json - Path mapping configured in root
tsconfig.json:{ "paths": { "@leafygreen-ui/*": ["packages/*/src"], "@lg-charts/*": ["charts/*/src"], "@lg-chat/*": ["chat/*/src"], "@lg-tools/*": ["tools/*/src"] } }
File Locations & Configurations
Key Configuration Files
eslint.config.mjs- Linting rules (extends@lg-tools/lint)prettier.config.js- Code formatting (extends@lg-tools/lint)turbo.json- Build orchestrationtsconfig.json- TypeScript path mapping and compilation.github/workflows/- CI/CD pipeline definitions
Build Tools
- Main CLI:
@lg-tools/cliprovideslgcommand - Build System:
@lg-tools/buildprovideslg-buildcommands - Validation:
@lg-tools/validatechecks dependencies and structure - Testing:
@lg-tools/testprovides Jest configuration
Performance Notes
- Build caching: Turbo extensively caches builds - clean cache if issues arise
- Icon package: Has special build caching due to SVG generation complexity
- Storybook: Large application - expect 30+ second build times
Code Style guide
Refer to STYLEGUIDE.md for code style guidelines
Additional instructions
- For Storybook files
**/*.stories.ts, do not comment on the inclusion ofconsolelogs.
Trust These Instructions
These instructions are based on comprehensive exploration and testing of the actual codebase. Only search for additional information if:
- These instructions are incomplete for your specific task
- You encounter errors not covered in the troubleshooting section
- The codebase has changed since these instructions were created
Always prefer following these established patterns over creating new approaches.
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.

