npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

fig4ai

v0.1.5

Published

A CLI tool to parse Figma URLs and generate AI-powered design rules for your AI editor.

Downloads

94

Readme

fig4ai

License

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.

Overview

https://github.com/user-attachments/assets/c80b7eee-7027-4872-ae30-5279289ff6f7

Features

  • 🎨 Extract design tokens (colors, typography, spacing, effects)
  • 🧩 Generate component documentation
  • 📐 Analyze layout structures
  • 🤖 AI-powered pseudo-code generation
  • 🔄 Real-time progress indicators
  • 📝 Markdown output format

Run

Run directly with npx:

npx fig4ai <figma-url> [--model=claude|gpt4] [--no-ai]

IDE Integration

After generating your .designrules file, you can use it with AI-powered IDEs to automatically generate code and configurations:

Cursor, Windsurf, VS Code

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...

How it Works

fig4ai follows a sophisticated process to transform your Figma designs into AI-ready context:

  1. Data Extraction

    • Connects to Figma API and retrieves comprehensive file data
    • Processes complex nested JSON structure containing all design information
  2. Design Token Parsing

    • Parses the JSON structure hierarchically: Canvas > Frame > Component / Instance
    • Extracts design tokens (colors, typography, spacing, effects)
    • Organizes components and their instances with style references
    • Maintains relationship between components and their variants
  3. AI-Powered Transformation

    • For each Canvas, sends structured data to GPT-4o
    • Generates semantic pseudo-code with complete styling context
    • Preserves all design decisions, constraints, and relationships
    • Includes accessibility considerations and responsive behaviors
  4. Structured Documentation

    • Stores all design tokens and pseudo-code representations in .designrules
    • Uses Markdown format for maximum compatibility
    • Maintains hierarchical structure of the design system
    • Preserves all style references and component relationships
  5. AI Context Integration

    • .designrules file serves as a comprehensive design context
    • When mentioned in AI-powered IDEs (Cursor/Windsurf), the file is parsed
    • AI understands the complete design system and can generate accurate code
    • Enables context-aware code generation based on your design system

In essence, fig4ai transforms your Figma file into a structured AI context, making your design system programmatically accessible to AI tools.

Usage

Command Line

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]

AI Options

The tool supports two AI models for enhanced design analysis:

  1. Claude (Default)

    • Uses Anthropic's Claude 3 Sonnet model
    • Set CLAUDE_API_KEY in your environment variables
    • Generally better at understanding design context
    • More detailed component analysis
  2. GPT-4o

    • Uses OpenAI's GPT-4 model
    • Set OPENAI_API_KEY in your environment variables
    • Alternative option if you prefer OpenAI

You 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.

Environment Setup

# 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

Output

The tool generates a .designrules file containing:

  • Design token documentation
  • Component specifications
  • Layout structures
  • AI-generated pseudo-code
  • Style references
  • Accessibility considerations

Contributing

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.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

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