> 中文:这是一个给 Pi / Codex / AI Agent 使用的工具错误恢复 Skill。它不会替你“瞎重试”,而是先识别错误、检索本地已验证方案、执行安全修复、验证结果,并把成功经验沉淀为可复用的 Markdown recipe。
> English: This skill helps Pi/Codex/AI agents recover from failed tools by searching local verified recipes, applying safe fixes, verifying the result, and saving only confirmed fixes.
Use this skill when any of these happens:
中文触发条件:
Do not use this skill for normal chatting, ordinary reasoning, general writing, or tasks unrelated to tool execution.
Do not guess -> search recipes -> match carefully -> apply safe fix -> verify -> save only verified fixes
不要猜 -> 先查 recipe -> 谨慎匹配 -> 只做安全修复 -> 验证成功 -> 只沉淀已验证方案
The agent must avoid blind retries. A retry is allowed only when there is a clear reason, such as a changed command, fixed environment variable, reloaded extension, installed missing dependency, or user-approved action.
Default local recipe directory:
~/.pi/agent/tool-recipes/
If it does not exist, create it:
mkdir -p ~/.pi/agent/tool-recipes
Windows PowerShell equivalent:
New-Item -ItemType Directory -Force "$HOME\.pi\agent\tool-recipes"
All recipes are Markdown files. No network service is required. No foreign service is required. This is friendly to domestic / offline environments.
When a tool or command fails, follow this exact flow:
Collect only information needed for debugging:
Never collect or store secrets.
Create a compact search string from stable identifiers:
<tool>|<command>|<package>|<main error phrase>|<exit code>|<OS>
Examples:
rg -i "npm|missing script|package.json|dev" ~/.pi/agent/tool-recipes/
rg -i "mcp|server|ENOENT|command not found" ~/.pi/agent/tool-recipes/
rg -i "playwright|browser|install|chromium" ~/.pi/agent/tool-recipes/
Preferred search command:
rg -i "<keywords>" ~/.pi/agent/tool-recipes/
If rg is not installed, use fallback commands:
# macOS / Linux fallback
grep -RniE "<keywords>" ~/.pi/agent/tool-recipes/
# Windows PowerShell fallback
Get-ChildItem "$HOME\.pi\agent\tool-recipes" -Recurse -Filter *.md | Select-String -Pattern "<keywords>"
If the recipe directory is missing:
If the recipe directory is empty:
No verified local recipe found yet.If recipe search fails:
If multiple recipes match:
A recipe matches only if at least two of these are true:
If only one condition matches, treat it as a hint, not as a verified fix.
Safe fixes can be applied without extra confirmation when they are local and reversible, such as:
Ask before risky actions listed in the safety section.
Verification must be observable. Examples:
command exits with code 0
/tool doctor passes
MCP server lists tools
npm run dev starts successfully
pnpm test passes
browser bridge connects
Git push succeeds after correct branch selection
A recipe is not verified if it is only a guess.
Save or append a recipe only when:
Use lowercase hyphenated file names:
npm-node.md
mcp-server.md
browser-cdp.md
playwright.md
git.md
windows-powershell.md
misc.md
When no recipe matches, diagnose in this order:
command -v, where, Get-Command.node -v, npm -v, python --version, java -version, etc.中文速记:先看错误原文,再看目录,再看命令是否存在,再看版本,再看配置,再看权限,最后才修改环境。
Never save:
Always ask before:
sudorm -rf.zshrc, .bashrc, PowerShell profileRedaction rule:
Replace secrets with <REDACTED_SECRET> before saving any recipe.
When using this skill, respond in this structure:
## Tool Error Recovery
### Error Detected
- Tool:
- Command / Action:
- Error Signature:
- Environment:
### Recipe Search
- Query:
- Result:
### Matched Recipe
- Recipe:
- Match confidence:
- Why it matches:
### Action Taken
- Steps:
- Safety notes:
### Verification
- Verification method:
- Result:
### Saved Recipe
- Status:
- Path:
### Next Time
- Reuse trigger:
- One-line fix:
If no recipe is saved:
Saved Recipe: Not saved because the fix was not verified.
If no recipe exists:
Recipe Search: No verified local recipe found yet. I will use the fallback diagnosis checklist and save a recipe only after the fix is verified.
Do not:
This package includes common verified recipe templates for:
src refspec main does not match anyMore project-specific recipes should be added after real verified fixes.
共 2 个版本