A CLI tool that uses AI to generate design rules and documentation from your Figma files. It analyzes your Figma designs and automatically extracts design tokens, components, and layout information into a structured format.
https://github.com/user-attachments/assets/c80b7eee-7027-4872-ae30-5279289ff6f7
Run directly with npx:
npx fig4ai <figma-url> [--model=claude|gpt4] [--no-ai]
After generating your .designrules file, you can use it with AI-powered IDEs to automatically generate code and configurations:
Simply mention the .designrules file in your prompts:
> Generate a Tailwind config based on @.designrules file
> Create a Vue login page using the design tokens from @.designrules
> Build a React component library following @.designrules specifications
The AI will analyze your .designrules file and generate code that matches your design system's:
- Color palette
- Typography scales
- Spacing system
- Component structures
- Layout patterns
- Shadow effects
- Border styles
- And more...
fig4ai follows a sophisticated process to transform your Figma designs into AI-ready context:
Processes complex nested JSON structure containing all design information
Design Token Parsing
Maintains relationship between components and their variants
AI-Powered Transformation
Includes accessibility considerations and responsive behaviors
Structured Documentation
.designrulesPreserves all style references and component relationships
AI Context Integration
.designrules file serves as a comprehensive design contextIn essence, fig4ai transforms your Figma file into a structured AI context, making your design system programmatically accessible to AI tools.
npx fig4ai <figma-url> [--model=claude|gpt4] [--no-ai]
Or if you've set FIGMA_DESIGN_URL in your .env file:
npx fig4ai [--model=claude|gpt4] [--no-ai]
The tool supports two AI models for enhanced design analysis:
CLAUDE_API_KEY in your environment variablesMore detailed component analysis
GPT-4o
OPENAI_API_KEY in your environment variablesYou can also run without AI enhancement:
npx fig4ai <figma-url> --no-ai
This will output raw design data in a structured format without AI processing.
# Required
FIGMA_ACCESS_TOKEN=your_figma_token
# Optional - At least one needed for AI features
CLAUDE_API_KEY=your_claude_api_key
OPENAI_API_KEY=your_openai_api_key
# Optional
FIGMA_DESIGN_URL=your_default_figma_url
The tool generates a .designrules file containing:
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, please: 1. Check the issues page 2. Create a new issue if your problem isn't already listed
$ claude mcp add fig4ai \
-- python -m otcore.mcp_server <graph>