system-prompt-engineering
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSystem Prompt Engineering Skill
系统提示词工程技能
Design effective system prompts for custom agents that establish identity, rules, and behavior.
为自定义Agent设计可确立身份、规则与行为模式的高效系统提示词。
Purpose
用途
Create system prompts that shape agent behavior across all conversations. System prompts are orders of magnitude more important than user prompts.
创建可在所有对话中塑造Agent行为的系统提示词。系统提示词的重要性远超用户提示词。
When to Use
适用场景
- Creating new custom agents
- Establishing agent expertise
- Defining persistent rules
- Building specialized assistants
- 创建新的自定义Agent
- 确立Agent的专业领域
- 定义持久生效的规则
- 构建专业助手类Agent
System Prompt vs User Prompt
系统提示词 vs 用户提示词
| Aspect | System Prompt | User Prompt |
|---|---|---|
| Scope | All conversations | Single task |
| Persistence | Affects everything | Per-request |
| Impact | Orders of magnitude higher | Lower blast radius |
| Sections | Purpose, Instructions, Examples | All sections |
| 维度 | 系统提示词 | 用户提示词 |
|---|---|---|
| 覆盖范围 | 所有对话 | 单个任务 |
| 持久性 | 影响所有交互 | 仅针对单次请求 |
| 影响力 | 量级更高 | 影响范围更小 |
| 组成部分 | 用途、说明、示例 | 所有部分 |
Key Sections
核心组成部分
Purpose (Required)
用途(必填)
Define who the agent is and what it does.
markdown
undefined定义Agent的身份与核心功能。
markdown
undefinedPurpose
用途
You are a security expert specializing in code review.
Your role is to identify vulnerabilities and suggest fixes.
You focus on OWASP Top 10 and secure coding practices.
**Guidelines:**
- Direct, clear identity statement
- Specific expertise area
- What the agent DOES你是一名专注于代码审查的安全专家。
你的职责是识别漏洞并提出修复建议。
你聚焦于OWASP Top 10与安全编码实践。
**指导原则:**
- 直接、清晰的身份声明
- 明确的专业领域
- 明确Agent的核心动作Instructions (Recommended)
说明(推荐)
Establish rules, constraints, and boundaries.
markdown
undefined确立规则、约束与边界。
markdown
undefinedInstructions
说明
- Focus only on security concerns
- Always explain the reasoning behind findings
- Prioritize issues by severity (Critical, High, Medium, Low)
- Do not modify code without explicit permission
- When uncertain, ask clarifying questions
**Guidelines:**
- Bullet points for clarity
- Positive and negative rules
- Edge case handling
- Boundary definition- 仅关注安全相关问题
- 始终解释发现问题的推理过程
- 按严重程度(关键、高、中、低)优先处理问题
- 未经明确许可不得修改代码
- 存在疑问时,提出澄清问题
**指导原则:**
- 用项目符号列表提升可读性
- 包含允许与禁止的规则
- 覆盖边缘场景处理方式
- 明确能力边界Examples (Critical)
示例(关键)
Shape behavior through concrete examples.
markdown
undefined通过具体示例塑造Agent行为。
markdown
undefinedExamples
示例
Example 1: SQL Injection Finding
示例1:SQL注入漏洞发现
Input: "Review this login function"
Output: "Found SQL injection vulnerability at line 42. The user input is directly concatenated into the query string. Recommendation: Use parameterized queries instead."
输入: "审查这个登录函数"
输出: "在第42行发现SQL注入漏洞。用户输入被直接拼接进查询语句。建议:改用参数化查询。"
Example 2: Out of Scope Request
示例2:超出范围的请求
Input: "Fix this CSS styling issue"
Output: "That's outside my security focus. I specialize in security vulnerabilities, not styling. Consider consulting a frontend expert for CSS issues."
输入: "修复这个CSS样式问题"
输出: "这超出了我的安全领域范畴。我专注于安全漏洞,而非样式问题。建议咨询前端专家处理CSS问题。"
Example 3: Clean Code
示例3:无问题代码
Input: "Check this authentication module"
Output: "Reviewed the authentication module. No security vulnerabilities found. The code follows secure practices: uses parameterized queries, hashes passwords with bcrypt, and implements rate limiting."
**Guidelines:**
- 2-4 diverse examples
- Cover common cases
- Include edge cases
- Show desired output format输入: "检查这个认证模块"
输出: "已审查认证模块。未发现安全漏洞。代码遵循安全实践:使用参数化查询、用bcrypt哈希密码,并实现了速率限制。"
**指导原则:**
- 2-4个多样化示例
- 覆盖常见场景
- 包含边缘场景
- 展示期望的输出格式Design Process
设计流程
Step 1: Define Agent Identity
步骤1:定义Agent身份
Answer:
- What expertise does this agent have?
- What domain does it operate in?
- What is its primary purpose?
- What tone should it use?
回答以下问题:
- 该Agent具备哪些专业能力?
- 它运作在哪个领域?
- 它的核心目标是什么?
- 它应使用何种语气?
Step 2: Establish Boundaries
步骤2:确立能力边界
Answer:
- What should the agent do?
- What should the agent NOT do?
- When should it ask for clarification?
- What are its limitations?
回答以下问题:
- Agent应该做什么?
- Agent不应该做什么?
- 何时需要请求澄清?
- 它的局限性是什么?
Step 3: Create Examples
步骤3:创建示例
For each key scenario:
- What's a typical input?
- What's the ideal output?
- How should edge cases be handled?
针对每个关键场景:
- 典型输入是什么?
- 理想输出是什么?
- 边缘场景应如何处理?
Step 4: Validate Design
步骤4:验证设计
Check:
- Purpose is clear and specific
- Instructions are unambiguous
- Examples cover key scenarios
- Boundaries are well-defined
- Tone is consistent
检查项:
- 用途清晰且具体
- 说明无歧义
- 示例覆盖关键场景
- 边界定义明确
- 语气保持一致
What to Avoid
需避免的情况
| Avoid | Why | Instead |
|---|---|---|
| Detailed workflows | Reduces autonomy | High-level guidelines |
| Dynamic variables | System prompt is static | Use user prompts |
| Prescriptive formats | Over-constrains | Flexible guidelines |
| Everything "just in case" | Context bloat | Only essentials |
| 需避免的内容 | 原因 | 替代方案 |
|---|---|---|
| 详细工作流 | 降低自主性 | 高层级指导原则 |
| 动态变量 | 系统提示词是静态的 | 使用用户提示词传递动态内容 |
| 强制性格式 | 过度约束Agent | 灵活的指导方针 |
| 冗余内容“以防万一” | 导致上下文冗余 | 仅保留核心必要内容 |
System Prompt Architecture
系统提示词架构
markdown
---
name: agent-name
description: When to use this agent (for auto-delegation)
tools: [minimal tool set]
model: sonnet
color: blue
---markdown
---
name: agent-name
description: 该Agent的适用场景(用于自动委派)
tools: [最小工具集]
model: sonnet
color: blue
---Agent Name
Agent名称
Purpose
用途
[Identity and role definition]
[身份与角色定义]
Instructions
说明
[Rules and constraints]
[规则与约束]
Examples
示例
Example 1: [Scenario]
示例1:[场景]
Input: [typical input]
Output: [ideal output]
输入: [典型输入]
输出: [理想输出]
Example 2: [Edge Case]
示例2:[边缘场景]
Input: [edge case input]
Output: [handling output]
输入: [边缘场景输入]
输出: [处理结果]
Example 3: [Boundary]
示例3:[边界场景]
Input: [out-of-scope request]
Output: [how to decline/redirect]
undefined输入: [超出范围的请求]
输出: [拒绝/转导方式]
undefinedOutput Format
输出格式
When designing a system prompt:
markdown
undefined设计系统提示词时遵循以下格式:
markdown
undefinedSystem Prompt Design
系统提示词设计
Agent Name: [name]
Domain: [expertise area]
Model: [sonnet/opus/haiku]
Agent名称: [名称]
领域: [专业领域]
模型: [sonnet/opus/haiku]
Purpose
用途
[2-3 sentences defining identity]
[2-3句话定义身份]
Instructions
说明
- [rule 1]
- [rule 2]
- [rule 3]
- [规则1]
- [规则2]
- [规则3]
Examples
示例
Example 1: [scenario]
- Input: [input]
- Output: [output]
Example 2: [scenario]
- Input: [input]
- Output: [output]
示例1: [场景]
- 输入:[输入内容]
- 输出:[输出内容]
示例2: [场景]
- 输入:[输入内容]
- 输出:[输出内容]
Validation
验证
- Purpose is specific
- Instructions are actionable
- Examples are diverse
- Boundaries are clear
undefined- 用途明确具体
- 说明可执行
- 示例多样化
- 边界清晰
undefinedCommon Agent Types
常见Agent类型
Expert Agent
专家Agent
Focus: Deep domain knowledge
markdown
undefined核心:深度领域知识
markdown
undefinedPurpose
用途
You are an expert in [domain] with deep knowledge of [specifics].
undefined你是[领域]专家,精通[具体技能]。
undefinedGuard Agent
守卫Agent
Focus: Validation and safety
markdown
undefined核心:验证与安全
markdown
undefinedInstructions
说明
- Validate all inputs against [criteria]
- Block requests that [conditions]
- Log suspicious activity
undefined- 依据[标准]验证所有输入
- 拦截符合[条件]的请求
- 记录可疑活动
undefinedTranslator Agent
转换Agent
Focus: Format conversion
markdown
undefined核心:格式转换
markdown
undefinedExamples
示例
Input Format
输入格式
[format A]
[格式A]
Output Format
输出格式
[format B]
undefined[格式B]
undefinedKey Quote
核心观点
"System prompts are orders of magnitude more important than user prompts. They run once and affect everything."
“系统提示词的重要性远超用户提示词。它们仅运行一次,却影响所有交互。”
Cross-References
交叉引用
- @system-vs-user-prompts.md - Distinction and best practices
- @agent-expert-creation skill - Creating expert agents
- @one-agent-one-purpose.md - Specialization principle
- @system-vs-user-prompts.md - 区别与最佳实践
- @agent-expert-creation skill - 创建专家Agent
- @one-agent-one-purpose.md - 专业化原则
Version History
版本历史
- v1.0.0 (2025-12-26): Initial release
- v1.0.0 (2025-12-26): 初始版本
Last Updated
最后更新
Date: 2025-12-26
Model: claude-opus-4-5-20251101
日期: 2025-12-26
模型: claude-opus-4-5-20251101