mk:stitch
Generates a novel UI design from a text prompt via Stitch AI, exporting Tailwind and HTML. NOT for mk:figma.
- License 许可
- MIT
- 最近更新
- 2026-11-12
- Stars
- ★ 16
- Forks
- 3
01 前言 Front Matter
- name
- mk:stitch
- owner
- utility
- phase
- on-demand
- status
- active
- runtime
- claude-code
- category
- frontend
- keywords
- [ "stitch", "ui-generation", "text-to-ui", "prototyping", "design-generation", "tailwind", "html-export", "design-to-code", "design-handoff", "ai-design", "rapid-prototyping", "mock-ui", "screen-design" ]
- metadata
- { "author": "meowkit", "version": "1.0.0" }
- criticality
- medium
- description
- Generates a novel UI design from a text prompt via Stitch AI, exporting Tailwind and HTML. NOT for mk:figma.
- trust_level
- kit-authored
- when_to_use
- No design source exists and one must be invented from a description.
- requires_env
- [ { "name": "STITCH_API_KEY", "setup": "Get from https://stitch.withgoogle.com/settings/api", "fallback": "Skill is disabled without this key. Use mk:frontend-design for text-based design instead.", "required": true, "description": "Stitch API key (sk_...) for design generation" } ]
- allowed-tools
- [ "Bash", "Read", "Write", "Edit" ]
- argument-hint
- [generate|export|quota] [args]
- injection_risk
- high
- user-invocable
- true
- default_enabled
- false
- stable_output_contract
- true
- requires_external_service
- [ "stitch" ]
02 资源文件 10
- 参考文档references/design-to-code-pipeline.md4.0 KB
- 参考文档references/quota-management.md2.3 KB
- 参考文档references/stitch-mcp-setup.md2.3 KB
- 参考文档references/stitch-operations.md1.1 KB
- 参考文档references/stitch-sdk-api.md4.0 KB
- 参考文档references/stitch-setup.md492 B
- 脚本scripts/package.json403 B
- 脚本scripts/stitch-api-call.ts12.3 KB
- 脚本scripts/stitch-quota.ts4.6 KB
- 脚本scripts/stitch-write-output.ts11.4 KB
03 SKILL.md 正文
Stitch — AI Design Generation
Generate high-fidelity UI designs from text prompts. Export Tailwind/HTML, PNG screenshot,
and DESIGN.md for handoff to mk:frontend-design.
Use only for a novel, text-prompt design. Existing design sources belong to mk:figma or
mk:frontend-design.
Setup and guard
Set STITCH_API_KEY in the project env file, then install the scripts once:
cd ${CLAUDE_SKILL_DIR}/scripts && npm install
Run the prerequisite check before any API command; it fails before a network request if the key
or tsx is unavailable. Full setup, optional variables, and MCP setup: references/stitch-setup.md.
Fail-Closed Gate
Before any script runs, verify both prerequisites:
# Key gate
[ -z "$STITCH_API_KEY" ] && { echo "[X] STITCH_API_KEY not set — add it to the project env file"; exit 1; }
# tsx gate
npx tsx --version 2>/dev/null || { echo "[X] tsx not found — run: cd ${CLAUDE_SKILL_DIR}/scripts && npm install"; exit 1; }
stitch-api-call.ts also checks STITCH_API_KEY as its first action before any Stitch SDK
call. If the key is unset the script exits 1 immediately — no network request is made.
Quick Start
# 1. Check quota
npx tsx ${CLAUDE_SKILL_DIR}/scripts/stitch-quota.ts check
# 2. Generate (API call only — returns JSON with screenId + imageUrl)
npx tsx ${CLAUDE_SKILL_DIR}/scripts/stitch-api-call.ts \
generate "A checkout page with cart summary and payment form"
# 3. Export + write files (pipe: API call → schema-validate → write to disk)
npx tsx ${CLAUDE_SKILL_DIR}/scripts/stitch-api-call.ts export <screen-id> | \
npx tsx ${CLAUDE_SKILL_DIR}/scripts/stitch-write-output.ts
Commands
| Task | Command / contract |
|---|---|
| Check quota | npx tsx ${CLAUDE_SKILL_DIR}/scripts/stitch-quota.ts check |
| Generate | npx tsx ${CLAUDE_SKILL_DIR}/scripts/stitch-api-call.ts generate "<prompt>" — returns screenId, projectId, imageUrl, and quota data |
| Export | npx tsx ${CLAUDE_SKILL_DIR}/scripts/stitch-api-call.ts export <screen-id> | npx tsx ${CLAUDE_SKILL_DIR}/scripts/stitch-write-output.ts |
Show imageUrl and obtain user approval before exporting. Detailed flags, quota operations, and
the API/write security boundary: references/stitch-operations.md.
Workflow
- Check quota; if exhausted (exit 2), route to
mk:frontend-design. - Generate, review the returned screenshot with the user, then export and write.
- Handoff
DESIGN.mdtomk:frontend-designfor implementation.
Load references/design-to-code-pipeline.md for variants, iteration patterns, and detailed handoff guidance.
The writer outputs the HTML, image, and DESIGN.md handoff under tasks/designs/; exact paths
and the handoff contract are in references/stitch-operations.md.
Limitations
- HTML/Tailwind only — no React/Vue/Svelte export; use
mk:frontend-designto convert - Non-responsive layouts — add breakpoints during implementation
- Static only — no animations; add micro-interactions in code
- Local quota tracking — actual usage may diverge if designs are generated outside this skill
Gotchas
STITCH_API_KEYmust be set in the project env file — the skill fails closed (exit 1) if unset; no network call is attemptedtsxmust be installed (npm installinscripts/) — scripts will not run without it; install once per machine- Local quota can drift from real Stitch usage (e.g., designs made via the Stitch web UI); if you hit
RATE_LIMITEDdespite the tracker showing credits, runstitch-quota.ts reset - Quota limits and paid-tier availability are volatile; load quota-management.md before making a quota-based decision.
- Screen IDs returned by
generateare stable (Tool Contract Rule 2); project name auto-detection uses git remote then CWD basename - The optional MCP integration stores the API key in
.claude/.mcp.json— never commit that file; the kit's.gitignorecovers it stitch-write-output.tsvalidates CDN URLs against a Google-domain allowlist; if Stitch changes CDN domains, updateALLOWED_CDN_SUFFIXESin that script
References
| Topic | File |
|---|---|
| SDK API | references/stitch-sdk-api.md |
| MCP Setup | references/stitch-mcp-setup.md |
| Pipeline Patterns | references/design-to-code-pipeline.md |
| Quota Strategy | references/quota-management.md |
04 同仓库更多 Skills
mk-sequential-thinking
Structured step-by-step reasoning before acting, to avoid guessing. For complex debugging, multi-step analysis, hypothesis checks. NOT for being stuck on approach (mk:problem-solving).
mk:fixture-valid
A valid fixture used to verify the skill structure validator.
invalid
暂无简介
mk:sample-skill
Sample skill for fixture purposes — small enough to land below noise floor.
mk-worktree
Manages git worktrees for parallel agent isolation: creates parallel/{name}-{timestamp} branches, merges with conflict detection. NOT for user feature branches (use git worktree directly).
mk-workflow-orchestrator
Auto-invoked 7-phase workflow for complex-feature intent; fasttrack mode for pre-approved specs. NOT for explicit single tasks (mk:cook), green-field builds (mk:autobuild), or simple fixes (mk:fix).