# silships/figma-cli architecture

> Architecture diagram of the GitHub repository silships/figma-cli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/silships/figma-cli
- Repository: https://github.com/silships/figma-cli

## Overview

figma-cli is a local command-line product that lets an AI assistant operate on editable Figma Desktop documents. Its principal workflow is a user request routed through the CLI and its shared connection layer to Figma; setup supports patched Desktop, browser, and safe-plugin modes. Major capabilities also include token and code import, design extraction, component generation, accessibility checks, and FigJam operations. Relationships for unsampled command subsystems are kept conservative; the graph uses README statements and the provided source index where available.

Main entry points: [`src/commands`](https://github.com/silships/figma-cli/tree/main/src/commands) (Command handlers), [`src/index.js`](https://github.com/silships/figma-cli/blob/main/src/index.js) (CLI entry), [`src/lib/cli-core.js`](https://github.com/silships/figma-cli/blob/main/src/lib/cli-core.js) (CLI core), [`src/figma-client.js`](https://github.com/silships/figma-cli/blob/main/src/figma-client.js) (Figma CDP client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI workflow"]
  node_cli["CLI entry<br/>[index.js]"]
  node_commands["Command handlers"]
  node_core["CLI core<br/>[cli-core.js]"]
end

subgraph group_connect["Figma connectivity"]
  node_daemon["Local daemon<br/>[daemon.js]"]
  node_figma["Figma CDP client<br/>[figma-client.js]"]
  node_figjam["FigJam CDP client<br/>[figjam-client.js]"]
  node_patch["Desktop patch<br/>[figma-patch.js]"]
  node_platform["Platform support<br/>[platform.js]"]
end

subgraph group_design["Design capabilities"]
  node_tokens["Token management<br/>[tokens.js]"]
  node_codeimport["Code import<br/>[index.js]"]
  node_importparsers["Import parsers"]
  node_designextract["Design extraction<br/>[design-extract.js]"]
  node_designmd["Design.md format<br/>[design-md.js]"]
  node_components["Component generation<br/>[shadcn.js]"]
  node_blocks["Block templates<br/>[dashboard-01.js]"]
  node_a11y["Accessibility checks<br/>[a11y.js]"]
  node_figjamops["FigJam operations<br/>[figjam.js]"]
  node_analysis["Design analysis"]
end

subgraph group_integrations["Optional integrations"]
  node_safeplugin["Safe-mode plugin<br/>[code.js]"]
  node_voice["Voice plugin<br/>[index.js]"]
end

node_user(("User / assistant"))
node_desktop(("Figma Desktop"))

node_user -->|"requests design"| node_cli
node_cli -->|"routes commands"| node_commands
node_commands -->|"uses CLI services"| node_core
node_core -->|"connects via CDP"| node_figma
node_figma -->|"evaluates in"| node_desktop
node_commands -->|"configures connection"| node_patch
node_patch -->|"gets platform paths"| node_platform
node_commands -->|"imports design sources"| node_codeimport
node_codeimport -->|"dispatches parsing"| node_importparsers
node_commands -.->|"manages variables"| node_tokens
node_commands -.->|"extracts designs"| node_designextract
node_designextract -->|"exports format"| node_designmd
node_commands -.->|"generates components"| node_components
node_commands -.->|"creates blocks"| node_blocks
node_commands -.->|"checks accessibility"| node_a11y
node_commands -.->|"edits FigJam"| node_figjamops
node_commands -.->|"analyzes designs"| node_analysis
node_safeplugin -->|"runs in"| node_desktop
node_voice -.->|"invokes CLI"| node_commands

click node_cli "https://github.com/silships/figma-cli/blob/main/src/index.js"
click node_commands "https://github.com/silships/figma-cli/tree/main/src/commands"
click node_core "https://github.com/silships/figma-cli/blob/main/src/lib/cli-core.js"
click node_daemon "https://github.com/silships/figma-cli/blob/main/src/daemon.js"
click node_figma "https://github.com/silships/figma-cli/blob/main/src/figma-client.js"
click node_figjam "https://github.com/silships/figma-cli/blob/main/src/figjam-client.js"
click node_patch "https://github.com/silships/figma-cli/blob/main/src/figma-patch.js"
click node_platform "https://github.com/silships/figma-cli/blob/main/src/platform.js"
click node_safeplugin "https://github.com/silships/figma-cli/blob/main/plugin/code.js"
click node_tokens "https://github.com/silships/figma-cli/blob/main/src/commands/tokens.js"
click node_codeimport "https://github.com/silships/figma-cli/blob/main/src/code-import/index.js"
click node_importparsers "https://github.com/silships/figma-cli/tree/main/src/code-import"
click node_designextract "https://github.com/silships/figma-cli/blob/main/src/design-extract.js"
click node_designmd "https://github.com/silships/figma-cli/blob/main/src/design-md.js"
click node_components "https://github.com/silships/figma-cli/blob/main/src/shadcn.js"
click node_blocks "https://github.com/silships/figma-cli/blob/main/src/blocks/dashboard-01.js"
click node_a11y "https://github.com/silships/figma-cli/blob/main/src/commands/a11y.js"
click node_figjamops "https://github.com/silships/figma-cli/blob/main/src/commands/figjam.js"
click node_analysis "https://github.com/silships/figma-cli/blob/main/src/gradient-extractor.js"
click node_voice "https://github.com/silships/figma-cli/blob/main/plugins/voice/index.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_commands,node_core,node_user toneBlue
class node_daemon,node_figma,node_figjam,node_patch,node_platform toneAmber
class node_tokens,node_codeimport,node_importparsers,node_designextract,node_designmd,node_components,node_blocks,node_a11y,node_figjamops,node_analysis toneMint
class node_safeplugin,node_voice toneRose
class node_desktop toneIndigo
```

## Components

### CLI workflow

- [CLI entry](https://github.com/silships/figma-cli/blob/main/src/index.js): `src/index.js`
- [Command handlers](https://github.com/silships/figma-cli/tree/main/src/commands): `src/commands`
- [CLI core](https://github.com/silships/figma-cli/blob/main/src/lib/cli-core.js): `src/lib/cli-core.js`

### Figma connectivity

- [Local daemon](https://github.com/silships/figma-cli/blob/main/src/daemon.js): `src/daemon.js`
- [Figma CDP client](https://github.com/silships/figma-cli/blob/main/src/figma-client.js): `src/figma-client.js`
- [FigJam CDP client](https://github.com/silships/figma-cli/blob/main/src/figjam-client.js): `src/figjam-client.js`
- [Desktop patch](https://github.com/silships/figma-cli/blob/main/src/figma-patch.js): `src/figma-patch.js`
- [Platform support](https://github.com/silships/figma-cli/blob/main/src/platform.js): `src/platform.js`

### Design capabilities

- [Token management](https://github.com/silships/figma-cli/blob/main/src/commands/tokens.js): `src/commands/tokens.js`
- [Code import](https://github.com/silships/figma-cli/blob/main/src/code-import/index.js): `src/code-import/index.js`
- [Import parsers](https://github.com/silships/figma-cli/tree/main/src/code-import): `src/code-import`
- [Design extraction](https://github.com/silships/figma-cli/blob/main/src/design-extract.js): `src/design-extract.js`
- [Design.md format](https://github.com/silships/figma-cli/blob/main/src/design-md.js): `src/design-md.js`
- [Component generation](https://github.com/silships/figma-cli/blob/main/src/shadcn.js): `src/shadcn.js`
- [Block templates](https://github.com/silships/figma-cli/blob/main/src/blocks/dashboard-01.js): `src/blocks/dashboard-01.js`
- [Accessibility checks](https://github.com/silships/figma-cli/blob/main/src/commands/a11y.js): `src/commands/a11y.js`
- [FigJam operations](https://github.com/silships/figma-cli/blob/main/src/commands/figjam.js): `src/commands/figjam.js`
- [Design analysis](https://github.com/silships/figma-cli/blob/main/src/gradient-extractor.js): `src/gradient-extractor.js`

### Optional integrations

- [Safe-mode plugin](https://github.com/silships/figma-cli/blob/main/plugin/code.js): `plugin/code.js`
- [Voice plugin](https://github.com/silships/figma-cli/blob/main/plugins/voice/index.js): `plugins/voice/index.js`

### Other components

- **User / assistant**
- **Figma Desktop**

## Connections

- User / assistant → CLI entry: requests design
- CLI entry → Command handlers: routes commands (evidence: `src/index.js`)
- Command handlers → CLI core: uses CLI services (evidence: `src/commands/tokens.js`)
- CLI core → Figma CDP client: connects via CDP (evidence: `src/lib/cli-core.js`)
- Figma CDP client → Figma Desktop: evaluates in
- Command handlers → Desktop patch: configures connection (evidence: `src/commands/setup.js`)
- Desktop patch → Platform support: gets platform paths (evidence: `src/figma-patch.js`)
- Command handlers → Code import: imports design sources (evidence: `src/commands/setup.js`)
- Code import → Import parsers: dispatches parsing (evidence: `src/code-import/index.js`)
- Command handlers → Token management: manages variables
- Command handlers → Design extraction: extracts designs
- Design extraction → Design.md format: exports format (evidence: `src/design-extract.js`)
- Command handlers → Component generation: generates components (evidence: `src/commands/variants.js`)
- Command handlers → Block templates: creates blocks (evidence: `src/commands/misc.js`)
- Command handlers → Accessibility checks: checks accessibility
- Command handlers → FigJam operations: edits FigJam
- Command handlers → Design analysis: analyzes designs
- Safe-mode plugin → Figma Desktop: runs in
- Voice plugin → Command handlers: invokes CLI (evidence: `plugins/voice/index.js`)
