xiaohongshu
xiaohongshu
feature-flag-manager
Adds feature flag support using LaunchDarkly or JSON-based configuration to toggle features in UI components and Server Actions. This skill should be used when implementing feature flags, feature toggles, progressive rollouts, A/B testing, or gating functionality behind configuration. Use for fea...
Full skill instructions
Implement comprehensive feature flag management for controlled feature rollouts and A/B testing in worldbuilding applications.
To add feature flag capabilities:
To integrate LaunchDarkly:
npm install launchdarkly-react-client-sdkUse scripts/setup_launchdarkly.py to scaffold LaunchDarkly configuration.
To implement local JSON-based flags:
config/feature-flags.json with flag definitionsUse scripts/setup_json_flags.py to generate JSON flag structure.
Consult references/feature-flag-patterns.md for implementation patterns and best practices.
To set up LaunchDarkly in Next.js:
// app/providers.tsx
import { LDProvider } from 'launchdarkly-react-client-sdk';
export function Providers({ children }: { children: React.ReactNode }) {
return (
<LDProvider
clientSideID={process.env.NEXT_PUBLIC_LD_CLIENT_ID}
user={{
key: 'user-id',
email: '[email protected]',
}}
>
{children}
</LDProvider>
);
}
To create custom JSON provider:
// lib/feature-flags/provider.tsx
import { createContext, useContext } from 'react';
import flags from '@/config/feature-flags.json';
const FeatureFlagContext = createContext(flags);
export function FeatureFlagProvider({ children }: { children: React.ReactNode }) {
return (
<FeatureFlagContext.Provider value={flags}>
{children}
</FeatureFlagContext.Provider>
);
}
export function useFeatureFlags() {
return useContext(FeatureFlagContext);
}
Reference assets/feature-flag-provider.tsx for complete provider implementation.
To gate UI components behind flags:
import { useFeatureFlag } from '@/lib/feature-flags';
export function NewFeatureComponent() {
const isEnabled = useFeatureFlag('new-timeline-view');
if (!isEnabled) {
return null;
}
return <div>New Timeline View</div>;
}
To show different variants based on flags:
export function EntityList() {
const useNewLayout = useFeatureFlag('entity-list-redesign');
return useNewLayout ? <NewEntityList /> : <LegacyEntityList />;
}
To gate Server Actions:
// app/actions/entity-actions.ts
'use server';
import { getFeatureFlag } from '@/lib/feature-flags/server';
export async function createEntity(data: EntityData) {
const allowBulkCreate = await getFeatureFlag('bulk-entity-creation');
if (allowBulkCreate && data.items?.length > 1) {
return bulkCreateEntities(data.items);
}
return createSingleEntity(data);
}
Reference assets/server-actions-with-flags.ts for server-side flag patterns.
Define flags with metadata:
{
"flags": {
"new-timeline-view": {
"enabled": true,
"description": "Enable new timeline visualization",
"rolloutPercentage": 100,
"allowedUsers": [],
"environments": {
"development": true,
"staging": true,
"production": false
}
}
}
}
Support different flag types:
Consult references/flag-types.md for detailed flag type specifications.
To implement gradual feature rollouts:
Use scripts/rollout_manager.py to automate rollout percentage updates.
To target specific user segments:
const flags = evaluateFlags(userId, flagConfig);
const flags = evaluateFlags({
userId: 'user-123',
email: '[email protected]',
role: 'admin',
tier: 'premium',
});
const flags = evaluateFlags(user, {
rules: [
{ property: 'role', operator: 'equals', value: 'admin' },
{ property: 'tier', operator: 'in', values: ['premium', 'enterprise'] },
],
});
To configure flags per environment:
{
"flags": {
"debug-mode": {
"development": true,
"staging": true,
"production": false
},
"experimental-features": {
"development": true,
"staging": false,
"production": false
}
}
}
Load environment-specific configuration at build time or runtime.
To implement A/B tests:
export function EntityDetailPage() {
const variant = useFeatureFlagVariant('entity-detail-layout', {
control: 'grid',
variantA: 'list',
variantB: 'cards',
});
return variant === 'list' ? (
<EntityListView />
) : variant === 'cards' ? (
<EntityCardView />
) : (
<EntityGridView />
);
}
Track variant exposure for analytics:
useEffect(() => {
trackExposure('entity-detail-layout', variant);
}, [variant]);
To add a new feature flag:
To clean up completed feature flags:
Use scripts/find_flag_usage.py to locate all usages of a flag before removal.
To override flags in development:
// .env.local
NEXT_PUBLIC_FEATURE_FLAGS_OVERRIDE='{"new-timeline-view":true}'
To test flag variations:
// test/setup.ts
import { mockFeatureFlags } from '@/lib/feature-flags/testing';
beforeEach(() => {
mockFeatureFlags({
'new-timeline-view': true,
'bulk-entity-creation': false,
});
});
Reference assets/testing-utils.ts for testing utilities.
To track feature flag impact:
Integrate with analytics platform:
import { analytics } from '@/lib/analytics';
export function useFeatureFlagWithTracking(flagName: string) {
const isEnabled = useFeatureFlag(flagName);
useEffect(() => {
analytics.track('feature_flag_exposure', {
flag: flagName,
enabled: isEnabled,
});
}, [flagName, isEnabled]);
return isEnabled;
}
To leverage LaunchDarkly capabilities:
Consult LaunchDarkly documentation for advanced features.
Common issues:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience