Continue's Prompt File System Architecture: A Deep Dive into YAML-Driven LLM Customization
Continue's prompt file system is a file-based, YAML-driven architecture that separates prompt definitions from core logic, enabling developers to customize LLM behavior through version-controlled YAML files without modifying source code.
The open-source code assistant Continue (continuedev/continue) implements a sophisticated four-layer prompt architecture. This system stores prompt definitions as plain YAML files, loads them through a dedicated configuration package, generates dynamic conversations using lazy-apply logic, and exposes them through IDE-integrated slash commands.
Prompt Definition Layer: YAML Schema and Structure
Continue stores prompt definitions as YAML files within the user's .continue/ directory or any CLI-specified location. According to the source code in packages/config-yaml/src/__tests__/local-files/prompt.yaml, each prompt file contains four primary components:
- system: The system message defining the AI's persona and constraints
- user: The user message template containing the core instruction
- variables: Reusable placeholders for dynamic content (e.g.,
UNCHANGED_CODE) - rules: Behavioral constraints that guide model output formatting
# ~/.continue/prompt.yaml
system: |
You are an expert programmer.
user: |
Please rewrite the following file.
variables:
UNCHANGED_CODE: "UNCHANGED CODE"
rules:
- "Your response should be a code block containing a rewritten version of the file."
- "Whenever any part of the code is the same as before, indicate this with a comment saying \"{{UNCHANGED_CODE}}\"."
The schema supports block delimiters (---) within a single file, allowing multiple named prompt segments that can be referenced individually via the /promptBlock command.
Loading and Merging with Config-Yaml
The packages/config-yaml/src/index.ts module handles prompt file discovery, validation, and merging. The loadPromptFile() function parses YAML into JavaScript objects and applies inheritance patterns:
import { loadPromptFile } from "packages/config-yaml";
const prompt = await loadPromptFile("/home/me/.continue/prompt.yaml");
// Returns: { system, user, variables, rules, ... }
This layer supports environment variable interpolation and extends directives, enabling shared base prompts across projects. The loader merges user-defined prompts with built-in defaults before passing the configuration to the core editing engine.
Lazy Prompt Generation for Code Diffing
When applying code modifications, Continue doesn't send static prompts. Instead, core/edit/lazy/prompts.ts implements lazy prompt generation, dynamically constructing conversations that inject the original file content and new code snippets at invocation time.
The claudeSonnetLazyApplyPrompt() function exemplifies this approach:
function claudeSonnetLazyApplyPrompt(
oldCode: string,
filename: string,
newCode: string,
): ChatMessage[] {
const userContent = dedent`
ORIGINAL CODE:
\`\`\`${filename}
${oldCode}
\`\`\`
NEW CODE:
\`\`\`
${newCode}
\`\`\`
Above is a code block containing the original version of a file (ORIGINAL CODE) and below it is a code snippet (NEW CODE) that was suggested as modification to the original file. Your task is to apply the NEW CODE to the ORIGINAL CODE and show what the entire file would look like after it is applied.
- ${RULES.join("\n- ")}
`;
// ...
}
The function automatically injects the RULES array from the loaded YAML configuration, ensuring every model invocation respects the same constraints defined in the prompt file.
Slash Commands and IDE Integration
Continue exposes prompt files through two core slash commands implemented in core/commands/slash/promptFileSlashCommand.ts and core/commands/slash/promptBlockSlashCommand.ts:
/promptFile: Opens a picker of all discovered prompt YAML files, loads the selected configuration, and passes it to the lazy-apply generator/promptBlock: Allows selection of specific named blocks within prompt files, merging only that segment into the conversation
The VS Code extension provides intelligent completions via extensions/vscode/src/lang-server/promptFileCompletions.ts. The language server scans loaded YAML files to suggest variable names (e.g., {{UN…}}) and block identifiers as the user types:
// Inside promptFileCompletions.ts
connection.onCompletion(({ textDocument, position }) => {
// Look up the nearest prompt file, parse its variables/blocks,
// and return a CompletionList.
});
Customizing Prompts Without Code Changes
Developers can extend Continue's prompt file system by creating new YAML files in the .continue/ directory:
mkdir -p ~/.continue
cat > ~/.continue/myPrompt.yaml <<'EOF'
system: |
You are a senior TypeScript engineer.
user: |
Refactor the following code to use async/await.
variables:
UNCHANGED_CODE: "UNCHANGED CODE"
EOF
The CLI interface supports prompt file invocation via flags:
continue chat \
--prompt-block "refactor-python" \
--file src/main.py
This command locates the "refactor-python" block in any loaded prompt file and constructs the lazy conversation as defined in core/edit/lazy/prompts.ts.
Summary
- Continue's prompt file system uses a four-layer architecture: YAML definition, config-yaml loading, lazy generation, and IDE bridge
- Prompt files live in
.continue/and define system messages, user templates, variables, and rules - Lazy generation in
core/edit/lazy/prompts.tsdynamically injects code context at runtime rather than using static prompts - Slash commands (
/promptFile,/promptBlock) and language-server completions provide IDE-native access to custom prompts - Inheritance and environment variables enable reusable, project-specific prompt configurations without code modification
Frequently Asked Questions
What file format does Continue use for prompt definitions?
Continue uses YAML files with a specific schema containing system, user, variables, and rules keys. These files typically reside in the .continue/ directory and support block delimiters (---) for defining multiple named prompts within a single file.
How does Continue handle prompt inheritance and reuse?
The config-yaml package (packages/config-yaml/src/index.ts) supports inheritance through extends directives and environment variable interpolation. This allows teams to define base prompts and extend them with project-specific modifications while maintaining shared configurations across repositories.
What is lazy prompt generation in Continue?
Lazy prompt generation refers to the architecture in core/edit/lazy/prompts.ts where the final LLM payload is constructed at invocation time. Rather than sending static text, Continue dynamically injects the original code file and new code snippets into the conversation, allowing the model to produce complete, context-aware file rewrites based on the YAML-defined rules.
How do I access custom prompt files in VS Code?
Use the /promptFile slash command to open a picker of available prompt YAML files, or /promptBlock to select specific named blocks within those files. The VS Code language server also provides autocomplete suggestions for variable names and block identifiers as you type in the chat interface.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →