|
| 1 | +--- |
| 2 | +title: Recommended Improvements |
| 3 | +--- |
| 4 | + |
| 5 | +# Recommended Improvements |
| 6 | + |
| 7 | +This document lists high-impact improvements to make Variables Contract feel and function like a mature technical standard (spec + schema + conformance + reference tooling). It is intentionally concrete: what to add, why it matters, and what to do next. |
| 8 | + |
| 9 | +## Executive summary |
| 10 | + |
| 11 | +You already have strong standards signals: |
| 12 | + |
| 13 | +- Deterministic spec language |
| 14 | +- Governance sections (change control, versioning, validation) |
| 15 | +- Conformance criteria + technical tests |
| 16 | +- JSON Schema v1 published as a static artifact (`/assets/schema/v1.json`) |
| 17 | +- Standards-style top-of-page metadata |
| 18 | +- License posture with explicit conformance and AI laundering restrictions |
| 19 | + |
| 20 | +The main gap is that most of the tooling is described but not shipped. The next step for maximum authority is to publish a small reference toolchain (validator + normalizers + minimal export pipeline) and back it with test vectors. |
| 21 | + |
| 22 | +## P0 (Highest impact) |
| 23 | + |
| 24 | +### 1. Ship a reference validator (CLI + library) |
| 25 | + |
| 26 | +**Goal:** Make conformance enforceable, not just documented. |
| 27 | + |
| 28 | +**What to add:** |
| 29 | + |
| 30 | +- `packages/validator/` (or `src/` if you want to stay single-package) |
| 31 | +- `@variables-contract/validator` (library) |
| 32 | +- `@variables-contract/cli` (CLI) |
| 33 | + |
| 34 | +**Minimum features (v0):** |
| 35 | + |
| 36 | +- Schema validation with Ajv using `assets/schema/v1.json` |
| 37 | +- Canonical reference syntax enforcement (`{path.to.variable}` in contract files) |
| 38 | +- Reference resolution across the document |
| 39 | +- Circular reference detection |
| 40 | +- Mode key consistency checks |
| 41 | +- Group `$ref` resolution checks + circular group ref detection |
| 42 | + |
| 43 | +**Why it matters:** |
| 44 | + |
| 45 | +- Hiring managers and standards-minded engineers immediately respect a validator. |
| 46 | +- It creates a pass/fail line for “compatibility” claims. |
| 47 | +- It turns your conformance tests into executable criteria. |
| 48 | + |
| 49 | +### 2. Add test vectors as a conformance suite |
| 50 | + |
| 51 | +**Goal:** Make conformance testable by third parties. |
| 52 | + |
| 53 | +**What to add:** |
| 54 | + |
| 55 | +- `tests/fixtures/valid/*.json` |
| 56 | +- `tests/fixtures/invalid/*.json` |
| 57 | +- `tests/fixtures/edge/*.json` |
| 58 | + |
| 59 | +Each fixture should include: |
| 60 | + |
| 61 | +- What it is testing |
| 62 | +- Expected errors (for invalid fixtures) |
| 63 | + |
| 64 | +**Why it matters:** |
| 65 | + |
| 66 | +- Standards bodies publish test suites. |
| 67 | +- It reduces ambiguity and prevents “vibe interpretations.” |
| 68 | + |
| 69 | +### 3. Remove the duplicate schema source or make it explicit |
| 70 | + |
| 71 | +Right now you have: |
| 72 | + |
| 73 | +- `assets/schema/v1.json` (served) |
| 74 | +- `docs/schema/v1.json` (not served, and easy to confuse) |
| 75 | + |
| 76 | +**Recommendation:** |
| 77 | + |
| 78 | +- Keep only one authoritative schema file (served from `assets/`) and remove or clearly label the other. |
| 79 | + |
| 80 | +**Why it matters:** |
| 81 | + |
| 82 | +- Single source of truth prevents downstream ecosystem confusion. |
| 83 | + |
| 84 | +## P1 (High impact) |
| 85 | + |
| 86 | +### 4. Make adapters real code, not only documentation |
| 87 | + |
| 88 | +You already document adapters well (`docs/adapters/*`). Next step is to ship reference implementations. |
| 89 | + |
| 90 | +**What to add:** |
| 91 | + |
| 92 | +- `packages/adapters/figma/` (normalize Figma export JSON) |
| 93 | +- `packages/adapters/tokens-studio/` (mostly validate + preserve metadata) |
| 94 | +- Minimal shared helpers: |
| 95 | + - reference syntax conversion |
| 96 | + - metadata relocation into `$extensions` |
| 97 | + - naming normalization utilities |
| 98 | + |
| 99 | +**CLI UX suggestion:** |
| 100 | + |
| 101 | +- `variables-contract normalize figma --in figma-export.json --out variables.json` |
| 102 | +- `variables-contract normalize tokens-studio --in export.json --out variables.json` |
| 103 | + |
| 104 | +**Why it matters:** |
| 105 | + |
| 106 | +- “Adapters with confidence” means you publish the canonical adapter behavior. |
| 107 | +- This is how you stop fragmentation. |
| 108 | + |
| 109 | +### 5. Add more adapters (highest ROI) |
| 110 | + |
| 111 | +If you want to expand the adapter surface area, the best additions are ones that are widely used and generate lots of broken exports: |
| 112 | + |
| 113 | +**Input adapters (normalize into contract):** |
| 114 | + |
| 115 | +- Figma REST API format (separate from “Dev Mode export”) if it differs |
| 116 | +- Style Dictionary legacy token formats (many orgs still have these) |
| 117 | +- Supernova export format (common in enterprise) |
| 118 | + |
| 119 | +**Output adapters (generate platforms):** |
| 120 | + |
| 121 | +- CSS variables (direct, without Style Dictionary) for a minimal reference output |
| 122 | +- TypeScript types + runtime accessors |
| 123 | +- Tailwind CSS v4 (`@theme`) generator (already documented; ship generator) |
| 124 | + |
| 125 | +**Why it matters:** |
| 126 | + |
| 127 | +- More inputs increases adoption. |
| 128 | +- More outputs makes the spec immediately useful. |
| 129 | + |
| 130 | +### 6. CI: add an actual workflow that runs the validator |
| 131 | + |
| 132 | +You have CI/CD documentation, but there is only a deploy workflow. |
| 133 | + |
| 134 | +**What to add:** |
| 135 | + |
| 136 | +- `.github/workflows/validate.yml` |
| 137 | + - run schema + custom validation on every PR touching `tokens/**/*.json` and `examples/**/*.json` |
| 138 | + |
| 139 | +**Why it matters:** |
| 140 | + |
| 141 | +- “Governed standard” means changes are blocked by automated checks. |
| 142 | + |
| 143 | +## P2 (Standards-body polish) |
| 144 | + |
| 145 | +### 7. Version single source of truth and auto-sync |
| 146 | + |
| 147 | +Right now the version is hardcoded in multiple places: |
| 148 | + |
| 149 | +- `package.json` (`0.3.7`) |
| 150 | +- `README.md` (Version: 0.3.7) |
| 151 | +- `docs/index.md` (Version row) |
| 152 | + |
| 153 | +**Recommendation:** Keep `package.json` as the single source of truth and add an explicit sync step. |
| 154 | + |
| 155 | +**Best practical approach (no `pnpm version` required):** |
| 156 | + |
| 157 | +- Add `scripts/sync-version.mjs` that: |
| 158 | + - reads `package.json.version` |
| 159 | + - updates: |
| 160 | + - `docs/index.md` version row |
| 161 | + - `README.md` version line |
| 162 | + - optionally validates that they match (fail CI if not) |
| 163 | + |
| 164 | +Add scripts: |
| 165 | + |
| 166 | +- `pnpm run version:sync` |
| 167 | +- `pnpm run version:check` |
| 168 | + |
| 169 | +**Why this is better than auto-magic on build:** |
| 170 | + |
| 171 | +- Build steps that mutate tracked files are easy to forget and cause dirty git state. |
| 172 | +- Explicit version sync is predictable and standards-friendly. |
| 173 | + |
| 174 | +### 8. Rename “Draft Standard” semantics into a proper status model |
| 175 | + |
| 176 | +Consider a status taxonomy that reads like a spec body: |
| 177 | + |
| 178 | +- Draft |
| 179 | +- Candidate Standard |
| 180 | +- Stable |
| 181 | +- Deprecated |
| 182 | + |
| 183 | +Then define what those mean (change control thresholds, compatibility promises). |
| 184 | + |
| 185 | +### 9. Publish a “Status of this Document” page |
| 186 | + |
| 187 | +W3C-style structure: |
| 188 | + |
| 189 | +- Status of this Document (SOTD) |
| 190 | +- Patent policy (if relevant) |
| 191 | +- How to file issues |
| 192 | +- Editors and acknowledgments |
| 193 | + |
| 194 | +You already have most parts; a single canonical SOTD page consolidates it. |
| 195 | + |
| 196 | +## Spec depth improvements (content) |
| 197 | + |
| 198 | +### 10. Add a formal glossary for “Base / Alias / Component” and show invariants |
| 199 | + |
| 200 | +You already define anatomy, but the standards move is to explicitly state invariants: |
| 201 | + |
| 202 | +- Base variables may be literals |
| 203 | +- Alias variables should be references |
| 204 | +- Component variables should reference alias layer |
| 205 | +- Flattening is non-conformant |
| 206 | + |
| 207 | +### 11. Expand group extension semantics |
| 208 | + |
| 209 | +`docs/contract/groups.md` is good. Next depth add: |
| 210 | + |
| 211 | +- Merge precedence rules (explicit) |
| 212 | +- What happens on conflict (variable overrides) |
| 213 | +- Prohibit `$ref` + `$type`/`$value` (already implied; can make explicit) |
| 214 | + |
| 215 | +### 12. Add a section for canonical file layout |
| 216 | + |
| 217 | +People will ask “how should I lay out tokens in a repo?” |
| 218 | + |
| 219 | +- Suggested folder layout |
| 220 | +- Suggested grouping strategy |
| 221 | +- Example multi-brand / multi-theme tree |
| 222 | + |
| 223 | +## Website authority improvements |
| 224 | + |
| 225 | +### 13. Add a conformance registry page |
| 226 | + |
| 227 | +Create `docs/reference/implementations.md`: |
| 228 | + |
| 229 | +- Conformant implementations (with version tested) |
| 230 | +- Compatible implementations |
| 231 | +- Known non-conformant (optional, if you want to keep it calm) |
| 232 | + |
| 233 | +This is extremely “standards body.” |
| 234 | + |
| 235 | +### 14. Make schema discoverable in multiple places |
| 236 | + |
| 237 | +Already good. Ensure: |
| 238 | + |
| 239 | +- `docs/schema/index.md` links to `/assets/schema/v1.json` |
| 240 | +- homepage references the correct URL |
| 241 | +- license references the correct URL |
| 242 | + |
| 243 | +## Notes on licensing posture |
| 244 | + |
| 245 | +Your current approach (recognized base license + integrity addendum) is an aggressive standards move. |
| 246 | + |
| 247 | +Two practical recommendations: |
| 248 | + |
| 249 | +- Add a one-paragraph section to `docs/license.md` explaining intended audience: |
| 250 | + |
| 251 | + - Adoption is welcome |
| 252 | + - Forking the spec text into competing standards is not |
| 253 | + - False compatibility claims are treated as a violation |
| 254 | + |
| 255 | +- If you ever need to harden enforceability, the next real-world step is trademark registration for the name. |
| 256 | + |
| 257 | +## Proposed roadmap |
| 258 | + |
| 259 | +- **v0.3.x:** validator + fixtures + CI validation workflow |
| 260 | +- **v0.4.x:** reference adapters (figma + tokens studio) as code |
| 261 | +- **v0.5.x:** reference output generators (css + ts + tailwind) |
| 262 | +- **v1.0.0:** formal SOTD, conformance registry, stabilized schema |
| 263 | + |
| 264 | +## Specific cleanup tasks |
| 265 | + |
| 266 | +- Remove or clearly label `docs/schema/v1.json` to avoid ambiguity |
| 267 | +- Update `docs/schema/index.md` raw GitHub link if you move schema source of truth |
| 268 | +- Add a link to the Change Log in homepage or navigation if you want more “spec body” feel |
| 269 | + |
| 270 | +END |
0 commit comments