From hypervibe
Internal helper invoked by /add-automation once Wrangler is installed and the project is a monorepo. Creates the apps/worker/ directory, scaffolds a Cloudflare Worker via wrangler init, optionally adds CRON triggers natively in wrangler.toml, implements scheduled+fetch handlers, and deploys. Returns the deployed worker URL. Not meant to be invoked directly by users.
How this skill is triggered — by the user, by Claude, or both
Slash command
/hypervibe:_create-cloudflare-workerThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
```bash
wrangler (to be done BEFORE any other wrangler command in this skill)eval "$(node "${CLAUDE_SKILL_DIR}/../../scripts/wrangler-env-init.mjs")"
This line loads CLOUDFLARE_API_TOKEN from the User scope (Windows registry / shell rc on Mac/Linux) if it is not in process.env, and adds the pnpm bin to the PATH (for bash sessions where pnpm setup has not yet propagated). Without it, wrangler fails with "command not found" on Mac (Spotlight), or may use a different Cloudflare account than the one the user expects.
You scaffold and deploy a Cloudflare Worker inside apps/worker/.
The caller (/add-automation) has already:
_setup-wrangler)_convert-to-turborepo)If any of these are not true, refuse and tell the user to invoke /add-automation instead.
The caller passes (or will tell you) two parameters:
NEEDS_CRON - yes or noCRON_EXPRESSION - a standard 5-field cron expression (only if NEEDS_CRON=yes)mkdir -p apps/worker
cd apps/worker
pnpm dlx wrangler init . --yes
This creates a minimal Worker template with wrangler.toml, src/index.ts, and a package.json.
Read the project name from the root package.json:
node -e "process.stdout.write(require('../../package.json').name)"
Read the Cloudflare account ID:
wrangler whoami | grep -oE '[a-f0-9]{32}' | head -1
Update apps/worker/wrangler.toml with:
name = "<project-name>-worker"
main = "src/index.ts"
compatibility_date = "<today's date in YYYY-MM-DD>"
account_id = "<account id>"
Append to wrangler.toml:
[triggers]
crons = ["<CRON_EXPRESSION>"]
Replace apps/worker/src/index.ts with:
export interface Env {
// Add your environment variables here, e.g.:
// SOME_API_KEY: string;
}
export default {
async scheduled(event: ScheduledEvent, env: Env, ctx: ExecutionContext): Promise<void> {
// TODO: your scheduled task logic here
console.log("Cron triggered:", event.cron, "at", new Date().toISOString());
},
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
return new Response("Worker is running", { status: 200 });
},
};
export interface Env {
// Add your environment variables here
}
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
// TODO: handle incoming requests
return new Response("Worker is running", { status: 200 });
},
};
Make sure apps/worker/package.json has:
{
"scripts": {
"dev": "wrangler dev",
"deploy": "wrangler deploy",
"tail": "wrangler tail"
}
}
cd apps/worker
wrangler deploy
Capture the deployed URL from the output (looks like https://<project-name>-worker.<your-subdomain>.workers.dev).
If the deploy fails:
wrangler whoami and verify it's set in wrangler.tomlSo the Next.js app can call the worker via HTTP, invoke _push-env-vars with:
WORKER_URL=<worker URL from Step 5>The helper writes to .env local AND pushes to Vercel (production/preview/development) in one operation.
Tell the user:
✅ Cloudflare Worker deployed.
URL:
<worker URL>Code:apps/worker/src/index.tsReal-time logs:pnpm --filter=worker tailLocal dev:pnpm --filter=worker dev
If NEEDS_CRON=yes, also tell the user:
The CRON is handled natively by Cloudflare via
[triggers]inwrangler.toml. Current schedule:<CRON_EXPRESSION>. To change it, editwrangler.tomland redeploy.
Return control to the calling skill (/add-automation). Pass back the worker URL so the orchestrator can include it in its final summary.
npx claudepluginhub flavien-ia/hypervibe-harness --plugin hypervibeGuides Cloudflare Workers and Pages development with Wrangler CLI, including project init, wrangler.toml config, D1/R2/KV/Queues setup, secrets management, and deployment.
Deploys a project to Cloudflare Workers using the Wrangler CLI, with custom domain binding and accessibility verification. Explains the free tier (100k requests/day).
Builds and deploys serverless applications on Cloudflare Workers using JavaScript, TypeScript, Python, or Rust. Useful for APIs, full-stack web apps, edge functions, background jobs, and real-time apps.