P
Prompt Master
Prompt 大师

掌握和 AI 对话的艺术

Prompt Library

A collection of reusable, task-oriented prompt templates

This is your prompt arsenal. We've collected and organized the most practical, battle-tested prompt templates across the industry -- covering everything from basic text classification to complex code generation.

Prompt Lab

Turn this chapter's knowledge into practical skills

Enter the interactive lab and practice Prompt with real tasks. Get started in 10 minutes.

View Now

These templates aren't rigid rules. They're reusable starting points. Copy them, fill in your specific Context and Constraints, and you've got a high-quality prompt in seconds.


Why Use a Template Library?

AdvantageDescription
Save timeSkip the blank-page problem. Start with a proven framework.
Better qualityTemplates bake in techniques that work (Chain-of-Thought, Few-Shot, etc.).
StandardizationUnify your team's prompt style for easier maintenance and collaboration.
Fewer blind spotsGood templates remind you to include context and output format requirements.

Core Prompt Structure

A solid general-purpose prompt usually has four core elements (CRDO):

graph LR
    C[Context<br>Background info] --> P[Prompt]
    R[Role<br>Role assignment] --> P
    T[Task<br>Specific task] --> P
    O[Output<br>Output requirements] --> P

Or as a more intuitive text structure:

# Role
You are a [expert role] skilled in [core competency].

# Context
I'm facing [specific situation/problem] and need [specific goal].

# Task
Please complete the following:
1. [Step 1]
2. [Step 2]

# Constraints
- [Constraint 1, e.g., word limit]
- [Constraint 2, e.g., tone of voice]

# Output Format
Please output in [Markdown/JSON/list] format.

Template Library Navigation

We've organized prompts by task type. Click any link to jump to the template page.

📊 Classification & Analysis

For labeling, sentiment analysis, intent detection, and similar tasks.

🧠 Reasoning & Logic

For tasks that need logical thinking, math, or complex problem-solving.

📝 Generation & Creativity

For writing, brainstorming, image generation prompts, and more.

💻 Coding & Engineering

For code generation, explanation, debugging, and refactoring.

🛡️ Safety & Evaluation

Model security, red teaming, and output quality assessment.

⚠️ Note: Adversarial prompts are for Red Teaming and security research only. Don't use them for malicious purposes.


How to Use These Templates

  1. Copy: Find a template that matches your task, copy it.
  2. Fill: Replace the [variables] with your actual business content.
  3. Test: Run the prompt, observe the output.
  4. Iterate: If the result isn't great, tweak the Context or Constraints until you're happy.

🌟 Universal Starter Template

Not sure which template to use? Start here:

# Role

You are an experienced [domain expert] focused on providing high-quality solutions for [target audience].

# Task

Given the following [input content], perform [specific operation (e.g., analyze, summarize, rewrite)].

# Input Data

"""
[Paste your text/data here]
"""

# Constraints

-   Keep the tone [professional/friendly/objective].
-   Focus on [key point 1] and [key point 2].
-   If you encounter [situation A], then [response action].

# Output

Please output the result in [specific format].

Takeaways

  • Don't memorize templates: Understanding the logic behind them matters more than rote memorization.
  • Context is King: No matter how good the template is, providing accurate, rich context is always the key to better results.
  • Keep iterating: Prompt development is an experimental process. There's no perfect prompt -- only prompts that keep getting better.

📚 Related resources

Common questions

Open a question to review the practical answer.

Who is the prompt template library actually for, and is copy-pasting safe for beginners?

Templates are reusable starting points, not magic spells. The chapter teaches a CRDO skeleton — Context, Role, Task, Output — and you must swap every `[variable]` for real business context before sending it. The most common trap with copy-paste is leaving Context blank, so the model fills the gap by guessing and you get worse output than if you had written from scratch.

What happens if I drop one of the four CRDO sections?

Drop Role and the model defaults to a generic-assistant tone with no domain weight. Drop Context and it invents business background, raising hallucination. Vague Task means the output drifts off-target. Skip Output Format and the structure shifts every call, breaking downstream parsers. Output Format is the section people skip most often, and it is the one whose absence costs you the most stability.

Should I start with the universal starter template or pick a task-specific one?

If you are not sure what category the task is, start with the universal starter (Role + Task + Input Data + Constraints + Output) just to make it run. Once the task is clear, switch to the specific template — Classification for labels, Information Extraction for entities, Coding for code. The specific templates already encode the pitfalls of that task type, so they are more reliable than the generic version.

Should our team keep our own prompt template library, and where should we store it?

Once the team is bigger than three people it pays off. Store templates with their CRDO sections and variable placeholders in Git, not in a wiki doc, and write a changelog every time you iterate. Keep production prompts in a dedicated repo with version numbers, owners and A/B data attached. Editing a prompt then becomes editing code — reviewable, revertable, and traceable to whoever changed it.

Why does the library include a Safety and Evaluation section — do regular teams need adversarial prompts?

Yes. Even if you do not run a red team, real users will try prompt injection, jailbreak and prompt leaking once the product is live. The Safety and Evaluation templates exist so you can see what an attack looks like and then add defences — input partitioning, threat-model declarations, output filtering. The site only shows the defender side and does not publish working jailbreak scripts.