Skip to content

xinetzone/SpecWeave / .agents/skills/design-library-creator

design-library-creator

Flagged

Create, expand, and refine professional Design Libraries / Design Systems with structured token architecture. ONLY invoke when user EXPLICITLY mentions design-system terminology: 'Design Library', 'Design System', '设计系统', '设计库', 'token system', 'design tokens', '组件库规范', or provides a parsed design-spec bundle (ZIP/Figma export). Also covers creating a new theme / color theme as a design-system deliverable (创建主题/新建暖色主题/深色主题等 — tokens + palette + component styling). Do NOT route here for: '素材库', '全套素材', '素材合集', '物料库', '生成素材', '做一套设计', '做几张图', '设计一套页面', '帮我出图', page/poster/landing-page creation, or any visual-asset generation intent where the user does not demonstrate knowledge of design-system concepts. Those belong to solo-design.

FileKindSize
SKILL.mdskill md19.3 KB
aesthetics/dark-mode.mdmarkdown1.8 KB
aesthetics/index.mdmarkdown33.8 KB
aesthetics/navigation-footer.mdmarkdown2.2 KB
aesthetics/screen-craft.mdmarkdown9.2 KB
aesthetics/self-check.mdmarkdown24.9 KB
examples/templates/component-dispatch-rules.mdmarkdown9.1 KB
examples/templates/figma-token-gen.mdmarkdown50.3 KB
examples/templates/incremental.mdmarkdown5.7 KB
examples/templates/phase-2-analysts.mdmarkdown6.8 KB
examples/templates/phase-2-structured-spec.mdmarkdown8.8 KB
examples/templates/phase-2.5-intent-synthesis.mdmarkdown31.0 KB
examples/templates/phase-3-4-component.mdmarkdown9.0 KB
examples/templates/phase-4-ui-kit.mdmarkdown39.3 KB
examples/templates/phase-5-docs.mdmarkdown12.5 KB
examples/templates/scratch-token-gen.mdmarkdown14.4 KB
examples/templates/specimen-reference.htmlother6.0 KB
file-specs/css-json.mdmarkdown9.5 KB
file-specs/css-tokens.mdmarkdown33.6 KB
file-specs/design-library-output.mdmarkdown10.3 KB
file-specs/design-spec-bundle.mdmarkdown5.9 KB
file-specs/documentation.mdmarkdown12.3 KB
file-specs/preview-pages.mdmarkdown28.0 KB
file-specs/ui-kit.mdmarkdown28.5 KB
operation-policies/agent-orchestration.mdmarkdown20.2 KB
operation-policies/bundle-exploration.mdmarkdown9.0 KB
operation-policies/decision-rules.mdmarkdown10.7 KB
operation-policies/quality-gates.mdmarkdown10.5 KB
operation-policies/user-output-policy.mdmarkdown7.8 KB
scripts/check-design-library-phase.mjsscript85.1 KB
scripts/copy-bundle-assets.mjsscript12.3 KB
scripts/css-to-json.mjsscript53.1 KB
scripts/css-utils.mjsscript748 B
scripts/extract-components-css.mjsscript10.3 KB
scripts/generate-uikit-plan.mjsscript27.5 KB
scripts/jsonl-utils.mjsscript7.3 KB
scripts/validate-design-library-output.mjsscript3.1 KB
scripts/validate-intent.mjsscript7.3 KB
scripts/validate-token-input.mjsscript4.0 KB
scripts/validate-uikit-plan.mjsscript13.6 KB
skill-release-manifest.jsonconfig202 B
workflows/create-from-scratch.mdmarkdown22.5 KB
workflows/create-from-structured-spec.mdmarkdown17.5 KB
workflows/create-library.mdmarkdown53.0 KB
workflows/expand-components.mdmarkdown9.0 KB
workflows/generate-additional-kit.mdmarkdown4.9 KB
workflows/refine-library.mdmarkdown9.7 KB

scripts/validate-intent.mjs

View on GitHub
#!/usr/bin/env node
/**
 * validate-intent.mjs
 * Advisory check: validates component intent JSON files after Phase 3 synthesis.
 *
 * Usage:
 *   node validate-intent.mjs --intent-dir <path> --vars-file <path> [--strict]
 *
 * Exit codes:
 *   0 = check completed; schema issues are reported as warnings by default
 *   1 = validation errors found only when --strict is passed
 */

import { readFileSync, readdirSync } from 'fs';
import { join, basename } from 'path';
import { parseArgs } from 'util';
import { CSS_VAR_NAME } from './css-utils.mjs';

const { values } = parseArgs({
  options: {
    'intent-dir': { type: 'string' },
    'vars-file': { type: 'string' },
    strict: { type: 'boolean', default: false },
  },
});

const intentDir = values['intent-dir'];
const varsFile = values['vars-file'];
const strict = values.strict === true;

if (!intentDir || !varsFile) {
  console.error('Usage: node validate-intent.mjs --intent-dir <path> --vars-file <path> [--strict]');
  process.exit(2);
}

const VALID_CATEGORIES = ['Action', 'Display', 'Overlay', 'Form', 'Navigation', 'Feedback'];
const ADVISORY_SIZE_BYTES = 3072;

function extractAvailableVariableNames(raw) {
  if (Array.isArray(raw)) {
    return raw;
  }
  if (raw && typeof raw === 'object' && Array.isArray(raw.cssVariables)) {
    return raw.cssVariables;
  }
  if (raw && typeof raw === 'object') {
    return Object.keys(raw);
  }
  throw new Error('vars-file has no cssVariables[] and is not an object/array');
}

// Load available variables — accepts .css (extracts custom properties) or .json (legacy)
let availableVars;
try {
  const content = readFileSync(varsFile, 'utf-8');
  if (varsFile.endsWith('.css')) {
    availableVars = new Set(
      [...content.matchAll(new RegExp(`--([${CSS_VAR_NAME}]+)\\s*:`, 'g'))].map(m => m[1])
    );
  } else {
    const raw = JSON.parse(content);
    availableVars = new Set(extractAvailableVariableNames(raw));
  }
} catch (e) {
  console.error(`Failed to read vars file: ${e.message}`);
  process.exit(2);
}

// Find all intent JSON files (exclude index.json and _evidence/)
const files = readdirSync(intentDir)
  .filter(f => f.endsWith('.json') && f !== 'index.json' && !f.startsWith('_'));

const results = { valid: [], invalid: [], warnings: [] };
const parsedIntents = new Map();

for (const file of files) {
  const filePath = join(intentDir, file);
  const errors = [];

  let intent;
  try {
    const content = readFileSync(filePath, 'utf-8');

    const sizeBytes = Buffer.byteLength(content, 'utf-8');
    if (sizeBytes > ADVISORY_SIZE_BYTES) {
      results.warnings.push({
        file,
        warning: `large intent JSON (${sizeBytes}B > ${ADVISORY_SIZE_BYTES}B advisory); kept because structure is valid`,
      });
    }

    intent = JSON.parse(content);
    parsedIntents.set(file, intent);
  } catch (e) {
    errors.push(`parse error: ${e.message}`);
    results.invalid.push({ file, errors });
    continue;
  }

  // Required fields (v6 evidence-based schema)
  const required = ['slug', 'name', 'category', 'summary', 'controlMatrix', 'geometry', 'patterns', 'contentPolicy'];
  for (const field of required) {
    if (intent[field] === undefined || intent[field] === null) {
      errors.push(`missing required field: ${field}`);
    }
  }

  // Category enum
  if (intent.category && !VALID_CATEGORIES.includes(intent.category)) {
    errors.push(`invalid category "${intent.category}" — must be one of: ${VALID_CATEGORIES.join(', ')}`);
  }

  // controlMatrix checks
  if (intent.controlMatrix && typeof intent.controlMatrix === 'object') {
    if (!intent.controlMatrix.dimensions || !Array.isArray(intent.controlMatrix.dimensions) || intent.controlMatrix.dimensions.length < 1) {
      errors.push('controlMatrix.dimensions must be a non-empty array');
    }
  }

  // geometry checks
  if (intent.geometry && typeof intent.geometry === 'object') {
    if (!intent.geometry.sizing) {
      errors.push('geometry.sizing is required');
    }
  }

  // patterns checks
  if (intent.patterns && typeof intent.patterns === 'object') {
    // componentAnatomy is recommended but not strictly required
    // listModel is optional
  }

  // contentPolicy checks
  if (intent.contentPolicy && typeof intent.contentPolicy === 'object') {
    if (!intent.contentPolicy.uiCopySamples || !Array.isArray(intent.contentPolicy.uiCopySamples)) {
      errors.push('contentPolicy.uiCopySamples must be an array');
    }
  }

  // renderObligations advisory check (advisory → warning, not error)
  if (intent.renderObligations && Array.isArray(intent.renderObligations) && intent.renderObligations.length < 1) {
    results.warnings.push({ file, warning: 'renderObligations should contain at least 1 obligation' });
  }

  // iconSlots advisory check
  if (intent.iconSlots && Array.isArray(intent.iconSlots)) {
    for (let i = 0; i < intent.iconSlots.length; i++) {
      const slot = intent.iconSlots[i];
      if (!slot.name || !slot.role) {
        errors.push(`iconSlots[${i}] missing name/role`);
        break;
      }
    }
  }

  if (errors.length === 0) {
    results.valid.push(file);
  } else {
    results.invalid.push({ file, errors });
  }
}

// Advisory: check componentRef cross-references in componentAnatomy / listModel
const availableSlugs = new Set(files.map(f => basename(f, '.json')));
for (const file of files) {
  const intent = parsedIntents.get(file);
  if (!intent) continue;

  const refs = [];
  // Collect componentRef from componentAnatomy slots (recursive)
  function collectRefs(node) {
    if (!node) return;
    if (node.componentRef) refs.push(node.componentRef);
    if (Array.isArray(node.children)) node.children.forEach(collectRefs);
  }
  const anatomy = intent.patterns?.componentAnatomy ?? intent.componentAnatomy;
  if (anatomy?.scenarios) {
    for (const sc of anatomy.scenarios) collectRefs(sc.root);
  }
  // Collect from listModel itemSlots structure
  const listModel = intent.patterns?.listModel ?? intent.listModel;
  if (listModel?.itemSlots) {
    for (const slot of listModel.itemSlots) {
      if (slot.structure?.componentRef) refs.push(slot.structure.componentRef);
    }
  }
  // Collect from tableModel columns
  const tableModel = intent.patterns?.tableModel ?? intent.tableModel;
  if (tableModel?.columns) {
    for (const col of tableModel.columns) {
      if (col.componentRef) refs.push(col.componentRef);
      if (col.cellRenderer?.componentRef) refs.push(col.cellRenderer.componentRef);
    }
  }
  // Collect from segmentedGroups
  const segGroups = intent.patterns?.segmentedGroups ?? intent.segmentedGroups;
  if (Array.isArray(segGroups)) {
    for (const group of segGroups) {
      if (group.componentRef) refs.push(group.componentRef);
      if (Array.isArray(group.segments)) {
        for (const seg of group.segments) {
          if (seg.componentRef) refs.push(seg.componentRef);
        }
      }
    }
  }

  for (const ref of refs) {
    if (ref.slug && !availableSlugs.has(ref.slug)) {
      results.warnings.push({
        file,
        warning: `componentRef references unknown slug "${ref.slug}" — no matching intent JSON found`,
      });
    }
  }
}

// Output
const summary = {
  mode: strict ? 'strict' : 'advisory',
  total: files.length,
  valid: results.valid.length,
  invalid: results.invalid.length,
  failures: results.invalid,
  warnings: results.warnings,
};

console.log(JSON.stringify(summary, null, 2));
process.exit(strict && results.invalid.length > 0 ? 1 : 0);
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 197kUpdated Claude CodeCodexVerifiedInstall