ui-scaffold
Generates a React + ShadCN/ui study application with podcast player, quiz, teach-back, and research browser — driven by Stitch design reference
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generates a React + ShadCN/ui study application with podcast player, quiz, teach-back, and research browser — driven by Stitch design reference
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
The SOLE WRITER to the V3.0 mem0 second brain. Invoked agentically by the executive at write moments — post-run, post-retro, post-spec-merge, manual /harvest. Decides which facts to classify into which memory type (principle/semantic/procedural/episodic/reflective), validates against the schema, and calls the deterministic plumbing in references/ via Bash. Blocks until writes are durable (poll event endpoint for SUCCEEDED). Never invoked from worker code.
Consult the V3.0 mem0 second brain agentically during executive planning, work selection, pre-spawn memory pack building, and failure diagnosis. Use this skill whenever the executive needs to remember prior runs, retros, or learned principles. Read-only — never writes. Drives the unified `mem0` CLI via Bash, orchestrating multiple iterative search queries (mem0 does not do multi-hop graph traversal natively, so iterative search IS the multi-hop).
Hook D — Failure-Diagnosis memory consultation. Runs at executive Phase 7 (after 3+ consecutive failures on a work item) BEFORE the failure-diagnosis skill itself runs. Consults the second brain for similar prior failures and successful retry strategies, then hands enriched context to the failure-diagnosis skill. Read-only. Invokes the memory-reader skill.
Hook E — Post-Retrospective Harvest. Runs after a retrospective markdown doc completes (per-run or weekly). Reads the retro fully and decides which durable lessons (reflective, semantic, procedural memories) to write to the second brain. Typically 3–8 writes per weekly retro, 0–3 per per-run retro. Invokes the memory-harvester skill for the actual writes.
Hook C — Post-Run Harvest. Runs after a worker completes (executive Phase 6 success path). Decides agentically which facts from the run to write to the second brain — typically 0–3 memory writes per run (one episodic, optionally a semantic or procedural). Invokes the memory-harvester skill to do the actual writes (with event-polling for durability).
Hook B — Pre-Spawn Memory Pack build. Runs before each worker spawn (executive Phase 4 prep). Reads the second brain for project-specific memories and produces a Memory Pack markdown block that worker-spawner injects into the worker's generated CLAUDE.md. Workers consume this as static markdown — they never call mem0 themselves. Read-only. Invokes the memory-reader skill.
| name | ui-scaffold |
| description | Generates a React + ShadCN/ui study application with podcast player, quiz, teach-back, and research browser — driven by Stitch design reference |
Generate or update a React + ShadCN/ui study application for interactive exam preparation, using Stitch HTML screens as visual blueprints.
Build incrementally. At each checkpoint, run npm run build. Fix build errors before proceeding. Commit each passing checkpoint to git.
{{TARGET_DIR}} — Directory where the React project will be generated.{{MANIFEST_PATH}} — Path to manifest.json with topic tree, quiz data, podcast metadata.{{TOPIC_TITLE}} — Human-readable title for the study environment.{{DESIGN_REF_DIR}} — Path to design reference directory with DESIGN.md and screens/*.html.{{SCAFFOLD_MODE}} — bootstrap (fresh build) or extend (incremental update).Before writing any code, read these files:
{{DESIGN_REF_DIR}}/DESIGN.md — the full design system (colors, typography, surfaces, components){{DESIGN_REF_DIR}}/screens/:
home.html → Study Command Center (HomePage)research.html → Research Browser (ResearchPage)quiz.html → Reasoning Arena MCQ (QuizPage)podcast.html → Audio Lab (PodcastPage)teachback.html → Topic Masterclass (TeachBackPage){{MANIFEST_PATH}} — understand title, topicTree, podcastEpisodes, quizPath, researchDirFrom DESIGN.md, extract and apply these tokens throughout:
| Token | Value | Usage |
|---|---|---|
surface | #060e20 | Base background |
surface-container | #0c1934 | Content areas |
surface-container-high | #101e3e | Elevated cards |
surface-container-highest | #142449 | Active/focused elements |
primary | #9d8fff | Accent, links, active states |
primary-container | #5628fe | Gradient endpoints, CTAs |
secondary | #b4d400 | Success, correct answers |
tertiary | #a1faff | Highlights, focus glow |
error | #fd6f85 | Wrong answers, warnings |
on-surface | #dee5ff | Primary text |
on-surface-variant | #9baad6 | Secondary text |
outline-variant | #38476d | Ghost borders (15% opacity) |
Typography: Space Grotesk for headlines, Inter for body, JetBrains Mono for code/AI processing.
No 1px borders. Use tonal shifts, negative space, and edge lighting.
Glass panels: backdrop-filter: blur(20px) with surface-variant at 60% opacity.
Gradient CTAs: 45-degree linear gradient from primary to primary-container.
Read each HTML screen file and extract:
Map these to shadcn/ui components:
| Stitch HTML Pattern | shadcn/ui Component |
|---|---|
| Answer option cards | RadioGroup + Card |
| Progress bar | Progress |
| Navigation tabs | Tabs / NavigationMenu |
| Topic tree sidebar | Collapsible + Button |
| Metric badges | Badge |
| Glass panels | Card with custom glassmorphism class |
| Input fields | Input / Textarea |
| Action buttons | Button (gradient variant) |
| Episode list | Card list with custom styling |
The target directory may be inside a parent monorepo. Never run git init inside the target. Detect the git root first:
GIT_ROOT=$(cd {{TARGET_DIR}} && git rev-parse --show-toplevel 2>/dev/null) && echo "GIT_ROOT=$GIT_ROOT" || echo "NO_GIT"
For all commit blocks below, use git -C $GIT_ROOT (not cd {{TARGET_DIR}} && git). If NO_GIT, skip git commands.
{{SCAFFOLD_MODE}} is bootstrap:Execute all 5 checkpoints below sequentially.
{{SCAFFOLD_MODE}} is extend:{{TARGET_DIR}}/src/ code to understand current stateGoal: Vite + React scaffolded, installs complete, build passes.
cd {{TARGET_DIR}}
npm create vite@latest . -- --template react --yes 2>/dev/null || npx create-vite@latest . --template react
npm install
npm install react-router-dom react-markdown
Install Tailwind CSS v4:
cd {{TARGET_DIR}}
npm install -D tailwindcss @tailwindcss/vite
Configure Tailwind — add @tailwindcss/vite to vite.config.js plugins and add @import "tailwindcss" to src/index.css.
Configure the Cognitive Flux theme in src/index.css (after the Tailwind import):
@import "tailwindcss";
@theme {
--color-surface: #060e20;
--color-surface-dim: #060e20;
--color-surface-container: #0c1934;
--color-surface-container-low: #081329;
--color-surface-container-high: #101e3e;
--color-surface-container-highest: #142449;
--color-surface-bright: #172b54;
--color-surface-variant: #142449;
--color-primary: #9d8fff;
--color-primary-dim: #7157ff;
--color-primary-container: #5628fe;
--color-secondary: #b4d400;
--color-secondary-dim: #a7c500;
--color-tertiary: #a1faff;
--color-error: #fd6f85;
--color-on-surface: #dee5ff;
--color-on-surface-variant: #9baad6;
--color-outline: #65759e;
--color-outline-variant: #38476d;
--font-display: 'Space Grotesk', sans-serif;
--font-body: 'Inter', sans-serif;
--font-mono: 'JetBrains Mono', monospace;
}
Add Google Fonts to index.html:
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
Install ShadCN/ui core (invoke shadcn-ui skill if available for best practices):
cd {{TARGET_DIR}}
npx shadcn@latest init --defaults --yes 2>/dev/null || npx shadcn-ui@latest init --defaults
npx shadcn@latest add button card tabs input textarea dialog badge progress radio-group collapsible tooltip
Build gate:
cd {{TARGET_DIR}} && npm run build 2>&1
echo "EXIT: $?"
Fix any errors. Do not proceed until build exits 0.
Commit:
git -C $GIT_ROOT add {{TARGET_DIR}}
git -C $GIT_ROOT commit -m "chore(scaffold): vite+react baseline with Cognitive Flux theme
- Vite + React template
- Tailwind CSS v4 with Cognitive Flux design tokens
- ShadCN/ui: Button, Card, Tabs, Input, Textarea, Dialog, Badge, Progress, RadioGroup, Collapsible, Tooltip
- Typography: Space Grotesk + Inter + JetBrains Mono
- Dark mode: surface #060e20, primary #9d8fff, secondary #b4d400"
Goal: React Router configured, top nav and sidebar render matching the Stitch home screen layout.
Reference: Read {{DESIGN_REF_DIR}}/screens/home.html for the navigation structure, sidebar layout, and header design.
Create src/layouts/AppLayout.jsx:
{{TOPIC_TITLE}}), nav links, search icon, user avatar placeholder/, Podcast /podcast, Quiz /quiz, Teach-Back /teach-back, Research /research<Outlet /> for page content (right side, fills remaining width)surface background). Light mode toggle in nav barmd: breakpoint).glass-panel { background: rgba(20, 36, 73, 0.6); backdrop-filter: blur(20px); }Create src/components/TopicSidebar.jsx:
topicTree, selectedTopic, onSelectTopicUpdate src/main.jsx and src/App.jsx:
<BrowserRouter>/ → <HomePage>, /podcast → <PodcastPage>, /quiz → <QuizPage>, /teach-back → <TeachBackPage>, /research → <ResearchPage><AppLayout>Build gate:
cd {{TARGET_DIR}} && npm run build 2>&1
echo "EXIT: $?"
Commit:
git -C $GIT_ROOT add {{TARGET_DIR}}
git -C $GIT_ROOT commit -m "feat(scaffold): app shell with Cognitive Flux nav and glassmorphism sidebar
- React Router v6 with AppLayout
- Glassmorphism sidebar matching Stitch design
- Navigation: Dashboard, Podcast, Quiz, Teach-Back, Research
- Dark theme with Cognitive Flux tokens
- Stub page components for all 5 routes"
Goal: Manifest loaded, Home page matches the Stitch "Study Command Center" design.
Reference: Read {{DESIGN_REF_DIR}}/screens/home.html for the layout.
Copy manifest to public directory:
cp {{MANIFEST_PATH}} {{TARGET_DIR}}/public/manifest.json
Create src/hooks/useManifest.js:
fetch('/manifest.json') on mount{ manifest, loading, error }Create src/pages/HomePage.jsx — match the Study Command Center layout:
Wire TopicSidebar with real topic tree data.
Build gate + Commit (same pattern as above)
Goal: Three pages matching their Stitch screen blueprints.
podcast.html)Reference: Read {{DESIGN_REF_DIR}}/screens/podcast.html
Create src/components/PodcastPlayer.jsx:
<audio> with custom controls matching Stitch: play/pause, skip prev/next, seek bar, time display, speed selector (1x/1.25x/1.5x/2x)PodcastPage: episode list sidebar + PodcastPlayer
quiz.html)Reference: Read {{DESIGN_REF_DIR}}/screens/quiz.html
Create src/components/QuizCard.jsx:
Create src/components/PerformancePanel.jsx:
QuizPage: fetch quiz JSON, shuffle questions, track score + index
research.html)Reference: Read {{DESIGN_REF_DIR}}/screens/research.html
Create src/components/ResearchViewer.jsx:
[n] patterns → clickable superscript badgesResearchPage: read ?domain= query param, pre-select domain
Build gate + Commit
Goal: All 5 pages complete matching Stitch designs, app fully functional with real AI-powered teach-back evaluation.
teachback.html)Reference: Read {{DESIGN_REF_DIR}}/screens/teachback.html and {{TARGET_DIR}}/.claude/skills/score-explanation/SKILL.md (the deposited evaluation skill — use its schema as the source of truth for grading output).
src/components/ApiKeyModal.jsxModal dialog for entering/managing the Claude API key:
claude-api-keyopen, onClose, onSavesrc/lib/claude-client.jsClient-side wrapper for Claude API grading calls:
const CLAUDE_API_URL = 'https://api.anthropic.com/v1/messages'
const CLAUDE_MODEL = 'claude-haiku-4-5'
Function: evaluateExplanation({ apiKey, explanation, topicTitle, researchContent })
System prompt: Port the evaluation dimensions and scoring guidelines from the deposited score-explanation skill. The system prompt must instruct Claude to:
"surface", "moderate", or "deep" (NOT a number)Output JSON schema (must match the deposited skill):
{
"completeness": 65,
"accuracy": 80,
"depth": "moderate",
"coveredWell": ["Correctly explained the role of X..."],
"partiallyCorrect": ["Mentioned caching but did not distinguish..."],
"missing": ["No mention of consistency trade-offs"],
"followUpQuestion": "You explained how caching improves performance, but what happens when...",
"overallFeedback": "You have a solid grasp of the core mechanics but..."
}
Critical implementation details:
'anthropic-dangerous-direct-browser-access': 'true' (required for CORS from browser)'anthropic-version': '2023-06-01''invalid-api-key', 429 → rate limit message, network → connection message```json ... ``` fences even when told not to. Before JSON.parse, always strip fences:
rawText = rawText.replace(/^```(?:json)?\s*\n?/i, '').replace(/\n?```\s*$/i, '').trim()
src/components/TeachBackInput.jsxclaude-api-key — if missing, show ApiKeyModal and return/research/{topicId}.md (graceful 404 handling)evaluateExplanation() with key, explanation, topic title, research contentinvalid-api-key → reopen modal; otherwise → inline error bannerApply consistently across all pages:
cp {{MANIFEST_PATH}} {{TARGET_DIR}}/public/manifest.json
cp -r {{TARGET_DIR}}/research {{TARGET_DIR}}/public/research 2>/dev/null || true
cp -r {{TARGET_DIR}}/podcasts/audio {{TARGET_DIR}}/public/podcasts 2>/dev/null || true
Final build gate + Commit
| Component | File | Stitch Screen | Key Pattern |
|---|---|---|---|
| AppLayout | src/layouts/AppLayout.jsx | home.html | Glass sidebar, top nav, dark mode |
| TopicSidebar | src/components/TopicSidebar.jsx | research.html | Collapsible tree, completion dots |
| PodcastPlayer | src/components/PodcastPlayer.jsx | podcast.html | HTML5 audio, custom controls |
| QuizCard | src/components/QuizCard.jsx | quiz.html | RadioGroup answer cards, explanation panel |
| PerformancePanel | src/components/PerformancePanel.jsx | quiz.html | Accuracy gauge, domain mastery |
| ResearchViewer | src/components/ResearchViewer.jsx | research.html | 3-column, citations, synthesis links |
| TeachBackInput | src/components/TeachBackInput.jsx | teachback.html | Real API grading, three-tier gaps, Socratic coaching |
| ApiKeyModal | src/components/ApiKeyModal.jsx | teachback.html | Claude API key entry/management |
| claude-client | src/lib/claude-client.js | — | Browser-side Claude API wrapper, score-explanation schema |
| useManifest | src/hooks/useManifest.js | — | Fetch manifest.json |
fetch() against /public, not direct file reads.