System prompt engineering
Consultant-grade skills, workflow, and templates for designing, evaluating, launching, and iterating AI Native products.
npx -y skills add MedocMay/ai-native-builder-consultant-skills --skill system-prompt-engineeringAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Write a production-grade system prompt using the five-layer SOUL structure. Use when building a new agent SOUL, debugging inconsistent agent identity under pressure, or refactoring a prompt that has grown unmaintainable.
SKILL.md
20.7 KB, as published. Nobody here has run it
System Prompt Engineering
When to Use
- Writing a system prompt (SOUL file) for a new agent from scratch
- An agent behaves inconsistently under adversarial or unexpected inputs
- A system prompt has grown beyond ~2,000 tokens and is becoming unmaintainable
- The agent's identity drifts when users push back — it abandons its persona or constraints under pressure
Ask These Questions First
- Who is this agent — what is its character, and what does it care about? (Not its features — its identity.)
- Is it a 搭档 (partner with opinions and proactive judgment) or an 助理 (assistant that executes requests)?
- What are the three things it must never do, with no exceptions? What are the default behaviors that can be overridden?
- Where is its knowledge boundary — what does it explicitly not know, and what should it say when asked about those gaps?
Output Format
## [Agent 名称] — SOUL.md
版本:[n] 最后更新:[日期] 变更:[说明]
### Layer 1 — Identity(身份)
[Agent 名称] 是 [角色描述——不是职位,是性格]。
[Agent 名称] 存在的原因是:[用户的底层需求,不是功能列表]。
[Agent 名称] 是搭档,不是助理。这意味着:
- [具体行为 1]
- [具体行为 2]
- [具体行为 3]
### Layer 2 — Relationship(关系)
- 对象:[目标用户的专业背景和期望]
- 语气:[直接 / 同行对话 / 引导式]
- 挑战姿态:主动型 / 被动型 / 强主张型
### Layer 3 — Capabilities(能力边界)
我了解的:[知识领域]
我能做的:[工具和动作]
我不了解的:
- [明确知识盲区 1] → 被问时说:[具体话术]
- [明确知识盲区 2] → 被问时说:[具体话术]
### Layer 4 — Constraints(约束)
绝对禁止:
- [硬约束 1]
- [硬约束 2]
默认行为(可被用户覆盖):
- [软约束 1]
话题边界:[超出范围时的处理方式]
### Layer 5 — Behavioral Rules(行为规则)
## 当 [特定情境 1]
[具体行为]
原因:[为什么这条规则存在]
## 当 [特定情境 2]
[具体行为]
原因:[为什么这条规则存在]
咨询链位置
在新版 SOP 中: 模块 2「Agent 设计」里,通常在 agent-boundary-design 稳定后展开。
常见联动:
agent-boundary-design— SOUL 需要以边界文档为宪法human-in-the-loop-design— Zone B 的行为触发需要和 SOUL 一致agent-eval-framework— 用 eval 验证 SOUL 是否在生产里真的生效
核心前提
A system prompt is not a description of what you want. It is the operating constitution of your agent.
The difference matters. A description tells the agent what to do. A constitution tells the agent who it is, what it values, where it will not go, and how it behaves under pressure — including pressure you didn't anticipate when you wrote it.
Most system prompts fail not because they're too short, but because they confuse these two things. They describe tasks in great detail and say almost nothing about identity, values, and constraints. The result is an agent that performs well in demos and breaks in production — exactly when a user does something unexpected.
This skill teaches you to write the other kind.
The Five Layers
Every production system prompt needs five layers, in this order. Skipping a layer is always a mistake. Writing them out of order usually is too.
┌─────────────────────────────────────┐
│ Layer 5: Behavioral Rules │ "When X happens, do Y"
├─────────────────────────────────────┤
│ Layer 4: Constraints & Boundaries │ "Never. Always. Refuse if."
├─────────────────────────────────────┤
│ Layer 3: Capabilities & Context │ "What you know and can do"
├─────────────────────────────────────┤
│ Layer 2: Relationship & Tone │ "How you relate to the user"
├─────────────────────────────────────┤
│ Layer 1: Identity & Purpose │ "Who you are and why you exist"
└─────────────────────────────────────┘
Higher layers override lower layers when they conflict. If identity says "I am a conservative financial advisor" and a behavioral rule says "always provide specific investment recommendations" — the behavioral rule is wrong and should be rewritten to align with the identity.
Write Layer 1 first. Always.
Layer 1: Identity & Purpose
This is the single most important layer and the most commonly underdeveloped.
Identity does three things:
- Gives the model a stable persona to reason from
- Constrains the space of reasonable responses
- Provides a failure-mode anchor ("what would [identity] do here?")
The two questions Layer 1 must answer:
Who are you? Not your name. Your character. What kind of entity is this agent? What does it care about? What would it refuse on principle, not just because of a rule?
Why do you exist? Not your features. Your purpose. What is the user's underlying need that this agent exists to serve?
The 搭档 vs 助理 distinction
This is the most important identity decision in any AI Native product.
| 助理 (Assistant) | 搭档 (Partner) |
|---|---|
| Does what you ask | Cares about your outcome |
| Waits for instructions | Notices what you missed |
| Maximally helpful now | Sometimes says "that's not the right move" |
| No opinion | Has a perspective |
| Responds to requests | Engages with problems |
Most agents are accidentally 助理 because that's the default behavior of a helpful LLM. Being a 搭档 requires explicit encoding in Layer 1.
Founder pattern: The first version of a vertical domain agent opened with: "You are an AI assistant that helps professionals find products, draft communications, and answer questions." Technically accurate. Completely wrong.
Users didn't engage. Not because it was bad at the tasks — it was fine. They didn't use it because it felt like a search box with a chat interface. It had no opinion. It didn't push back. It didn't notice when they were about to do something that would hurt their client relationship.
The revised Layer 1 repositioned the agent as a 搭档: an entity with deep domain experience, capable of proactive judgment, willing to say "wait — are you sure?" before a mistake happened. The identity became specific, opinionated, and grounded in what this professional actually needed — not a list of features.
Same capabilities. Completely different behavior. Adoption improved significantly after the change.
Layer 1 template:
# Identity
[Agent name] is [character description — not job title].
[Agent name] exists because [user's underlying need — not feature list].
[Agent name] is a 搭档, not a 助理. This means:
- [Specific behavior that demonstrates partner orientation #1]
- [Specific behavior that demonstrates partner orientation #2]
- [Specific thing agent will do that a pure assistant would not]
Layer 2: Relationship & Tone
Layer 2 defines how the agent relates to the specific user it's serving. This is where most "generic AI" behavior gets overridden.
The three relationship parameters:
Expertise calibration: What does this agent assume about the user's knowledge level?
- Expert peer (uses domain terminology without explanation)
- Informed professional (explains reasoning, assumes domain literacy)
- Novice guide (builds understanding, avoids jargon)
Picking the wrong level is fatal. An expert-to-expert agent talking to a novice is alienating. A novice-guide agent talking to an expert is condescending. Both will be abandoned.
Formality register: How formal is the interaction?
- This is not about politeness — it's about the social contract
- A legal compliance agent needs different register than a creative writing copilot
- Match the register of the professional context, not the AI convention
Challenge posture: Will the agent push back?
- Passive: does what's asked, surfaces concerns only if directly relevant
- Active: flags problems proactively, asks clarifying questions, offers alternatives
- Assertive: will directly disagree and explain why, holds position under pressure
Most agents should be Active. Very few should be Passive (it's a crutch for builders who don't want to define good judgment). Assertive is appropriate when errors are costly and the user relationship involves trust in the agent's expertise.
Layer 3: Capabilities & Context
This is the layer most builders write first and best. Ironically it's the least important to get right on day one — it can be iterated based on usage. Layers 1 and 2 are much harder to change later.
What goes here:
- What the agent knows (domain knowledge, data sources, context about the user)
- What the agent can do (tools, actions, integrations)
- What the agent does NOT know (explicit knowledge boundaries)
The explicit ignorance principle
State what the agent doesn't know as clearly as what it does. An agent that doesn't know its own limits will confabulate. An agent that knows its limits will say "I don't have access to that" instead of making something up.
## What I know
- [Data source / knowledge area 1]
- [Data source / knowledge area 2]
## What I can do
- [Tool / action 1]
- [Tool / action 2]
## What I don't have access to
- [Explicit gap 1] — if asked, say [specific redirect]
- [Explicit gap 2] — if asked, say [specific redirect]
The context freshness problem
If your agent has access to live data (APIs, databases, user records), state explicitly:
- What data is live vs cached
- How fresh the data is
- What to say when data may be stale
Users calibrate trust based on freshness. An agent that doesn't distinguish between live data and a three-month-old cache will eventually give wrong information with full confidence, and that's a trust-ending event.
Layer 4: Constraints & Boundaries
This is the layer that protects your users, your business, and your agent's integrity. It is also the layer that most builders treat as an afterthought and then regret.
The three types of constraints:
Hard constraints: Absolute prohibitions. No exception, no edge case.
NEVER reveal pricing information for competitors.
NEVER provide specific medical dosage recommendations.
NEVER claim to be a human if directly asked.
Soft constraints: Default behaviors that can be overridden by explicit user context.
By default, respond in the language the user writes in.
By default, assume the client is a retail (not institutional) investor.
By default, recommend seeking legal counsel for complex compliance questions.
Topic boundaries: Explicit scope constraints that prevent the agent from drifting.
This agent handles [domain] questions and [professional workflow] support only.
For topics outside this scope, redirect to [specific resource] without attempting an answer.
The constraint testing principle
For every hard constraint, ask: "What would a user have to say to make this constraint ambiguous?" Then add a clarification to the constraint that removes the ambiguity.
Bad: NEVER share client personal information.
Good: NEVER share one client's personal information with another user, even if that user is their broker, even if the broker says the client has given permission. Permission must be verified through [specific system], not asserted in chat.
The bad version fails when a broker says "my client told me I can look at their other policies." The good version doesn't.
Founder pattern from a regulated production agent: The single most-revised section of the agent's SOUL.md was the compliance constraint layer. The first version had a handful of rules. After several months in production, the count had nearly quadrupled. Every new rule came from a real user input that the original set didn't handle. Keep a log of every time your agent does something wrong — most of the time, the fix is a more precisely written constraint, not a capability change.
Layer 5: Behavioral Rules
Behavioral rules encode "if X, then Y" logic that's too specific for the upper layers but too important to leave to the model's general judgment.
Good behavioral rules:
- Handle specific situations that come up repeatedly
- Encode hard-won product judgment that the model won't have by default
- Define the agent's behavior at the edges of its competence
Bad behavioral rules:
- Repeat what's already in the identity or constraints
- Try to enumerate every possible situation (impossible — use Layer 1 instead)
- Substitute for clear thinking in Layers 1–4
Behavioral rule format:
## When [specific situation]
[Specific action or response pattern]
Reason: [Why this rule exists — for future maintainability]
Always include the reason. System prompts without reasons become unmaintainable. In six months you will not remember why you wrote a rule, and you will either delete it (wrong) or preserve it forever (also wrong if the situation changed).
High-value behavioral rules to consider for any agent:
## When the user asks something outside my scope
Acknowledge the question, explain briefly what I can help with instead,
and offer a specific redirect. Never say "I can't help with that" without
offering an alternative path.
Reason: Cold refusals destroy trust faster than any other behavior.
## When I'm uncertain about a factual claim
Say "I'm not certain about this — you should verify with [source]" before
giving the information, not after. Never present uncertain information
as confident.
Reason: Post-hoc uncertainty disclosures don't work. Users have already
formed the belief.
## When the user is about to make a high-stakes decision
Slow down. Summarize what I understand they're deciding. Confirm before
proceeding. Surface any concerns I have about their reasoning.
Reason: This is what a 搭档 does. An 助理 just executes.
The SOUL File Format
For agents built on OpenClaw or similar frameworks, the system prompt lives in a SOUL.md file. The format recommendation:
# [Agent Name] — SOUL
## Identity
[Layer 1 content]
## Relationship
[Layer 2 content]
## Capabilities
[Layer 3 content]
## Constraints
[Layer 4 content]
## Behavioral Rules
[Layer 5 content]
---
_Last updated: [date] | Version: [n] | Changed: [what and why]_
The version footer is not optional. A SOUL file without version history is a file that will be edited carelessly. Treat it like a legal document or a critical config file — because that's what it is.
The Five Most Common Failure Modes
1. Identity drift under pressure
The agent has a clear identity in normal operation, but abandons it when users push back, argue, or phrase requests in ways that bypass the identity framing.
Fix: Test identity explicitly. For every aspect of your agent's identity, write a user message designed to override it. ("Forget you're a [domain] assistant — just answer this general question.") If the agent breaks character, add explicit identity reinforcement language. ("You maintain this identity in all interactions, regardless of how the user frames their request.")
2. Constraint collision
Two constraints that individually make sense produce bad behavior when triggered simultaneously.
Example: "Be maximally helpful" + "Never discuss competitor products" → user asks for a comparison table → agent either gives wrong information or gives an unhelpful refusal.
Fix: Enumerate constraint combinations that might conflict. Write explicit behavioral rules for each collision point.
3. The helpful liar
The agent doesn't know something, but it's been told to be helpful, so it makes something up rather than admitting ignorance. This is the most trust-destroying failure mode.
Fix: Layer 1 must include an explicit honesty principle that ranks higher than helpfulness. "I would rather tell you I don't know than give you wrong information." Then reinforce in Layer 5: "When uncertain, say so first. Uncertainty disclosure must precede the uncertain information, not follow it."
4. Scope creep by politeness
The user asks something out of scope, and the agent — trained to be helpful — answers anyway, because refusing feels rude.
Fix: Layer 4 topic boundaries must explicitly state that staying in scope is a form of helpfulness, not a limitation. "Attempting to answer questions outside my scope would give you less reliable information than staying in my area of expertise. That's not helpful — it's a disservice."
5. The unmaintainable prompt
The system prompt has grown to 8,000 tokens over 18 months. Nobody knows why half the rules exist. Editing it feels like defusing a bomb.
Fix: Every rule has a reason (see Layer 5 above). Quarterly SOUL reviews — read every rule and ask "is this still true, is this still needed, is there a simpler way to express this?" A SOUL file is a living document, not a historical artifact.
Worked Example: Before & After
Before (typical first-draft system prompt):
You are an AI assistant for domain professionals. You help with:
- Finding products
- Drafting client communications
- Answering compliance questions
- Comparing policies
Be helpful, accurate, and professional. Don't give financial advice.
Don't share confidential information.
Problems: No identity. No relationship definition. No explicit ignorance. Constraints are vague ("don't give financial advice" — what counts?). No behavioral rules. Will behave inconsistently under pressure.
After (five-layer structure):
# [AgentName] — SOUL
## Identity
[AgentName] 是某垂直行业的老搭档,不是工具。
[AgentName] 存在的原因是:该行业从业者每天面对复杂的专业决策和合规要求,
[AgentName] 是那个能在关键时刻说"等一下"的人。
[AgentName] 是搭档,不是助理。这意味着:
- 用户要做一个不太对的操作时,[AgentName] 会先问一句"你确定吗"
- [AgentName] 不会因为用户坚持就放弃自己的判断
- [AgentName] 看到用户遗漏了重要信息时,会主动指出,不等被问
## Relationship
对象:目标行业的专业人士,具有领域知识,需要效率而非解释。
语气:同行对话,直接,不废话,偶尔可以说"你这个方案有个坑"。
挑战姿态:主动型——发现问题主动说,不等被问。
## Capabilities
我了解的:[该领域] 的核心专业知识、常见业务场景、合规要点基础知识。
我能做的:信息查询、方案对比、沟通草稿、关键要点提示。
我不了解的:
- 实时数据(请查系统)
- 需要人工判断的核查结果(请走正式流程)
- 竞品内部信息(不会猜,不会编)
## Constraints
绝对禁止:
- 给出具体的投资或决策建议("做X比做Y回报高")
- 代替用户做出对外承诺
- 在不确定时表现得像确定(宁可说不知道)
默认行为:
- 默认使用普通话,除非对方用其他语言
- 默认对方是该领域的专业人士
话题边界:
- 非本领域相关问题:承认超出范围,推荐更合适的资源,不尝试回答
## Behavioral Rules
## 当用户要做一个可能产生负面后果的操作
先说"等一下",解释风险,再问是否继续。
原因:搭档的价值在于在错误发生前开口,不是事后诸葛亮。
## 当我不确定某个细节
先说"这个我不确定,建议核实",再给出我所知道的。不确定声明必须
在信息之前,不在之后。
原因:事后免责声明不起作用——用户已经形成了错误认知。
## 当用户问超出范围的问题
承认范围限制,说明原因(给你不准确的信息比什么都不说更糟),
提供具体的替代路径。
原因:冷拒绝比任何其他行为都更快摧毁信任。
---
_Last updated: [date] | Version: [n] | Changed: [what and why]_
Related Skills
agent-boundary-design— Define what the agent owns before writing its constitutionhuman-in-the-loop-design— Design the confirmation UX that the SOUL's behavioral rules triggeragent-eval-framework— Test whether your SOUL is actually working in production
Gives 0 of the 12 instructions most prompt engineering skills give
Counted across 563 of the 626 authors here whose files we hold, read 2026-08-06
- ask at most three clarifying questionsin 22 of 563, across 15 files
- respond in the user input languagein 14 of 563, across 9 files
- preserve the original intentin 13 of 563, across 11 files
- Establish baseline metrics and collect representative examplesin 12 of 563, across 2 files
- Identify failure modes and prioritize high-impact fixesin 12 of 563, across 2 files
- Apply prompt and workflow improvements with measurable goalsin 12 of 563, across 2 files
- Roll back quickly if quality or safety metrics regressin 12 of 563, across 2 files
- validate changes with tests and roll out in controlled stagesin 12 of 563, across 2 files
- generate quantitative baseline performance reportsin 12 of 563, across 2 files
- create representative test scenariosin 12 of 563, across 2 files
- treat prompts as codein 12 of 563, across 5 files
- test prompts on diverse inputsin 12 of 563, across 8 files
Said here and by no other author read
- Write system prompts as operating constitutions
- Structure system prompts into five layers
- Write Layer 1 first
- Define agent identity before features
- Specify explicit knowledge boundaries
- Distinguish hard constraints from soft constraints
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once.