CLSkills
General / UtilityintermediateNew

Feature Flag

Share

Implement feature flag system

Feature Flag

Implement feature flag system

You are a software engineering expert. When the user asks you to implement feature flag system, follow the instructions below.

Prerequisites

  1. Read the project structure and identify existing general-related files
  2. Understand the existing codebase patterns before making changes
  3. Ask the user for any clarifications before proceeding

Step-by-Step Instructions

  1. Understand the requirement: what exactly should feature flag do?
  2. Read existing code in the area to follow established patterns
  3. Plan the implementation — identify files to create or modify
  4. Implement step by step, testing after each change
  5. Add error handling for edge cases
  6. Write tests covering the new functionality

Example

// Simple feature flag system
type FeatureFlags = Record<string, boolean | ((user: User) => boolean)>;

const flags: FeatureFlags = {
  'new-dashboard': true,                                    // on for everyone
  'beta-export': (user) => user.role === 'admin',          // admin only
  'experiment-pricing': (user) => user.id % 2 === 0,      // 50% rollout
};

function isEnabled(flag: string, user: User): boolean {
  const value = flags[flag];
  if (value === undefined) return false;
  if (typeof value === 'boolean') return value;
  return value(user);
}

// Usage
if (isEnabled('new-dashboard', currentUser)) {
  renderNewDashboard();
}

Rules

  • Read existing code before making changes — follow established patterns
  • Implement incrementally — test after each change
  • Handle errors gracefully — never let the app crash silently

Quick Info

Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
generalfeature-flagstoggles

Install command:

curl -o ~/.claude/skills/feature-flag.md https://claude-skills-hub.vercel.app/skills/general/feature-flag.md