Skip to main content

figma-cli

Headless Figma CLI for AI coding agents and automated design inspection.

Requires Python 3.11 or newer. Licensed under MIT.

Commands

The package installs two console scripts that run the same entrypoint:

  • figma-cli
  • figma (short alias)

Each reports its own name in --help and --version:

$ figma-cli --version
figma-cli 0.1.0
$ figma --version
figma 0.1.0

The npm package silships/figma-cli also installs a figma-cli executable. If both are installed, whichever directory comes first on PATH wins. Run command -v figma-cli to check which one you get, or use the figma alias.

Usage

Every command talks to the Figma REST API with a personal access token. Create one under Figma account settings and export it:

export FIGMA_TOKEN=figd_...
export FIGMA_API_BASE=https://api.figma.com   # optional, this is the default

Every subcommand prints human-readable text by default and a JSON document on stdout with --json.

Command Figma endpoint
figma auth check GET /v1/me
figma file get <file_key> [--depth N] GET /v1/files/{file_key}?depth=N
figma export <file_key> --nodes <ids> [--format png|svg] [--output DIR] GET /v1/images/{file_key}, then the asset URLs
figma comment list <file_key> GET /v1/files/{file_key}/comments
figma comment post <file_key> --message TEXT [--comment-id ID] [--node-id ID] POST /v1/files/{file_key}/comments
figma comment delete <file_key> <comment_id> DELETE /v1/files/{file_key}/comments/{comment_id}

The file key is the segment after /design/ (or /file/) in a Figma URL. Node ids use the 1:2 form; a URL shows them as node-id=1-2.

Examples

Check the token:

$ figma auth check --json
{
  "id": "123456789",
  "handle": "Design Bot",
  "email": "bot@example.com"
}

Inspect only the pages of a file. --depth is passed to Figma, so the server trims the tree before it is sent:

figma file get AbCdEf123 --depth 1
figma file get AbCdEf123 --depth 2 --json | jq '.document.children[].name'

Render two frames to PNG and print where they were written. Files are named <file_key>_<node_id>.<format> with : and other unsafe characters replaced by -; re-exporting the same node overwrites its file:

$ figma export AbCdEf123 --nodes 1:2,1:3 --output shots
shots/AbCdEf123_1-2.png
shots/AbCdEf123_1-3.png

Post a comment pinned to a frame, reply to it, list the thread, then clean up:

id=$(figma comment post AbCdEf123 --message "Spacing is off" --node-id 1:2 --json | jq -r .id)
figma comment post AbCdEf123 --message "Fixed in the next build" --comment-id "$id"
figma comment list AbCdEf123
figma comment delete AbCdEf123 "$id"

Errors and exit codes

Exit code Meaning
0 Success
2 Usage error (bad or missing arguments)
3 Figma API, network, or local write failure

With --json, a failure prints a JSON object on stdout; without it, a one-line message goes to stderr. HTTP 401, 403, 404 and 5xx become unauthorized, forbidden, not_found and server_error:

{"error": "forbidden", "status": 403, "message": "Invalid token"}

HTTP 429 is reported at once, never retried, so the caller decides when to try again. retry_after comes from the Retry-After header and is null when Figma sends none:

{"error": "rate_limit_exceeded", "status": 429, "retry_after": 30}

Token safety

A request carrying X-Figma-Token follows no redirects. Any 3xx answer is refused with {"error": "redirect_refused"} and exit code 3 before a second request is made, so the token never reaches another host. Exported images are downloaded from the pre-signed URLs Figma returns with a separate request that carries no token; only that request follows redirects.

Installation and quick run

Run on-demand without installing via uv:

uvx figma-cli --help
uvx figma-cli auth check --json

Or install from PyPI:

pip install figma-cli

From a local checkout:

uvx --from . figma-cli --version

Development

python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"
ruff check .
ruff format --check .
pytest tests/

The tests are hermetic: no network access and no Figma token are needed. The redirect tests use real sockets on 127.0.0.1.

tests/test_live.py runs against the real API only when FIGMA_TOKEN and FIGMA_TEST_FILE_KEY are set (add FIGMA_TEST_NODE_ID to exercise export). It posts one comment and deletes it. CI runs it in the live job from the FIGMA_TOKEN secret and the FIGMA_TEST_FILE_KEY / FIGMA_TEST_NODE_ID repository variables, and skips it when they are absent.

Release

Bump __version__ in src/figma_cli/__init__.py, merge, then push a matching tag (v0.1.0 for 0.1.0). The release workflow refuses a tag that does not match __version__, builds the sdist and wheel, runs twine check, and publishes to PyPI through trusted publishing (OIDC, the pypi environment).

License

MIT, see LICENSE.

Metadata

Release files for figma-cli 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for figma-cli 0.2.0
File Size Uploaded
figma_cli-0.2.0.tar.gz 14.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for figma-cli 0.2.0
File Interpreter ABI Platform
figma_cli-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.2 kB

Release files / figma_cli-0.2.0.tar.gz

Download URL figma_cli-0.2.0.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2d3a7fa320680c58b741280d15dbbb04a8ca0a0ded14b5133812cb0045d10940
BLAKE2b-256 checksum
How to use checksums
b92f01173a90c1bec1306f52a6d3c045f21ce8231246ee13045394e192d61889
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / figma_cli-0.2.0-py3-none-any.whl

Download URL figma_cli-0.2.0-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74f3e09159daa456cb88f40cc8c7cb02bafa6919f0a8aa62db1cb83a89678059
BLAKE2b-256 checksum
How to use checksums
6c9f455fbe588731244eefd21b7774249f95452dc5e9125b4174ad1705f2b970
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page