Skip to content

Commit 9fdcfc7

Browse files
auge2uclaude
andcommitted
feat: add diagnose-tokens standalone command
9-step read-only diagnostic for token installations: package version, CSS entry point, :root completeness, dark mode block, circular var() refs, strategy alignment, semantic pairing, contrast ratios, typography loading. Outputs PASS/FAIL/WARN per check. Was listed in plugin.json since v0.4.1 but command file never created. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a92ac26 commit 9fdcfc7

1 file changed

Lines changed: 179 additions & 0 deletions

File tree

commands/diagnose-tokens.md

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# diagnose-tokens — Token Installation Diagnostic
2+
3+
> Standalone command · No frame dependency
4+
> Read-only — does not modify any files
5+
6+
---
7+
8+
## What this command does
9+
10+
Runs a 9-step diagnostic on an existing design token installation to detect
11+
silent failures. Outputs `[PASS]`, `[FAIL]`, or `[WARN]` per check with
12+
specific fix instructions.
13+
14+
Use this when tokens appear installed but styling is broken, dark mode doesn't
15+
work, or Tailwind utilities don't resolve to theme values.
16+
17+
---
18+
19+
## Prerequisites
20+
21+
- Project must have a CSS entry point (e.g. `src/styles/app.css`)
22+
- Tailwind CSS v3 or v4 must be installed
23+
24+
---
25+
26+
## Diagnostic Steps
27+
28+
Run each check in order. Report results in a summary table at the end.
29+
30+
### Step 1: Package Version
31+
32+
Check if `@syncupsuite/themes` is installed and which version.
33+
34+
```bash
35+
# Check package.json or node_modules
36+
cat node_modules/@syncupsuite/themes/package.json | grep version
37+
```
38+
39+
- `[PASS]` if >= 0.2.2
40+
- `[WARN]` if < 0.2.2 (pre-security-audit version — upgrade recommended)
41+
- `[FAIL]` if not installed
42+
43+
### Step 2: CSS Entry Point
44+
45+
Locate the main CSS file and verify it imports a theme.
46+
47+
Look for an `@import` of `@syncupsuite/themes/*/tailwind.css` or a local
48+
`tokens/core.css` file.
49+
50+
- `[PASS]` if theme import found
51+
- `[FAIL]` if no token/theme import in CSS entry point
52+
53+
### Step 3: `:root` Completeness
54+
55+
Verify all required CSS custom properties are defined in `:root`.
56+
57+
**Required semantic tokens** (minimum set):
58+
- `--color-primary`, `--color-accent`, `--color-background`, `--color-surface`
59+
- `--color-text`, `--color-text-secondary`, `--color-text-muted`
60+
- `--color-border`, `--color-error`, `--color-success`, `--color-warning`
61+
- `--font-family-sans`, `--font-family-mono`
62+
- `--radius-sm`, `--radius-md`, `--radius-lg`
63+
64+
- `[PASS]` if all present
65+
- `[FAIL]` if any missing — list which ones
66+
67+
> This is the #1 silent failure mode. Tailwind utilities resolve to empty
68+
> values when `:root` properties are missing.
69+
70+
### Step 4: Dark Mode Block
71+
72+
Check that a dark mode block exists and has 1:1 parity with `:root` color tokens.
73+
74+
- For Tailwind v4 / class strategy: look for `[data-theme="dark"]` or `.dark` selector
75+
- For Tailwind v3 / media strategy: look for `@media (prefers-color-scheme: dark)`
76+
77+
- `[PASS]` if dark block exists with matching token count
78+
- `[WARN]` if dark block exists but has fewer tokens than `:root`
79+
- `[FAIL]` if no dark mode block found
80+
81+
### Step 5: Circular `var()` References
82+
83+
Scan CSS for self-referential custom properties that would silently resolve to
84+
the initial value (usually empty).
85+
86+
```
87+
BAD: --color-primary: var(--color-primary); /* in :root — circular */
88+
OK: --color-primary: var(--color-primary); /* in @theme — Tailwind v4 registration pattern */
89+
```
90+
91+
- `[PASS]` if no circular references in `:root` or dark mode blocks
92+
- `[FAIL]` if circular reference found — list which properties
93+
94+
> Note: Self-referential `var()` inside a Tailwind v4 `@theme` block is the
95+
> correct registration pattern, not a bug.
96+
97+
### Step 6: Strategy Alignment
98+
99+
Verify the dark mode strategy in CSS matches the Tailwind configuration.
100+
101+
| Tailwind Version | Expected Strategy | CSS Selector |
102+
|-----------------|-------------------|-------------|
103+
| v4 (CSS-first) | `class` (default) | `[data-theme="dark"]` or `.dark` |
104+
| v3 (config) | Check `darkMode` in `tailwind.config.*` | Matches config value |
105+
106+
- `[PASS]` if CSS selector matches Tailwind strategy
107+
- `[FAIL]` if mismatch (e.g. CSS uses `@media` but Tailwind expects `class`)
108+
109+
### Step 7: Semantic Pairing
110+
111+
Verify that text colors have sufficient contrast against their intended
112+
background colors by checking the token pairs exist:
113+
114+
| Foreground | Background |
115+
|-----------|-----------|
116+
| `--color-text` | `--color-background` |
117+
| `--color-text-secondary` | `--color-background` |
118+
| `--color-text-muted` | `--color-background` |
119+
| `--color-text` | `--color-surface` |
120+
121+
- `[PASS]` if all pairs have both tokens defined
122+
- `[WARN]` if surface-level pairs are missing
123+
124+
### Step 8: Contrast Ratios
125+
126+
For each semantic pair from Step 7, compute the WCAG 2.1 contrast ratio.
127+
128+
- `[PASS]` if all text pairs >= 4.5:1 (AA normal text)
129+
- `[WARN]` if any pair is between 3:1 and 4.5:1 (AA large text only)
130+
- `[FAIL]` if any pair < 3:1
131+
132+
> If token values use OKLCH or HSL, convert to sRGB for contrast calculation.
133+
134+
### Step 9: Typography Loading
135+
136+
Check that `--font-family-sans` and `--font-family-mono` reference fonts that
137+
are actually loaded (via `@font-face`, Google Fonts import, or system font stack).
138+
139+
- `[PASS]` if font families resolve to loaded fonts or system stacks
140+
- `[WARN]` if custom font referenced but no `@font-face` or import found
141+
142+
---
143+
144+
## Output Format
145+
146+
After running all checks, output a summary table:
147+
148+
```
149+
Token Installation Diagnostic
150+
==============================
151+
152+
Step 1: Package version [PASS] @syncupsuite/themes@0.2.2
153+
Step 2: CSS entry point [PASS] src/styles/app.css imports tailwind.css
154+
Step 3: :root completeness [FAIL] Missing: --color-warning, --radius-lg
155+
Step 4: Dark mode block [WARN] 14/17 tokens have dark equivalents
156+
Step 5: Circular var() [PASS] No circular references
157+
Step 6: Strategy alignment [PASS] class strategy, [data-theme="dark"] selector
158+
Step 7: Semantic pairing [PASS] All pairs defined
159+
Step 8: Contrast ratios [PASS] All pairs >= 4.5:1
160+
Step 9: Typography loading [WARN] "Inter" referenced but no @font-face found
161+
162+
Result: 7 PASS · 2 WARN · 1 FAIL
163+
```
164+
165+
For each `[FAIL]` or `[WARN]`, provide a specific fix instruction immediately
166+
below the summary.
167+
168+
---
169+
170+
## Routing
171+
172+
This is a standalone diagnostic. It reads the following skill for token
173+
architecture context:
174+
175+
| Resource | Path |
176+
|----------|------|
177+
| Token skill | `skills/theme-inspired-tokens/skill.md` |
178+
| Token schema | `skills/theme-inspired-tokens/references/token-schema.md` |
179+
| Scaffold CSS | `scaffold/greenfield/base/src/styles/` |

0 commit comments

Comments
 (0)