Skip to content

Feature Request: Inferred feature flags via void/flags (AST discovery & typegen) #987

Backlog

Description

@mfulton26

Updated with Cloudflare Flagship in mind.

Summary

Add inferred feature flags via void/flags backed by Cloudflare Flagship—allowing developers and AI agents to define flags directly in code while Void automatically provisions the Flagship app/binding, registers inferred flags, generates TypeScript types, and exposes toggle controls in the CLI and Platform UI.

Why This Fits Void

Void already turns code imports (void/db, void/kv, void/env) into provisioned Cloudflare bindings with zero boilerplate. Now that Cloudflare has a native, OpenFeature-compatible Workers binding for feature flags (Flagship), void/flags can follow the exact same pattern:

  • Zero-config Flagship provisioning: Importing void/flags automatically creates the Flagship app, wires up the Workers binding (env.FLAGS), and syncs inferred flag definitions—no manual dashboard setup or wrangler configuration required.
  • Built for AI agent workflows: Coding agents routinely wrap new features in flags to safely ship to production. Static AST inference prevents "orphan" flags in code that haven't been registered in the control plane yet.
  • OpenFeature standard: Because Flagship is natively built on OpenFeature, developers get a clean, portable API with sub-millisecond edge evaluation and zero vendor lock-in.

Proposed DX

// routes/api/checkout.ts
import { defineHandler } from 'void';
import { flags } from 'void/flags';

export const POST = defineHandler(async ({ request }) => {
  // Statically inferred: key = 'new-checkout', type = boolean, default = false
  const useNewCheckout = await flags.getBoolean('new-checkout', false, {
    targetingKey: request.headers.get('x-user-id') ?? undefined,
  });

  return { flow: useNewCheckout ? 'v2' : 'v1' };
});

Core Capabilities

  1. Static Inference & Typegen: Build/dev scanning extracts flag keys, inferred variant types (boolean, string, number, json), and default values—generating .void/flags.d.ts for autocomplete and catching type mismatches if a key is reused with conflicting default types.
  2. Automatic Flag Sync & Local Dev: Defaults to code-defined fallbacks in void dev (with local overrides via CLI or env), while void deploy syncs newly discovered flags to Flagship without overwriting existing targeting rules or rollout percentages.
  3. CLI & Platform Controls:
    • void flags list / void flags set <key> <value> for quick terminal toggles and kill switches.
    • Surface Flagship status and deep-links/toggles inside the Void Platform UI alongside inferred DBs and KVs.
    • Stale-flag warnings when a flag exists in Flagship but no longer appears in the AST.

Open Questions for Maintainers

  • Should void/flags expose thin wrappers (flags.getBoolean(...)) around the Flagship binding, or directly expose an initialized OpenFeature client?
  • Note: Cloudflare Flagship is currently in beta—would you want to gate void/flags behind an experimental flag until Flagship reaches GA?

Drafted with assistance from Gemini.

Activity

  1. cpojer commented on Dec 1, 2026

    @cpojer
    Member

    I think it would be great to use Flagship if possible: https://developers.cloudflare.com/flagship/ – but with a Void-like API.

  2. mfulton26 commented on Dec 1, 2026

    @mfulton26
    Author

    Yes, perfect. I did not know Flagship was a thing. Void APIs also help developers discover things like this. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions