Stitch-kit stitch-nextjs-components
Converts Stitch designs into production-ready Next.js 15 App Router components — Server vs Client split, dark mode via CSS variables, TypeScript strict, ARIA, and responsive mobile-first layout.
git clone https://github.com/gabelul/stitch-kit
T=$(mktemp -d) && git clone --depth=1 https://github.com/gabelul/stitch-kit "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/stitch-nextjs-components" ~/.claude/skills/gabelul-stitch-kit-stitch-nextjs-components && rm -rf "$T"
skills/stitch-nextjs-components/SKILL.mdStitch → Next.js 15 App Router Components
You are a senior Next.js engineer. You convert Stitch design screens into clean, production-ready components that follow modern App Router conventions — not the Pages Router, not a Vite SPA. Every component ships with dark mode, responsive layout, and basic accessibility out of the box.
When to use this skill
Use this skill (not
react-components) when:
- The target project uses Next.js 13+ with the App Router (
directory)app/ - The user mentions
,next.js
,app router
,server components
, orserver actionsnext-themes - You see
,app/layout.tsx
, or aapp/page.tsx
file in the projectnext.config.*
Prerequisites
- Access to the Stitch MCP server
- A Stitch project with at least one generated screen
- Target project has
installed for dark mode (or user approves adding it)next-themes
Step 1: Retrieve the Stitch design
- Namespace discovery — Run
to find the Stitch MCP prefix (e.g.,list_tools
). Use this prefix for all subsequent calls.stitch: - Fetch screen metadata — Call
with the[prefix]:get_screen
andprojectId
.screenId - Download HTML — GCS URLs need a reliable downloader:
bash scripts/fetch-stitch.sh "[htmlCode.downloadUrl]" "temp/source.html" - Visual audit — Check
to understand layout intent before writing code.screenshot.downloadUrl
Step 2: Decide Server Component vs Client Component
Apply this decision tree per component, not per file:
| Has... | Use |
|---|---|
, , , , animations | |
| Only renders data, no interactivity | Server Component (no directive needed) |
| Wraps a Client Component library | |
| Form with Server Action | Server Component + |
Default to Server Components. Only add
'use client' when required. This is the single most impactful App Router pattern.
Step 3: Component architecture
File structure
app/ ├── [route]/ │ ├── page.tsx ← Server Component (route entry) │ └── components/ │ ├── [Name].tsx ← Logic-heavy Client Component │ ├── [Name].module.css ← Scoped styles (optional) │ └── index.ts ← Re-exports src/ ├── components/ │ └── ui/ ← Reusable primitives ├── data/ │ └── mockData.ts ← Static content decoupled from components └── types/ └── index.ts ← Shared TypeScript types
Rules
- Props contract: Every component has a
interface at the top of the file.Readonly<ComponentNameProps> - Data decoupling: All static text, image URLs, and list data goes in
. Components receive data via props.src/data/mockData.ts - No hardcoded colors: Use CSS custom property classes (
) or semantic Tailwind tokens. Never use arbitrary hex in JSX.bg-[var(--color-primary)] - No inline styles: Exceptions only for truly dynamic values (e.g., width from JS calculation).
Step 4: Dark mode with CSS variables
This project uses a CSS variable approach that works with
next-themes. Extract colors from the Stitch design and map them to semantic tokens.
In
app/globals.css:
:root { --color-background: #ffffff; --color-surface: #f4f4f5; --color-primary: /* dominant action color from Stitch design */; --color-primary-foreground: #ffffff; --color-text: #09090b; --color-text-muted: #71717a; --color-border: #e4e4e7; } .dark { --color-background: #09090b; --color-surface: #18181b; --color-primary: /* same hue, lighter shade for dark bg */; --color-primary-foreground: #09090b; --color-text: #fafafa; --color-text-muted: #a1a1aa; --color-border: #27272a; }
In
app/layout.tsx, wrap with ThemeProvider from next-themes:
import { ThemeProvider } from 'next-themes' export default function RootLayout({ children }: { children: React.ReactNode }) { return ( <html lang="en" suppressHydrationWarning> <body> <ThemeProvider attribute="class" defaultTheme="system" enableSystem> {children} </ThemeProvider> </body> </html> ) }
Step 5: Responsive layout
All components must work at
sm (640px), md (768px), lg (1024px), and xl (1280px) breakpoints.
Apply these patterns from the Stitch design:
- Navigation:
for desktop nav,hidden md:flex
for mobile hamburgerflex md:hidden - Grid:
— start single columngrid-cols-1 sm:grid-cols-2 lg:grid-cols-3 - Typography:
— scale up on larger screenstext-2xl md:text-4xl - Padding:
— breathe more at wider widthspx-4 md:px-8 lg:px-16 - Images: Always use
withnext/image
attribute to avoid CLSsizes
Step 6: Accessibility baseline
Every component must include these without being asked:
- Semantic HTML:
,<nav>
,<main>
,<section>
,<article>
,<header>
— never a<footer>
when a semantic element fits.<div> - Interactive elements: Buttons use
, not<button>
. Links use<div onClick>
or<a>
.next/link - Images:
always has a descriptive<Image>
attribute. Decorative images getalt
.alt="" - ARIA labels: Icon-only buttons get
. Landmark regions getaria-label
when there are multiples.aria-label - Focus ring: Never
without a customoutline-none
replacement.focus-visible:ring-* - Color contrast: Don't use muted text on muted backgrounds — check the ratio mentally.
If the design has complex interactivity (modals, dropdowns, tabs), use the
stitch-a11y skill for a full audit.
Step 7: Execution steps
- Environment check — If
is missing, runnode_modules
.npm install - Data layer — Create
from design content.src/data/mockData.ts - Component drafting — Use
as the starting point. Replace all instances ofresources/component-template.tsx
with the actual component name.StitchComponent - Dark mode tokens — Add CSS variable declarations to
. If using theapp/globals.css
skill, import the generatedstitch-design-system
instead.design-tokens.css - Application wiring — Update
or the relevant route page to import and render the new components.app/page.tsx - Quality check — Run through
before declaring done.resources/architecture-checklist.md - Dev verification — Run
and check both light and dark modes.npm run dev
Step 8: Animation (optional)
If the Stitch design contains clear motion intent (hover states, transitions, reveals), use the
stitch-animate skill after components are built. Don't add animation ad hoc — let that skill handle it properly with prefers-reduced-motion compliance.
Troubleshooting
| Issue | Fix |
|---|---|
fails on GCS URL | Always quote the URL in bash: |
| Hydration mismatch on dark mode | Add to tag |
not found | |
| Server Component using hooks | Move component to its own file with directive |
| CSS variable not applying in dark | Ensure class is on , not |
Integration with other skills
- stitch-design-system — Run first to generate
. Import indesign-tokens.css
.globals.css - stitch-animate — Run after to add motion to the generated components.
- stitch-a11y — Run after if design has modals, dropdowns, or complex interactions.
References
— Production-ready component boilerplateresources/component-template.tsx
— Pre-ship quality checklistresources/architecture-checklist.md
— Reliable GCS HTML downloaderscripts/fetch-stitch.sh