This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a monorepo using Turbo and Yarn workspaces. The main Figma plugin is in packages/tokens-studio-for-figma/.
yarn --frozen-lockfile --immutable- Install dependenciesyarn build- Build all packagesyarn start- Start development mode (runs webpack in watch mode)yarn lint- Run ESLint across all packagesyarn test- Run Jest tests across all packagesyarn test:watch- Run tests in watch mode
yarn build- Production build with webpackyarn build:dev- Development buildyarn start- Start webpack in development watch modeyarn test- Run Jest tests with feature flags enabledyarn test:watch- Run tests in watch mode without coverageyarn test:coverage- Run tests with coverage reportingyarn cy:open- Open Cypress for E2E testingyarn cy:run- Run Cypress tests headlesslyyarn lint- Run ESLint with auto-fixyarn lint:nofix- Run ESLint without auto-fixyarn storybook- Start Storybook for component development
- Jest configuration is in
packages/tokens-studio-for-figma/jest.config.ts - Test files follow
.test.tsor.test.tsxnaming - E2E tests use Cypress and are in
packages/tokens-studio-for-figma/cypress/ - Feature flags are enabled during testing via
LAUNCHDARKLY_FLAGSenvironment variable
- Root-level package.json manages the monorepo with Turbo
packages/tokens-studio-for-figma/contains the main Figma plugin- Developer documentation is in
developer-knowledgebase/
The Figma plugin follows a dual-thread architecture:
-
Main Thread (Plugin Controller):
src/plugin/controller.ts- Handles Figma API interactions
- Manages async message handlers
- Controls plugin lifecycle
-
UI Thread (React App):
src/app/index.tsx- React application using Redux for state management
- Uses Stitches for CSS-in-JS styling
- Rematch for Redux store configuration
src/plugin/- Plugin-side code that runs in Figma's plugin environmentsrc/app/- UI React application codesrc/storage/- Token storage providers (GitHub, GitLab, Azure DevOps, etc.)src/selectors/- Redux selectors for state managementsrc/utils/- Shared utility functionssrc/types/- TypeScript type definitionssrc/constants/- Application constants and enumssrc/figmaStorage/- Figma plugin data storage management
The plugin uses an AsyncMessageChannel pattern for communication between the main plugin thread and UI thread. Message handlers are defined in src/plugin/controller.ts and types in src/types/AsyncMessages.ts.
- Uses Redux with Rematch for state management
- Store configuration in
src/app/store.ts - Selectors are organized by domain in
src/selectors/ - State is persisted to Figma's plugin storage via
src/figmaStorage/
- Token resolution handled by
src/utils/TokenResolver.ts - Support for multiple token formats and transformations
- Variable creation and management for Figma Variables API
Multiple storage providers are supported for token synchronization:
- GitHub (
src/storage/GithubTokenStorage.ts) - GitLab (
src/storage/GitlabTokenStorage.ts) - Azure DevOps (
src/storage/ADOTokenStorage.ts) - JSONBin (
src/storage/JSONBinTokenStorage.ts) - Local file storage and more
- Webpack configuration in root and plugin-specific configs
- Supports development, production, and preview builds
- Bundle analysis and benchmarking tools available
- Uses SWC for fast TypeScript compilation
- Always run formatting tools after making code changes:
yarn lint- Run ESLint with auto-fix across all packagesnpx prettier --write <file>- Format specific filesnpx eslint <file> --fix- Fix ESLint issues in specific files
- Code style: Follow existing patterns with 2-space indentation, single quotes, trailing commas
- Console statements: console.log is acceptable for debugging (widely used in codebase)
- Before committing: Ensure code passes linting checks
- Follow existing component and utility patterns
- Use TypeScript types consistently
- Implement proper error handling with try/catch blocks
- Use async/await patterns with
defaultWorker.schedule()for operations that need progress tracking
- The plugin requires specific Figma API permissions defined in
manifest.json - Feature flags are managed via LaunchDarkly integration
- Internationalization support with i18next
- Comprehensive test coverage with both unit and E2E tests
- Uses Figma Plugin DS for consistent UI components