Introduction to Prompt Engineering: 10 Practical Tips for Writing High-Quality AI Prompts
Have you ever had this experience: using the same AI tool, others get precise and professional outputs, while you get verbose and nonsensical responses?
The difference lies not in the tool, but in the quality of the prompt. Prompt engineering is not some mysterious technology; it is a learnable and iterative methodology of communication. This article compiles 10 proven practical techniques, each with a negative example and a correct example for comparison.
Why Prompt Quality Determines AI Output Quality
Large language models are essentially extremely complex 'completion machines'—they predict the most reasonable subsequent content based on your input. Your prompt quality directly determines the model's 'direction of thought'.
A vague prompt lets the model guess your intent on its own, and the model's guesses are often the most conservative and mediocre answers. A precise prompt is like installing navigation for the model, allowing it to head directly to the destination you need.
10 Practical Techniques
Technique 1: Clearly Specify the Role
Give AI a specific role, and it will invoke the knowledge base and expression style most matching that role.
❌ Incorrect Example
帮我写一篇关于 Python 的文章。
✅ Correct Example
你是一位有 10 年经验的 Python 工程师,擅长向非技术人员解释编程概念。
请为完全没有编程基础的产品经理写一篇 Python 入门文章,重点说明 Python 能解决哪些实际工作问题。
Role setting doesn't need to be exaggerated; it should fit actual needs. 'World-class expert' is less specific and effective than 'practitioner with X years of experience'.
Technique 2: Describe the Desired Output Format
Tell AI what format of output you need, and it will generate it strictly according to the format, saving you a lot of secondary organization work.
❌ Incorrect Example
列出 5 个热门 JavaScript 框架的对比。
✅ Correct Example
请用 Markdown 表格对比以下 5 个 JavaScript 框架:React、Vue、Angular、Svelte、Solid.js
表格列包含:框架名称、发布年份、学习曲线(低/中/高)、适用场景、2026年 GitHub Star 数量级
Common format instructions: JSON 格式、Markdown 表格、编号列表、代码块、分点说明。
Technique 3: Provide Contextual Background Information
AI doesn't know your specific situation; give it background information so it can give targeted advice instead of generic nonsense.
❌ Incorrect Example
帮我优化这个 SQL 查询速度。
✅ Correct Example
我有一个 MySQL 8.0 数据库,用户表有 500 万条记录。
以下查询每次执行需要 8 秒,已严重影响用户体验:
SELECT u.*, o.order_count
FROM users u
LEFT JOIN (SELECT user_id, COUNT(*) as order_count FROM orders GROUP BY user_id) o
ON u.id = o.user_id
WHERE u.created_at > '2025-01-01';
请分析性能瓶颈并给出优化方案,说明每个优化的原理。
Three elements of context: environment (tech stack/version/scale), current situation (specific problem/data/code), goal (what effect you expect to achieve).
Technique 4: Use Few-Shot Examples
Show AI 2-3 examples of 'the output you want', and it will understand your taste and standards, mimicking that style for output.
❌ Incorrect Example
帮我写几条产品文案,要有吸引力。
✅ Correct Example
请按照以下风格,为我们的 Markdown 在线编辑器写 3 条 Twitter 宣传文案。
风格参考:
示例1:"停止在 Word 和网页之间切换。MagicTools 让你的 Markdown 实时渲染,一键分享。"
示例2:"代码、表格、数学公式——一个编辑器全搞定。还免费。"
现在请为「图床上传工具」写 3 条,强调上传快速和 CDN 加速。
Technique 5: Chain-of-Thought
For problems that require reasoning, ask AI to think step by step instead of directly giving conclusions. This can significantly improve the response quality for complex problems.
❌ Incorrect Example
这个商业计划可行吗?[粘贴商业计划书]
✅ Correct Example
请分析这个商业计划的可行性。要求:
1. 先分析市场规模和竞争格局
2. 再评估团队能力与所需资源的匹配度
3. 然后识别最关键的 3 个风险点
4. 最后给出综合评分(1-10)和理由
请按这个顺序逐步分析,不要跳步骤。
[商业计划内容]
Keywords: 逐步分析、一步一步、先...再...然后...、不要跳过中间步骤。
Technique 6: Set Constraints
Clearly tell AI word count limits, target audience, writing style, etc., to avoid output deviating from expectations.
❌ Incorrect Example
解释一下什么是机器学习。
✅ Correct Example
用不超过 200 字解释什么是机器学习。
受众:对技术一无所知的 50 岁企业主
风格:类比生活场景,避免所有技术术语
结尾:说明机器学习能为他们的业务带来什么具体价值
Common constraint dimensions: word count (not exceeding X words/exactly X words), audience (beginners/experts/specific profession), style (formal/colloquial/humorous), language (Chinese/English).
Technique 7: Iteratively Optimize Prompts
Treat the prompt as code; if the first version doesn't work well, change it. Establish a feedback loop of "Prompt → Output → Evaluation → Improvement".
A practical iterative framework:
第一轮(粗稿):
"帮我写一份产品发布公告"
评估问题:太长了,语气太正式,缺少具体数据
第二轮(改进):
"帮我写一份产品发布公告,要求:
- 不超过 150 字
- 语气轻松活泼,像朋友分享好消息
- 突出三个核心功能:实时协作、版本历史、移动端支持
- 结尾加一句 CTA(行动号召)"
评估:好多了,但 CTA 不够有力
第三轮(精修):
[在第二轮基础上调整 CTA 部分...]
Technique 8: Decompose Complex Tasks
Forcing a complex task to be solved with a single prompt often results in poor quality. Break it down into multiple subtasks, ensuring quality at each step.
Scenario: Writing a 3000-word technical blog post
❌ Let AI write the entire article at once
✅ Complete step by step:
步骤1:"请为「React 18 并发特性」这个主题生成一个详细的文章大纲,包含 5 个主要章节,每章 2~3 个子节点"
步骤2:"根据上面的大纲,先展开第一章:并发渲染的背景与问题"
步骤3:"第一章写得很好。请继续展开第二章..."
(依次完成每个章节)
步骤4:"请帮我统一全文的写作风格,使语气更加一致"
Technique 9: Use Delimiters to Clearly Distinguish Content
When a prompt contains multiple types of content (instructions, data, examples), use delimiters to clearly distinguish them, avoiding AI confusion.
❌ Incorrect Example
把下面这段英文翻译成中文,要保持原文语气,用正式风格,This is the text I want to translate: The system encountered an unexpected error...
✅ Correct Example
请将以下英文翻译成中文,要求:保持正式语气,技术术语保留英文原文
---
The system encountered an unexpected error during the initialization phase.
Please contact your system administrator if this problem persists.
---
Common delimiters: --- (three dashes), ``` (code fences), [BEGIN]...[END], <text>...</text> (XML tag style).
Technique 10: Clearly State What You Don't Want (Negative Constraints)
Tell AI what you do not want, which can effectively avoid its "bad habits".
❌ Incorrect Example
帮我写一封道歉邮件。
(AI usually writes an overly humble email full of clichés)
✅ Correct Example
帮我给客户写一封关于项目延期的道歉邮件。
不要:
- 过分道歉或卑微("非常非常抱歉""给您带来了极大不便")
- 含糊其辞(直接说明延期原因和新的交付时间)
- 空洞承诺(只写已经落实的改进措施)
要:专业、诚恳、给出具体行动计划
Advanced: System Prompts vs User Prompts
If you are using AI via API or building applications, you need to understand the difference between two types of prompts:
System Prompt: Set before the conversation starts, defining AI's role, capability range, and behavioral rules. It has higher priority than user prompts and remains effective throughout the conversation.
系统提示示例:
"你是 MagicTools 的客服助手,只回答与在线工具使用相关的问题。
对于与工具无关的问题,礼貌地引导用户回到正题。
回答语言:跟随用户语言(中文/英文)。"
User Prompt: The content sent by the user in each round of conversation, operating within the framework set by the system prompt.
For ordinary users using ChatGPT/Claude web versions, you can send a "role setting" message at the beginning of the conversation to simulate the effect of a system prompt.
Common Mistakes
Mistake 1: Prompt is too vague "Help me improve this" - improve what? In what direction? To what extent?
Mistake 2: Information overload Cramming 10 requirements into one prompt; AI often only completes a few. Put the highest priority requirements first, and split complex tasks for execution.
Mistake 3: Unrealistic expectations AI cannot "search the internet for the latest data" (unless it has tool calling capabilities), cannot "remember the last conversation" (default is no memory), and cannot guarantee 100% factual accuracy (you need to verify important information).
FAQ
Q: Does prompt engineering require programming basics?
A: Not at all. The core of prompt engineering is clear expression—telling AI what you want like writing a requirements document. Mastering the 10 techniques in this article, anyone can get started. Of course, if you want to build AI applications via API, basic programming skills will be helpful.
Q: Are prompts通用 for different AI models?
A: The core ideas are通用, but details vary. ChatGPT (GPT-4o) responds better to role-playing; Claude is better at long document analysis and strictly adheres to constraints; Gemini excels in multimodal tasks. Suggestion: first learn通用 techniques, then fine-tune for commonly used models.
Q: How to save and manage prompts?
A: There are several ways: 1) Build a personal prompt library—use Notion or Obsidian to save effective prompts by scenario; 2) Use professional tools—PromptBase (buy/sell prompts), FlowGPT (prompt sharing community); 3) For frequently used prompts, you can encapsulate them into custom assistants using AI applications (such as Dify, Coze) for one-click invocation.
Summary
The essence of prompt engineering is turning vague requirements into precise instructions. The 10 techniques can be summarized in one sentence: tell AI who it is, what format you want, what the background is, what constraints there are, and what you don't want.
From today on, every time you open an AI tool, spend 30 seconds thinking about your prompt—this 30 seconds can often save you 10 minutes of rework. The difference between a good and bad prompt is immediately apparent.