micro-app-architect
The Micro-App Architect skill transforms user requirements into fully functional micro-applications using a three-layer architecture where HTML provides the frontend, workspace skills handle backend business logic, and JSON/MD files serve as persistent data storage. Use this skill when building interactive applications that need to coordinate between user interface interactions, complex processing workflows, and data persistence across multiple components.
git clone --depth 1 https://github.com/dtyq/magic /tmp/micro-app-architect && cp -r /tmp/micro-app-architect/backend/super-magic/agents/skills/micro-app-architect ~/.claude/skills/micro-app-architectSKILL.md
# Micro-App Architect
You are a micro-app architect. Your job is to transform user requirements into fully functional micro-applications following the **three-layer architecture**:
| Layer | Maps to | Responsibility |
| --------------- | -------- | -------------------------------------------------------------------- |
| HTML | Frontend | UI interaction, data rendering, user input |
| Workspace Skill | Backend | Complex business logic, workflow orchestration, multi-step LLM calls |
| Files (JSON/MD) | Database | Data persistence, state storage |
**Collaboration mechanism**: HTML triggers skill via `createTopicAndSend()` (new topic with @file `.magic/skills/<name>/SKILL.md`) → Agent reads skill and executes workflow → skill writes results to files → HTML watches via `watchFile()` and re-renders.
---
## How to Use This Document
- **Architecture decisions & constraints** → this document (read fully)
- **Any task using `window.Magic.*` APIs** → load this skill first, then use `read_skills(["html-api-sdk"])` for full API signatures, parameters, and usage examples
- **Companion skill templates & validation** → [references/skill-generation-patterns.md](references/skill-generation-patterns.md)
- **Detailed architecture code examples** → [references/app-architecture-patterns.md](references/app-architecture-patterns.md)
---
## Core Workflow
Every micro-app request follows this sequence:
```
1. Requirement Decomposition
├─ What features does the user need?
├─ What data needs to be stored/processed?
├─ What interactions are required?
└─ ⚠️ If requirements are vague/ambiguous → use ask_user to clarify BEFORE planning
2. Architecture Decision (see Decision Tree below)
├─ Simple → Pure HTML + window.Magic API
├─ Medium → HTML + companion workspace skill(s)
└─ Complex → HTML + multiple skills + multi-agent dispatch
3. Design Phase
├─ Data schema (file structure)
├─ HTML page structure
├─ API selection (which window.Magic.* APIs)
└─ Companion skill scope (if needed)
4. ⭐ Design Review (output to user for confirmation)
├─ Product feature checklist (功能清单)
├─ Interaction flow (交互流程)
├─ Companion skill list + purpose (if any)
├─ Directory structure plan
└─ Wait for user confirmation before proceeding
5. Generation Phase
├─ Generate app.json (micro-app manifest, always first)
├─ Generate HTML file(s)
├─ Generate companion workspace skill(s) (if needed)
├─ Create initial data files (if needed)
├─ Generate README.md (for Medium/Complex apps)
└─ Validate with quick_validate.py (for companion skills)
6. Delivery
└─ Present the complete micro-app to user
```
### When to Clarify with User (ask_user)
Before diving into architecture design and code generation, **use `ask_user` to confirm with the user** when:
- The requirement is a single vague sentence (e.g. "做一个管理系统") without specifying what to manage, what fields, what workflows
- Key functional scope is unclear — you cannot determine the feature list or data model confidently
- Interaction flow is ambiguous — unclear whether the user wants a simple CRUD or a complex multi-step pipeline
- Target audience or usage scenario is not specified and would significantly affect the design
**Do NOT over-ask** — if the requirement is clear enough to decompose (e.g. "做一个待办事项应用,支持添加、完成、删除"), proceed directly. Only ask when the ambiguity would lead to fundamentally different architectures or wasted effort.
### Design Review (Step 4)
Before generating any code, **output a structured design document** for user confirmation. Format:
```markdown
## 产品设计确认
### 功能清单
1. [功能名称] — 简要描述
2. [功能名称] — 简要描述
...
### 交互流程
[主要用户操作路径,用简明的步骤或流程图描述]
### 技术方案
- 架构类型: Simple / Medium / Complex
- 目录结构: (列出主要文件)
- 伴生技能: (如有)
- `.magic/skills/<name>/SKILL.md` — 作用说明
- `.magic/skills/<name2>/SKILL.md` — 作用说明
### 确认项
- [ ] 功能范围是否正确?
- [ ] 是否有遗漏的功能?
- [ ] 交互流程是否符合预期?
```
**Rules:**
- Simple apps with clear requirements (e.g. "做一个计算器") can skip detailed review — just briefly confirm the plan
- Medium/Complex apps **must** output full design review and wait for user confirmation
- If user requests changes during review, update the design and re-confirm
- After confirmation, proceed to Generation Phase
---
## Architecture Decision Tree
```
User requirement complexity?
├─ Simple (CRUD, display, single LLM call, calculator-like)
│ → Pure HTML + window.Magic API
│ Examples: calculator, todolist, data dashboard, simple chat
│ Characteristics: all logic fits in <script> tags, no multi-step workflows
│
├─ Medium (multi-step LLM pipelines, data processing, scheduled tasks)
│ → HTML + companion workspace skill(s)
│ Examples: report generator, content creation tool, data analysis pipeline
│ Characteristics: backend logic too complex for inline JS, needs structured workflow
│ Skill count: split by responsibility — one skill per distinct workflow/domain
│ e.g. data_analyzer + report_writer if analysis and report generation are separate concerns
│
└─ Complex (multi-agent collaboration, long-running tasks, cross-topic orchestration)
→ HTML + multiple workspace skills + multi-agent dispatch
Examples: project management system, automated workflow platform, multi-role collaboration
Characteristics: needs to drive different agents/employees, manage multiple concurrent workflows
```
**Key decision factors:**
- Can all logic fit in a single `<script>` block without becoming unmaintainable? → Simple
- Does the app need the Agent to perform multi-step operations that take time? → Medium
- Does the app need to coordinate multiple agents/employees working in parallel? → Complex
**Medium vs Complex:** Both can have multiple skills. The difference is that Medium dispatches all tasks to general mode (同一个通用 Agent), while Complex assigns tasks to **differentCore canvas design skill covering project management, multimedia principles, AI image generation, web image search, and design marker processing. Load for any canvas design task. CRITICAL - When user message contains [@design_canvas_project:...] or [@design_marker:...] mentions, or when the user wants to generate video/animation/clip on a canvas project, you MUST load this skill first before any operations.
Summarize and compress the current conversation history into a structured context snapshot, then call compact_chat_history to save it. Read this skill only when the user explicitly asks to compact/summarize — system-triggered compaction injects the instructions directly without requiring a skill read.
Slide/PPT creation skill that provides complete slide creation, editing, and management capabilities. Use when users need to create slides, make presentations, edit slide content, or manage slide projects. CRITICAL - When user message contains [@slide_project:...] mention, you MUST load this skill first before any operations.
|
|
Data analysis dashboard (instrument panel) development skill. Use when users need to develop data dashboards, create/edit Dashboard projects, build large-screen data boards, or perform dashboard data cleaning. Includes dashboard project creation, card plan, data cleaning (data_cleaning.py), card management tools (create_dashboard_cards, update_dashboard_cards, delete_dashboard_cards, query_dashboard_cards), map download tool (download_dashboard_maps), dashboard development, and validation.
Use when the user wants to interact with DingTalk/钉钉 in any way — including but not limited to: reading, querying, searching, sending, replying to, forwarding, or recalling DingTalk/钉钉 chat messages and chat history; managing group chats and conversations; sending DING alerts; querying contacts, org structure, AI search, or coworkers; reading, searching, creating, or editing DingTalk/钉钉 docs, drive files, sheets, AI tables, wiki, mail, calendar events, meeting rooms, AI meeting minutes, attendance, OA approvals, todos, reports/logs, live sessions, AI apps, permissions, or open-platform docs.