Generation module — local (subscription) vs hosted (API) mode

One env flag, GENERATION_MODE, decides which path actually runs. local reuses the same automated agent already deploying this app every 30 minutes — it runs the ep044_group skills itself, using your Claude subscription, at no per-call cost. hosted is the Render cron + LLM-API loop already built in lib/generation/. Only one path is ever active; both produce identical output at the same GitHub location and both hand back to the same three endpoints, so the rest of the pipeline never needs to know which mode built a given site.

GENERATION_MODE = click to preview each path — this toggle is illustrative only, the real flag lives in .env / Render env vars

Shared trigger — same for both modes

A business enters the queue the moment claim approval fires (already built).

Claim approved

Business stage set to awaiting_site_generation in the same transaction as approval.

claims-approval.ts
→

Queue readable

Any consumer — local agent or hosted cron — can see it.

GET …/queue
→

GENERATION_MODE?

local → left path runs, hosted path is inert.

local mode — subscription-driven, no per-call cost

The same agent already redeploying this app every 30 minutes also runs this loop on its own cycle.

Agent checks queue

Its normal 30-min pass now also calls the queue endpoint.

GET …/queue
→

Picks category → skill

Same normalize-and-match this session already built for the hosted path.

lib/generation/skill-loader.ts
→

Agent runs the skill itself

No LLM API call — the agent is the model, reasoning directly against SKILL.md + business data + images, under your existing subscription.

skills/ep044_group/…
→

Commit & push

Same output location the hosted path would use — GitHub Pages serves either identically.

epics/ep_006_website_rebuilds/redesigns/<slug>/
→

Report complete

Already built — advances the pipeline stage.

POST …/complete
→

Notify owner

Already built — preview-ready email.

POST …/notify

hosted mode — Render cron + LLM API (built this session, dormant until a key + this flag exist)

Same skill and image inputs, but the model call goes over HTTP with metered billing — the path for once there are paying clients and no one's watching a subscription session.

Render cron fires

Every 15 minutes, independent of any local session.

render.yaml → ep047-site-generation
→

Checks queue + config

No-ops cleanly if LLM_PROVIDER/key unset.

lib/generation/config.ts
→

Calls Anthropic or OpenAI

One prompt, one structured JSON-files response — no tool-use loop yet.

lib/generation/llm-client.ts
→

Writes files (not pushed)

Deliberately not auto-committed/pushed — left as a confirmed step.

run-generation.ts
→

Report complete

Same seam as local mode.

POST …/complete
→

Notify owner

Same seam as local mode.

POST …/notify
Why one flag, not both running: both paths call the same complete endpoint, which advances the pipeline stage — if both ran against the same queue at once, a business could get double-generated (or the second run's completion call could silently overwrite the first). GENERATION_MODE is a hard either/or switch, not a preference; whichever path is not selected must exit immediately without touching the queue at all.