Engineering Guide · Prompt Design

Prompt-Design-Guide

Battle-tested prompt patterns and iteration workflows for AI agents, code generation, and content processing.

License MITFormat Markdown · PDFLanguages EN · CNScenarios Agent · Code · Content
Features

What it does

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.

🧩

Five-module prompt structure

Role, Task, Context, Output Spec and Interaction Guide compose as independent, single-responsibility blocks — merge or omit for simple tasks.

📐

Principles that hold up

Positive instructions over negative constraints, explicit reasoning paths, few-shot example rules, and anchor reset for conversations beyond 4000 tokens.

🔁

Six-step iteration workflow

Baseline, smoke test, root-cause analysis, targeted fix, regression, release — with every change logged and one module modified at a time.

🌐

Web Q&A playbooks

A context-injection template, a High/Medium/Low confidence self-check, and multi-turn evidence summaries keep answers inside the given material.

🛠️

Large-project agent strategies

Project-level instructions, module-level task decomposition, change prompts with impact analysis, and debug prompts for OpenCode, Cursor and peers.

📏

Four hard evaluation metrics

Format compliance, key-element coverage, factual hallucination rate, and instruction-following deviation — each with an acceptable threshold.

🏷️

Prefix tag system

[Hard Constraint], [Important], [Optional], [Background] and [Counter-example] prefixes help models parse long prompts reliably.

Details

The five modules

ModulePurpose
RoleDefine expertise and perspective
TaskState what to accomplish explicitly
ContextProvide background, constraints, or prior logs
Output SpecSpecify format, length, structure, style
Interaction GuideRequest step-by-step reasoning or intermediate outputs
Quick Start

How to use

  1. Clone the repository — the whole guide is plain files, no build step.
  2. Read Prompt Design Guide.md (renders on GitHub) or open the PDF edition.
  3. Start with Prompt Structure, then apply the Design Principles to your own prompts.
  4. Tune with the Iteration Workflow and score outputs against the Evaluation Metrics.
shell
git clone https://github.com/AkiroMusic/Prompt-Design-Guide.git

“Prompt quality directly determines output accuracy, consistency, and safety.”

工程化指南 · 提示词设计

项目简介

一本面向 AI 智能体、代码生成和内容处理场景的工程化提示词设计实战指南。汇集经过实战验证的模式、标准化迭代工作流与可度量的评估指标——不谈主观审美,只讲跨任务可复现的方法。提供 Markdown 与 PDF 两种格式,中英双语。

🧩

五模块提示词结构

角色、任务、上下文、输出规范与交互指引作为独立、单一职责的模块自由组合——简单任务可合并或省略。

📐

经得起推敲的设计原则

正面指令优于负面约束、明确的推理路径、少样本示例规则,以及针对 4000 token 以上长对话的锚点重置。

🔁

六步迭代工作流

基线、冒烟测试、根因分析、定向修复、回归测试、发布——记录每一次变更,一次只修改一个模块。

🌐

Web 问答场景方案

上下文注入模板、高/中/低置信度自检与多轮证据摘要,让回答严格限定在给定材料之内。

🛠️

大型项目智能体策略

面向 OpenCode、Cursor 等工具的项目级系统指令、模块级任务拆解、含影响分析的变更提示词与调试提示词。

📏

四项硬评估指标

格式合规率、关键要素覆盖率、事实幻觉率与指令遵循偏差——每项均给出可接受阈值。

🏷️

前缀标签体系

[Hard Constraint]、[Important]、[Optional]、[Background]、[Counter-example] 等前缀帮助模型更可靠地解析长提示词。

明细

五模块结构

模块作用
角色 (Role)定义专业领域与视角
任务 (Task)明确陈述要完成的目标
上下文 (Context)提供背景、约束或历史日志
输出规范 (Output Spec)规定格式、长度、结构、风格
交互指引 (Interaction Guide)要求逐步推理或输出中间结果
  1. 克隆仓库——整个指南就是纯文本文件,无需构建。
  2. 阅读 Prompt Design Guide.md(GitHub 可直接渲染)或打开 PDF 版。
  3. 从提示词结构入手,再将设计原则应用到自己的提示词上。
  4. 用迭代工作流调优,并按评估指标为输出打分。
shell
git clone https://github.com/AkiroMusic/Prompt-Design-Guide.git

“提示词的质量直接决定输出的准确性、一致性与安全性。”