feat(docs): read this guide one section at a time - #41
Open
clementcopper wants to merge 1 commit into
Open
Conversation
CLAUDE.md is ~10,200 tokens. An agent that follows "read the guide first" pays that on every session, even when the task needs one 930-token section — and it is by far the largest fixed cost in a figma-cli session, since the commands themselves return 40-500 tokens each. `figma-cli docs` lists the 19 topics with their token cost; `figma-cli docs <topic>` prints one. Matching is ranked (exact slug, whole word, substring, heading text) and reports ambiguity instead of guessing: "token" names both Design Tokens and Token Hygiene, so it lists both. Section text goes to stdout so it pipes; listings and errors to stderr. Splitting and matching are pure functions in src/lib/doc-sections.js with 10 unit tests. The guide is found by convention (docs/FIGMA-USAGE.md, then CLAUDE.md), overridable with --file, so a checkout that keeps a short CLAUDE.md for repo instructions still works. Measured against the full guide (~10,283 tok): jsx-syntax + critical-pitfalls 1,850 tok -82% key-rules + quick-reference 3,317 tok -68% motion 932 tok -91% deterministic-validation 722 tok -93% Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
clementcopper
added a commit
to clementcopper/figma-claude
that referenced
this pull request
Sep 3, 2026
Seven branches became one on 2026-09-03. The skill's first line still said the default was v2, and it is the file you read right before merging from upstream. What the cleanup was based on: `feat/swift-host` was v2 plus 26 commits with v2 fully contained, the only tree difference being `swift-host/`, and `app/` sitting in both. The Electron app is a directory, not a branch — `make-app.sh` reads `app/build/icon.icns` — so a second branch beside the trunk would have been a copy of the same CLI falling behind. v2 had stood still since 22.08. `v2` and `archive/draft-v1` are now the tags `v2-final` and `draft-v1`. The four PR branches stay on origin because deleting them there closes PRs silships#40, silships#41, silships#43 and silships#44; that is written down so nobody tidies them away later. Also noted: CI triggers on `branches: [main]`, which this fork has never had, so it has never run on a push here. Left alone. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QuvZuDad3hi3CVwNDbTvr2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Where the tokens actually go
The README makes the case that figma-cli costs an agent far fewer tokens than an API-based MCP. Measuring a session end to end, the commands hold up their side — but the guide dominates everything:
CLAUDE.md(the guide)REFERENCE.mdcanvas info/var list/findverify(PNG on disk, not base64)So the per-command work is already lean, and
verifywriting the PNG to disk instead of inlining base64 was the right call. What's left is the guide: an agent pays ~10k tokens up front even when the task is "render one frame" and it needs the JSX section and nothing else.The change
figma-cli docs <topic>prints one##section.figma-cli docslists what's available with each topic's cost:Measured against reading the whole guide:
jsx-syntax+critical-pitfallskey-rules+quick-referencemotiondeterministic-validationBehavioural details:
jsx,jsx-syntaxandrenderall reach the JSX section.docs tokenmatches both Design Tokens and Token Hygiene, so it lists both and exits 1 rather than silently picking one.figma-cli docs jsx-syntax > /tmp/jsx.mdworks.--file <path>overrides the guide location; without it the command looks fordocs/FIGMA-USAGE.mdfirst, thenCLAUDE.md, so a checkout that keeps a shortCLAUDE.mdfor repo instructions still works.Two bullets in the guide point at it: one in Token Hygiene, one in Other Commands.
Implementation
Splitting and matching are pure functions in
src/lib/doc-sections.js, following thebrowserDebugArgs/connect-planpattern, with 10 unit tests intests/doc-sections.test.js— no disk access, no Figma.src/commands/docs.jsonly does I/O, andsrc/lib/command-map.jsgains the two lines the lazy loader needs (tests/lazy-command-map.test.jsenforces that).npm test→ 531 passing.Notes
###subsections deliberately stay inside their parent topic — they're detail of that topic, not topics of their own. If you'd rather have deeper granularity, or different topic names than the auto-slugs, both are a small change.