Charming CLI
Charming is a hosting platform for personal apps you and your agent build, update, and use together. Learn more at usecharming.com. Install: npm install -g usecharming.
Charming hosts small single-purpose personal apps. You write two files, push them with charming, and the user gets a real URL with real storage that any agent — including this one, later — can keep editing.
An app is a directory:
module.js— required. The backend: amanifestand aroutesarray.ui.js— optional. One JavaScript program that fills#app.styles.css— optional. Overrides only.
Do not free-hand the skeleton. Copy templates/crud, then change the data model.
111dce1 (Teach the skill to build apps, not just drive the CLI)
Start
charming auth status. If"authenticated": false, runcharming auth login --no-openand give the user the approval URL and code.- Copy the CRUD template into a working directory:
cp -r "$(npm root -g)/usecharming/templates/crud" ./my-appChangemanifest.id,manifest.meta.name, the storage key, and thewindow.charming.api("<id>")argument inui.jsto match. charming apps create ./my-app --description "<one line>" --dry-runcharming apps create ./my-app --description "<one line>" --yes- Smoke-test the backend before you claim it works:
charming apps call <app-id> list --input '{}' - Return the
urlfrom the JSON result.
--yes is required on a signed-in create because a create whose manifest.id already exists replaces that app in place. Ask the user before running it, and keep manifest.id stable and unique per app.
Without a saved token, charming apps create still works: it pairs the new app to this machine and stores an app-scoped credential locally, so later update and call on that app work from the same machine without charming auth login.
Iterate
The CLI has no partial-edit mode. The loop is export, edit, push:
charming apps source <app-id> --out ./my-app # writes module.js / ui.js / styles.css
# edit the files
charming apps update <app-id> ./my-app --dry-run
charming apps update <app-id> ./my-app
apps update reads the current source, matches its ETag, and fails loudly on a conflicting concurrent write instead of clobbering it — there's no revision number to track. A field missing locally is left as-is on the server: a directory with no ui.js updates the module and keeps the deployed UI.
Other commands: charming apps list, charming apps describe <app-id> (the public descriptor — ops and input schemas), charming apps rename <app-id> <name>, charming apps delete <app-id> --yes.
Run mutations with --dry-run first. Signed-in creates and deletions require --yes; pass it only after the user approves that action.
Read JSON results from stdout. Login instructions and JSON errors use stderr. Branch on error.kind. Follow error.recovery when present. Never print tokens or device_code values. Show user_code only during login.
charming auth logout removes the user credential and every app credential for the selected origin. Unclaimed apps that relied on those app credentials become unreachable.
The module
export const manifest = {
$schema: 'https://charm.ing/schema/app-manifest/2026-07-31.json',
id: 'water-log', // stable, unique, never changes
meta: { name: 'Water Log', icon: { emoji: '💧', bg: '#0ea5e9' } },
capabilities: { imports: ['charming:storage/kv@1.0'] },
};
export const routes = [
{
op: 'list',
method: 'GET',
annotations: { readOnlyHint: true },
handler: async (_input, { env }) => (await env.storage.get('items_v1')) ?? [],
},
];
manifestis parsed statically. Keep it a plain literal — no computed values.- Unknown top-level keys are rejected. The keys are
$schema,id,meta,capabilities,permissions. There is noversionordisplayNamekey — the display name ismeta.name. meta.iconis one emoji plus a hex background, not an array of image URLs.- Declare the capabilities you use, nothing more. There is no capability
exportsarray —routesis the only way to expose an operation. routesis an array of route objects, never an object keyed by op name.opvalues must be unique.- Charming does not infer
readOnlyHintfrommethod: 'GET'. Set it explicitly on every read, or the operation publishes as a mutation. - Handlers receive
(input, { env, ctx, request })and return a JSON-compatible value; Charming wraps it as{ ok: true, value }on the wire (or{ ok: false, error: { kind, message } }on failure). - Only WinterTC globals (Request, Response, URL, crypto, TextEncoder, …). No Node APIs, no DOM.
- Omit
default.fetchunless the app needs custom fallback HTTP; Charming supplies a 404 handler when it's absent.
Storage
env.storage (get / put / delete / list) stores JSON values directly. Never JSON.stringify on the way in or JSON.parse on the way out. Storage is per-app and survives updates, so iterate freely.
env.storage works everywhere the app runs — the web app and inside Claude/ChatGPT. localStorage / sessionStorage / IndexedDB need the claim-gated charming:browser/storage@1.0 capability and are empty inside chat hosts. Anything the user expects to keep belongs in env.storage.
Keep user data in env.storage, never in module constants — a shared or templated copy of the app then starts empty instead of leaking the author's data.
Full capability list, permissions.server.fetch rules, secrets, and external images: resources/contract.md.
The UI
ui.js is one JavaScript program — not HTML, not a module. Charming injects <div id="app"></div>, a Tailwind-compatible runtime, and a default theme.
const api = window.charming.api('water-log'); // manifest.id, NOT the URL's UUID
const items = await api.list({}); // the value itself; throws on failure
window.charming.api(id).<op>(input) returns the value directly and throws CharmingOperationError on failure. It is not api.operation(name, params), and it is never a raw fetch().
Sandbox rules that silently break apps:
alert,confirm, andpromptdo nothing. Build inline UI instead.- No external
<script>tags or CDN imports. Inline a UMD build if a library is truly needed. - Prevent native form submission and handle it in JavaScript.
- Set
#appinnerHTML before attaching listeners, and re-bind after every re-render. Re-render narrow containers, not the whole root, or a refresh wipes half-typed input. - Reserve the bottom-right 64px square — Charming's protected control sits there. Do not build a Charming badge, share button, app switcher, or account nav inside the app; the outer shell owns those.
window.charming.viewer.can(op) is a UI hint for read-only viewers, not an auth check — the server enforces access. Catch forbidden / forbidden_write and render a read-only state.
Visual style
Charming apps should look like one product, not one generated page.
- Page
bg-stone-50; cardsbg-white border border-stone-200 rounded-md. - Labels
text-sm font-semibold text-stone-700; numberstabular-nums. - One accent color per app (emerald / amber / violet / cyan / sky); stone neutrals everywhere else.
- Sticky header with the title and one live metric. Optional tab nav with
border-b-2on the active tab. - Fill the viewport. Don't wrap the whole app in a narrow
max-w-*box, and don't default every app to heading + input + button + empty list. - No tiny all-caps tracked eyebrows, no empty settings pages, no fake account fields — they read as generated.
Patterns that keep biting
- Undo-toast deletes beat confirm dialogs (which no-op here): delete immediately, show "Removed · Undo" for ~6s, and have Undo call a
restoreop that upserts by id. The CRUD template includes this. - Inline confirm for genuinely destructive actions: swap the button for "Delete? [Delete] [Cancel]".
- Migration discipline: a versioned storage key (
items_v1) plus anormalize()on read that fills defaults for new fields. On a shape change, writemigrate(old)and keep the old key one cycle. - Live updates:
window.charming.onStateChange?.(() => refresh()), with a ~4ssetIntervalas a backstop.
More patterns, including agent-mediated enrichment and display-only apps: resources/patterns.md.
Beyond apps: the platform API
charming apps … covers create / read / update / call / delete. Everything else — sharing, public access, templates, routines, secrets, feedback — goes through the generated catalog:
charming api list, thencharming api describe <operation-id>.charming api request set-app-public --param id=<app-id> --body '{"public":true}' --dry-run
charming doctor checks connectivity, auth, and contract freshness. charming agent-context prints the CLI's own contract as JSON.
