Skip to content
Back to skills

Myco Server Provisioning

ASecurity

Provision, update, roll back and destroy the Cloudflare Deployment — the Worker front door — with `myco server <verb> --target cloudflare`. One verb, from artifacts the binary carries: no source checkout on the machine that deploys, and no container runtime anywhere.

  • 17 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 19, 2026
ai-agentsjavascriptrustgojavashellbashsqlnodenodejsdocker

Works with

  • cli
  • api
  • mcp

Security analysis

A100/100

Scanned November 29, 2026

npx -y skills add goondocks-co/myco --skill myco-server-provisioning --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Myco Server Provisioning?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Myco Server Provisioning
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/goondocks-co-myco-server-provisioning/badge)](https://www.skillsdirectory.com/skills/goondocks-co-myco-server-provisioning)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: myco-server-provisioning
description: >-
  Provision, update, roll back and destroy the Cloudflare Deployment — the Worker front
  door — with `myco server <verb> --target cloudflare`. One verb, from artifacts the
  binary carries: no source checkout on the machine that deploys, and no container
  runtime anywhere.
when_to_use: >-
  Use for any Cloudflare provisioning or deploy work, for D1 migration ordering against
  a live Deployment, for the free-tier surface rule, when changing the Worker bundle the
  binary carries, and when debugging a wrangler failure during a deploy. Also read it
  before adding any binding to `wrangler.toml`.
allowed-tools: Read, Edit, Write, Bash, Grep, Glob
user-invocable: true
---

# Cloudflare Deployment lifecycle

The Cloudflare Deployment is one of two front doors. It is storage, MCP, ingest and a scheduler; it runs no harness. Provisioning is **one verb from artifacts the binary carries** — there is no source checkout on the machine that deploys, and no container runtime anywhere.

## Guided owner setup

Lead with `myco setup` for a new owner. On a fresh machine, choose **Start a new Myco**, then Cloudflare. To choose explicitly:

```bash
myco setup --create cloudflare
```

A supported Node.js is required on the operator's machine. Setup checks the engine requirement declared by the Wrangler used to build this binary; missing or unsupported Node names the required version and https://nodejs.org/en/download as the next step. With consent, setup installs the binary's pinned Wrangler privately under `<MYCO_HOME>/server/tools/`, without root or a global npm prefix. It offers Cloudflare sign-in when needed. Setup asks for the Cloudflare account and address before creating resources, guides GitHub sign-in registration, prints a private owner link and waits for linking before signing this machine in. Choose the address before registering sign-in.

Rerun `myco setup` after interruption; it continues from observed state. Existing machine connections can select a joining journey, so use `--create cloudflare` explicitly when creating is intended. Use `myco setup --status` for read-only progress, with `--check-remote` for remote checks.

After sign-in, follow **Get started** on **Today** for the next action. Creating a server does not enroll a runner. A runner is an explicit choice on a machine with a supported coding agent signed in; see [Runners](https://myco.sh/runners). Automatic work also needs **Work on its own** enabled in **Settings**.

For a 1.4 machine, follow **myco-setup** or [Moving from Myco 1.4](https://myco.sh/upgrade#upgrading-from-myco-14). Guided setup previews the move and asks for approval. The manual reference is `myco cutover --dry-run`, then `myco cutover`; keep its backups and `restore.md`. `myco cutover --dismiss-earlier-copies` only acknowledges earlier copies locally after review; it deletes no history and contacts no Deployment.

To leave a wrong Deployment, use `myco logout <address>`. It preserves capture and runner registrations and updates each agent separately. A partial logout names any agent configuration it could not update; fix the named files and rerun the same command, even after local membership has been removed. With an unreachable server, `myco logout <address> --local-only` removes local connections without revoking the remote credential.

## Manual operator reference

Node and Wrangler are needed here, not on machines merely capturing sessions or running tasks. Server commands select the sole existing Deployment, or local on a fresh home. If both Deployments exist, or an old Compose installation is retained, name the supported target explicitly.

```bash
myco setup --create cloudflare
myco server create --target cloudflare --account-id <id> [--url https://myco.example.com]
myco server github-app --target cloudflare --url <chosen-address>
myco server setup-owner --target cloudflare
myco server status --target cloudflare
myco server update --target cloudflare
myco server rollback --target cloudflare [--version <id>]
myco server destroy --target cloudflare --yes
```

Use the printed workers.dev address or a custom domain in the same Cloudflare account. Complete GitHub app registration, then open the private, expiring owner link from `setup-owner`, sign in and choose **Connect this account**. Repeating owner setup replaces a pending link; an already connected account is preserved and setup refuses. Hosted owner setup uses the operator's Cloudflare login while the Deployment keeps serving.

Sign this machine in with `myco setup --join <address>`, then follow the dashboard checklist. Invite teammates through **Settings › People and machines** → **Invite a teammate**; **Connect GitHub** gives them dashboard sign-in.

`create` is idempotent: every resource is ensured, an existing record keeps its ids, and a re-run converges. That also makes it the adopt path for resources created by hand. `destroy` removes the Worker only — the database, bucket, store and record all stand, because the Worker is re-creatable from the binary and the data is not.

Every verb checks supported Node and selects one Wrangler before running provider commands: an operator installation found by read-only local/global package discovery is preferred only when its major matches the bundled Wrangler; otherwise the private pinned copy is used. A failed operator check falls back to that copy with a diagnostic note; only when neither works does it refuse, retaining the first meaningful diagnostic.

Discovery reads npm configuration and installed manifests through Node without starting npm's CLI or contacting a registry. Version probes disable Node compile caches, npm updates/logs and Wrangler logs/metrics. Commands execute the selected JavaScript entry directly through Node; they never install packages.

Older or damaged private tools are repaired through the same consented setup step: the tools owner stages and verifies the replacement under the operator lock while existing tools stay available, then swaps it into place and restores the old folders if publication fails. Cleanup of unused installation folders is best-effort and does not fail a successful installation. Installation removes Cloudflare credential variables and explicitly overrides npm global mode and location. A missing compatible tool names `myco setup --create cloudflare` as the next action; only setup offers the consented installation. `myco doctor` and `myco setup --status` report the selected version and runnable command.

Identity-check failures retain Wrangler's diagnostic; only signed-out results offer browser login.

Readiness also requires a Cloudflare identity — setup's consented browser sign-in, or `CLOUDFLARE_API_TOKEN` in a shell that cannot open a browser, which is taken on trust rather than verified, so a stale or wrong-scope token fails in the first command's own words. Each missing one is refused by name in one line, so the first thing an operator reads is Myco's instruction rather than wrangler's.

Creating resources requires `--account-id`; subsequent commands can use the recorded account. A login reaching several accounts must not silently choose where new resources go. `myco setup --create cloudflare` lists the accounts and asks which to use.

`--dir` and `--no-drain` are refused **by name**. Neither applies: there is no checkout to point at, and a deploy replaces no runtime so it waits for nothing.

## What a deploy is made of

A deploy runs entirely out of `~/.myco/server/cloudflare/deploy/`, which the binary writes and resets on every run:

| Staged | From |
|---|---|
| `worker/worker.js` | `BUNDLED_WORKER`, built by wrangler from `packages/myco-server/src` |
| `ui/dist/**` | `BUNDLED_SERVER_UI`, the Deployment dashboard |
| `migrations/*.sql` | `renderMigrationFiles()`, rendered from `SCHEMA_STEPS` |
| `wrangler.deploy.toml` | `renderDeployConfig(record, recordPath)` |

`packages/myco/src/server/cloudflare-stage.ts` is the single writer of that directory. Do not add a second one, and do not hand a deploy a path an operator typed.

**The entry sits alone under `worker/` and the config sets `find_additional_modules = false`.** Both. `no_bundle = true` turns that option on by default and `base_dir` defaults to the entry's directory, so an entry beside the dashboard and the migrations carries both into the Worker script as modules — measured at 31 extra modules and 65 KiB. Either measure alone would prevent it; keeping both means the regression needs two independent mistakes.

## Changing the Worker

Any change under `packages/myco-server/src/` changes the bundle. It is **generated, not committed**: `codegen` builds it, and `prelint`/`pretest` build it so a fresh clone has it before the typechecker reads it. Regeneration is skipped when every input is older than the module, so those hooks are free on an unchanged tree.

The generated module records the wrangler version that built it, and that is compared to the lockfile before the staleness check — a bundler bump fails on the next command rather than the next command that happens to rebuild. Run `npm ci` if it fires.

To build it by hand: `npx tsx packages/myco/scripts/gen-worker-bundle.ts`. It builds against the committed configuration minus its `[assets]` table, because assets upload beside the script rather than into it and wrangler refuses to run at all when the directory that table names is absent.

## The free-tier rule

The Deployment can deploy on Workers Free and uses no required paid add-on. Its usage decides which plan fits. Workers Free allows **10 ms of CPU per invocation (requests and scheduled ticks)**; heavy work such as transcript import or large reads may be cut short. Workers Paid removes that 10 ms restriction and permits a configurable CPU limit. See [Cloudflare CPU limits](https://developers.cloudflare.com/workers/platform/limits/#cpu-time). Durable Objects use the free plan's **SQLite** backend (`new_sqlite_classes`); Containers require a paid plan and are absent.

`[limits]` is a paid-plan table. If `wrangler deploy` or `wrangler versions upload` refuses with numeric code **100328**, Myco saves `cpuLimitRefusedRelease` in the deployment record, renders without that table and retries that step once. It prints the CPU restriction on the first recorded refusal; a previously recorded refusal gets one short repeat line. Later creates and updates with the same binary release omit the table from the start. Rollback activates an existing version without uploading configuration and preserves the fact. A different binary release tries the limit again, and `--cpu-limit` on `myco server update --target cloudflare` or `myco server create --target cloudflare --account-id <id>` tries immediately without waiting for a release. The flag probes once for that run: acceptance clears the refusal; another 100328 records it again and retries without the table. Hosted restore uses the same uploader for publication, persisting the fact in its recovery journal before retry and carrying it into the restored record. No billing or subscription API is queried.

Before adding any table to `wrangler.toml`, admit it in `FREE_TIER_SURFACES` (`packages/myco/src/server/deploy-config.ts`), or explicitly handle a conditional paid table in `PAID_PLAN_SURFACES` and the renderer. The gate checks the committed base and both rendered variants in both directions: every table must be admitted, every admitted table must ship, and the refusing-account config must contain exactly the free surfaces.

## Durable Object class lifecycle

The `migrations` array is an **ordered ledger, appended to** — never edited in place. Retiring a class means removing its binding and its code, then appending a delete entry while leaving the entry that created it:

```toml
[[migrations]]
tag = "v3-harness-retired"
deleted_classes = [ "HarnessContainer" ]
```

Three things to know before you run one:

- **It is one-way and it destroys the namespace's stored data.** Rehearse against a throwaway Worker name that first carried the class, not against a fresh one — a delete on a namespace that never existed proves nothing.
- **The class must be absent from the code**, or the deploy is refused.
- The parity harness drops any migration naming a class the Worker no longer exports, because a local boot resolves every named class against the code it runs (`parityDrops`, `deploy-config.ts`).

Cloudflare's newer declarative `exports` field is mutually exclusive with `migrations`. Moving across is a separate change with its own risk; do not mix them.

## Order, and what it protects

Updates upload the bundled Worker and dashboard with `wrangler versions upload` **before** applying D1 migrations. Upload does not activate that version: the serving Worker and schema stay together during upload retries. Only after the schema reaches its target does `wrangler versions deploy <uploaded-version>@100% --yes` activate that exact version. Routes and cron schedules are then applied with `wrangler triggers deploy`. Create still migrates before its first `wrangler deploy`. A Worker serves only the schema it was built for.

Upload has its own 10 minutes of command time and backoff. After migrations complete, activation and trigger updates share a fresh 10-minute budget. Each phase waits from 15 seconds up to 1 minute between attempts, and each command is capped at 2 minutes or the remaining time. D1 migrations have their own pacing budget. Each attempt and wait is reported. Cloudflare 10021 with “try again later”, HTTP 5xx, network failures and timeouts are retried. A permanent refusal stops as **stopped: Worker refused**; exhaustion stops as **stopped: Worker update ran out of time**. Both name the phase and the next command: `myco server update --target cloudflare`. A stop after the schema advances warns that the Deployment refuses requests until the Worker lands and members are spooling capture. A timeout, connection failure or exhausted activation budget can leave activation unconfirmed; check `myco server status --target cloudflare` when the report says this is unconfirmed. The deployment record changes its serving version only after activation is acknowledged, and retains the applied migration recovery point on an activation stop.

The Deployment’s GitHub App supplies sign-in and read-only repository permissions (Contents, Pull requests and Metadata). `myco server github-app --target local|cloudflare --url <address>` registers a fresh App only when sign-in is absent; for configured sign-in it guides extension of that same registration. Import a generated key through `--private-key-file <downloaded.pem>` or `--private-key-stdin`. Key-only imports verify the configured Client ID and required permissions while preserving sign-in credentials. Explicit `--existing --client-id <id> --client-secret-stdin` installs or rotates the sign-in pair first, including on a configured server. A fresh registration also installs sign-in first; a key failure leaves sign-in installed and prints the repository-setup command. Remove the downloaded PEM after checking dashboard Settings → Connections → GitHub. Native import requires a stopped server; start it afterward.

The key is one infrastructure secret, `GITHUB_APP_PRIVATE_KEY`, never a provider slot or recovery credential. After restore or key loss, generate a new key in GitHub and run the import again. Sign-in remains available without it. The key is the only repository access a Deployment has: an admin connects each Project's repository in its Settings → Repository from an installation of this App, after approving the installing account; there are no per-Project tokens.

Finish a stopped update before editing secrets: run `myco server update --target cloudflare` first. Wrangler refuses secret edits while the newest Worker version is undeployed; this can block backup-credential and GitHub App secret installation.

Cloudflare does not support version uploads that create, delete, rename or transfer Durable Object classes. Such an upload is refused before D1 migrations; the update never switches to `wrangler deploy` to bypass that refusal. Review the class lifecycle change before rerunning. The bundled script and static assets themselves support version uploads.

Before advancing an existing database's schema, create and update obtain a current D1 Time Travel bookmark and save it with the before/after schema versions, timestamp and prior Worker version in `~/.myco/server/cloudflare/record.json` under `schemaUpdates`. A missing or invalid bookmark refuses the operation before remote mutation. Fresh provisioning into a verified empty database is exempt; a resumed create uses the existing-database gate. Code-only updates need no bookmark. Recovery records admitted bookmarks in `recovery.json` until publication.

A failed migration command is settled against the live schema through the same probe as status. The target version confirms application, records completion and permits the Worker deploy; the update names the provider error and confirmation. The starting version means failed with nothing applied. Any other version, including an intermediate migration, or a failed probe keeps the outcome unknown and stops before the Worker. Read the reported version and `myco server status --target cloudflare` before choosing a retry or recovery.

D1 answers code 7429 when a large database is overloaded, typically by index builds over history-sized tables. Each migration file applies whole and Wrangler resumes after the last one applied, so the update waits with bounded backoff and applies again, reading and reporting the live schema (`schema 728 of 772`) after each attempt; the live-schema read is retried the same way. The 8 waits are counted at one live schema and start over whenever the schema advances, so a run that keeps making progress does not run out. An apply that answers nothing for 15 minutes is ended; the live schema is read before any rerun, since the stalled call may have committed files. It stops by name instead of reporting an unknown outcome: **stopped: D1 overloaded** when the waits at one schema run out, with the live schema and the rerun command, **stopped: a migration exceeds D1 limits** when two attempts in a row apply nothing at the same live schema while the database answers, naming the next file, **stopped: a migration timed out** when two stalled applies in a row apply nothing, or **stopped: the update ran out of time** when the whole update passes 2 hours. An attempt that advanced the schema never counts against a file: a migration can commit and still answer 7429. That stop gives the restore command for the most recent bookmark taken at the schema the old Worker serves, warns when that bookmark is past the Free plan's 7-day Time Travel window, says so when none is recorded, and lists this update's own recovery point separately. Either stop says which release the Worker was left on and whether it serves the live schema: a Worker serves only the schema it was built for. An update that finds D1 already overloaded before it starts refuses with nothing changed. Other migration failures settle once, as above.

`myco server rollback --target cloudflare` rolls back code only. Cloudflare Time Travel restores the database alone and discards later database writes; Myco does not yet coordinate it with writers, in-flight jobs, Durable Object state or Vectorize. A compatible Worker is required after a database restore. Hosted stored objects are held for 30 days after release regardless of plan, preserving their bytes for database points within that protected window; objects removed before the hold was installed remain unavailable. Keep the provider restore output and undo bookmark. Before choosing database recovery, read [the coordination boundary](https://github.com/goondocks-co/myco/blob/main/docs/architecture/hosted-rewind.md). A complete recovery artifact is separate and may not exist: verify its presence and coverage before choosing artifact recovery.

Use `myco server backup --target cloudflare --to <dir>` for a full verified database-and-blob recovery artifact. Each hosted backup pauses database requests while it exports the database: the dashboard and tools cannot read or save data, capture waits on members’ machines for later delivery, and larger databases take longer. Only the database export blocks requests; later reconstruction and object copying do not prolong the pause. Capture remains on each member and is delivered on a later hook or drain. Native `myco server backup --to <dir>` keeps serving during the copy. Time Travel is the everyday in-place database protection within the plan’s window (30 days on Paid, 7 on Free), while an independent complete copy covers losing the database/account or moving. A hosted schedule is optional and carries the same export pause; do not recommend enabling it without that disclosure. Keep the credentials it names separately. Restore into fresh resources under a fresh `MYCO_HOME` with `myco server restore --target cloudflare --from <dir> --secrets-from <file> --account-id <id> --source-retired --yes` only when the source is retired; use `--fork` instead if it remains serving. See [backup and recovery](https://myco.sh/self-hosting#back-up-and-restore).

The deployment record at `~/.myco/server/cloudflare/record.json` is written **before** the first deploy, so a failure mid-create leaves a record naming what already exists. It holds no credentials — the account id and resource names are not secrets, and the token that reaches them lives in the operator's own wrangler login.

Secrets travel on **stdin, never argv**: the wrapping key into the Secrets Store, `SESSION_SECRET` onto the live Worker after the first deploy. Never `WRANGLER_LOG=debug` while installing one; it prints the request.

## Debugging a failed deploy

- **`Docker build exited with code: 1`** — a `[[containers]]` table is back in the configuration. It should not be; containers are gone and are a paid surface.
- **`The entry-point file ... was not found`** — a config outside the package. Wrangler resolves `main` relative to the config file's own directory.
- **`assets.directory ... does not exist`** — building the bundle against the committed config instead of the stripped one.
- **A deploy that carries 30-odd extra modules** — `find_additional_modules` is on, or something joined the entry's directory.
- **Work stays queued** — check `myco server status --target cloudflare` and **Runners**. The Deployment runs no harness; queued work waits for a registered runner with a usable agent sign-in and model profile. A concurrency limit also queues work; a daily ceiling holds off another start until a later wake.

## What this Deployment does not do

It runs no harness and starts no container. Task execution belongs to registered runners using coding agents signed in on their machines. Runners update themselves between runs. A change that gives the Worker a runtime is a change of architecture, not a configuration edit — take it to the plan first.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.