ai-prompt-engineering by vasilyu1983/ai-agents-public
npx skills add https://github.com/vasilyu1983/ai-agents-public --skill ai-prompt-engineering现代最佳实践(2026年1月) :版本化提示、明确的输出契约、回归测试,以及针对工具/RAG提示的安全威胁建模(OWASP LLM Top 10:https://owasp.org/www-project-top-10-for-large-language-model-applications/)。
此技能为构建生产就绪的提示提供操作指南,涵盖标准任务、RAG工作流、智能体编排、结构化输出、隐藏推理和多步骤规划。
所有内容均为操作性的,而非理论性的。专注于模式、检查清单和可复制粘贴的模板。
assets/ 中的模板开始,填写 TASK、INPUT、RULES 和 OUTPUT FORMAT。null/明确标记缺失。广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
此技能包含针对 Claude Code + Codex CLI 的优化:
优先使用“简要理由”而非要求思维链。当使用私有推理模式时,指示:内部思考;仅输出最终答案。
| 任务 | 使用模式 | 关键组件 | 何时使用 |
|---|---|---|---|
| 机器可解析输出 | 结构化输出 | JSON 模式、"仅 JSON" 指令、无散文 | API 集成、数据提取 |
| 字段提取 | 确定性提取器 | 精确模式、缺失->null、无转换 | 表单数据、发票解析 |
| 使用检索到的上下文 | RAG 工作流 | 上下文相关性检查、块引用、明确缺失信息 | 知识库、文档搜索 |
| 内部推理 | 隐藏思维链 | 内部推理、仅最终答案 | 分类、复杂决策 |
| 使用工具的智能体 | 工具/智能体规划器 | 先计划后行动、每轮一个工具 | 多步骤工作流、API 调用 |
| 文本转换 | 重写 + 约束 | 风格规则、意义保留、格式规范 | 内容适配、摘要 |
| 分类 | 决策树 | 有序分支、互斥、JSON 结果 | 路由、分类、分流 |
用户需求:[提示类型]
|-- 输出必须是机器可读的?
| |-- 仅提取特定字段? -> **确定性提取器模式**
| `-- 生成结构化数据? -> **结构化输出模式(JSON)**
|
|-- 使用外部知识?
| `-- 检索到的上下文必须被引用? -> **RAG 工作流模式**
|
|-- 需要推理但隐藏过程?
| `-- 分类或决策任务? -> **隐藏思维链模式**
|
|-- 需要调用外部工具/API?
| `-- 多步骤工作流? -> **工具/智能体规划器模式**
|
|-- 转换现有文本?
| `-- 风格/格式约束? -> **重写 + 约束模式**
|
`-- 分类或路由到类别?
`-- 互斥规则? -> **决策树模式**
TASK:
{{one_sentence_task}}
INPUT:
{{input_data}}
RULES:
- 严格遵循 TASK。
- 仅使用 INPUT(以及允许的工具输出)。
- 不虚构细节。缺少必需信息 -> 说明缺少什么。
- 保持推理过程隐藏。
- 严格遵循 OUTPUT FORMAT。
OUTPUT FORMAT:
{{schema_or_format_spec}}
AVAILABLE TOOLS:
{{tool_signatures_or_names}}
WORKFLOW:
- 制定一个简短的计划。
- 仅在完成任务需要时调用工具。
- 在使用工具输出前进行验证。
- 如果环境支持并行工具调用,请并行运行独立的调用。
RETRIEVED CONTEXT:
{{chunks_with_ids}}
RULES:
- 仅使用检索到的上下文来陈述事实。
- 为每个主张引用块 ID。
- 如果证据缺失,请说明缺失什么。
验证或调试提示时,请参考以下内容:
frameworks/shared-skills/skills/ai-prompt-engineering/references/quality-checklists.mdframeworks/shared-skills/skills/ai-prompt-engineering/references/production-guidelines.md提示工程的真正专业知识不仅限于编写指令,还包括塑造模型运行的整个上下文。上下文工程包括:
| 方面 | 提示工程 | 上下文工程 |
|---|---|---|
| 重点 | 指令文本 | 完整输入流水线 |
| 范围 | 单个提示 | RAG + 历史 + 工具 |
| 优化 | 措辞选择、结构 | 信息架构 |
| 目标 | 清晰的指令 | 最优的上下文窗口 |
1. 上下文优先级:将最相关的信息放在前面;模型对早期上下文关注度更高。
2. 上下文压缩:总结历史、截断工具输出、选择最相关的 RAG 块。
3. 上下文分离:使用清晰的分隔符(<system>、<user>、<context>)来分隔指令类型。
4. 动态上下文:根据任务复杂性调整上下文——简单任务需要较少上下文,复杂任务需要更多。
应做
应避免
模板可直接复制粘贴,并按复杂度组织:
外部参考资料列在 data/sources.json 中:
当被问及“最新”提示建议时,优先参考 data/sources.json 中的供应商文档和标准。如果无法进行网络搜索,请说明此限制,并避免做出过于自信的“当前最佳”声明。
此技能提供基础的提示工程模式。针对专门的实现:
AI/LLM 技能:
软件开发技能:
对于 Claude Code:
对于 Codex CLI:
medium(默认),复杂自主多小时任务使用 high/xhigh每周安装次数
92
代码仓库
GitHub 星标数
49
首次出现
2026年1月23日
安全审计
安装于
opencode76
gemini-cli75
codex72
cursor70
github-copilot68
claude-code63
Modern Best Practices (January 2026) : versioned prompts, explicit output contracts, regression tests, and safety threat modeling for tool/RAG prompts (OWASP LLM Top 10: https://owasp.org/www-project-top-10-for-large-language-model-applications/).
This skill provides operational guidance for building production-ready prompts across standard tasks, RAG workflows, agent orchestration, structured outputs, hidden reasoning, and multi-step planning.
All content is operational , not theoretical. Focus on patterns, checklists, and copy-paste templates.
assets/ and fill in TASK, INPUT, RULES, and OUTPUT FORMAT.null/explicit missing.This skill includes Claude Code + Codex CLI optimizations:
Prefer “brief justification” over requesting chain-of-thought. When using private reasoning patterns, instruct: think internally; output only the final answer.
| Task | Pattern to Use | Key Components | When to Use |
|---|---|---|---|
| Machine-parseable output | Structured Output | JSON schema, "JSON-only" directive, no prose | API integrations, data extraction |
| Field extraction | Deterministic Extractor | Exact schema, missing->null, no transformations | Form data, invoice parsing |
| Use retrieved context | RAG Workflow | Context relevance check, chunk citations, explicit missing info | Knowledge bases, documentation search |
| Internal reasoning | Hidden Chain-of-Thought | Internal reasoning, final answer only | Classification, complex decisions |
| Tool-using agent | Tool/Agent Planner | Plan-then-act, one tool per turn | Multi-step workflows, API calls |
User needs: [Prompt Type]
|-- Output must be machine-readable?
| |-- Extract specific fields only? -> **Deterministic Extractor Pattern**
| `-- Generate structured data? -> **Structured Output Pattern (JSON)**
|
|-- Use external knowledge?
| `-- Retrieved context must be cited? -> **RAG Workflow Pattern**
|
|-- Requires reasoning but hide process?
| `-- Classification or decision task? -> **Hidden Chain-of-Thought Pattern**
|
|-- Needs to call external tools/APIs?
| `-- Multi-step workflow? -> **Tool/Agent Planner Pattern**
|
|-- Transform existing text?
| `-- Style/format constraints? -> **Rewrite + Constrain Pattern**
|
`-- Classify or route to categories?
`-- Mutually exclusive rules? -> **Decision Tree Pattern**
TASK:
{{one_sentence_task}}
INPUT:
{{input_data}}
RULES:
- Follow TASK exactly.
- Use only INPUT (and tool outputs if tools are allowed).
- No invented details. Missing required info -> say what is missing.
- Keep reasoning hidden.
- Follow OUTPUT FORMAT exactly.
OUTPUT FORMAT:
{{schema_or_format_spec}}
AVAILABLE TOOLS:
{{tool_signatures_or_names}}
WORKFLOW:
- Make a short plan.
- Call tools only when required to complete the task.
- Validate tool outputs before using them.
- If the environment supports parallel tool calls, run independent calls in parallel.
RETRIEVED CONTEXT:
{{chunks_with_ids}}
RULES:
- Use only retrieved context for factual claims.
- Cite chunk ids for each claim.
- If evidence is missing, say what is missing.
Use these references when validating or debugging prompts:
frameworks/shared-skills/skills/ai-prompt-engineering/references/quality-checklists.mdframeworks/shared-skills/skills/ai-prompt-engineering/references/production-guidelines.mdTrue expertise in prompting extends beyond writing instructions to shaping the entire context in which the model operates. Context engineering encompasses:
| Aspect | Prompt Engineering | Context Engineering |
|---|---|---|
| Focus | Instruction text | Full input pipeline |
| Scope | Single prompt | RAG + history + tools |
| Optimization | Word choice, structure | Information architecture |
| Goal | Clear instructions | Optimal context window |
1. Context Prioritization : Place most relevant information first; models attend more strongly to early context.
2. Context Compression : Summarize history, truncate tool outputs, select most relevant RAG chunks.
3. Context Separation : Use clear delimiters (<system>, <user>, <context>) to separate instruction types.
4. Dynamic Context : Adjust context based on task complexity - simple tasks need less context, complex tasks need more.
Do
Avoid
Best Practices (Core) - Foundation rules for production-grade prompts
Production Guidelines - Deployment and operational guidance
Quality Checklists - Validation checklists before deployment
Domain-Specific Patterns - Claude 4+ optimized patterns for specialized domains
RAG Patterns - Retrieval-augmented generation workflows
Agent and Tool Patterns - Tool use and agent orchestration
Extraction Patterns - Deterministic field extraction
Reasoning Patterns (Hidden CoT) - Internal reasoning without visible output
- Extended prompt engineering techniques
Templates are copy-paste ready and organized by complexity:
External references are listed in data/sources.json:
When asked for “latest” prompting recommendations, prefer provider docs and standards from data/sources.json. If web search is unavailable, state the constraint and avoid overconfident “current best” claims.
This skill provides foundational prompt engineering patterns. For specialized implementations:
AI/LLM Skills :
Software Development Skills :
For Claude Code :
For Codex CLI :
medium for interactive coding (default), high/xhigh for complex autonomous multi-hour tasksWeekly Installs
92
Repository
GitHub Stars
49
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode76
gemini-cli75
codex72
cursor70
github-copilot68
claude-code63
AI Elements:基于shadcn/ui的AI原生应用组件库,快速构建对话界面
66,200 周安装
AI流量追踪指南:在GA4和GSC中精准分析AI搜索流量与AI概览
326 周安装
SRED 工作汇总技能:自动聚合 GitHub PR、Notion 文档和 Linear 工单,生成年度工作报告
330 周安装
网站可抓取性优化指南:robots.txt、网站结构、内部链接与AI爬虫优化
328 周安装
customaize-agent:create-command - 创建与管理AI助手命令的元命令工具
327 周安装
鱼骨图因果分析工具 - 系统化问题根源诊断与解决方案优先级排序
333 周安装
会话记录器:自动保存AI对话历史到Markdown文件,提升开发与知识管理效率
331 周安装
| Rewrite + Constrain |
| Style rules, meaning preservation, format spec |
| Content adaptation, summarization |
| Classification | Decision Tree | Ordered branches, mutually exclusive, JSON result | Routing, categorization, triage |
Prompt Testing& CI/CD - Automated prompt evaluation pipelines
Multimodal Prompt Patterns - Vision, audio, and document input patterns
Prompt Security& Defense - Securing LLM applications against adversarial attacks