Micro app architect

From dtyq/magic · View interactive version

Micro app architect is an AI agent skill from the GitHub repository dtyq/magic. Use for developing and maintaining a published SuperMagic HTML micro-app with the built-in micro-app.agent. This skill defines the micro-app-only workflow, manifest and memory files, MagicBase boundaries, companion business skills, runtime Agent messaging, UI constraints, and validation rules. Do no

How to use this skill

Skill file

Micro-App Architect

This skill defines the implementation contract for a real, publishable SuperMagic HTML micro-app. It is preloaded by micro-app.agent and supplements the agent's role, tools, and general coding guidance.

Interaction Boundaries

For casual conversation, keep the response brief. Start the detailed workflow only for a concrete micro-app task; for unrelated requests, state the role and confirm whether the user still wants to proceed.

Scope

Use this skill only for real, publishable micro-apps: the workspace root is the app root, and the host identifies, previews, and publishes it from app.json and magic.project.js. For HTML apps opened from ordinary projects, use html-app-architect instead.

AI Execution Routing

Classify each user-facing AI operation by how it must execute; do not infer the route only from the overall app size.

Development Workflow

  1. Identify the app type, core scenario, real page count, whether a database is needed, and the execution route for each AI operation.
  2. Read the root MICRO-APP.md; if only the legacy HTML-APP.md exists, read it first and migrate it to MICRO-APP.md before finishing. MagicBase migration history is managed in .magicbase/migrations.json; reconcile any Pending migration first.
  3. Use ask_user only when missing information would materially change the product direction and cannot be safely inferred; otherwise enter micro_app_plan with explicit assumptions.
  4. Choose the file structure from real pages and reuse relationships. Put all artifacts directly in the workspace root; do not create src/, app/, or web/ wrapper directories.
  5. Use micro_app_plan to complete the real features, data objects, fields, operations, states, identity, permissions, feedback, analytics, and persistence fields.
  6. Before a new micro-app, substantial change, file-structure change, or MagicBase schema change, call micro_app_plan to present the plan and wait for user approval. Do not write business files or change the schema before approval.
  7. In the plan, requirements, implementation_steps, acceptance_criteria, and assumptions must be JSON arrays, while files and data_model must be arrays of objects. For permission work, assumptions must include permission_feasibility: enforceable_by_magicbase, ui_only_not_secure, or requires_backend.
  8. After approval, implement the page, styles, interactions, and data logic so the request forms a real working loop.
  9. Before finishing, call update_html_app_memory once to update MICRO-APP.md with only the completed state; do not edit it with file-editing tools.
  10. Self-check after generation: no fake features, undefined variables, or inline events; verify data reads and mobile usability. The final response should only describe what was actually completed.

Files and Manifest

New micro-apps must be generated directly in the workspace root:

Do not create wrapper directories or use ../ to traverse above the root. Unless explicitly requested, do not create home.html, test.html, verify.html, or documentation-only pages.

Data-oriented micro-apps use MagicBase by default for user-submitted, editable, searchable, analytical, exportable, or reusable business records. Use files for file-shaped configuration, imports, caches, derived artifacts, and exports, or when the user explicitly chooses file-backed persistence. If CRUD is explicitly file-backed, follow the shared-data rules in html-api-sdk: store one file per record, render lists from listDir() and filename projections, and read record details on demand. Do not maintain the same source-of-truth records in both MagicBase and files.

Anonymous Access and Form Drafts

MagicBase, Identity, and Permissions

Companion business skills

Use skill-creator to generate a business workflow Skill at .magic/skills/<skill-name>/SKILL.md when an Agent task has a repeatable domain workflow, business-specific tool sequence, MagicBase mutation or permission flow, required intermediate or output artifacts, or recovery rules that must remain consistent across runs. Do not create a companion Skill merely because the app is medium or complex, or because it sends a one-off Agent task that the message can specify completely. Operations routed to window.Magic.llm do not need a companion Skill.

When a companion Skill is required, it must specify:

For a task that uses a companion Skill, the micro-app implementation chooses the Skill name and writes it in the task message. For example:

window.Magic.project.createTopicAndSend(
  "Use the inventory_manager Skill to query low-stock products and generate replenishment suggestions",
  { model: selectedModelId },
);

Agent Messages and Runtime Loading

When a published micro-app calls createTopicAndSend or sendMessage, the host automatically prepends the current micro-app's trusted @micro_app mention. The micro-app describes the task and, when applicable, the companion Skill name in the message; it does not pass skillName, appId, or projectId through the public API and cannot forge the micro-app identity.

If the task message names a companion Skill, load that companion Skill with read_skills(skill_names=[...], project_id=...) using the project_id printed under the host-provided mention; include project_id on the first attempt for that Skill. Companion skills live on the mounted source project's .magic/skills/ and are not listed in <available_skills>. The current workspace, including a published micro-app runtime project, is not that source; do not search its .magic/skills/ with list_dir, read_files, or a guessed mount path. System skills such as use-magicbase still omit project_id. If the directory, target Skill, or share permission is unavailable, continue as a normal task without falling back to a same-named workspace skill, bypassing permissions, or writing to the source project.

When one exact Skill file is required, the message may still include an explicit @file mention for .magic/skills/<skill-name>/SKILL.md; this supplements rather than replaces the host-provided @micro_app identity context.

UI, Code, and Error Handling

Acceptance Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.