flags

Configure Next.js experimental feature flags across config and runtime layers.

Updated Apr 7, 2026
One-click install
npx skills add https://github.com/villa1/backupshop --skill flags-villa1
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: flags
Source: https://github.com/villa1/backupshop/tree/main/.agents/skills/flags
Command: npx skills add https://github.com/villa1/backupshop --skill flags-villa1

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

How to add or modify Next.js experimental feature flags end-to-end. Use when editing config-shared.ts, config-schema.ts, define-env.ts, next-server.ts, export/worker.ts, or module.compiled.js. Covers type declaration, zod schema, build-time injection, runtime env plumbing, and the decision between runtime env-var branching vs separate bundle variants.

Core Features & Use Cases

  • Centralized wiring for feature flags across compile-time and runtime paths.
  • Ensures flags are declared, validated, and wired through config-shared.ts, config-schema.ts, and, when needed, define-env.ts for client-bundled code.
  • Supports runtime propagation in server-side paths (next-server.ts) and binary bundles (export/worker.ts) to select appropriate feature variants.

Quick Start

Add a new flag by updating config-shared.ts and config-schema.ts, wire it into define-env.ts if it affects client bundles, and enable runtime propagation in next-server.ts or export/worker.ts as needed.

Frequently Asked Questions about flags

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new experimental feature flag in Next.js config?

Adding a Next.js feature flag requires updating config-shared.ts and config-schema.ts with type declarations and zod validation, then wiring runtime propagation in next-server.ts or export/worker.ts as needed.

What is the difference between runtime env-var branching and separate bundle variants for feature flags?

Runtime env-var branching selects feature variants dynamically at runtime using injected environment variables, while separate bundle variants generate distinct build-time bundles to isolate feature logic.

When do I need to wire feature flags into define-env.ts for Next.js?

You need to wire feature flags into define-env.ts when the flag affects client-bundled code, ensuring build-time injection properly exposes the feature variant to the client bundle.

Can I use zod schema validation for Next.js feature flags?

Yes, you can use zod schema validation for Next.js feature flags by defining the schema in config-schema.ts to ensure type safety and validate flag configurations.

How do I propagate feature flags to Next.js server-side paths and binary bundles?

To propagate feature flags to server-side paths, enable runtime injection in next-server.ts and export/worker.ts, ensuring the server and worker binaries select the appropriate feature variants.

What are the limitations of build-time feature flag injection in Next.js?

Build-time feature flag injection in Next.js requires separate bundles for different variants and cannot dynamically toggle flags at runtime without recompiling, limiting runtime flexibility.