feature-flags

Feature flag evaluation backed by Unleash using AT.Common.FeatureFlags. Use this skill when adding, checking, or testing feature flags in a .NET application, exposing a feature flag HTTP endpoint, or configuring context-based flag evaluation.

arbeidstilsynet/dotnet-common2 installsMITSynced Aug 22

Works with

Claude CodeCursorCodex CLIGitHub CopilotGemini CLI
---
name: feature-flags
description: Feature flag evaluation backed by Unleash using AT.Common.FeatureFlags. Use this skill when adding, checking, or testing feature flags in a .NET application, exposing a feature flag HTTP endpoint, or configuring context-based flag evaluation.
license: MIT
---

# FeatureFlags Skill — Arbeidstilsynet/dotnet-common

`Arbeidstilsynet.Common.FeatureFlags` (`AT.Common.FeatureFlags.Publish`) wraps the Unleash client in a simple `IFeatureFlags` interface with context support, automatic fallback for testing, and an optional HTTP endpoint.

---

## Installation

```bash
dotnet add package Arbeidstilsynet.Common.FeatureFlags
```

---

## Configuration

Add to `appsettings.json`:

```json
{
  "FeatureFlags": {
    "Url": "https://unleash.example.com/api",
    "ApiKey": "your-api-key-here",
    "AppName": "my-application",
    "Environment": "development"
  }
}
```

---

## Dependency Injection Setup

```csharp
using Arbeidstilsynet.Common.FeatureFlags.DependencyInjection;
using Arbeidstilsynet.Common.FeatureFlags.Model;

var featureFlagSettings = builder.Configuration
    .GetSection("FeatureFlags")
    .Get<FeatureFlagSettings>() ?? new FeatureFlagSettings();

builder.Services.AddFeatureFlags(featureFlagSettings);
```

> **Note:** If `Url` or `ApiKey` is empty in `featureFlagSettings`, the service automatically uses `FakeUnleash` — all flags are disabled by default. This keeps tests and local development working without an Unleash server.

---

## Checking Feature Flags

Inject `IFeatureFlags` into any service or controller.

```csharp
using Arbeidstilsynet.Common.FeatureFlags.Ports;

public class MyService(IFeatureFlags featureFlags)
{
    public void DoSomething()
    {
        if (featureFlags.IsEnabled("my-new-feature"))
        {
            // New code path
        }
        else
        {
            // Old code path
        }
    }
}
```

### Context-based evaluation

Pass a `FeatureFlagContext` to enable user-specific or group-specific rollouts:

```csharp
var context = new FeatureFlagContext
{
    UserId = userId,
    AppName = appName,
    SessionId = sessionId,
};

if (featureFlags.IsEnabled("user-specific-feature", context))
{
    // Only enabled for this user
}
```

---

## HTTP Endpoint

Expose a feature flag check endpoint for frontend or cross-service consumers:

```csharp
// Default route: POST /featureflag
app.MapFeatureFlagEndpoint();

// Custom route
app.MapFeatureFlagEndpoint("/api/features");
```

### `FeatureFlagRequest`

```csharp
public record FeatureFlagRequest
{
    public required string FeatureName { get; init; }
    public FeatureFlagContext? Context { get; init; }
}
```

### `FeatureFlagResponse`

```csharp
public record FeatureFlagResponse
{
    public required bool IsEnabled { get; init; }
    public required string FeatureName { get; init; }
}
```

**Request:**

```http
POST /featureflag
Content-Type: application/json

{
  "featureName": "my-new-feature",
  "context": {
    "userId": "user123",
    "appName": "my-application",
    "sessionId": "abc-123"
  }
}
```

**Response:**

```json
{
  "featureName": "my-new-feature",
  "isEnabled": true
}
```

---

## Testing

When `Url` or `ApiKey` is empty, `FakeUnleash` is registered automatically. Toggle flags directly via the `FakeUnleash` instance in tests:

```csharp
services.AddFeatureFlags(new FeatureFlagSettings());

// Resolve the FakeUnleash instance and enable a flag
var fakeUnleash = (FakeUnleash)serviceProvider.GetRequiredService<IUnleash>();
fakeUnleash.SetToggle("test-feature", true);
```

Or rely on the auto-fallback (all flags disabled by default):

```csharp
// All flags disabled; call SetToggle on the resolved FakeUnleash to override per test
services.AddFeatureFlags(new FeatureFlagSettings());
```

---

## `IFeatureFlags` Interface

```csharp
public interface IFeatureFlags
{
    bool IsEnabled(string featureName, FeatureFlagContext? context = null);
}
```

---

## Adding a Feature Flag — Checklist

1. Define the flag in Unleash (name must match the string passed to `IsEnabled`)
2. Wrap the new code path with `if (featureFlags.IsEnabled("flag-name"))`
3. In tests, use `fakeUnleash.SetToggle("flag-name", true)` to activate the flag
4. Remove the flag and old code path once the feature is fully rolled out

More Deployment & CI/CD skills

azure-enterprise-infra-planner

microsoft/azure-skills

Architect and provision enterprise Azure infrastructure from workload descriptions. For cloud architects and platform engineers planning networking, identity, security, compliance, and multi-resource topologies with WAF alignment. Generates Bicep or Terraform directly (no azd). WHEN: 'plan Azure infrastructure', 'architect Azure landing zone', 'design hub-spoke network', 'plan multi-region DR topology', 'set up VNets firewalls and private endpoints', 'subscription-scope Bicep deployment', 'Azure Backup for VM workloads'. PREFER azure-prepare FOR app-centric workflows.

387.5k

azure-kubernetes-app-deploy

microsoft/azure-skills

Use when deploying an existing web application or API to an already-running Azure Kubernetes Service cluster. Detects the framework, generates a Dockerfile and Kubernetes manifests, validates against AKS Deployment Safeguards, and deploys with verification. WHEN: deploy app to AKS, deploy to existing AKS cluster, containerize app for Kubernetes, generate K8s manifests for Azure, set up CI/CD for AKS, my AKS deployment is failing safeguard checks, I have a Django/Express/Spring Boot app to run on AKS. DO NOT USE FOR: creating or provisioning an AKS cluster (use azure-kubernetes), assessing migration to AKS Automatic (use azure-kubernetes-automatic-readiness), or deploying to non-AKS targets like Web Apps, Container Apps, or Functions.

380.4k

finetuning

microsoft/azure-skills

Fine-tune models on Microsoft Foundry using SFT (supervised), DPO (preference), or RFT (reinforcement with graders). Covers dataset preparation, training job submission, deployment, and evaluation. USE FOR: fine-tune, SFT, DPO, RFT, training data, grader, distillation, fine-tuned model, training job, large file upload, calibrate grader, deploy fine-tuned model, evaluate fine-tuned model. DO NOT USE FOR: general model deployment without fine-tuning (use deploy-model), agent creation (use agents), prompt optimization without training (use prompt-optimizer).

323.2k

← All Deployment & CI/CD skills

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY