feature-flags

Evaluate feature flags from a self-hosted ffs server. Use when you need to check whether a feature is enabled, get a variant value for an A/B test, or batch-evaluate multiple flags for a user. Triggers include "check feature flag", "is feature enabled", "evaluate flag", "feature toggle", "ffs evaluate", or any task that needs to gate behavior behind a flag.

7 stars

Best use case

feature-flags is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Evaluate feature flags from a self-hosted ffs server. Use when you need to check whether a feature is enabled, get a variant value for an A/B test, or batch-evaluate multiple flags for a user. Triggers include "check feature flag", "is feature enabled", "evaluate flag", "feature toggle", "ffs evaluate", or any task that needs to gate behavior behind a flag.

Teams using feature-flags should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/feature-flags/SKILL.md --create-dirs "https://raw.githubusercontent.com/heldernoid/agentic-build-templates/main/projects/developer-tools/feature-flag-server/skills/feature-flags/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/feature-flags/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How feature-flags Compares

Feature / Agentfeature-flagsStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Evaluate feature flags from a self-hosted ffs server. Use when you need to check whether a feature is enabled, get a variant value for an A/B test, or batch-evaluate multiple flags for a user. Triggers include "check feature flag", "is feature enabled", "evaluate flag", "feature toggle", "ffs evaluate", or any task that needs to gate behavior behind a flag.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# feature-flags

Evaluate feature flags from a self-hosted feature-flag-server instance.

## When to use

- Checking whether a feature is enabled for a specific user
- Getting a variant value for an A/B test or multivariate experiment
- Batch-evaluating multiple flags in a single request
- Gating code paths behind flags before deploying

## Prerequisites

1. A running feature-flag-server instance
2. An API key (`ffs_...`) from the server admin
3. The `@ffs/js-sdk` installed, or use the REST API directly

## Installation (JS SDK)

```bash
pnpm add @ffs/js-sdk
```

## Quick Start

```typescript
import { FlagClient } from '@ffs/js-sdk';

const client = new FlagClient({
  baseUrl: 'http://localhost:7777',
  apiKey: process.env.FFS_API_KEY!,
  environment: 'production',
  cacheTtl: 30_000,
});

// Check a boolean flag
const enabled = await client.isEnabled('new-checkout-flow', { userId: 'user_123' });

// Get a variant
const variant = await client.getVariant('button-color-test', {
  userId: 'user_123',
  plan: 'beta',
});
// variant.value => "#10B981"

// Batch evaluate
const flags = await client.evaluateAll(
  ['new-checkout-flow', 'dark-mode'],
  { userId: 'user_123' }
);
```

## REST API (direct HTTP)

```bash
# Single flag evaluation
curl -s -X POST http://localhost:7777/api/evaluate \
  -H "Authorization: Bearer ffs_..." \
  -H "Content-Type: application/json" \
  -d '{ "flagKey": "new-checkout-flow", "userId": "user_123", "environmentId": "production" }'
# Response:
# { "value": true, "variant": "control", "reason": "enabled", "flagKey": "new-checkout-flow" }

# Batch evaluation
curl -s -X POST http://localhost:7777/api/evaluate/batch \
  -H "Authorization: Bearer ffs_..." \
  -H "Content-Type: application/json" \
  -d '{ "flags": ["new-checkout-flow", "dark-mode"], "userId": "user_123", "environmentId": "production" }'

# Simple GET (boolean flags)
curl -s "http://localhost:7777/api/evaluate/new-checkout-flow?userId=user_123&env=production&key=ffs_..."
```

## Evaluation Response

| Field | Type | Description |
|---|---|---|
| `value` | `boolean \| string \| number` | The evaluated flag value |
| `variant` | `string` | Variant key for segment/percentage flags |
| `reason` | `string` | Why this value was returned |
| `flagKey` | `string` | Echo of the requested flag key |

Reason values:
- `enabled` - flag is on in this environment
- `disabled` - flag is off in this environment
- `percentage` - user fell within the rollout percentage
- `segment_match` - user matched a targeting segment
- `default` - flag not found or evaluation error

## Environment Variables

| Variable | Description |
|---|---|
| `FFS_API_KEY` | API key for the ffs server |
| `FFS_BASE_URL` | Server URL (default: http://localhost:7777) |
| `FFS_ENVIRONMENT` | Environment name (default: production) |
| `FFS_CACHE_TTL` | Client-side cache TTL in ms (default: 30000) |

## Behavior

- **Caching:** SDK caches evaluation results for `cacheTtl` ms. A cache hit returns instantly with no HTTP call.
- **Context:** Any key-value pairs in the context object are available to segment rules (e.g., `user.plan`, `user.country`).
- **Consistency:** Percentage flags use deterministic hashing of `flagKey:userId`, so the same user always gets the same result for a given flag.

## Troubleshooting

### "401 Unauthorized"

API key is missing or invalid. Check `FFS_API_KEY` and verify the key exists on the server with `ffs-server key list`.

### "404 Not Found" on /api/evaluate

The flag key does not exist. Create it in the dashboard or via `POST /api/flags`.

### SDK returns stale values

Cache TTL has not expired. Call `client.cache.invalidate('flag-key')` to force a fresh evaluation, or reduce `cacheTtl` in the client config.

Related Skills

Skill: Uptime Monitoring

7
from heldernoid/agentic-build-templates

## Overview

Skill: Status Page

7
from heldernoid/agentic-build-templates

## Overview

Skill: unit-conversion

7
from heldernoid/agentic-build-templates

## Overview

Skill: recipe-scaler

7
from heldernoid/agentic-build-templates

## Overview

reading-list

7
from heldernoid/agentic-build-templates

Operate the reading-list API to save, manage, tag, search, and export articles.

email-digest

7
from heldernoid/agentic-build-templates

Configure, test, and troubleshoot the reading-list daily email digest delivered via nodemailer.

websocket-realtime

7
from heldernoid/agentic-build-templates

Use the WebSocket connection in poll-builder to receive live vote updates. Use when you need to stream real-time poll results, monitor a poll for new votes, or build a live dashboard. Triggers include "live results", "real-time updates", "stream votes", "watch poll", or "WebSocket".

poll-builder

7
from heldernoid/agentic-build-templates

Self-hosted poll creation tool with real-time results. Use when you need to create a poll, check vote counts, close a poll, export results, or get the shareable link for a poll. Triggers include "create poll", "vote", "poll results", "survey", "collect votes", "share poll", or any task involving polling or voting.

Skill: personal-finance

7
from heldernoid/agentic-build-templates

## Overview

Skill: csv-import

7
from heldernoid/agentic-build-templates

## Overview

Skill: Syntax Highlighting

7
from heldernoid/agentic-build-templates

## Purpose

Skill: Pastebin Core

7
from heldernoid/agentic-build-templates

## Purpose