← All modules
platform

Feature Flags

Live

Manage rollout rules, targeting, and audit-backed flag changes from the same portal.

event.type === "flag" modules/feature-flags
Overview

What Feature Flags does

Feature Flags manages rollout percentages, cohort targeting, kill switches, and transactional history from the same portal that records the audit trail.

SDK helpers evaluate flags locally with the same SHA-256 bucket rule as the server. The TypeScript helper also listens for live updates and refreshes periodically so stale flag state is short lived.

Wire payload

Same shape, three syntaxes

The wire protocol is plain HTTP, plain JSON, HMAC-SHA256. The TypeScript tab uses the SDK; the cURL tab is the raw HTTP equivalent; the Python tab shows the preview SDK shape.

import { createCuittyClient } from "@cuitty/sdk";
import { flagsPlugin } from "@cuitty/sdk/plugins/flags";

const cuitty = createCuittyClient({
  portalUrl: "https://app.cuitty.com",
  projectId: process.env.CUITTY_PROJECT_ID!,
  apiKey: process.env.CUITTY_API_KEY!,
});
cuitty.use(flagsPlugin());
cuitty.start();

const enabled = cuitty.flags.isEnabled("new-checkout", {
  userId: "user_123",
  env: "production",
  role: "admin",
});
SDK plugin

Drop-in plugin

@cuitty/sdk/plugins/feature-flags
import { createFlagsPlugin } from "@cuitty/sdk/plugins/flags";

cuitty.use(createFlagsPlugin({
  sseEnabled: true,
  refreshIntervalMs: 60_000,
}));
Storage

Database schema

Excerpt from modules/feature-flags/schema.sql. One libSQL file per module — back it up with cp.

CREATE TABLE cuitty_feature_flags.flags (
  id BIGSERIAL PRIMARY KEY,
  project_id TEXT NOT NULL,
  key TEXT NOT NULL,
  enabled BOOLEAN NOT NULL DEFAULT FALSE,
  rollout_percentage INTEGER NOT NULL DEFAULT 0,
  cohorts JSONB NOT NULL DEFAULT '{}',
  killed BOOLEAN NOT NULL DEFAULT FALSE,
  updated_at BIGINT NOT NULL
);

Related modules