System Prompt
edge-pi includes a system prompt builder that generates instructions tailored to the enabled tools. You can use it as-is, extend it, or replace it entirely.
Default Behavior
When you create a CodingAgent without specifying a system prompt, it automatically builds one based on the selected tool set. The prompt includes:
- A description of each enabled tool
- Guidelines for tool usage (e.g., prefer grep over bash for search)
- Instructions to read files before editing
- Working directory context
buildSystemPrompt()
Use buildSystemPrompt() directly to generate or inspect the prompt.
import { buildSystemPrompt } from "edge-pi";
const prompt = buildSystemPrompt({
}, {
selectedTools: ["read", "bash", "edit", "write"],
cwd: process.cwd(),
});
console.log(prompt);Options
| Option | Type | Description |
|---|---|---|
customPrompt | string | Replace the entire generated prompt with a custom one. |
appendSystemPrompt | string | Text to append to the end of the generated prompt. |
contextFiles | Array<{ path: string; content: string }> | Pre-loaded file contents to include in the prompt context. |
skills | Record<string, Skill> | Pre-loaded skills to include in the model-visible skills section. The map key is the skill name shown to the model. |
Call options
Pass runtime values like selected tools and cwd in the second argument of buildSystemPrompt().
| Option | Type | Description |
|---|---|---|
selectedTools | string[] | Which tools to include descriptions for. Defaults to read, bash, edit, write. |
cwd | string | Working directory to include in the prompt footer. |
Tool Descriptions
The prompt builder includes short descriptions for each tool that guide the model on when and how to use them:
| Tool | Description |
|---|---|
read | Read file contents |
bash | Execute bash commands |
edit | Make surgical edits |
write | Create or overwrite files |
grep | Search file contents |
find | Find files by glob |
ls | List directory contents |
Customization Examples
Append instructions
const agent = new CodingAgent({
model,
systemPromptOptions: {
appendSystemPrompt: `
Always write tests for new code.
Follow the project's existing code style.
Use TypeScript strict mode.
`,
},
});Include context files
import fs from "fs";
const agent = new CodingAgent({
model,
systemPromptOptions: {
contextFiles: [
{
path: "CONVENTIONS.md",
content: fs.readFileSync("CONVENTIONS.md", "utf-8"),
},
],
},
});Include skills
import type { Skill } from "edge-pi";
const skills = {
codeReview: {
description: "Perform detailed code reviews",
filePath: "/tmp/skills/code-review/SKILL.md",
},
};
const agent = new CodingAgent({
model,
systemPromptOptions: {
skills,
},
});Replace the prompt entirely
const agent = new CodingAgent({
model,
systemPromptOptions: {
customPrompt: `You are a code review assistant.
Only analyze code - never modify files.
Focus on security issues and performance.`,
},
});