/kenji:workflow-feature-flagfrom kenji skills
Plans and executes feature-flag rollouts with gating, gradual rollout, monitoring, kill switch, and cleanup. Useful for dark launches, canary releases, and staged deployments.
Ships in kenji skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Degree of freedom: MIXED. Who is in the cohort and when to promote
[HIGH freedom]; default-off, kill switch, and cleanup [LOW freedom — run exactly].
Observe: new checkout step; no flag library; 100% of traffic would hit it on deploy. Interpret: ship dark, enable 5%, watch payment errors. Classify: add default-off flag + kill switch; do not delete the old path yet. Monitor: error rate > baseline → kill; stable → promote and remove the flag.
deploy-npm; observe window → workflow-ship-and-observeShipping code and switching it on are two separate acts. A feature flag lets you deploy on your schedule, enable for specific users or a percentage of traffic, and kill it instantly if anything goes wrong — without a rollback deploy. This skill gives that discipline to any feature.
package.json → launchdarkly-node-server-sdk, @launchdarkly/js-client-sdk,
flagsmith, growthbook, unleash-client, posthog-js
.env.* → LD_SDK_KEY, FLAGSMITH_ENV_KEY, GROWTHBOOK_API_HOST,
POSTHOG_KEY (reference by name only)
src/lib/flags.* → custom feature-flag utility
src/config/flags.* → env-var-based flags
| Detected platform | Approach |
|---|---|
| LaunchDarkly | Use LD SDK client; flags managed in LD dashboard |
| PostHog | Use PostHog feature flags API; tied to analytics context |
| GrowthBook | Open-source, self-hosted or cloud; SDK + feature API |
| Flagsmith | Open-source or cloud; REST API + SDK |
| None / custom | Simple env-var or database-backed flag (implement below) |
Before writing any code, define the flag contract:
Flag name: [kebab-case, descriptive, present-tense: "new-checkout-flow"]
Description: [What this flag controls — plain English]
Type: Boolean / String variant / JSON payload
Targeting: [Who sees it first: internal users? 5% of traffic? specific org IDs?]
Rollout plan: 0% → internal only → 5% → 25% → 100%
Kill-switch: If Sentry error rate on [metric] exceeds [threshold], roll back to 0%
Cleanup date: [When to remove the flag — typically 2 weeks after 100% stable]
Naming rules:
kebab-case, present-tense action: new-checkout-flow, not checkoutV2 or feature123billing-usage-dashboard, auth-passkey-loginbeta, v2, new-feature — they become permanent accidents// src/lib/flags.ts
export const FLAGS = {
newCheckoutFlow: process.env.NEXT_PUBLIC_FLAG_NEW_CHECKOUT_FLOW === 'true',
billingUsageDashboard: process.env.NEXT_PUBLIC_FLAG_BILLING_USAGE_DASHBOARD === 'true',
} as const;
export type FeatureFlag = keyof typeof FLAGS;
Usage:
import { FLAGS } from '@/lib/flags';
if (FLAGS.newCheckoutFlow) {
return <NewCheckoutFlow />;
}
return <LegacyCheckoutFlow />;
For server-side percentage rollout without a vendor, use a hash of the user ID:
function isInRollout(userId: string, flagName: string, percentage: number): boolean {
const hash = parseInt(
require('crypto').createHash('md5')
.update(`${userId}:${flagName}`)
.digest('hex').slice(0, 8),
16,
);
return (hash % 100) < percentage;
}
import { useFeatureFlagEnabled } from 'posthog-js/react';
function CheckoutPage() {
const useNewFlow = useFeatureFlagEnabled('new-checkout-flow');
if (useNewFlow) return <NewCheckoutFlow />;
return <LegacyCheckoutFlow />;
}
Server-side (Next.js Server Component):
import { PostHog } from 'posthog-node';
const client = new PostHog(process.env.POSTHOG_KEY!);
const isEnabled = await client.isFeatureEnabled('new-checkout-flow', userId);
import { useFlags } from 'launchdarkly-react-client-sdk';
const { newCheckoutFlow } = useFlags();
Set the flag enabled only for internal team accounts / test emails. Verify the feature works end-to-end for the team.
Check for errors in Sentry immediately after enabling:
sentry:search_issues
{
"organizationSlug": "<ORG>",
"query": "new issues in the last 1 hour",
"projectSlugOrId": "<PROJECT>",
"regionUrl": "<REGION_URL>",
"limit": 10
}
Enable for 5% of real users (random cohort). Monitor for 24–48 hours.
Define the health gates before enabling:
Check Supabase logs for unexpected errors:
supabase:query_logs
{
"sql": "select timestamp, event_message, log_attributes['request.method'] as method, log_attributes['request.path'] as path, log_attributes['response.status_code'] as status_code from logs where source = 'edge_logs' order by timestamp desc limit 100"
}
Each step: enable, wait 24 h, check Sentry + Supabase + business metrics. Only proceed when the health gates are green.
If any health gate fails at any stage:
sentry:analyze_issue_with_seer
{ "organizationSlug": "", "issueId": "<ISSUE_ID>", "regionUrl": "<REGION_URL>" }
3. Fix the root cause (do not re-enable until fixed and re-tested internally)
4. Document what happened in the flag's description
---
## Phase 5: Promote to 100% and clean up [LOW freedom — run exactly]
Once the feature is stable at 100% for at least 1 week:
1. Remove the flag check from the code — ship the new path as the default
2. Delete the fallback code (old path)
3. Delete the flag from the flag platform (LaunchDarkly / PostHog / etc.)
4. Remove the env var from all environments
5. Delete the flag from `src/lib/flags.ts` (for the env-var approach)
**Why cleanup matters:** Stale flags become permanent conditions. Code that says
`if (FLAGS.newCheckoutFlow)` six months later is a landmine nobody dares touch.
CLEANUP CHECKLIST:
---
## Phase 6: Rollout report [LOW freedom — do not skip]
```markdown
## Feature Flag Rollout — [flag-name] — [Date]
### Flag
- Name: [flag-name]
- Description: [what it controlled]
- Targeting: [who saw it, what percentage stages]
### Rollout timeline
| Date | Stage | Duration | Health status |
|------|-------|----------|---------------|
| ... | 0% → Internal | 2 days | ✅ Green |
| ... | Internal → 5% | 2 days | ✅ Green |
| ... | 5% → 100% | 3 days | ✅ Green |
### Health gate checks
- Sentry new issues at each stage: [count]
- P95 response time delta: [ms]
- Error rate delta: [%]
### Outcome
**Promoted to 100% / Rolled back** — [reason]
### Cleanup scheduled
[Date to remove the flag from code]
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub kensaurus/skills --plugin kenji162 skills in this plugin
/audit-accessibilityWCAG 2.2 AA audit via playwright-cli: axe-core, keyboard, contrast, target size, focus, ARIA. Use when "audit accessibility", "check a11y", "WCAG audit", "check keyboard nav", or "test screen reader".
/audit-agent-speedMeasure and fix a slow coding-agent setup: status line, hooks, instruction bloat, effort, worktree pile-up, antivirus and indexer scans. Use when "Claude is slow" or "CPU is pinned". App speed → audit-performance.
/audit-analyticsRead-only audit of product-analytics events (PostHog, Amplitude, Mixpanel, GA4): taxonomy, funnels, consent-gated firing, dead or duplicate events. Use when "audit our analytics", "are we tracking the right events", or "funnel instrumentation".
Other plugins' skills for the same job