useLaunchDarkly hook in Chef codebase.
In this article, we review useLaunchDarkly hook in Chef codebase. We will look at:
-
What is Chef?
-
useLaunchDarkly hook in Chef codebase.
-
What is LaunchDarkly?
I study patterns used in an open source project found on Github Trending. For this week, I reviewed some parts of Chef codebase and wrote this article.

What is Chef?
Chef is open-source, check out the GitHub repo here.
This is the only AI app builder that knows backend. By applying Convex primitives directly to your code generation, your apps are automatically equipped with optimal backend patterns and best practices. Your full-stack apps come with a built-in database, zero config auth, file uploads, real-time UIs, and background workflows. If you want to check out the secret sauce that powers Chef, you can view or download the system prompt here.
As mentioned above, Chef’s capabilities are enabled by being built on top of Convex, the open-source reactive database designed to make life easy for web app developers. The “magic” in Chef is just the fact that it’s using Convex’s APIs, which are an ideal fit for codegen.
This project is a fork of the stable branch of bolt.diy.
Learn more about Chef.
useLaunchDarkly hook in Chef codebase.
You will find the following code at lib/hooks/useLaunchDarkly.ts
import { useFlags } from 'launchdarkly-react-client-sdk';
import { kebabCase } from 'lodash';
const flagDefaults: {
maintenanceMode: boolean;
showUsageAnnotations: boolean;
recordRawPromptsForDebugging: boolean;
maxCollapsedMessagesSize: number;
maxRelevantFilesSize: number;
minCollapsedMessagesSize: number;
useGeminiAuto: boolean;
notionClonePrompt: boolean;
newChatFeature: boolean;
minMessagesForNudge: number;
enableResend: boolean;
enableGpt5: boolean;
useAnthropicFraction: number;
} = {
maintenanceMode: false,
showUsageAnnotations: false,
recordRawPromptsForDebugging: false,
maxCollapsedMessagesSize: 65536,
maxRelevantFilesSize: 8192,
minCollapsedMessagesSize: 8192,
useGeminiAuto: false,
notionClonePrompt: false,
newChatFeature: false,
minMessagesForNudge: 40,
enableResend: false,
enableGpt5: false,
useAnthropicFraction: 1.0,
};
function kebabCaseKeys(object: typeof flagDefaults) {
return Object.entries(object).reduce(
(carry, [key, value]) => ({ ...carry, [kebabCase(key)]: value }),
{} as { [key: string]: any },
);
}
// Flag defaults need to be in the default kebab-case format:
// https://docs.launchdarkly.com/sdk/client-side/react/react-web#configuring-the-react-sdk
export const flagDefaultsKebabCase = kebabCaseKeys(flagDefaults);
// useLaunchDarkly is a thin wrapper on LaunchDarkly's react sdk which adds manual to flag keys.
// At some point, we can generate this file.
export function useLaunchDarkly() {
return useFlags<typeof flagDefaults>();
}
showUsageAnnotations flag is used in AssistantMessage.tsx component.
export const AssistantMessage = memo(
function AssistantMessage({ message }: AssistantMessageProps) {
const { showUsageAnnotations } = useLaunchDarkly();
This is fine but what exactly is LaunchDarkly? Let’s find out.
What is LaunchDarkly?
Ship safely and sleep soundly. LaunchDarkly is a platform for developers to ship with confidence by combining feature flags, observability, experimentation, analytics, and AI configuration to de-risk every release and reduce outages.
- Safe get features to the right users.
-
Targeting & segmentation
-
Progressive rollouts
-
Flag lifecycle management
-
AI prompt, model, agent manager
2. See what is happening in real-time
-
Performance thresholds
-
Error monitoring & alerting
-
Automated feature rollback
-
Stack traces & session replay
3. Learn and improve continuously
-
Feature-based experiments
-
Product signals & user behavior
-
Statistically rigorous data analysis
-
Warehouse-native implementation
Check out the LaunchDarkly getting started documentation.
About me:
Hey, my name is Ramu Narasinga. I study codebase architecture in large open-source projects.
Email: ramu.narasinga@gmail.com
I spent 200+ hours analyzing Supabase, shadcn/ui, LobeChat. Found the patterns that separate AI slop from production code. Stop refactoring AI slop. Start with proven patterns. Check out production-grade projects at thinkthroo.com