StyleSeed Synthesis: Cognitive Grammar, Token Canon DAG & Spatial Rhythm Guard
Enforce Cognitive Job Output Grammars, 4-Tier Token Layering (Primitive -> Semantic -> Spatial/Type -> Component), 6-Role Spatial Rhythm Hierarchy, and S1 Multi-Screen Longitudinal Drift bounds across AI-generated UI systems.
Why This Skill Is Needed & Target State
Standard aesthetic linters apply one monolithic standard to every interface, ignoring the user's cognitive job:
- In an Operations Console (
operations-console), large decorative margins, hero cards, and oversized pill buttons are visual slop; 100% information density, tabular rows, compact monospace readouts, and immediate alert triage are essential.
- In Editorial Reading (
editorial-reading), dense dashboards and noisy badges are slop; typographic hierarchy, optical baselines, and generous margins are essential.
- In Technical Instruments (
technical-instrument), rounded cartoon buttons and gradient borders are slop; deterministic controls, explicit units, and zero layout shift are essential.
Furthermore, AI models generate Token Spaghetti and Spatial Slop:
- Primitive Token Leakage: Hardcoded hex codes (
#2563EB) or raw primitives (colors.blue.600) directly injected into leaf components, bypassing semantic themes.
- Circular and Upward Aliasing: Primitives referencing primitives or semantic tokens aliasing component tokens.
- Contrast Deficits: Defining
primary without verifying mathematical contrast against primaryForeground across 11 canonical pairs.
- Spatial Inversion Anomalies: Elements inside a card (
stackGap) spaced further apart than the gap between independent sections (sectionGap).
- S1 Fifth-Screen Longitudinal Drift: Diverging across screens 2..N away from baseline Screen 1 geometry, radii, and color.
- Decision Amnesia: Re-inventing button heights and tokens across sessions without an auditable decisions/exceptions ledger.
The target state is a mathematically anchored, job-calibrated, token-layered design system with zero primitive leakage, strict spatial hierarchy, bounded longitudinal drift, and immutable invariants.
The Non-Negotiable Invariants
- Anti-Leakage Token DAG (No Primitive Leakage in Components): Component code (
.tsx, .jsx, .vue, .svelte, .css) must NEVER consume Tier 1 primitive literals or colors directly. Components consume Tier 2 Semantic tokens or Tier 4 Component tokens only.
- Pairwise Contrast Gates (11 Deterministic Pairs): Semantic token pairs must satisfy WCAG 2.2 AA contrast ratios ($4.5:1$ for foreground/background/chrome/status pairs, $3.0:1$ for focus rings against surfaces).
- Spatial Rhythm Hierarchy (No Inversion Anomalies): Inner sibling spacing (
stackGap) must never exceed outer group spacing (groupGap) or section spacing (sectionGap):
$$\text{stackGap} \le \text{groupGap} \le \text{sectionGap} \le \text{pageInset}$$
- Exceptions Cannot Waive Invariants: A project decisions ledger (
.anti-slop/design-decisions.json or .styleseed/project.json) may grant scoped exceptions to default craft rules, but no exception can ever waive an invariant (INV-*). Invariant waiver attempts fail closed.
- S1 Longitudinal Drift Bound ($S_1 \le 0.25$): Screens 2..N must not drift from baseline Screen 1 by more than $\Delta S_1 = 0.25$ across color, border radius, typography, and control heights.
Mathematical Formulation
1. S1 Longitudinal Multi-Screen Drift Metric ($\Delta S_1$)
$$\Delta S_1 = \omega_c \cdot \Delta E(c_1, c_i) + \omega_r \cdot \frac{|r_1 - r_i|}{24} + \omega_f \cdot \delta_f(f_1, f_i) + \omega_h \cdot \frac{|h_1 - h_i|}{20}$$
Where:
- $\omega_c = 0.40, \omega_r = 0.20, \omega_f = 0.20, \omega_h = 0.20$
- $\Delta E(c_1, c_i)$ is normalized Euclidean color distance in sRGB / OKLab space.
- $r_1, r_i$ are observed border radii in pixels.
- $\delta_f$ is typographic font divergence ($0.0$ if matching family, $0.5$ if mismatched).
- $h_1, h_i$ are observed control heights in pixels.
2. Relative Luminance & Pairwise Contrast ($C_r$)
$$L = 0.2126 R_{\text{lin}} + 0.7152 G_{\text{lin}} + 0.0722 B_{\text{lin}}$$
$$C_r = \frac{L_{\text{lighter}} + 0.05}{L_{\text{darker}} + 0.05} \ge 4.5:1$$
4-Tier Token Layering Architecture
Tier 1: Primitives [ #0F172A, #2563EB, 8px, 16px, 24px ]
│ (alias only)
▼
Tier 2: Semantics [ bg-surface, fg-default, border-subtle, primary, accent ]
│ (alias only)
▼
Tier 3: Spatial & Type [ pageInset, sectionGap, stackGap, display, body, mono ]
│ (alias only)
▼
Tier 4: Components [ button-primary-bg, card-elevation-border, input-height ]
CLI Usage
# Scan repository for StyleSeed token leakage and spatial slop
bunx anti-slop-engineering styleseed --scan src/
# Audit against a specific tokens file and output grammar
bunx anti-slop-engineering styleseed --scan src/ --tokens tokens.json --grammar operations-console
# Validate spatial rhythm contract and decisions ledger
bunx anti-slop-engineering styleseed --spacing spacing.json --decisions decisions.json --strict
# Calculate S1 multi-screen drift index from probe measurements
bunx anti-slop-engineering styleseed --screens screens.json --json
# Inter-agent TOON protocol payload for get-fable / Poteto handoff
bunx anti-slop-engineering styleseed --scan src/ --toon
Inter-Agent Handoff Contract (TOON Protocol)
When passing StyleSeed audit results between autonomous subagents, emit the formal TOON block:
styleseed-audit[v1.0.0]:
verdict: PROCEED
grammar: operations-console (density: compact)
token-layers: { primitive: 32, semantic: 18, contrast-deficits: 0, leakage: 0 }
spatial-rhythm: { roles: 6, inversions: 0, ad-hoc: 0 }
s1-drift: { status: ANCHORED, max-dist: 0.04 }
decisions-ledger: { decisions: 3, approved-exceptions: 1, invalid-exceptions: 0 }
findings-count: [0]
1---2name: styleseed-guard3description: Enforce StyleSeed Cognitive Job Output Grammars, 4-tier token canon DAG, 18-role semantic graph completeness, 11 pairwise contrast gates, 6-role spatial rhythm hierarchy, and S1 multi-screen longitudinal drift bounds.4license: MIT5metadata:6 source: https://skillmd.com/skills/immamdouhaboammar/styleseed-guard7 version: "1.0.0"8 parent: anti-slop-engineering9---1011# StyleSeed Synthesis: Cognitive Grammar, Token Canon DAG & Spatial Rhythm Guard1213> Enforce Cognitive Job Output Grammars, 4-Tier Token Layering (Primitive -> Semantic -> Spatial/Type -> Component), 6-Role Spatial Rhythm Hierarchy, and S1 Multi-Screen Longitudinal Drift bounds across AI-generated UI systems.1415## Why This Skill Is Needed & Target State1617Standard aesthetic linters apply one monolithic standard to every interface, ignoring the **user's cognitive job**:18- In an **Operations Console** (`operations-console`), large decorative margins, hero cards, and oversized pill buttons are visual slop; 100% information density, tabular rows, compact monospace readouts, and immediate alert triage are essential.19- In **Editorial Reading** (`editorial-reading`), dense dashboards and noisy badges are slop; typographic hierarchy, optical baselines, and generous margins are essential.20- In **Technical Instruments** (`technical-instrument`), rounded cartoon buttons and gradient borders are slop; deterministic controls, explicit units, and zero layout shift are essential.2122Furthermore, AI models generate **Token Spaghetti** and **Spatial Slop**:231. **Primitive Token Leakage:** Hardcoded hex codes (`#2563EB`) or raw primitives (`colors.blue.600`) directly injected into leaf components, bypassing semantic themes.242. **Circular and Upward Aliasing:** Primitives referencing primitives or semantic tokens aliasing component tokens.253. **Contrast Deficits:** Defining `primary` without verifying mathematical contrast against `primaryForeground` across 11 canonical pairs.264. **Spatial Inversion Anomalies:** Elements inside a card (`stackGap`) spaced further apart than the gap between independent sections (`sectionGap`).275. **S1 Fifth-Screen Longitudinal Drift:** Diverging across screens 2..N away from baseline Screen 1 geometry, radii, and color.286. **Decision Amnesia:** Re-inventing button heights and tokens across sessions without an auditable decisions/exceptions ledger.2930The target state is a mathematically anchored, job-calibrated, token-layered design system with zero primitive leakage, strict spatial hierarchy, bounded longitudinal drift, and immutable invariants.3132---3334## The Non-Negotiable Invariants35361. **Anti-Leakage Token DAG (No Primitive Leakage in Components):** Component code (`.tsx`, `.jsx`, `.vue`, `.svelte`, `.css`) must NEVER consume Tier 1 primitive literals or colors directly. Components consume Tier 2 Semantic tokens or Tier 4 Component tokens only.372. **Pairwise Contrast Gates (11 Deterministic Pairs):** Semantic token pairs must satisfy WCAG 2.2 AA contrast ratios ($4.5:1$ for foreground/background/chrome/status pairs, $3.0:1$ for focus rings against surfaces).383. **Spatial Rhythm Hierarchy (No Inversion Anomalies):** Inner sibling spacing (`stackGap`) must never exceed outer group spacing (`groupGap`) or section spacing (`sectionGap`):39 $$\text{stackGap} \le \text{groupGap} \le \text{sectionGap} \le \text{pageInset}$$404. **Exceptions Cannot Waive Invariants:** A project decisions ledger (`.anti-slop/design-decisions.json` or `.styleseed/project.json`) may grant scoped exceptions to `default` craft rules, but **no exception can ever waive an invariant (`INV-*`)**. Invariant waiver attempts fail closed.415. **S1 Longitudinal Drift Bound ($S_1 \le 0.25$):** Screens 2..N must not drift from baseline Screen 1 by more than $\Delta S_1 = 0.25$ across color, border radius, typography, and control heights.4243---4445## Mathematical Formulation4647### 1. S1 Longitudinal Multi-Screen Drift Metric ($\Delta S_1$)4849$$\Delta S_1 = \omega_c \cdot \Delta E(c_1, c_i) + \omega_r \cdot \frac{|r_1 - r_i|}{24} + \omega_f \cdot \delta_f(f_1, f_i) + \omega_h \cdot \frac{|h_1 - h_i|}{20}$$5051Where:52- $\omega_c = 0.40, \omega_r = 0.20, \omega_f = 0.20, \omega_h = 0.20$53- $\Delta E(c_1, c_i)$ is normalized Euclidean color distance in sRGB / OKLab space.54- $r_1, r_i$ are observed border radii in pixels.55- $\delta_f$ is typographic font divergence ($0.0$ if matching family, $0.5$ if mismatched).56- $h_1, h_i$ are observed control heights in pixels.5758### 2. Relative Luminance & Pairwise Contrast ($C_r$)5960$$L = 0.2126 R_{\text{lin}} + 0.7152 G_{\text{lin}} + 0.0722 B_{\text{lin}}$$6162$$C_r = \frac{L_{\text{lighter}} + 0.05}{L_{\text{darker}} + 0.05} \ge 4.5:1$$6364---6566## 4-Tier Token Layering Architecture6768```69Tier 1: Primitives [ #0F172A, #2563EB, 8px, 16px, 24px ]70 │ (alias only)71 ▼72Tier 2: Semantics [ bg-surface, fg-default, border-subtle, primary, accent ]73 │ (alias only)74 ▼75Tier 3: Spatial & Type [ pageInset, sectionGap, stackGap, display, body, mono ]76 │ (alias only)77 ▼78Tier 4: Components [ button-primary-bg, card-elevation-border, input-height ]79```8081---8283## CLI Usage8485```bash86# Scan repository for StyleSeed token leakage and spatial slop87bunx anti-slop-engineering styleseed --scan src/8889# Audit against a specific tokens file and output grammar90bunx anti-slop-engineering styleseed --scan src/ --tokens tokens.json --grammar operations-console9192# Validate spatial rhythm contract and decisions ledger93bunx anti-slop-engineering styleseed --spacing spacing.json --decisions decisions.json --strict9495# Calculate S1 multi-screen drift index from probe measurements96bunx anti-slop-engineering styleseed --screens screens.json --json9798# Inter-agent TOON protocol payload for get-fable / Poteto handoff99bunx anti-slop-engineering styleseed --scan src/ --toon100```101102---103104## Inter-Agent Handoff Contract (TOON Protocol)105106When passing StyleSeed audit results between autonomous subagents, emit the formal TOON block:107108```toon109styleseed-audit[v1.0.0]:110 verdict: PROCEED111 grammar: operations-console (density: compact)112 token-layers: { primitive: 32, semantic: 18, contrast-deficits: 0, leakage: 0 }113 spatial-rhythm: { roles: 6, inversions: 0, ad-hoc: 0 }114 s1-drift: { status: ANCHORED, max-dist: 0.04 }115 decisions-ledger: { decisions: 3, approved-exceptions: 1, invalid-exceptions: 0 }116 findings-count: [0]117```