All skills
acedergren avatar

/stitch-to-react

@9d099e9

Use when converting Stitch designs into production React components. Enforces modular architecture: logic in hooks, data in mockData.ts, Readonly TypeScript interfaces, theme-mapped Tailwind classes. Triggers on: Stitch to React, design to code, stitch export, stitch MCP, stitch:get_screen. Triggers on "convert Stitch to React" or "implement design export".

Use this Skill: https://skilld.dev/gh/acedergren/agentic-tools/stitch-to-react

This session only. Nothing lands on disk.

SKILL.md

β‰ˆ94 tokens always: the name and description. β‰ˆ976 when used: this file.

Stitch to React Components

When to Use

Load this skill when the user request matches the frontmatter description for Stitch to React Components.

NEVER

  • NEVER fetch without checking .stitch/designs/ first β€” always ask user about refresh intent before re-downloading
  • NEVER hardcode hex codes as Tailwind arbitrary values (bg-[#2563eb]) β€” extract to theme, use semantic classes
  • NEVER skip AST validation β€” architecture checklist is non-optional before marking done
  • NEVER put logic in component bodies β€” event handlers and state logic go in src/hooks/
  • NEVER omit TypeScript interfaces β€” every component needs a Readonly Props type
  • NEVER bundle data in component files β€” all static text, images, lists go in src/data/mockData.ts
  • NEVER include Google license headers in generated React components
  • NEVER use internal AI fetch tools for Google Cloud Storage URLs β€” they fail on GCS domains; use the bash script

Namespace Discovery

Run list_tools to find the Stitch MCP prefix (usually stitch: or mcp_stitch:). Use that prefix for all calls.

Call [prefix]:get_screen β€” captures:

  • screenshot.downloadUrl + htmlCode.downloadUrl
  • width, height, deviceType
  • designTheme (colors, fonts, roundness)

Design Caching Decision

.stitch/designs/{page}.html + .stitch/designs/{page}.png exist?
β”‚
β”œβ”€ YES β†’ Ask user: "Use cached designs or refresh from Stitch?"
β”‚         Re-download ONLY if user confirms
β”‚
└─ NO β†’ Proceed to download

High-Reliability Download

Internal AI fetch fails on GCS. Use the bash script:

# HTML
bash scripts/fetch-stitch.sh "[htmlCode.downloadUrl]" ".stitch/designs/{page}.html"

# Screenshot β€” append =w{width} to URL
bash scripts/fetch-stitch.sh "[screenshot.downloadUrl]=w{width}" ".stitch/designs/{page}.png"

Architecture Rules (Non-Negotiable)

Rule Enforcement
Modular files Never output single-file component dumps
Logic isolation Event handlers β†’ src/hooks/
Data decoupling Static content β†’ src/data/mockData.ts
Type safety Readonly interface named [Component]Props on every component
Style mapping Extract tailwind.config from HTML <head>, sync to resources/style-guide.json

File Structure

src/
β”œβ”€β”€ components/     # One file per component + index.ts barrel
β”œβ”€β”€ hooks/          # useNavigation.ts, useFormState.ts, etc.
β”œβ”€β”€ data/
β”‚   └── mockData.ts # All static text, images, config
β”œβ”€β”€ styles/
β”‚   └── theme.ts    # Extracted Tailwind tokens
└── App.tsx

Validation Sequence

After generating each component:

  1. npm run validate <file_path> β€” AST compliance
  2. Check against resources/architecture-checklist.md
  3. npm run dev β€” zero console errors required

A component is not done until it passes the checklist AND the dev server shows no errors.

Troubleshooting

Issue Fix
Fetch fails (403) Check script quotes; verify =w{width} appended to screenshot URL
AST shows hardcoded styles Extract hex β†’ style-guide.json β†’ replace with Tailwind class
TypeScript prop errors Add Readonly interface following template in resources/component-template.tsx
Theme class not recognized Verify tailwind.config extracted and synced to style-guide.json
Cached screenshot stale Check file timestamps; ask user to confirm refresh

Arguments

$ARGUMENTS: Optional user-provided target, path, environment, symptom, or constraint. When empty, infer the narrowest safe scope from the current repository context and ask only if multiple high-impact choices remain.

Source: SKILL.md on GitHub

1 alert5mo5 checks Β· Risk MEDIUM
  • Gen Agent Trust Hub6mo

    The skill automates the conversion of design files into React components, which involves executing local shell scripts and package managers. Security concerns include the execution of unprovided local scripts with externally sourced arguments and a significant indirect prompt injection surface when processing design data from external tools.

  • Socket6mo

    No alerts

  • Snyk6mo

    Risk: HIGH Β· 2 issues

  • Runlayer6mo

    2/2 files flagged

  • ZeroLeaks5mo

    1 finding Β· Score: 86/100

Signed by skilld at 9d099e9. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Steadyupdated 4 months ago

README badge

README badge for acedergren/agentic-tools/stitch-to-react