@directededges/specs-cli

中文文档
0.36.0发布于 2026/10/30MITTypeScriptES Module近 30 天下载 2万

Command-line interface for Spectacular design system operations

原始使用文档
文档目录20 节
  1. The ecosystem
  2. Why computation over inference?
  3. Schema: what Specs record
  4. Decision records
  5. Setting up a workspace
  6. Commands
  7. Whole workspace
  8. Setup
  9. Data in
  10. Specs out
  11. Code out
  12. Analysis
  13. Versioning
  14. Figma, Storybook, and visual testing
  15. The Figma plugin
  16. Documentation
  17. Further reading
  18. Free and Pro
  19. Issues
  20. Licensing

Spectacular

Spectacular turns a Figma component into a compact, schema-valid specification — and then turns that specification into working code, Figma canvas documentation, analysis reports, and a versioned record of how the component changed. A Figma plugin and a command-line interface produce the same output, from the same schema.

Evaluating styles and layers across variants is a differencing problem, not a judgment call, so a script does it in about a second per component for zero AI tokens. What a spec deliberately leaves out — behavior, accessibility nuance, motion, naming taste — is where agents and engineers are good, and that work happens downstream against a record they can trust.

The record is the point. When Figma, agents, engineers, and CI all read from the same spec, change stops being a handoff and starts being a sync.

Open the plugin · Set up the CLI · Explore the schema · Docs

Background reading: Components as data · Spec-driven UI component development

The ecosystem

The CLI installs some dependencies and the private transform packages for you (but not storybook, you do that); the plugin compiles specs-from-figma and figma-from-specs from source.

SurfaceWhat it isWhere it lives
SpectacularFigma plugin — specs on canvas, spec data on the documentFigma Community
@directededges/specs-cli18 commands running the ecosystem plus source for analysis, versions, css, storybook, testingpackages/cli/
@directededges/specs-schemaThe contract — TypeScript types and JSON Schemapackages/schema/
Documentation site~150 pagesSource in site/
@directededges/specs-from-figmaTransform Figma → spec, with Plugin API and REST runtimesPrivate, published to npm
@directededges/react-from-specsTransform spec → ReactPrivate, published to npm
@directededges/webcomponents-from-specsTransform spec → Web Components (Lit)Private, published to npm
@directededges/figma-from-specsTransform spec → Figma canvasPrivate, published to npm
from-specsShared spec-reading core for the emittersPrivate, never published

Why computation over inference?

SpectacularAgentic Figma extraction
Speed~1 sec (CLI) / ~10 sec (plugin) per component~5–10 minutes per component
AI costScripted — 0 tokens per component25/50/100,000+ tokens per component
RepeatabilityDeterministic and mechanicalInference errors, gaps, and overconfidence
OutputSchema-valid YAML/MD, ready for testing and versioningUnstructured Markdown, unpredictable to verify
PlatformsSchema-based and cross-platformGuessing your intents

Schema: what Specs record

@directededges/specs-schema is the contract. TypeScript types and JSON Schema describe the same structure at all times, the package carries no logic, and both the CLI and the Figma plugin consume it rather than defining their own shapes. One spec accounts for every layer and property of a component, consistently across its variants.

npm install @directededges/specs-schema
PartTypesPro
ComponentComponent, Variant, Variants, Metadata, RunMetadata, concern documents
AnatomyAnatomy, AnatomyElement, ElementTypeRef, RoleConceptName, ActionEntry
PropsProps, BooleanProp, StringProp, EnumProp, SlotProp, NumberProp, PropConfigurations
ElementsElement, Elements, ElementType, ElementExtensions
LayoutLayout, LayoutNode, Sides, Corners, Position, ItemSpacing
StylingStyles, Style, ColorStyle, Typography, Effects, GradientValue, TokenReferenceTokenReference
ImagesImageValue, ImageData, ImageProp, ImageBinding, ObjectFit
SlotsChildren, SlotBinding, SlotContent, SlotContentRef, Compositionall
BindingsPropBinding, Conditional, ConditionExpressionPropBinding
SubcomponentsSubcomponent, Subcomponents, SubcomponentSourceall
Instance examplesInstanceExample, InstanceExamplesall
AssetsGlyphStructure, GlyphStructureNode
ConventionsConventions, PlatformConventions, SpecsConventions, ValueConvention
SettingsSettings, ResolvedSettings, ColorFormat, SourceEntry

Exports are type-only but for two runtime constants, DEFAULT_CONVENTIONS and DEFAULT_SETTINGS. JSON Schema ships five addressable subpaths — component, concern, metadata, conventions, settings — alongside the TypeScript types. Every type has a page under Schema, and CONSTITUTION.md governs what may change and how.

Further reading: Component contracts and schemas.

Decision records

Schema changes are proposed and tracked through Architecture Decision Records in adr/. Each one records the context, the options considered, and the decision; accepted ADRs publish to the docs site automatically.

Contributions are welcome. Clone the repo, run npm install at the root, and use npm run build and npm test to validate changes. All packages use Vitest with globals enabled. This repo ships Claude Code skills for the full ADR lifecycle:

SkillPurpose
/specs.adr.createDraft a new ADR, claim the next number, and reserve it in the index
/specs.adr.implementApply an ADR's type and schema changes to types, schema, tests, and changelog
/specs.adr.acceptValidate the implementation, mark the ADR accepted, and update the index

Setting up a workspace

Two paths to the same workspace. Neither is a lesser version of the other — the CLI is a command-line tool first, and the agent path drives those same commands.

Command by command, following Getting Started:

npm install -g @directededges/specs-cli
specs init       # write config/conventions/<platform>.yaml and config/settings.yaml
# add your Figma file key to config/settings.yaml, and FIGMA_TOKEN to .env
specs fetch      # pull the file, variables, and styles
specs scan       # write the manifest, then tick the components you want
specs build      # generate, analyze, emit every platform, publish Storybook — once

The first build emits every platform, because nothing has said otherwise yet. The trees it creates are then the standing answer: delete webcomponents/ and later runs stop emitting there. Naming steps explicitly — --only react — also counts as saying otherwise.

With an agent, three steps:

npm install -g @directededges/specs-cli
specs skills install    # writes the procedures into .claude/skills/

Then tell Claude Code:

Follow the specs-cli.workspace.setup skill to set up a Spectacular workspace here.

It handles install, config, token setup, fetch, curation, the first build, and a running Storybook — stopping twice: once for which components to spec, once for which of the icon, state and role passes to run. The only prerequisites are Node 20.19+, a Figma file URL, and a Figma personal access token.

Commands

Two commands do everything in order. The rest are the steps they run, and each reads what the one before it wrote.

data/ ──► data/<alias>.manifest.md ──► specs/ ──┬──► react/src/
  ▲              ▲                               ├──► webcomponents/src/
  │              │                               └──► storybook/content/
specs fetch    you tick the boxes

Exp marks an experimental command — usable, but its flags and output may still change.

Whole workspace

CommandWhat it doesTier
specs buildBring the workspace up to date once, then exit with the chain's code — the CI shapeFreeExp
specs runThe same, then watch specs, data, and config and redo only what a change affectsFreeExp

Setup

CommandWhat it doesTier
specs initWrite config/conventions/<platform>.yaml and config/settings.yaml with production defaultsFree
specs skills installInstall the premerge and release orchestration skills into .claude/skills/Free
specs migrateConvert an older workspace layout to the current oneFree

Data in

CommandWhat it doesTier
specs fetchDownload raw REST payloads — file, variables, styles — for every configured Figma sourceFree
specs scanDiscover components and write a manifest you curate by ticking boxesFree
specs applyCustomTokensInject $custom token objects from a mapping file into fetched dataFree
specs cacheBuild the lookup tables render resolves specs againstFreeExp

Specs out

CommandWhat it doesTier
specs generateGenerate specs from fetched data, a curated manifest, or the live Figma selection with --from-bridgeFree + Pro

This is the one command a license changes. Free output carries full component structure; Pro output adds token references, prop and visibility bindings, composition, and invalid variant combinations.

Further reading: Figma component specs on command.

Code out

CommandWhat it doesTier
specs reactEmit the React target into react/Free + ProExp
specs webcomponentsEmit the Web Components (Lit) target into webcomponents/Free + ProExp

Both targets write the same five artifacts, documented one page each under Code: the contract, the scaffold, the stylesheet, its CSS variables, and Storybook stories. Behavior comes from role concepts declared in the spec rather than from per-component code.

Further reading: Generating code from specs.

Analysis

CommandWhat it doesTier
specs analyzeRun analyzers over the spec tree and write aggregate reports to analysis/FreeExp
  • props — every prop across the library, and which components share one
  • styling — token and raw-value usage across the spec tree
  • dependencies — what composes what, and the blast radius of a change
  • keys — naming consistency across properties and elements
  • roles — which role concepts are declared, and where they are missing

Versioning

CommandWhat it doesTier
specs versionVersion the spec workspace: diff, history, cut, tag, restore, figmapremerge, reportFreeExp

Versioning classifies a workspace diff, cuts a version folder, writes ledger entries, and produces an itemized changelog — including a pre-merge report for a Figma branch before anyone merges it.

Figma, Storybook, and visual testing

CommandWhat it doesTier
specs bridgestart, stop, status for the local bridge that reaches a running pluginFreeExp
specs renderSend a spec back into Figma and build the component on canvasFreeExp
specs storybookinit, dev, publish — a portable Storybook over the emitted treesFreeExp
specs testing visualPixel-diff the Storybook render against Figma exports, in eight explicit stagesFreeExp

render closes the loop: a spec authored or edited outside Figma becomes a real component on the canvas. See Render to Figma, Storybook, and Testing.

The Figma plugin

Spectacular selects a component or component set, draws a visual specification onto the canvas, and caches the machine-readable spec data on the document — ready to copy into an LLM or read over the bridge.

Six output sections are drawn on canvas: Anatomy, Props, styling inventory, Modes, Layout, and Data. Seven panes control them:

  • Specs — every spec already generated in the document, to re-run, inspect, or copy as YAML or JSON.
  • Create — generate a spec from the current selection, with progress as it goes.
  • Canvas Output — control the spec frames drawn on the canvas.
  • Settings — sections, format, detail level, props, variants, elements, examples, foundations, layout and multi-column layout, and custom styling.
  • Bridge — an opt-in local WebSocket on port 9001 that lets the CLI read the current selection, or build a component from a spec.
  • Account — license activation and tier state.
  • About — version and links.

Figma best practices covers what the plugin expects of a well-built library.

Documentation

spectacular.systems is authoritative for how Spectacular is intended to work; this repository is authoritative for what the code does.

  • Command line — overview, workflows, and one page per command with its flags
  • Schema — one page per type, plus the deep style, typography, and effects property trees
  • Figma — plugin output sections and formatting
  • Code — what specs react and specs webcomponents emit, artifact by artifact
  • Storybook — the portable Storybook over the emitted trees
  • Versioning — change classification, history, identity, reports
  • Guides — 19 how-tos for specific features, from variant layering to code-only props
  • Settings — one page per convention and setting
  • Roles — role concepts, inventory, and precedence
  • Releases — merged schema and CLI changelogs

The site's Decision Records section is generated from adr/ at build time, so an accepted ADR publishes itself.

Further reading

Free and Pro

Everything is usable free. Nothing is time-limited, watermarked, or withheld — a free spec is a complete, valid spec, and a free React component renders. Pro connects a component to your token system, its other components, and every state it can be in.

FreePro adds
DataComponent structure, variant evaluation, metadataToken and style references, prop bindings, invalid combinations
Figma canvas outputEvery output section, multi-column layout, all settingsCustom styling, the Examples settings, the Bridge pane
CodeThe component, its contract, its stylesheet, one story per variant axisComposition, glyphs, background images, compound stories, sticker sheets

Pro is $10/month. Purchase a license, or read Licensing for keys, metering, and the full gating detail.

Issues

Check the existing issues before opening a new one. For a bug, include:

  • Figma version and operating system
  • Steps to reproduce
  • Expected versus actual behavior
  • Screenshots, if they help

For a feature request, include a clear description, the use case, and any relevant mockups.

Questions are welcome in the Slack community.

Licensing

PackageLicense
packages/schema/CC BY 4.0
packages/cli/MIT

When extending or reusing the schema, credit Nathan Curtis, link to this repository and to the license, and indicate any modifications you made.

"This project uses the Spectacular UI Component Schema by Nathan Curtis of Directed Edges, licensed under CC BY 4.0."


Disclaimer: This is an independent project and is not officially affiliated with Figma Inc.

版本与发布记录

@directededges/specs-cli 共发布 36 个版本,首次发布于 2026/04/06;过去 12 个月发布了 36 个版本。

版本发布日期距今
0.36.0latest2026/10/3013 天前
0.35.02026/10/2221 天前
0.34.02026/10/2122 天前
0.33.02026/10/2023 天前
0.32.02026/10/1428 天前
0.31.02026/09/231 个月前

关于 @directededges/specs-cli 的常见问题

@directededges/specs-cli 是什么?

Command-line interface for Spectacular design system operations

如何安装 @directededges/specs-cli?

在项目目录运行 npm install @directededges/specs-cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 specs,可以用 npx specs 直接运行。

@directededges/specs-cli 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@directededges/specs-cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@directededges/specs-cli 可以商用吗?

@directededges/specs-cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@directededges/specs-cli 的下载量有多少?

根据 npm 官方下载统计,@directededges/specs-cli 在 2026/10/13 – 2026/11/11 这 30 天内被下载 20,125 次,日均约 671 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@directededges/specs-cli 还在维护吗?

最新版本 0.36.0 发布于 2026/10/30(13 天前);至今共发布 36 个版本,其中过去 12 个月发布了 36 个;首次发布于 2026/04/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。