In this article, we review stripIndents utility in Chef codebase. We will look at:
What is Chef?
stripIndents utility.
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.
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.
import { stripIndents } from '../utils/stripIndent.js';import type { SystemPromptOptions } from '../types.js';export function secretsInstructions(_options: SystemPromptOptions) { return stripIndents` <secrets_instructions> If you need to use a secret to call into an API, instruct the user to set up the secret as an environment variable in their Convex deployment. 1. Tell the user to setup the secret as an environment variable, and tell them exactly what name to use (e.g. \`OPENAI_API_KEY\`). 2. Give the user clear instructions for how to set the environment variable. They can do so by opening the "Database" tab, clicking on "Settings" (with the gear icon), clicking on "Environment variables", and then setting the variable. 3. After the user confirms they've set the environment variable, you can use the secret in your code. </secrets_instructions>`;}
How does calling stripIndents without ( or ) invoke the function? This usage is called template literals in JavaScript. Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded expressions, and special constructs called tagged templates.
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 atthinkthroo.com