mcpField
S
system-prompt-engineering

system-prompt-engineering

github.com/melodic-softwareAgent 工作流28170 次安装今天更新
代码仓库

关于 system-prompt-engineering

用于设计自定义 Agent 系统提示词的 skill,帮助明确身份、专业领域、长期规则和边界,并提供涵盖示例与验证的设计流程。

主要功能

  1. 01定义 Agent 身份与专业领域
  2. 02设置长期规则和行为边界
  3. 03为关键场景设计示例
  4. 04验证提示词的清晰度与覆盖范围
  5. 05区分系统提示词与用户提示词

适用场景

  1. 01创建专用自定义 Agent
  2. 02设定 Agent 的长期行为
  3. 03检查系统提示词是否存在遗漏

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/melodic-software/claude-code-plugins --skill system-prompt-engineering

安装后在 Claude Code 中输入/system-prompt-engineering确认已加载。

详细介绍

系统提示词工程技能

为自定义 Agent 设计有效的系统提示词,用于确立身份、规则和行为。

目的

创建能够在所有对话中塑造 Agent 行为的系统提示词。系统提示词的重要性远高于用户提示词。

适用场景

  • 创建新的自定义 Agent
  • 确立 Agent 的专业领域
  • 定义持久规则
  • 构建专业助手

系统提示词与用户提示词

方面系统提示词用户提示词
范围所有对话单项任务
持续性影响所有内容按请求生效
影响重要性远高于用户提示词影响范围较小
章节目的、指令、示例所有章节

关键章节

目的(必需)

定义 Agent 的身份和职责。

## Purpose

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.

指南:

  • 直接、清晰地说明身份
  • 指明具体的专业领域
  • 说明 Agent 的职责
指令(建议)

确立规则、约束和边界。

## Instructions

- 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

指南:

  • 使用项目符号,确保清晰易读
  • 列出正向和负向规则
  • 说明边缘情况的处理方式
  • 明确界定边界
示例(关键)

通过具体示例塑造行为。

## Examples

### Example 1: SQL Injection Finding
**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."

### Example 2: Out of Scope Request
**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."

### Example 3: Clean Code
**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."

指南:

  • 提供 2-4 个不同的示例
  • 覆盖常见情况
  • 包含边缘情况
  • 展示期望的输出格式

设计流程

第 1 步:定义 Agent 身份

回答以下问题:

  • 该 Agent 具备哪些专业知识?
  • 它在哪个领域运行?
  • 它的主要用途是什么?
  • 它应采用什么语气?
第 2 步:明确边界

回答以下问题:

  • Agent 应该做什么?
  • Agent 不应该做什么?
  • 何时应请求澄清?
  • 它有哪些局限?
第 3 步:创建示例

针对每个关键场景:

  • 典型输入是什么?
  • 理想输出是什么?
  • 应如何处理边缘情况?
第 4 步:验证设计

检查:

  • 目的清晰且具体
  • 指令明确无歧义
  • 示例覆盖关键场景
  • 边界定义明确
  • 语气一致

应避免的事项

应避免原因替代方案
详细的工作流降低自主性高层级指南
动态变量系统提示词是静态的使用用户提示词
规定性格式限制过多灵活的指南
面面俱到,以防万一导致上下文膨胀仅保留必要内容

系统提示词架构

---
name: agent-name
description: When to use this agent (for auto-delegation)
tools: [minimal tool set]
model: sonnet
color: blue
---

# Agent Name

## Purpose
[Identity and role definition]

## Instructions
[Rules and constraints]

## Examples

### Example 1: [Scenario]
**Input:** [typical input]
**Output:** [ideal output]

### Example 2: [Edge Case]
**Input:** [edge case input]
**Output:** [handling output]

### Example 3: [Boundary]
**Input:** [out-of-scope request]
**Output:** [how to decline/redirect]

输出格式

设计系统提示词时:

## System Prompt Design

**Agent Name:** [name]
**Domain:** [expertise area]
**Model:** [sonnet/opus/haiku]

### Purpose
[2-3 sentences defining identity]

### Instructions
- [rule 1]
- [rule 2]
- [rule 3]

### Examples

**Example 1:** [scenario]
- Input: [input]
- Output: [output]

**Example 2:** [scenario]
- Input: [input]
- Output: [output]

### Validation
- [ ] Purpose is specific
- [ ] Instructions are actionable
- [ ] Examples are diverse
- [ ] Boundaries are clear

常见 Agent 类型

专家 Agent

重点:深厚的领域知识

## Purpose
You are an expert in [domain] with deep knowledge of [specifics].
守护 Agent

重点:验证和安全

## Instructions
- Validate all inputs against [criteria]
- Block requests that [conditions]
- Log suspicious activity
翻译 Agent

重点:格式转换

## Examples
### Input Format
[format A]

### Output Format
[format B]

重要引述

“系统提示词的重要性远高于用户提示词。它们只运行一次,却会影响所有内容。”

交叉引用

  • @system-vs-user-prompts.md - 差异与最佳实践
  • @agent-expert-creation skill - 创建专家 Agent
  • @one-agent-one-purpose.md - 专业化原则

版本历史

  • v1.0.0(2025-12-26):首次发布

最后更新

日期: 2025-12-26 模型: claude-opus-4-5-20251101

评论

支持 Markdown