writing-agent-instructions
它能做什么
这份指南说明如何编写决定 AI 智能体在应用中行为的指令,包括主地图、详细技能和工具描述。适合为 AI 智能体构建应用或模板的人。
适用场景
- ✓当你编写或审阅应用的 AGENTS.md 文件的时候。
- ✓当你编写新的技能文件或描述智能体可用的操作的时候。
- ✓当你需要判断某项内容应放入指令、技能还是记忆中的时候。
技能链接
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/writing-agent-instructions/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我重写应用的指令,让 AI 知道何时使用每一个工具。”
每周 5 个新技能,1 分钟读完。
工作原理
指南要求保持主指令文件简短、易于浏览,把深入的细节移入技能,并编写工具描述,使智能体能够快速选出合适的工具。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Writing Agent Instructions & Skills
This is a creator-facing guide. When you build an agent-native app or template,
the agent's behavior is only as good as the instructions you give it. Three
surfaces carry that guidance: AGENTS.md (the map), skills (the deep dives),
and action/tool descriptions (how the agent picks the right tool). Write each
one for fast retrieval, not for prose.
Keep AGENTS.md small and skimmable
AGENTS.md is loaded as orientation. It should be the smallest thing that lets
the agent act correctly, with everything deep pushed into skills. Aim for these
sections and little else:
- Purpose line — one sentence on what the app is and the primary workflow.
- Core rules — the handful of invariants that must always hold (data in SQL, operations go through actions, AI goes through the agent chat, schema changes are additive). Short, imperative bullets.
- Application-state keys — the
navigation/selection/focus keys the agent reads to know what the user is looking at, with their shape. - Action table — a compact table of action name -> purpose (see below).
- Skills index — a list of the skills that exist and when to read each one.
If a section is growing past a screen, it belongs in a skill. AGENTS.md
answers "what is this app and what can I do," not "how exactly do I do the hard
thing."
The 6,000-character cap is real and silent
A template AGENTS.md is injected into the runtime agent's system prompt and
hard-sliced at COMPACT_PROMPT_RESOURCE_MAX_CHARS (6,000). Past that, the agent
sees a truncation marker instead of your text, so the tail stops being
always-on guidance and becomes something it has to go fetch. pnpm guard:agent-chat-context — the repository's own check — fails the build when a
first-party file overflows; generated apps do not ship that repository-only
guard. Keep files under ~5,500 so ordinary edits don't tip them over.
Two consequences worth designing around:
- Put the skills list second, right after the purpose line. It is the pointer to every deferred skill. If it lands in the truncated tail, the agent cannot discover any of the depth you carefully moved out.
- Markdown tables cost more than they look. Prettier pads table cells to
align columns, and that invisible whitespace counts against the cap — enough
padding in a wide action table to push a file back over it on its own. Both
**/AGENTS.mdand**/SKILL.mdare in.prettierignorefor this reason; keep them there and write table rows unpadded.
# Projects App
One workspace for projects, tasks, and notes. Agent and UI share the same SQL
data and the same actions.
## Core Rules
- Data lives in SQL via Drizzle. Use actions for all writes.
- All AI work goes through the agent chat; never call an LLM inline.
- Schema changes are additive only.
## Application State
- `navigation.view`: `home` | `project`
- `navigation.projectId`: selected project on a project page
## Actions
| Action | Purpose |
| --- | --- |
| `list-projects` | List accessible projects |
| `create-project` | Create a project |
| `update-project` | Rename or archive a project |
## Skills
- `project-imports` — read before importing legacy CSV exports.
- `sharing` — read before exposing a project to other users.
Single-source AGENTS.md (CLAUDE.md is a symlink)
Keep one canonical instructions file: AGENTS.md. If a client expects
CLAUDE.md, make it a symlink to AGENTS.md rather than a second copy. Two
hand-maintained files drift, and the agent ends up with contradictory rules.
One source of truth, linked where needed.
Keep generated guidance in sync
Framework guidance is authored once in this repo and copied outward. Treat
.agents/skills/ as the canonical source for shared skills. Generated
workspace skills in packages/core/src/templates/workspace-core/.agents/skills/
and first-party template copies of shared skills must stay byte-for-byte in
sync; run pnpm sync:workspace-skills after editing a shared skill, and
pnpm guard:workspace-skills before calling the guidance done.
Generated app and workspace instructions must teach the same action-first data contract:
- Normal app data goes through
defineActionfiles inactions/. - React calls actions with
useActionQuery,useActionMutation, orcallAction; route paths are a transport detail hidden behind helpers. - Custom
/api/*routes are only for route-shaped protocols such as uploads, str
常见问题
主指令文件应该多长?
指南要求保持文件精简,并指出该文件有字符数上限。
长篇的操作细节应放在哪里?
放在技能中,使主文件只说明应用是什么以及能做什么。
操作描述应侧重什么?
帮助智能体快速选出正确的工具,因此应为快速查找而写,而不是写成散文。
详情
作者的原始描述
How to write great agent instructions for an agent-native app or template: AGENTS.md, skills, and tool/action descriptions. Use when authoring or reviewing AGENTS.md, writing a SKILL.md, wording action descriptions, or deciding what belongs in instructions vs skills vs memory.
repo: BuilderIO/agent-native
热度
- GitHub 星标
- 7.6k
- 排名
- #13192
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …