taso-katsionis-7h68nZhAZbE-unsplash.webp 之前也提过Pi,我对它的理念是认同的,毕竟一个工具只需拥有基础的能力即可,盲目地把更多的能力塞进去,只会让工具越来越臃肿,到最后自己也会嫌弃。

今天,我把之前塞进Pi的能力又卸载了,因为总觉得是“不干净”的,可能我有点“洁癖”吧?哈哈!!清理干净之后,我就去跟ChatGPT讨论,怎么才能让Pi更好使用?问了一轮,似乎还是回到LLM的首要问题,就是提示词。ChatGPT给我说需要4层,Identity、Context、Session和Memory:


Identity

应该就是System Prompts,告诉LLM你是干嘛的?你应该怎么干这个任务,在Pi中我认为对应的是prompt-templates:


fix.md

---
description: Fix a bug with minimal, targeted changes
argument-hint: "[description]"
---
Fix ${1:-the bug described in context}.

Steps:
1. Identify the root cause — trace the failure path through the code.
2. Propose a minimal fix that addresses the root cause, not just symptoms.
3. Implement the fix with the smallest possible diff.
4. Add or update tests that would have caught this bug.
5. Verify the fix by running relevant tests or reproducing the original failure.

Do not refactor unrelated code. Explain what caused the bug and how the fix prevents recurrence.

## Output Language

Write your response in the same language as the user's request.

If the user's preferred language is unclear, use the primary language of the project's documentation.

Do not translate:
- Code
- Commands
- File paths
- API names
- Class, function, variable, or identifier names
- Configuration keys
unless the user explicitly requests it.

这就是告诉LLM按步骤去完成任务,最后根据用户语言输出结果


Context

这个应该就是Codex或Claude中使用的,AGENTS.md和Claude.md,告诉当前项目的架构,用了哪些技术栈,通常agent工具都会提供/init命令,生成这个文件,但Pi也是没有提供,所以也需要我们自己,通过提示词,让LLM生成我们需要的文档

---
description: Create AI guidance documents for the current project
argument-hint: "[path]"
---
Initialize AI guidance documents for ${1:-the current project}.

## Step 1: Explore

Thoroughly explore the codebase before writing anything:
- Read README, package manifests, build configs, and CI files
- Map directory structure and identify key entry points
- Detect tech stack, test framework, and build/run commands
- Note existing conventions: naming, error handling, commit style, i18n
- Check for existing `AGENTS.md`, `CLAUDE.md`, or `.pi/` config to avoid duplication

## Step 2: Create AGENTS.md

Write `AGENTS.md` at the project root. Pi loads this automatically at startup.

Structure (adapt sections to what is relevant — omit empty ones):

```markdown
# <Project Name> Agent Guide

## Overview
One paragraph: what the project does and its primary purpose.

## Tech Stack
Languages, frameworks, databases, and key dependencies.

## Structure
Directory tree with brief annotations for major folders.

## Where to Look
| Task | Location |
|------|----------|
| ... | ... |

## Commands
Build, test, lint, run, and deploy commands (copy-pasteable).

## Conventions
Coding style, patterns, naming, testing approach, commit message format.

## Anti-Patterns
Things agents must NOT do in this codebase.

## Safety & Constraints
Secrets handling, destructive operations, platform-specific notes.
```

Guidelines:
- Be specific and actionable — reference real file paths and commands, not generics
- Keep it concise; prefer tables and bullet lists over prose
- Do not invent conventions that do not exist in the code
- If the project already has `AGENTS.md`, update it in place rather than overwriting blindly

## Step 3: Optional Pi Config

If the project uses Pi-specific features, also create when appropriate:
- `.pi/SYSTEM.md` — custom system prompt (only if default behavior needs overriding)
- `.pi/prompts/` — project-specific prompt templates (only if requested)

## Step 4: Report

Summarize what was created or updated, highlight key conventions discovered, and note any gaps that need human input.

## Output Language

Write your response in the same language as the user's request.

If the user's preferred language is unclear, use the primary language of the project's documentation.

Do not translate:
- Code
- Commands
- File paths
- API names
- Class, function, variable, or identifier names
- Configuration keys
unless the user explicitly requests it.

For `AGENTS.md`, write the body text in the project's primary documentation language. Keep section headings unchanged.

Session

这个应该就是,我们跟LLM对话的内容了,如:

帮我实现web_browser,给予LLM提供使用无头浏览器浏览器网页的功能

帮我使用通用规范提交修改

一般的LLM都能理解你要完成的任务是什么

Memory

记忆,其实我认为是有两种,一种是全局和项目级。全局的就是,你喜欢用什么技术栈,如React、go等,而项目级,我认为是在项目中创建一个MEMORY.md,或REAMDE.md这种,持续记录你的项目进度。在Pi中,当然是没有这个概念的,这需要通过一些拓展实现。



以上,就是我今天对Pi的一些使用,可能有什么错误,我后续也会持续更新