feature-flags
БесплатноБез исполняемых скриптовНе проверенMicrosoft.FeatureManagement patterns for feature toggles, gradual rollouts, and A/B testing in ASP.NET Core Razor Pages applications. Use when implementing…
от wshaddix★ 94 звезды на GitHubОб этом скилле
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
Установить feature-flags в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл feature-flags?
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.
Как установить скилл feature-flags?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл feature-flags запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
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…
от 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…
от 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…
от 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…
от Anthropic