Pi Agent: Skills System

Last updated: 2026-08-31

Skills are the Agent's "professional certificates" — load code review, it's a reviewer; load translation, it's a translator.


1. What Are Skills

A Skill is a combination package of tools, prompt templates, and configuration that defines an Agent's complete capability in a domain:

TEXT 📖 Display only
Skill = Prompt Template + Tool List + Config Parameters + Examples

Example:
code_review skill =
  Prompt ("You are a code review expert...") +
  Tools (file_reader, search) +
  Config (temperature=0.3, max_tokens=2048)

2. Built-in Skills

Skill Description Tools
code_review Code review file_reader
bug_fix Bug fixing file_reader, search
test_gen Test generation file_reader, shell
doc_gen Documentation generation file_reader
translate Multi-language translation
summarize Content summarization file_reader
search_assistant Search assistant search
data_analyst Data analysis file_reader, calculator

(1) Using Built-in Skills

PYTHON
from pi_agent import Agent

agent = Agent(name="reviewer")
result = agent.run(skill="code_review", code="def add(a,b): return a+b")

(2) CLI Skill Usage

BASH
pi-agent chat --skill code_review "Review main.py"
pi-agent run --skill translate --lang ja "Translate this text"

3. Custom Skills

(1) YAML Definition

Create ~/.pi-agent/skills/api_designer.yaml:

YAML
name: api_designer
description: "REST API design expert"
version: "1.0"

system_prompt: |
  You are a REST API design expert.
  Follow these principles:
  1. Use plural nouns for resource paths
  2. Express operations with HTTP methods
  3. Return appropriate HTTP status codes
  4. Design consistent error response formats

tools:
  - file_reader
  - search

parameters:
  temperature: 0.3
  max_tokens: 4096

(2) Python Definition

PYTHON
from pi_agent import Agent, Skill

api_skill = Skill(
    name="api_designer",
    description="REST API design expert",
    system_prompt="You are a REST API design expert following best practices",
    tools=["file_reader", "search"],
    parameters={"temperature": 0.3, "max_tokens": 4096}
)

agent = Agent(name="api_guy", skills=[api_skill])
result = agent.run(skill="api_designer", prompt="Design a blog system API")

4. Skill Composition

Multiple skills can be used together:

Example 1: Full-Stack Dev Skill Pack (Difficulty: ⭐⭐)

PYTHON
from pi_agent import Agent, Skill

review_skill = Skill(name="code_review", tools=["file_reader"])
fix_skill = Skill(name="bug_fix", tools=["file_reader", "shell"])
test_skill = Skill(name="test_gen", tools=["file_reader", "shell"])

agent = Agent(
    name="full_stack",
    skills=[review_skill, fix_skill, test_skill]
)

review = agent.run(skill="code_review", code=source_code)
fix = agent.run(skill="bug_fix", code=source_code, issues=review)
tests = agent.run(skill="test_gen", code=fix)

5. Skill Parameters

Skills can define custom parameters:

YAML
name: translator
parameters:
  temperature: 0.5
  max_tokens: 4096
custom_params:
  source_lang:
    type: string
    default: "en"
  target_lang:
    type: string
    required: true
  style:
    type: string
    default: "formal"
    enum: ["formal", "casual", "technical"]
PYTHON
result = agent.run(
    skill="translator",
    text="Hello World",
    target_lang="ja",
    style="technical"
)

6. Skill Management

BASH
pi-agent skills list
pi-agent skills show code_review
pi-agent skills install community/web-scraper
pi-agent skills create my_skill --tools file_reader,shell

FAQ

Q Difference between skills and tools?
A A tool is a single capability (e.g., "read file"), while a skill is a combo of tool + prompt + config (e.g., "code review" = file_reader tool + review prompt + low temperature).
Q Can skills be switched dynamically?
A Yes. Use /skill in interactive mode, or agent.run(skill=...) to specify different skills per call.
Q Is there a skill marketplace?
A Pi Agent has a community skill repo. Use pi-agent skills search <keyword> to find them. See Lesson 17 for packages.

Summary


Exercises

  1. Basic (Difficulty: ⭐): Use the built-in code_review skill to review some code.
  2. Intermediate (Difficulty: ⭐⭐): Create a custom "SQL Optimization Advisor" skill with appropriate prompts and tools.
  3. Advanced (Difficulty: ⭐⭐⭐): Design a "DevOps Engineer" skill pack with log analysis, deployment check, and monitoring config sub-skills.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏