feature-switch

Guides gating new user-facing features behind feature flags in the vm0 codebase.

1.2k|70|Updated Nov 14, 2025
One-click install
npx skills add https://github.com/vm0-ai/vm0 --skill feature-switch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: feature-switch
Source: https://github.com/vm0-ai/vm0/tree/main/.claude/skills/feature-switch
Command: npx skills add https://github.com/vm0-ai/vm0 --skill feature-switch

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

New user-facing features shipped without rollout controls can expose unfinished functionality to all users at once. This Skill documents the vm0 feature switch system and provides step-by-step instructions for gating features behind flags for gradual, controlled rollout.

Core Features & Use Cases

  • Switch Registration: Add a key to the FeatureSwitchKey enum and register it in the FEATURE_SWITCHES record with maintainer, default state, and per-user, per-email, or per-org hash allowlists.
  • Multi-Layer Gating Patterns: Apply gating in server-side API routes, client-side platform UI components, sidebar navigation, connector auth methods, and agent token capabilities.
  • Override Layers: Understand the two-layer evaluation model combining the static core registry with database overrides stored per user or per org via the feature-switches API.
  • Use Case: When adding a new sidebar page, register a switch with staff-only org hashes, gate the nav item by reading featureSwitch$, and later flip enabled to true for general availability.

Quick Start

Ask the AI to add a new feature switch named MyFeature and gate a new sidebar navigation item behind it following the feature-switch guide.

Frequently Asked Questions about feature-switch

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

FAQPage Schema
How do I add a feature flag in a TypeScript monorepo?

Add a key to the FeatureSwitchKey enum in feature-switch-key.ts, then register it in the FEATURE_SWITCHES record with a maintainer email and default enabled state. Finally gate the feature in application code using isFeatureEnabled on the server or featureSwitch$ on the client.

When should a new feature be gated behind a feature switch?

Gate all new user-facing features including UI pages, sidebar items, API endpoints, integrations, and agent token capabilities. Internal refactors, test infrastructure, CI changes, bug fixes, and documentation updates do not require a switch.

How do I limit a feature to staff users only?

Set enabled to false and add STAFF_ORG_ID_HASHES to the enabledOrgIdHashes field in the switch registration. This is the most common default for new features and restricts access to staff organizations until broader rollout.

Can feature switches be overridden without changing code?

Yes, database overrides stored in user_feature_switches take priority over the static registry. They are written via POST /api/feature-switches and cleared via DELETE, with some switches scoped per org using a sentinel user id.

How do I gate a connector behind a feature flag?

Add an entry to FEATURE_SWITCH_BY_AUTH_METHOD in connector-auth-method-feature-switches.ts, keyed by connector slug and auth method id. Deploy the association before publishing the gated method and remove it once the switch graduates.