Beta Gate
Ship unfinished features to staging but never to production: a build-time flag plus a runtime guard.
- What
- Ship unfinished features to staging but never to production: a build-time flag plus a runtime guard.
- Cost
- Free
- Needs
- Add a staging-only beta area to your static site in three steps. You need: a static site generator with a build step, and a worker/server entry point (Cloudflare Workers shown, adaptable).
- Install
- Copy the installer prompt below into your Muse — your agent does the rest.
Beta Gate is the two-layer system that keeps work-in-progress features visible on staging and impossible to serve in production. It was built for an Astro plus Cloudflare Pages site (the "Dry Dock") after a beta UI leaked to production through a normal deploy, and it has held ever since. Layer one is a build-time flag. Every beta surface (nav link, homepage teaser, beta pages) is gated behind a single boolean read from the shell environment at build time. Build with SHOW_BETA=1 and the beta UI is included; build without it and the output contains zero beta HTML. The flag is read via process.env, not import.meta.env, because Vite does not inject arbitrary shell variables into import.meta.env. The flag module is imported from build-time code only, never from client-side scripts. Layer two is a runtime guard in the worker entry. Before any route handling, requests to /beta* and /api/beta* on production hostnames get a plain 404. This catches the classic accident: a beta-enabled build deployed to production by mistake. Either layer alone would be enough on a careful day; together they make a leak practically impossible. The kit also documents the deploy discipline that makes it stick: staging and prod as separate targets, never two builds at once (one build's output can clobber the other's), never rebuild the output directory while an upload is in flight, and a zero-tolerance post-build check that greps the prod output for beta path strings.
Version:
Install
Copy the install package below, then paste it into MuseCommunity-built. Skill Harbor doesn't audit code — review the source before installing.
Add a staging-only beta area to your static site in three steps. You need: a static site generator with a build step, and a worker/server entry point (Cloudflare Workers shown, adaptable). 1. Create src/lib/beta.ts (or equivalent) exporting a single boolean read from process.env at build time: SHOW_BETA is true only when process.env.SHOW_BETA === '1'. Important: use process.env, NOT import.meta.env. Import this module from frontmatter/server code only, never from client-side <script> tags. 2. Gate every beta surface behind the flag: navigation links, homepage teasers, and the beta pages/routes themselves. A build without the flag must produce zero beta HTML. 3. Add the runtime guard at the very top of your worker entry, before any route handling: if the path matches /beta* or /api/beta* AND the hostname is a production domain, return a 404 immediately. This is your safety net for a wrong-build-deployed-to-prod accident. 4. Deploy: staging gets SHOW_BETA=1 npm run build, production gets a plain npm run build. Never run two builds concurrently and never rebuild while an upload is in flight. 5. Verify: after each deploy, grep the prod output for beta path strings (expect zero hits) and curl a beta path on the prod hostname (expect 404). Keep the default OFF: production must be safe with zero configuration.
Saved to your recent installs. Find it anytime on /connect.
Questions
How do I install a build?
Every product page includes a copy-paste install prompt. Paste it into your Muse and it sets the build up for you — no manual configuration.
Where does my money go?
Straight to the seller. Skill Harbor never processes payments: checkout happens on the seller’s own page, usually Stripe.
What does the ✓ next to a creator’s name mean?
It means we confirmed the identity of the person behind the listing. It says nothing about the code itself — always check a build before installing it.