mcpField
P
prompt-engineer

prompt-engineer

github.com/htlin222Agent 工作流7846 次安装3 周前更新
代码仓库

关于 prompt-engineer

面向 LLM 应用和 Agent 构建者的提示词工程技能,介绍提示词设计模式、模板和测试方法,以塑造输出并管理 Token 用量。

主要功能

  1. 01角色与任务设定
  2. 02思维链提示词
  3. 03少样本示例
  4. 04结构化输出格式
  5. 05提示词测试与 Token 跟踪

适用场景

  1. 01编写系统提示词
  2. 02提升输出一致性
  3. 03制作 Agent 提示词模板
  4. 04减少 Token 用量

安装

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

$npx skills add https://github.com/htlin222/dotfiles --skill prompt-engineer

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

详细介绍

提示词工程

为大模型应用打造有效的提示词。

适用场景

  • 创建系统提示词
  • 提高 AI 输出质量
  • 构建 AI Agent
  • 优化令牌用量
  • 设计提示词模板

核心技巧

角色设定
You are an expert [role] with [X] years of experience in [domain].
Your task is to [specific goal].
思维链
Think through this step by step:
1. First, analyze [aspect 1]
2. Then, consider [aspect 2]
3. Finally, determine [conclusion]

Show your reasoning before giving the final answer.
少样本示例
Here are examples of the expected format:

Input: [example 1 input]
Output: [example 1 output]

Input: [example 2 input]
Output: [example 2 output]

Now process this input:
Input: {user_input}
Output:
结构化输出
Respond in the following JSON format:
{
  "analysis": "your analysis here",
  "confidence": 0.0-1.0,
  "recommendations": ["item1", "item2"]
}

Return valid JSON only, no additional text.

提示词模板

代码审查
You are a senior code reviewer. Review the code for:
1. Security vulnerabilities
2. Performance issues
3. Code quality and readability
4. Best practices violations

For each issue:
- Severity: Critical/High/Medium/Low
- Location: file:line
- Issue: description
- Fix: suggested solution

Code to review:
{code}
数据提取
Extract the following information from the text:
- Name: person's full name
- Email: email address
- Company: organization name
- Role: job title

If information is not found, use "NOT_FOUND".
Return as JSON.

Text:
{text}
分类
Classify the following text into one of these categories:
- POSITIVE
- NEGATIVE
- NEUTRAL

Consider tone, sentiment, and overall message.
Respond with only the category name.

Text: {text}
Category:

最佳实践

实践应该做不应该做
指令具体明确含糊不清
格式指定输出格式假定格式
示例包含 2-3 个示例复杂任务使用零样本
约束设定清晰的边界不设限制
长度必要时设定最大长度允许长度无限制

测试提示词

  1. 使用边界案例进行测试
  2. 尝试对抗性输入
  3. 检查多次运行的一致性
  4. 衡量输出质量
  5. 跟踪令牌用量

示例

输入:「创建一个用于摘要的提示词」 **操作:**设计提示词,加入长度限制、要点提取和格式规范

输入:「改进这个提示词的输出」 **操作:**添加示例、明确指令、指定格式并进行迭代测试

评论

支持 Markdown