Five-module prompt structure
Role, Task, Context, Output Spec and Interaction Guide compose as independent, single-responsibility blocks — merge or omit for simple tasks.
Battle-tested prompt patterns and iteration workflows for AI agents, code generation, and content processing.
A practical, engineering-oriented guide for designing prompts in AI Agent, code generation, and content processing scenarios. It collects battle-tested patterns, a standardized iteration workflow, and measurable evaluation metrics — no subjective aesthetics, only practices that reproduce across tasks. Shipped as Markdown and PDF, in English and Chinese.
Role, Task, Context, Output Spec and Interaction Guide compose as independent, single-responsibility blocks — merge or omit for simple tasks.
Positive instructions over negative constraints, explicit reasoning paths, few-shot example rules, and anchor reset for conversations beyond 4000 tokens.
Baseline, smoke test, root-cause analysis, targeted fix, regression, release — with every change logged and one module modified at a time.
A context-injection template, a High/Medium/Low confidence self-check, and multi-turn evidence summaries keep answers inside the given material.
Project-level instructions, module-level task decomposition, change prompts with impact analysis, and debug prompts for OpenCode, Cursor and peers.
Format compliance, key-element coverage, factual hallucination rate, and instruction-following deviation — each with an acceptable threshold.
[Hard Constraint], [Important], [Optional], [Background] and [Counter-example] prefixes help models parse long prompts reliably.
| Module | Purpose |
|---|---|
| Role | Define expertise and perspective |
| Task | State what to accomplish explicitly |
| Context | Provide background, constraints, or prior logs |
| Output Spec | Specify format, length, structure, style |
| Interaction Guide | Request step-by-step reasoning or intermediate outputs |
git clone https://github.com/AkiroMusic/Prompt-Design-Guide.git
“Prompt quality directly determines output accuracy, consistency, and safety.”
一本面向 AI 智能体、代码生成和内容处理场景的工程化提示词设计实战指南。汇集经过实战验证的模式、标准化迭代工作流与可度量的评估指标——不谈主观审美,只讲跨任务可复现的方法。提供 Markdown 与 PDF 两种格式,中英双语。
角色、任务、上下文、输出规范与交互指引作为独立、单一职责的模块自由组合——简单任务可合并或省略。
正面指令优于负面约束、明确的推理路径、少样本示例规则,以及针对 4000 token 以上长对话的锚点重置。
基线、冒烟测试、根因分析、定向修复、回归测试、发布——记录每一次变更,一次只修改一个模块。
上下文注入模板、高/中/低置信度自检与多轮证据摘要,让回答严格限定在给定材料之内。
面向 OpenCode、Cursor 等工具的项目级系统指令、模块级任务拆解、含影响分析的变更提示词与调试提示词。
格式合规率、关键要素覆盖率、事实幻觉率与指令遵循偏差——每项均给出可接受阈值。
[Hard Constraint]、[Important]、[Optional]、[Background]、[Counter-example] 等前缀帮助模型更可靠地解析长提示词。
| 模块 | 作用 |
|---|---|
| 角色 (Role) | 定义专业领域与视角 |
| 任务 (Task) | 明确陈述要完成的目标 |
| 上下文 (Context) | 提供背景、约束或历史日志 |
| 输出规范 (Output Spec) | 规定格式、长度、结构、风格 |
| 交互指引 (Interaction Guide) | 要求逐步推理或输出中间结果 |
git clone https://github.com/AkiroMusic/Prompt-Design-Guide.git
“提示词的质量直接决定输出的准确性、一致性与安全性。”