Anatomy of a Vibe
The local files your AI writes and the CLI uploads
Last updated: November 2026
Starter template files
The platform serves four templates, and the CLI downloads the one you pick. Start from tools, a blank data vibe on key-value storage; tools-sql is the same on SQL (Pro or Pro+). Both create the same small project shape:
my-vibe/
.vibe-coded.json # Local platform manifest
index.html # Frontend, styles, and browser code
worker.js # API routes, storage calls, and MCP tools
Run vibe templates to list them, then vibe init --template tools my-vibe to download one. site is a static page: index.html only, no worker. vue is a Vue 3 and TypeScript app with a build step and no backend. Template metadata decides the storage type.
A static vibe can contain only index.html and the manifest. When you ask your coding agent for a Vue and TypeScript app, the skill uses this structure:
my-vibe/
.vibe-coded.json # Local platform manifest
package.json # Dependencies and build script
tsconfig.json # TypeScript configuration
vite.config.ts # Vite and Vue configuration
index.html # HTML shell
worker.ts # Backend, for a full-stack vibe
src/
main.ts # Vue app initialization
vite-env.d.ts # Vite type declarations
App.vue # Root component
Your AI can add components, composables, views, and a hash-based Vue router as the app grows.
What vibe preview uploads
vibe preview uploads the local source tree and builds it on the platform. It skips node_modules, dist, .git, .vibe-coded, .vibe-coded.json, source maps, .DS_Store, .env, files named .env.*, .dev.vars, .sql files, and agent or editor folders such as .claude, .cursor and .vscode. To leave out more, list gitignore-style patterns in a .vibeignore file at the project root; vibe dev follows it too. Without one, root README, REPORT, NOTES, CHANGELOG and LICENSE files and root *.md files are left out. The platform also refuses file types outside its allowlist, any path containing .secret, and data or text files with password or credential in their path; see File type not accepted in the CLI guide. Do not keep credentials in the source tree.
By default, preview also removes remote source files that no longer exist locally, in the same step as the upload. Use --no-prune to keep remote-only files, or --prune to confirm a large removal.
File limits. One upload carries at most 1,000 files, counting the ones it removes, and a vibe's source holds at most 10,000. A build can serve at most 5,000 files and 500 MB, whether they come from dist/ or the project folder. Past a limit, the upload or the build is refused with a message that names it.
What a vibe without a build step serves. If your vibe has no dist/ folder, its files are served as they are, with some exceptions: the root worker (worker.js or worker.ts), config files (wrangler.*, vite.config.*, tsconfig*, package.json and lockfiles, vibe.json, template.json, .vibe-coded.json), and notes such as README.md are never served, even to you as the owner. Pages, scripts, styles and images are, and so are local modules the worker imports, such as lib/helper.js, and any data files in the folder. So keep server-only code in the root worker file, or build to dist/. Check what's live with vibe fetch <path>. On every vibe, /files/ is reserved for files the worker stores as files (see Storage bindings), so a files/ folder in your project is not served.
The frontend
The frontend can be plain HTML and JavaScript or a Vite app. Calls to the worker use relative, snake-case /api/ paths and POST:
const response = await fetch('/api/list_notes', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ tag: 'idea' })
})
const { success, data, error } = await response.json()
The worker and MCP tools
worker.ts or worker.js is a self-contained worker. It handles /api/ requests, uses platform storage bindings, and returns { success, data } or { success: false, error }.
This is add_note from the tools template:
/**
* @mcp-expose
* @description Save a note. Returns the saved note with its id.
* @param {string} text - The note (required)
* @param {string} [tag] - Optional tag for grouping, e.g. "idea"
*/
async function add_note(text, tag, env) {
if (!text || typeof text !== 'string') return { success: false, error: 'text is required' };
if (tag !== undefined && typeof tag !== 'string') return { success: false, error: 'tag must be a string' };
const id = crypto.randomUUID();
const now = new Date().toISOString();
const note = { id, text, tag: tag || null, createdAt: now, updatedAt: now };
await env.VIBE_STORAGE.put(`notes:${id}`, JSON.stringify(note));
return { success: true, data: note };
}
Key-value storage is strongly consistent: get() and list() see every earlier write, so a note your AI just added is in the list the next time it asks. list() returns at most 1,000 keys a page; the template's loadAll helper, which list_notes uses, follows the cursor to the last page.
The build extracts a tool only when @mcp-expose is attached to an async function declaration. Unannotated helpers, arrow functions, and object methods are not exposed. @mcp-scope is optional metadata; it does not grant access. Access is set per vibe by role, with viewers in read mode and writers, admins, and owners in write mode.
The worker reaches the outside world through web requests (fetch, including streamed responses) and outbound WebSockets. It cannot open raw TCP or TLS sockets, and it cannot serve inbound WebSocket connections: the platform refuses the upgrade with HTTP 400.
Limits of the worker. A request must send its first byte within 30 seconds or the platform answers 504. Work registered with ctx.waitUntil can carry on for about 30 seconds after the response. Whatever is still running then is cancelled, and the worker gets no error to catch. Each request can make 5 outbound requests on Free, 20 on Pro and 50 on Pro+. Builds refuse imports of cloudflare:sockets, node:net, node:tls and node:module.
Storage bindings
Key-value storage is available on every plan. SQL and file storage require Pro ($9/month) or Pro+ ($20/month). See Plans & Billing for quotas instead of copying them into your app documentation.
| Binding | Storage | Plans | Typical operations |
|---|---|---|---|
env.VIBE_STORAGE |
Key-value | Free, Pro, Pro+ | get, put, delete, list |
env.VIBE_D1 |
SQL | Pro, Pro+ | prepare, bind, run, all, first, batch; exec, raw and dump are refused, and each prepare takes one statement |
env.VIBE_R2 |
Files | Pro, Pro+ | put, get, delete, list |
env.VIBE_SECRETS |
Secrets | Pro, Pro+ | get |
On Free, env.VIBE_R2 is bound, but a write (put or an upload URL) throws an error with code: 'ENTITLEMENT_EXCEEDED' (a 403 if the worker doesn't catch it), so a worker that may run on Free catches that error instead of checking whether the binding exists. Reads, lists, deletes and download links work, so files stored before a downgrade stay available to the worker. A vibe downgraded to Free keeps env.VIBE_D1 bound to its existing database, read-only (see Downgrading).
await env.VIBE_SECRETS.get('NAME') returns a stored secret's value, or null when the vibe has none under that name; secrets are not set on env itself. The call throws an error with code: 'SECRET_READ_ONLY' in a read-only request, and the plan error above on Free; either is a 403 if the worker doesn't catch it. See the CLI guide.
Serving stored files
A file the worker stores through env.VIBE_R2 is served at /files/<key> on the vibe's own address, so <img src="/files/uploads/logo.png"> works in a page and the browser can seek in a video and cache. The same access rules as the vibe's pages apply, and each read counts against the vibe's daily file-read allowance (see Plans & Billing), separate from its API calls. Images, audio, video, PDFs, plain text and fonts display inline; anything else is offered as a download. Preview and production keep separate files. For browser uploads, the worker mints a one-time upload link with createUploadUrl: a link on the vibe's own address that takes one upload of the exact size the worker named, at most 100 MB, within 10 minutes, and counts against file storage when the file arrives. For a download from a script, createDownloadUrl returns a link to /files/<key> on the vibe's own address that anyone holding it can open for up to 120 seconds; vibe files url <key> --expires 7d prints one to share for up to 7 days. Such a link opens that one file whatever the vibe's access settings. A page doesn't need one to show a file.
Changing a SQL schema
Preview and production each have their own database. The preview's starts empty, so have the worker create its own tables with CREATE TABLE IF NOT EXISTS the first time a write tool runs, as the tools-sql template does, and apply schema changes the same way. When you publish, production runs the same code against its own data. Publishing copies no data, so the migration runs again there. Keep migrations additive (add columns or tables, don't rename or drop them), so production's existing rows keep working.
When the vibe is over its plan's SQL storage limit, or read-only after a downgrade, CREATE TABLE IF NOT EXISTS and CREATE INDEX IF NOT EXISTS do nothing instead of failing, so a tool that sets up its tables before deleting rows can still free space. Other writes are refused. A delete that cascades through ON DELETE CASCADE runs, since it only removes rows. A foreign-key action that rewrites rows (ON DELETE SET NULL or SET DEFAULT) is refused, and so is a statement that would fire a trigger; drop the trigger first.
A read-only caller (a viewer, or anyone the vibe's policy lets in read-only) can run SELECT, including WITH … SELECT. For them too, CREATE TABLE IF NOT EXISTS and CREATE INDEX IF NOT EXISTS do nothing, and any other write is refused. PRAGMA statements are refused on a read-only connection. The pragma functions that only read still run inside a SELECT: pragma_table_info, pragma_table_xinfo, pragma_table_list, pragma_index_list, pragma_index_info, pragma_index_xinfo, pragma_foreign_key_list, pragma_foreign_key_check and pragma_quick_check. Any other pragma function is refused. To read a table's columns, use SELECT * FROM pragma_table_info('table_name'). The same rule applies to a database that is over its storage limit or read-only after a downgrade, whoever the caller is.
Local, preview, and production
Use vibe dev while editing. It runs the worker with local key-value, SQL and file data and reloads it when you save worker code. Other files are served from your project as they are — it doesn't run Vite — so refresh the browser after frontend edits and use vibe preview to see a built Vue app. Use vibe preview when you need to test a live build, platform access checks, OAuth, or the full MCP transport. Previewing never changes production. After checking the preview URL, vibe publish deploys that exact build to production. Preview and production keep separate data (key-value storage, SQL and files): test records you add on the preview stay there, and publishing copies none of them. Calls your code makes to the outside world, such as webhooks or email, are real on the preview too.