feature-flags
FreeNo executable scriptsNot checkedMicrosoft.FeatureManagement patterns for feature toggles, gradual rollouts, and A/B testing in ASP.NET Core Razor Pages applications. Use when implementing…
by wshaddix★ 94 GitHub starsAbout this skill
Rationale
Feature flags enable safe deployments, gradual rollouts, A/B testing, and quick rollback capabilities. Without proper feature flag patterns, teams risk deploying incomplete features or cannot respond quickly to production issues. These patterns provide a robust, maintainable approach to feature management in Razor Pages applications.
Patterns
Pattern 1: Configuration-Based Feature Flags
Use appsettings.json for simple feature toggles with environment-specific overrides.
// appsettings.json
{
"FeatureManagement": {
"NewDashboard": false,
"BetaFeature": false,
"DarkMode": true,
"PaymentV2": {
"EnabledFor": [
{
"Name": "Microsoft.Targeting",
"Parameters": {
"Audience": {
"Users": [ "[email protected]" ],
"Groups": [ "BetaTesters" ],
"DefaultRolloutPercentage": 0
}
}
}
]
}
}
}
// appsettings.Production.json
{
"FeatureManagement": {
"NewDashboard": true,
"PaymentV2": {
"EnabledFor": [
{
"Name": "Microsoft.Targeting",
"Parameters": {
"Audience": {
"Users": [ "[email protected]" ],
"Groups": [ "BetaTesters" ],
"DefaultRolloutPercentage": 25
}
}
}
]
}
}
}
// Program.cs - Basic setup
builder.Services.AddFeatureManagement();
// With custom configuration section
builder.Services.AddFeatureManagement(
builder.Configuration.GetSection("FeatureManagement"));
// With feature filters
builder.Services.AddFeatureManagement()
.AddFeatureFilter<TargetingFilter>()
.AddFeatureFilter<PercentageFilter>()
.AddFeatureFilter<TimeWindowFilter>();
Pattern 2: Typed Feature Flags
Create strongly-typed feature flags for compile-time safety and discoverability.
// Feature flag constants
public static class FeatureFlags
{
public const string NewDashboard = "NewDashboard";
public const string BetaFeature = "BetaFeature";
public const string DarkMode = "DarkMode";
public const string PaymentV2 = "PaymentV2";
public const string ApiRateLimiting = "ApiRateLimiting";
public const string AdvancedReporting = "AdvancedReporting";
}
// Feature-aware service interface
public interface IFeatureAwareService
{
Task<bool> IsEnabledAsync(string featureName);
Task<bool> IsEnabledAsync<TContext>(string featureName, TContext context);
}
public class FeatureService : IFeatureAwareService
{
private readonly IFeatureManager _featureManager;
public FeatureService(IFeatureManager featureManager)
{
_featureManager = featureManager;
}
public Task<bool> IsEnabledAsync(string featureName) =>
_featureManager.IsEnabledAsync(featureName);
public Task<bool> IsEnabledAsync<TContext>(string featureName, TContext context) =>
_featureManager.IsEnabledAsync(featureName, context);
}
// Extension methods for easier usage
public static class FeatureManagerExtensions
{
public static Task<bool> IsNewDashboardEnabledAsync(this IFeatureManager manager) =>
manager.IsEnabledAsync(FeatureFlags.NewDashboard);
public static Task<bool> IsPaymentV2EnabledAsync(this IFeatureManager manager, string userId) =>
manager.IsEnabledAsync(FeatureFlags.PaymentV2, new TargetingContext { UserId = userId });
}
Pattern 3: Razor Pages Integration
Use feature flags in Razor Pages for conditional UI rendering and routing.
// PageModel with feature flag checks
public class DashboardModel : PageModel
{
private readonly IFeatureManager _featureManager;
public DashboardModel(IFeatureManager featureManager)
{
_featureManager = featureManager;
}
public bool UseNewDashboard { get; private set; }
public bool IsDarkModeEnabled { get; private set; }
public async Task OnGetAsync()
{
UseNewDashboard = await _featureManager.IsEnabledAsync(FeatureFlags.NewDashboard);
IsDarkModeEnabled = await _featureManager.IsEnabledAsync(FeatureFlags.DarkMode);
}
}
// View with conditional rendering
@page
@model DashboardModel
@inject IFeatureManager FeatureManager
@if (Model.UseNewDashboard)
{
<partial name="_NewDashboard" model="Model" />
}
else
{
<partial name="_LegacyDashboard" model="Model" />
}
@if (await FeatureManager.IsEnabledAsync(FeatureFlags.BetaFeature))
{
<div class="alert alert-info">
<strong>Beta:</strong> Try our new experimental features!
</div>
}
@if (Model.IsDarkModeEnabled)
{
<button id="theme-toggle" class="btn btn-outline-secondary">
Toggle Dark Mode
</button>
}
Pattern 4: Feature Gate Action Filter
Use the built-in feature gate filter for controller/page-level feature control.
// Controller/PageModel level feature gate
[FeatureGate(FeatureFlags.BetaFeature)]
public class BetaFeaturesMo
Install feature-flags in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the feature-flags skill do?
Microsoft.FeatureManagement patterns for feature toggles, gradual rollouts, and A/B testing in ASP.NET Core Razor Pages applications. Use when implementing feature toggles in ASP.NET Core applications, setting up gradual feature rollouts, or configuring A/B testing scenarios with feature flags.
How do I install the feature-flags skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the feature-flags skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
by Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
by Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
by Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
by Anthropic