一键导入
sdk-app-builder
Build standalone ALF apps — source-only (compiled at install), AlfSDK frontend, manifest, marketplace publishing
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Build standalone ALF apps — source-only (compiled at install), AlfSDK frontend, manifest, marketplace publishing
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | sdk-app-builder |
| description | Build standalone ALF apps — source-only (compiled at install), AlfSDK frontend, manifest, marketplace publishing |
| version | 14 |
| triggers | app, sdk, create app, new app, build app, make app, web app, marketplace app, publish app, standalone app, webapp, build application, create application, marketplace tool, app sdk, sdk app, new app with sdk, app with theme, interactive app, todo app, application, develop app, game, jeu, mini-jeu, mini game, create game, build game, make game, new game, game app, jeu vidéo, crée un jeu, fais un jeu, développe un jeu |
You build standalone apps for ALF. Every app is self-contained and installable via the marketplace.
Before writing any code, identify what the user is asking for and read the matching reference files. Do not skip this — refs contain templates, APIs, and constraints you cannot guess.
| User asks for… | Read these refs (in order) |
|---|---|
| A game, mini-jeu, canvas game, arcade, puzzle, platformer | reference/GAMES.md → reference/SKELETON.html → reference/AIG.md → reference/AIG-COMPONENTS.md → reference/FRONTEND.md |
| A frontend-only app (todo, notes, tracker, timer, dashboard) | reference/SKELETON.html → reference/AIG.md → reference/AIG-COMPONENTS.md → reference/UI-UX.md → reference/FRONTEND.md |
| A CLI tool the LLM calls (journal, bookmarks, search) | reference/CLI-TOOL.md → reference/FRONTEND.md (if has UI) |
| A REST server app (2048, heavy backend, external API) | reference/REST-SERVER.md → reference/SKELETON.html → reference/AIG.md |
| External APIs / vault / network access | reference/SANDBOX.md |
| Anything unclear about AlfSDK (storage, sheets, tool, haptics) | reference/FRONTEND.md |
Rule: if the user says "game" / "jeu", you MUST read reference/GAMES.md before choosing architecture — games have canvas, input, resize, and HUD patterns that differ from normal apps. Don't default to the todo skeleton.
If the request is ambiguous (fewer than 2 concrete details), apply the Scope check below before picking refs.
CRITICAL RULES:
Your app runs in two different execution contexts. Get this wrong and you'll chase phantom bugs for hours.
┌────────────────────────────── PARENT FRAME (Control Center) ──────────────────────────────┐
│ Full auth (session cookie). Can reach any CC URL directly. │
│ Sheets you open with AlfSDK.sheet(html, actions) RENDER HERE — HTML runs in parent scope. │
│ │
│ ┌─────────────────────── IFRAME (your app) ────────────────────────┐ │
│ │ sandbox="allow-scripts allow-forms allow-popups ..." (no allow-same-origin) │
│ │ → Origin: null (opaque). No cookies, no top.*, no parent.document. │
│ │ AlfSDK obtains a short-lived Bearer token via MessageChannel on init. │
│ │ │
│ │ AlfSDK.api(path) → fetch(path, {Authorization: Bearer ...}) ← token attached │
│ │ AlfSDK.fetch(path) → same, raw Response (for blobs/streams) │
│ │ AlfSDK.sheet(html) → postMessage to parent, parent renders the HTML │
│ │ │
│ │ <img src="/apps/SLUG/foo.png"> ✅ static file in your app dir (auth bypass │
│ │ via sandbox sub-resource gate) │
│ │ <img src="/apps/SLUG/api/42.jpg"> ✅ proxied to your backend (asset ext bypass) │
│ │ <img src="/apps/SLUG/api/data.json"> ❌ data endpoint → 401. Use AlfSDK.api() instead. │
│ │ fetch('/api/vault/...') without SDK ❌ no Bearer → 401 │
│ └──────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────────────────────┘
Consequences:
AlfSDK.api()/AlfSDK.fetch() for every authenticated call because the browser can't attach the Bearer token on its own. Raw fetch() in an iframe → 401.<img>, <audio>, <video>, @font-face) can use direct URLs if the path ends with a media/font extension — the CC recognizes sandboxed sub-resources via Sec-Fetch-* + Origin: null and waives auth. Only for .png .jpg .jpeg .gif .webp .svg .ico .avif .woff .woff2 .ttf .otf .eot .mp3 .mp4 .webm .ogg .wav under /apps/{slug}/ OR /apps/{slug}/api/.... Everything else (including .json, .js, .css, .wasm) requires the SDK.AlfSDK.sheet(html) sends HTML to the Control Center for rendering. The HTML runs outside your iframe with full CC origin, so direct <img src="/apps/SLUG/api/42.jpg"> works there even without the sub-resource bypass. Don't mix the two contexts up: code in AlfSDK.sheet() is NOT in your iframe.127.0.0.1:{port} (port written to data/port) and the CC reverse-proxies /apps/{slug}/api/* → localhost:{port}/api/*. Strip Cookie, Authorization, and forwarded headers — app servers are untrusted and the CC removes them before forwarding.AlfSDK.action(targetSlug, action, params) — declared in the target's manifest.json. Never call another app's /apps/{other}/api/* directly; it's blocked by referer check (SEC-005).If a hypothesis about routing or auth doesn't match one of these 5 points, the hypothesis is wrong — re-check the context (iframe vs parent) before digging.
Before building, if the request has fewer than 2 concrete details, ask:
| Frontend-only | CLI tool (appsdk) | REST server | |
|---|---|---|---|
| Best for | Simple user apps | Data tools the LLM calls | Complex apps with heavy backend |
| Backend | None — AlfSDK.storage | Go main.go with appsdk | Go/Python with service.json |
| Frontend | index.html + vanilla JS | AlfSDK.tool() | Direct fetch to server |
| LLM tool | No | Always | Only if LLM needs data access |
| Compilation | None — works instantly | Go compile at install | Go/Python at install |
| Example | Todo, Notes, Timer, Tracker | Journal, Bookmarks | 2048, Dashboard, API proxy |
Decision tree — follow in order:
Does the LLM need to call this app as a tool via bash? (e.g., "add a journal entry", "search bookmarks") → Yes: CLI tool (Go + appsdk + manifest tools) → No: continue ↓
Does the app need server-side logic that JS can't do? (SQLite queries, external API calls via vault, file processing, cron jobs, WebSocket server) → Yes: REST server (Go/Python + service.json) → No: continue ↓
Everything else → Frontend-only (index.html + AlfSDK.storage + vanilla JS) This covers: todo lists, notes, trackers, timers, calculators, games, dashboards with local data, habit trackers, budget planners, etc.
Frontend-only is the default. No Go, no compilation, instant install. AlfSDK.storage provides persistent server-side key-value storage — sufficient for most apps.
Do NOT create a CLI tool for games, calculators, visual tools.
Do NOT use Go when AlfSDK.storage can handle the data needs.
Read the relevant reference file for templates, patterns, and API details:
| File | Read when |
|---|---|
reference/SKELETON.html | ALWAYS copy first — complete starting template with theme, stat-grid, card-group, filters, CRUD, sheets. Adapt to your app. |
reference/AIG.md | ALWAYS read — design rules, tokens, Do/Don't, zero custom CSS rule |
reference/AIG-COMPONENTS.md | ALWAYS read — all <alf-*> web components with attrs, events, JS API |
reference/UI-UX.md | ALWAYS read — UI/UX design principles: hierarchy, states, feedback, navigation, color, responsive |
reference/FRONTEND.md | AlfSDK API details (storage, sheets, tool, confirm, haptics, events) |
reference/CLI-TOOL.md | Building a CLI tool app (appsdk, manifest, go source) |
reference/REST-SERVER.md | Building a REST server app (service.json, Go/Python server) |
reference/GAMES.md | Canvas games (resize, input, d-pad, overlay, HUD) |
reference/SANDBOX.md | Vault proxy, external APIs, sandbox constraints |
manifest.json — slug, version, description, category, icon, tools (if CLI), permissions
app.json — { "name": "...", "icon": "lucide-icon", "description": "..." } (if web UI)
go.mod — with all dependencies declared (only if Go backend)
README.md — mandatory for every app. 10–30 lines, human-readable. Must include:
data/ (files, DB name, directories)./api/... route the backend exposes (if any), with method + purpose.storage, bash, network, etc.) and why.The README is the first thing another LLM reads when asked to fix a bug — without it, they'll rebuild the mental model by grepping the code, wasting tokens and making wrong guesses.
AlfSDK.storage (server-side key-value, persists across updates). On-disk: data/apps/{slug}/data/storage.json — readable directly via catmodernc.org/sqlite), database in data/<slug>.db, WAL mode, SetMaxOpenConns(1)<alf-*> web components — tabs, inputs, dialogs, lists, stats, alerts, etc. are ALL <alf-*> custom elements. Never compose raw CSS classes for patterns that have a component. Read reference/AIG-COMPONENTS.md for the full reference. alf-ui.css (auto-injected) provides styling; alf-components.js (auto-injected) provides the components.reference/FRONTEND.md.--space-* tokens, explicit font-family, Lucide SVG icons.unsafe-eval is in CSP. No build-step frameworks (React, Vue SPA, Angular). No external scripts/stylesheets (CSP blocks them).localStorage, document.cookie, or credentials: 'same-origin' — iframes are sandboxed. Use AlfSDK.storage and AlfSDK.api().fetch() directly for data — use AlfSDK.api() (parsed JSON, throws on non-2xx) or AlfSDK.fetch() (raw Response, for blobs/streaming). Both attach the Bearer token automatically.<img>, <audio>, <video>, @font-face CAN use direct URLs — if the asset is served under /apps/{slug}/ or /apps/{slug}/api/... with a media/font extension (.png .jpg .webp .svg .woff2 .mp4 ...). See the "Architecture mental model" section. Data endpoints still require AlfSDK.api().reference/SANDBOX.md.Compatibility (SDK + AIG — both required):
onThemeChange(palette, isDark) callback (2 args, not 1)onThemeChange updates both palette CSS and dark/light mode (data-theme or theme CSS)/static/... relative paths only<alf-*> web components — no manual CSS class composition for standard patterns--space-* tokens, no inline style overridesAll apps:
manifest.json with slug, version, description, permissionsapp.json with Lucide icon (if web UI)index.html with AlfSDK + theme CSS + explicit font-familyls -la ~/data/apps/<slug>/manifest.json ~/data/apps/<slug>/app.jsoncat ~/data/apps/<slug>/manifest.json | grep permissionsFrontend-only — AlfSDK.storage, "permissions": ["storage"], no .go files:
ls ~/data/apps/<slug>/*.go 2>/dev/null && echo "ERROR: Go files in frontend-only app"CLI tool — go.mod, main.go with appsdk, "permissions": ["bash", "storage"]
REST server — service.json + free port + data/port, vault via appsdk.NewVaultClient()
After the checklist above passes, run an end-to-end test to confirm the app actually works:
Frontend-only apps:
app enable <slug> (if not already enabled)curl -s http://localhost:${CC_PORT:-9400}/apps/<slug>/ → must return 200 with HTML containing AlfSDKAlfSDK.storage, test a write+read cycle:
curl -s -X PUT http://localhost:${CC_PORT:-9400}/api/apps/<slug>/storage/test -d '{"value":"e2e"}'
curl -s http://localhost:${CC_PORT:-9400}/api/apps/<slug>/storage/test
# Cleanup:
curl -s -X DELETE http://localhost:${CC_PORT:-9400}/api/apps/<slug>/storage/test
CLI tool apps:
app enable <slug> (if not already enabled)--help → must exit 0x-test to the tool's JSON schema (same format as tool-creator)REST server apps:
app enable <slug> → wait 2s for server startupcurl -s http://localhost:$(cat ~/data/apps/<slug>/data/port)/health → must return 200If any E2E step fails, fix the issue immediately. Do NOT deliver the app until E2E passes.
NEVER say "it's ready" without running these checks AND E2E verification. Fix any failure before reporting success.
Creates well-structured CLI tools (bash/python scripts) in ~/data/tools/ with --help, error handling, and proper conventions
Security expert that audits user-created skills and tools for injection, data exfiltration, and privilege escalation risks
Silent system health check that analyzes logs, detects errors, and reports issues to the user
Periodic heartbeat that executes user-defined instructions from context/heartbeat.md
Silent system health check that analyzes logs, detects errors, and reports issues to the user