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:

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

OptionTypeDescription
customPromptstringReplace the entire generated prompt with a custom one.
appendSystemPromptstringText to append to the end of the generated prompt.
contextFilesArray<{ path: string; content: string }>Pre-loaded file contents to include in the prompt context.
skillsRecord<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().

OptionTypeDescription
selectedToolsstring[]Which tools to include descriptions for. Defaults to read, bash, edit, write.
cwdstringWorking 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:

ToolDescription
readRead file contents
bashExecute bash commands
editMake surgical edits
writeCreate or overwrite files
grepSearch file contents
findFind files by glob
lsList 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.`,
  },
});