← All modules
platform

Feature Flags

Live

Flag rollouts, cohort targeting, kill-switches with audit history.

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

What Feature Flags does

Feature Flags is a control-plane module for rollout decisions. Operators can group related flags, disable or kill an entire rollout area, and keep every flag/group mutation in transactional history.

SDK helpers in TypeScript, Python, Go, and Rust evaluate the same grouped flag fixture locally. Owner/developer self-overrides let one actor preview a flag without changing the default rollout, while SpiceDB-backed permissions keep reads and mutations scoped to the project. Local and staging users can also preview and toggle flags from the Cuitty toolbar.

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();

await cuitty.flags.listGroups({ refresh: true });

const enabled = cuitty.flags.isEnabled("new_checkout", {
  userId: "user_123",
  env: "staging",
  role: "developer",
});
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 observe/modules/feature-flags/schema.sql. One libSQL file per module — back it up with cp.

CREATE TABLE cuitty_flags.groups (
  id BIGSERIAL PRIMARY KEY,
  project_id UUID NOT NULL,
  key TEXT NOT NULL,
  name TEXT NOT NULL,
  enabled BOOLEAN NOT NULL DEFAULT TRUE,
  killed BOOLEAN NOT NULL DEFAULT FALSE
);

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

CREATE TABLE cuitty_flags.self_overrides (
  flag_id BIGINT NOT NULL REFERENCES cuitty_flags.flags(id),
  actor_id TEXT NOT NULL,
  enabled BOOLEAN NOT NULL,
  value BOOLEAN NOT NULL
);

Related modules