Conversation
Consolidates packages/linter into packages/cli as a single @google/design.md package with two entry points: a CLI binary and a programmatic linter API. Adds four commands: lint, diff, export (--format tailwind|dtcg), and spec. Implements W3C DTCG token export with Terrazzo conformance testing. Decomposes linter into pluggable rule modules. Renames Diagnostic→Finding across the public API. Includes 24-check packaging verification script.
xkxx
approved these changes
Apr 13, 2026
|
|
||
| **Typography:** `headline-display`, `headline-lg`, `headline-md`, `body-lg`, `body-md`, `body-sm`, `label-lg`, `label-md`, `label-sm` | ||
|
|
||
| **Spacing:** `unit`, `gutter`, `margin`, `xs`, `sm`, `md`, `lg`, `xl` |
Contributor
There was a problem hiding this comment.
I don't know if I'm ready to make recommendations for spacing yet, we need more testing.
Collaborator
Author
There was a problem hiding this comment.
On review, I agree. I'll address this in the follow up.
| # Recommended Token Names (Non-Normative) | ||
|
|
||
| The following names are commonly used across design systems. They are not required but are provided as guidance for consistency. | ||
|
|
Contributor
There was a problem hiding this comment.
Also add recommended color naming here?
Collaborator
Author
There was a problem hiding this comment.
Good call. I'll also address this in the follow up.
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.
The PR introduces a CLI package to be published as
@google/design.mdand specification changes for precision and extensibility.Specification changes (
docs/spec.md)Generated from source
The spec is no longer hand-edited. It's now generated from
spec.mdx+spec-config.yamlvia a compiler, and the output carries a header comment:This means that values like supported units, section order, typography properties, and component sub-tokens are defined once in
spec-config.yamland compiled into the spec. The linter also reads from this same config, so the spec and the tooling read from the same source of truth to prevent drift across changes.New sections
Recommended Token Names (Non-Normative)
This section provides suggested names for typography (
headline-display,body-md,label-sm, etc.), spacing (unit,gutter,xs–xl), and rounded (none,sm–full) tokens. These are recommendations, not requirements. They give agents and humans a shared vocabulary without mandating it.Consumer Behavior for Unknown Content
A table specifying what a compliant consumer (agent or tool) should do when it encounters content not defined by the spec. For example: unknown section headings should be preserved without error, unknown color token names should be accepted if the value is valid hex, but duplicate section headings should be rejected. This section is written to support forward compatibility, as it tells consumers how to be lenient in the right ways.
Schema changes
version: <string>(optional, current:"alpha")<Dimension><Dimension | number>(allows unitless values like column counts)backgroundColor,textColor,typography,rounded,paddingsize,height,widthtoken-name,level<token-name>,<scale-level>(angle-bracket notation)Section changes
{path.to.token}reference syntax." Added explicit front matter parsing rules.{typography.label-md}), while other sections require primitive references.gutter-s,gutter-l) to 8 (base,xs–xl,gutter,margin).Units
emwas added as a supported unit alongsidepxandrem. This is relevant forletterSpacingvalues (e.g.,-0.02em) which are conventionally relative to font size. Unit-less values such as'1.6' | 1.6were also added to supportlineHeightconventions.The CLI
The CLI is built for agents and humans. It allows the consumer to linit, diff, and export to W3C DTCG and Tailwind formats.
This PR collapses everything into a single
@google/design.mdpackage with a clear contract: every command writes structured JSON to stdout, errors are closed-enum objects on stderr, and exit codes are meaningful. The goal is a CLI that an LLM can call as a tool without any prompt engineering beyond "here's the--helpoutput."One package, two entry points
Everything now lives under
packages/cliand ships as@google/design.mdwith:@google/design.md— The CLI binary (npx @google/design.md <command>)@google/design.md/linter— The programmatic API (import { lint } from '@google/design.md/linter')Both entry points are bundled separately by Bun (
dist/index.jsanddist/linter/index.js) so consumers who only need the library don't pull in the CLI framework.Four CLI commands
lint <file>{ findings, summary }diff <before> <after>{ tokens, findings, regression }export --format <fmt> <file>specEvery command reads from a file path or stdin (
-), outputs JSON by default, and uses exit code1for errors.Pluggable lint rules
The monolithic linter was decomposed into individual rule modules, each a pure function
(DesignSystemState) → Finding[]:{section.token}referencesprimaryRules are registered via
RuleDescriptorobjects that carry metadata (name, severity, description), making them self-documenting for thespec --rulesoutput.W3C DTCG token export
The
exportcommand now supports--format dtcg, producing atokens.jsonfile compliant with the W3C Design Tokens Format Module (2025.10). The mapping:{ value, unit }objectsA conformance test pipes the DTCG output into Terrazzo (
@terrazzo/cli) and verifies it produces valid CSS. This ensures our output stays compatible with the real-world DTCG ecosystem, not just our own schema.Self-documenting specification
The
speccommand bundles and serves the DESIGN.md format specification itself. The spec is authored as MDX (spec.mdx) with a YAML config file (spec-config.yaml) as the single source of truth for version, supported units, section order, typography properties, and component sub-tokens. A compiler evaluates the MDX expressions against the config to produce the finalspec.md.This means an agent can run
npx @google/design.md spec --format jsonand get the entire format specification in its context window, including what rules are active.Terminology: Diagnostic → Finding
The public API previously used
Diagnostic(a term overloaded with IDE and compiler meanings). This PR renames it toFindingacross the entire public surface — types, fields, and variable names. The internal model layer retainsDiagnosticwhere it represents parser-level concerns, but everything a consumer touches saysFinding.Structure
The data flows in one direction: raw markdown → parsed AST → resolved model → findings + emitted output. Each layer is a stateless handler that takes input and returns a result, with no shared mutable state.
Packaging and verification
The
check-package.tsscript runs 24 checks across 4 phases to catch packaging bugs before they reach consumers:--help, andspeccommand all run successfully against the builtdist/