webiny-add-feature-flag

Adds new feature flags to the Webiny system across DTO types, Zod schemas, and license decorators.

8.0k|673|Updated Jan 9, 2018
One-click install
npx skills add https://github.com/webiny/webiny-js --skill webiny-add-feature-flag
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: webiny-add-feature-flag
Source: https://github.com/webiny/webiny-js/tree/main/skills/repo-skills/add-feature-flag
Command: npx skills add https://github.com/webiny/webiny-js --skill webiny-add-feature-flag

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Adding a feature flag in Webiny touches many files across multiple packages, and missing one step causes flags to silently fail or bypass license gating. This Skill provides the complete procedure for wiring a flag through the DTO type, KnownFeatureFlag union, toDto(), Zod schema, and WCP license decorators.

Core Features & Use Cases

  • Simple Boolean Flags: Step-by-step instructions for adding a flag to IFeatureFlagsDto, KnownFeatureFlag, toDto(), and the Zod validation schema.
  • Nested Flag Groups: Guidance for flags with sub-options using union types and dot-path resolution like myFeature.subFeatureA.
  • License Gating: Explains the LICENSE_CHECKS decision flow and how to wire flags into all three license decorators at API, build, and config levels.
  • Use Case: When building a new gated capability, use this Skill to gate it at the config level with FeatureFlag.CanUse, at admin runtime with useFeatureFlags().isEnabled(), and at the API level via the FeatureFlags abstraction.

Quick Start

Add a new feature flag called myNewFeature to the Webiny system and gate my extension component with it.

Frequently Asked Questions about webiny-add-feature-flag

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

FAQPage Schema
How do I add a new feature flag in Webiny?

Add the flag to IFeatureFlagsDto in packages/feature-flags/src/types.ts, extend the KnownFeatureFlag union, include it in toDto(), and add it to the Zod schema in packages/project/src/extensions/FeatureFlags.tsx. Then gate your feature with FeatureFlag.CanUse or useFeatureFlags().isEnabled().

How do I gate a feature behind a WCP license in Webiny?

Add the flag to the LICENSE_CHECKS map in all three decorators: the API-level FeatureFlagsWithLicenseDecorator, the build-level GetFeatureFlagsWithLicense, and the config-level LicenseDecoratedFeatureFlags. You must also add a canUse method to the ILicense interface in @webiny/wcp.

Why is my Webiny feature flag always returning false?

Flags return false when no WCP license exists, when the license blocks the flag, or when config explicitly sets it to false. Config can disable what a license allows but cannot enable what a license blocks, and flags default to false when undefined.

Can I create nested feature flag groups in Webiny?

Yes, define the flag as a union of boolean and an options object in IFeatureFlagsDto, add dot-path entries like myFeature.subFeatureA to KnownFeatureFlag, and use a Zod union schema. In toDto(), collapse the parent to false when disabled.

When should I not add a flag to LICENSE_CHECKS?

Do not add a flag to LICENSE_CHECKS until the WCP backend supports it. Flags not in LICENSE_CHECKS still require a license to exist, but the user config alone decides whether they are enabled.