8000 GitHub - tastolini/figma-cli Β· GitHub
[go: up one dir, main page]

Skip to content
tastoliniPublic
forked from silships/figma-cli

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Β 
Β 

Latest commit

Β 

History

135 Commits

Folders and files

8000
NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

figma-ds-cli

Into Design Systems Figma Desktop No API Key Claude Code

Control Figma Desktop with Claude Code.
Full read/write access. No API key required.
Just talk to Claude about your designs.

  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—       β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—       β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—     β–ˆβ–ˆβ•—
  β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β• β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—      β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•      β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘
  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘
  β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β•šβ•β•β•β•β•β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β•šβ•β•β•β•β–ˆβ–ˆβ•‘β•šβ•β•β•β•β•β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘
  β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘      β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘      β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘
  β•šβ•β•     β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β•     β•šβ•β•β•šβ•β•  β•šβ•β•      β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β•β•       β•šβ•β•β•β•β•β•β•šβ•β•β•β•β•β•β•β•šβ•β•

What is This?

A CLI that connects directly to Figma Desktop and gives you complete control:

  • Design Tokens β€” Create variables, collections, modes (Light/Dark), bind to nodes
  • Create Anything β€” Frames, text, shapes, icons (150k+ from Iconify), components
  • Team Libraries β€” Import and use components, styles, variables from any library
  • Analyze Designs β€” Colors, typography, spacing, find repeated patterns
  • Lint & Accessibility β€” Contrast checker, touch targets, design rules
  • Export β€” PNG, SVG, JSX, Storybook stories, CSS variables, Tailwind config
  • Batch Operations β€” Rename layers, find/replace text, create 100 variables at once
  • Works with Claude Code β€” Just ask in natural language, Claude knows all commands

Why This CLI?

This project includes a CLAUDE.md file that Claude reads automatically. It contains:

  • All available commands and their syntax
  • Best practices (e.g., "use render for text-heavy designs")
  • Common requests mapped to solutions

Want to teach Claude new tricks? Just update CLAUDE.md. No code changes needed.

Example: You type "Create Tailwind colors" β†’ Claude already knows to run node src/index.js tokens tailwind because it's documented in CLAUDE.md.


What You Need

  • Figma Desktop (free account works)
  • Claude Code (get it here)
  • Node.js (v18 or later)

Setup

1. Start Claude Code

Open Terminal and type:

claude

2. Install & Connect

Just say:

Help me install https://github.com/silships/figma-cli

Then:

Initiate project

Claude asks which connection mode:

  • Yolo Mode (Recommended) β€” Fully automatic, secure random port
  • Safe Mode β€” For corporate/restricted environments

Done! Now just talk to Claude about your designs.


Using It

Once connected, just talk to Claude:

"Create Tailwind colors"

"Add a card component"

"Check accessibility"

"Export variables as CSS"

The included CLAUDE.md teaches Claude all commands automatically. No manual required.

Safe Mode users: Start the FigCli plugin each time you open Figma.

Two Connection Modes

πŸš€ Yolo Mode (Recommended)

What it does: Patches Figma once to enable a debug port, then connects directly.

Pros:

  • Fully automatic (no manual steps after setup)
  • Slightly faster execution
  • Secure: random port (9222-9322) per session, localhost only

Cons:

  • Requires one-time Figma patch
  • Needs Full Disk Access on macOS (one-time)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      WebSocket (CDP)      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     CLI     β”‚ ◄───────────────────────► β”‚   Figma     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    localhost:random port  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
node src/index.js connect

πŸ”’ Safe Mode β€” For Restricted Environments

What it does: Uses a Figma plugin to communicate. No Figma modification needed.

Pros:

  • No patching, no app modification
  • Works everywhere (corporate, personal, any environment)
  • No Full Disk Access needed

Cons:

  • Start plugin manually each session (2 clicks)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     WebSocket     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     Plugin API     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     CLI     β”‚ ◄───────────────► β”‚   Daemon    β”‚ ◄────────────────► β”‚   Plugin    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   localhost:3456  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Step 1: Start Safe Mode

node src/index.js connect --safe

Step 2: Import plugin (one-time only)

  1. In Figma: Plugins β†’ Development β†’ Import plugin from manifest
  2. Select plugin/manifest.json from this project
  3. Click Open

Step 3: Start the plugin (each session)

  1. In Figma: Plugins β†’ Development β†’ FigCli
  2. Terminal shows: Plugin connected!

Tip: Right-click the plugin β†’ Add to toolbar for quick access.


Which Mode Should I Use?

Situation Recommended Mode
First time user Yolo Mode
Personal Mac Yolo Mode
Corporate laptop Safe Mode
Permission errors with Yolo Safe Mode
Can't modify apps Safe Mode

Troubleshooting

Permission Error When Patching (macOS)

If you see EPERM: operation not permitted, open '.../app.asar':

1. Grant Full Disk Access to Terminal

macOS blocks file access without this permission, even with sudo.

  1. Open System Settings β†’ Privacy & Security β†’ Full Disk Access
  2. Click the + button
  3. Add Terminal (or iTerm, VS Code, Warp, etc.)
  4. Restart Terminal completely (quit and reopen)

2. Make sure Figma is completely closed

# Check if Figma is still running
ps aux | grep -i figma

# Force quit if needed
killall Figma

3. Run connect again

node src/index.js connect

If still failing, try with sudo: sudo node src/index.js connect

4. Manual patch (last resort)

If nothing works, you can patch manually:

# Backup original
sudo cp /Applications/Figma.app/Contents/Resources/app.asar ~/app.asar.backup

# The patch changes one string in the file
# From: removeSwitch("remote-debugging-port")
# To:   removeSwitch("remote-debugXing-port")

# Use a hex editor or this command:
sudo sed -i '' 's/remote-debugging-port/remote-debugXing-port/g' /Applications/Figma.app/Contents/Resources/app.asar

# Re-sign the app
sudo codesign --force --deep --sign - /Applications/Figma.app

Windows Permission Error

Run Command Prompt or PowerShell as Administrator, then run node src/index.js connect.

Figma Not Connecting

  1. Make sure Figma Desktop is running (not the web version)
  2. Open a design file in Figma (not just the home screen)
  3. Restart connection: node src/index.js connect

Full Feature List

Design Tokens & Variables

  • Create complete design systems (colors, spacing, typography, radii)
  • Create Tailwind CSS color palettes (all 22 color families, 50-950 shades)
  • Create and manage variable collections
  • Variable modes (Light/Dark/Mobile) with per-mode values
  • Batch create up to 100 variables at once
  • Batch update variable values across modes
  • Bind variables to node properties (fill, stroke, gap, padding, radius)
  • Export variables as CSS custom properties
  • Export variables as Tailwind config

Create Elements

  • Frames with auto-layout
  • Rectangles, circles, ellipses
  • Text with custom fonts, sizes, weights
  • Lines
  • Icons (150,000+ from Iconify: Lucide, Material Design, Heroicons, etc.)
  • Groups
  • Components from frames
  • Component instances
  • Component sets with variants

Modify Elements

  • Change fill and stroke colors
  • Set corner radius
  • Resize and move
  • Apply auto-layout (row/column, gap, padding)
  • Set sizing mode (hug/fill/fixed)
  • Rename nodes
  • Duplicate nodes
  • Delete nodes
  • Flip nodes (horizontal/vertical)
  • Scale vectors

Find & Select

  • Find nodes by name
  • Find nodes by type (FRAME, COMPONENT, TEXT, etc.)
  • XPath-like queries (//FRAME[@width > 300])
  • Select nodes by ID
  • Get node properties
  • Get node tree structure

Canvas Operations

  • List all nodes on canvas
  • Arrange frames in grid or column
  • Delete all nodes
  • Zoom to fit content
  • Smart positioning (auto-place without overlaps)

Export

  • Export nodes as PNG (with scale factor)
  • Export nodes as SVG
  • Export multiple sizes (@1x, @2x, @3x)
  • Take screenshots
  • Export to JSX (React code)
  • Export to Storybook stories
  • Export variables as CSS
  • Export variables as Tailwind config

FigJam Support

  • Create sticky notes
  • Create shapes with text
  • Connect elements with arrows
  • List FigJam elements
  • Run JavaScript in FigJam context

Team Libraries

  • List available library variable collections
  • Import variables from libraries
  • Import components from libraries
  • Create instances of library components
  • Import and apply library styles (color, text, effect)
  • Bind library variables to node properties
  • Swap component instances to different library components
  • List all enabled libraries

Designer Utilities

  • Batch rename layers (with patterns: {n}, {name}, {type})
  • Case conversion (camelCase, PascalCase, snake_case, kebab-case)
  • Lorem ipsum generator (words, sentences, paragraphs)
  • Fill text with placeholder content
  • Insert images from URL
  • Unsplash integration (random stock photos by keyword)
  • Contrast checker (WCAG AA/AAA compliance)
  • Check text contrast against background
  • Find and replace text across all layers
  • Select same (fill, stroke, font, size)
  • Color blindness simulation (deuteranopia, protanopia, tritanopia)

Query & Analysis

  • Analyze colors β€” usage frequency, variable bindings
  • Analyze typography β€” all font combinations used
  • Analyze spacing β€” gap/padding values, grid compliance
  • Find clusters β€” detect repeated patterns (potential components)
  • Visual diff β€” compare two nodes
  • Create diff patch β€” structural patches between versions

Lint & Accessibility

  • Design linting with 8+ rules:
    • no-default-names β€” detect unnamed layers
    • no-deeply-nested β€” flag excessive nesting
    • no-empty-frames β€” find empty frames
    • prefer-auto-layout β€” suggest auto-layout
    • no-hardcoded-colors β€” check variable usage
    • color-contrast β€” WCAG AA/AAA compliance
    • touch-target-size β€” minimum 44x44 check
    • min-text-size β€” minimum 12px text
  • Accessibility snapshot β€” extract interactive elements tree

Component Variants

  • Create component sets with variants
  • Add variant properties
  • Combine frames into component sets
  • Organize variants into grid with labels
  • Auto-generate component sets from similar frames

Component Documentation

  • Add descriptions to components (supports markdown)
  • Document with template (usage, props, notes)
  • Read component descriptions

CSS Grid Layout

  • Set up grid layout with columns and rows
  • Configure column/row gaps
  • Auto-reorganize children into grid

Console & Debugging

  • Capture console logs from Figma
  • Execute code with log capture
  • Reload page
  • Navigate to files

Advanced

  • Execute any Figma Plugin API code directly
  • Render complex UI from JSX-like syntax
  • Full programmatic control over Figma
  • Match vectors to Iconify icons

Not Supported (requires REST API)

  • Comments (read/write/delete) β€” requires Figma API key
  • Version history
  • Team/project management

Author

Sil BormΓΌller β€” intodesignsystems.com

Powered By

This CLI is built on top of figma-use by dannote β€” an excellent Figma CLI with JSX rendering, XPath queries, design linting, and much more.

We use figma-use for:

  • JSX rendering (render command)
  • Node operations (node tree, node to-component, etc.)
  • Design analysis (analyze colors, analyze typography)
  • Design linting (lint)
  • And many other features

Big thanks to dannote for figma-use!

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0