How to Build a Harness

17. Project Context & Skills

Load AGENTS.md, skill files, and inject them into the prompt.

pi loads project-specific instructions from AGENTS.md files and skill files.

File: packages/coding-agent/src/core/system-prompt.ts L154-165

// Append project context files
if (contextFiles.length > 0) {
  prompt += "\n\n# Project Context\n\n";
  for (const { path: filePath, content } of contextFiles) {
    prompt += `## ${filePath}\n\n${content}\n\n`;
  }
}

File: packages/coding-agent/src/core/skills.ts L339-364

export function formatSkillsForPrompt(skills: Skill[]): string {
  const lines = [
    "\n\nThe following skills provide specialized instructions.",
    "Use the read tool to load a skill's file when the task matches.",
    "",
    "<available_skills>",
  ];
  for (const skill of skills) {
    lines.push("  <skill>");
    lines.push(`    <name>${skill.name}</name>`);
    lines.push(`    <description>${skill.description}</description>`);
    lines.push(`    <location>${skill.filePath}</location>`);
    lines.push("  </skill>");
  }
  lines.push("</available_skills>");
  return lines.join("\n");
}

For a minimal harness, you can skip skills entirely and just read AGENTS.md from the working directory if it exists.


Open this chapter inside the full course