Prompt

Learn the fundamentals of conversing with AI — write good prompts and use AI tools well.

Why are prompts important?

The same question, asked in different ways, can yield answers of vastly different quality.

You may have had an experience like this:

You ask AI: Help me write a report. AI gives you a generic, hollow article full of empty words.

But if you change the prompt and ask: "I am a product manager. Help me write a product roadmap report for Q2 2026, targeting the technical team. It needs 5 main feature points, each including development cycle and risk assessment, with the word count kept within 800 words." What AI provides is a document that is clear in structure, specific in content, and ready to use directly.

This is the difference in prompts.

A prompt is the language you use to communicate with AI.

AI can only respond based on the information you give; the more specific and clear the information is, the more the output will match expectations.

The golden rule of prompts:Vague input, vague output; specific input, specific output.。


What is a prompt?

Prompt is the text content you input to the AI.

A prompt can be a question, an instruction, a description, or a combination of these.

Good Prompt vs Bad Prompt

Let's use a comparison to illustrate the difference between the two:

Dimension❌ Not recommended✅ Recommended
Clarity"Help me write something""Help me write an email to customers informing them that our product will increase in price by 10% next month"
Role setting"Translate this passage""You are a professional English translator skilled in technical document translation. Please translate the following content into Chinese while maintaining the accuracy of technical terms"
Format requirements"Make a list""Use a bulleted list to list 5 key points, each no more than 20 characters"
Context"Help me look at this code""This is a Python web scraper. When running, it throws a 'connection timeout' error. Help me analyze the possible causes and give 3 solutions"
Style and tone"Write a notice""Write a holiday notice for all company employees. Use a formal tone, keep the content concise, and include three parts: holiday dates, precautions, and duty arrangements"

See the pattern?

A good prompt tells the AI: who you are, what to do, who it's for, what format to use, and what constraints there are.


Basic prompt structure

A complete prompt usually includes the following four elements.

You don't need to include all of them every time, but the more comprehensive your prompt, the more controllable the result.

Task Description (What to Do)

Clearly tell the AI what task you want it to complete.

This is the core part of the prompt and must be written clearly.

Summarize the main points of this article.

Convert this Python code to JavaScript.

Help me come up with 10 store names suitable for a milk tea shop.

Background information (context)

Tell the AI relevant background information to help it understand the task scenario.

Without context, the AI can only guess blindly. With context, its answers will be on point.

I am a junior computer science student preparing for an interview...

This is our company's product introduction, and the target customers are small and medium-sized business owners...

I want to write a popular science article for elementary school students, so I can't use complex terminology...

Output format requirements (how to present)

Specify the format of the AI's output: list, table, paragraph, code, JSON, etc.

Clear format requirements can save you the time of reorganizing the output.

Present it in a table format with three columns: step name, operation instructions, and precautions.

Output in JSON format, containing three fields: 'id', 'name', 'description'.

Answer in three paragraphs, each paragraph no more than 100 words.

Example (for reference)

Give the AI one or two examples so it understands what kind of output you want.

This is calledFew-shot Learning, which means giving a few examples for it to learn from.

For example:

Input: happy, Output: overjoyed, elated, pleasantly surprised

Now please process: sad


Three basic prompt types

Depending on your purpose, prompts can be divided into three basic types.

Question type: direct question.

Used to obtain information, explain concepts, and seek advice.

This is the simplest prompt type, suitable for information lookup scenarios.

What is the difference between list and tuple in Python?

How can we improve team communication efficiency?

Which front-end frameworks are most worth learning in 2026?

] Note when asking: the more specific, the better.

] Don't just ask: how to learn programming. Ask: I'm a complete beginner and want to do web development. Should I learn HTML/CSS or JavaScript first? Please give me a 3-month learning plan.

Instruction-based: tell the AI what to do.

] Used to complete specific tasks: writing, translation, code modification, data organization, etc.

] Instruction-type prompts need to be clear, specific, and executable.

] Translate this text into English, keeping the humor of the original.

] Split this long paragraph into 5 bullet points, each with a subheading.

] Help me optimize this code, add comments, and find possible bugs.

Dialogue type: multi-turn communication.

] It's not a one-time question, but an ongoing conversation that gradually goes deeper.

] This approach is suitable for complex tasks, allowing you to adjust direction while chatting.

] You: "I want to build a personal blog website. What technical solutions do you recommend?

] AI: "Based on your needs, you can consider the following options: ...

] You: "I'll go with Hugo. So how do I get started exactly?

] AI: "OK, the steps to set up a blog with Hugo are as follows: ...

] You: "Wait, I don't want to use GitHub Pages. Are there any other free hosting options?

] The key to conversation-type prompts is: remember the AI has contextual memory. You don't need to repeat what was said before every time—just continue the conversation directly.


Roleplay prompt

] Assign a role to the AI, and its answers will be more professional and better matched to the scenario.

This is one of the simplest yet most effective techniques.

Why is role-playing useful?

AI has seen a large amount of text from different roles during training. When you tell it "you are a lawyer," it automatically adjusts its tone, wording, and way of thinking to be more like a real lawyer.

The same question, different roles will give completely different answers.

For example, if you ask: "How can I let more people know about my product?

Set the roleAnswer focus
Marketing expertBrand positioning, channel selection, event planning
Sales directorConversion funnel, customer follow-up, closing techniques
Product managerProduct selling points, user experience, differentiation
Technical leadTechnical implementation, performance optimization, data analysis

Common character template

Here are some commonly used role settings. You can use them directly or modify them as needed:

You are an experienced Python development engineer, skilled in code review and performance optimization. Please help me take a look at this code...

You are a professional copywriter with 10 years of experience in the advertising industry. Please help me rewrite this product description...

You are my Japanese tutor, with standard pronunciation and good at correcting beginners' mistakes. Please help me check the grammar of this conversation...

You are a startup mentor who has successfully founded three tech companies. Please help me analyze this business plan...

The more specific the role setting, the better the effect.

Don't just say "you are an expert." Say "you are an expert with 5 years of experience in e-commerce data analysis, especially skilled in user behavior analysis."


Techniques for making output more precise

Master these techniques and your prompt skills will greatly improve.

Specify output format

Clearly telling the AI what format to output in can save you a lot of sorting time.

Common formats include:

Format typeExample instruction
List"List 5 key points using an unordered list..."
Table"Present it in a table, with column names: feature, advantage, disadvantage..."
Code"Output complete Python code, including comments..."
JSON"Output in JSON format, with fields: id, name, price..."
Markdown"Use Markdown format, including 3 level-2 headings..."

Control length

Tell the AI how long you want the output to be, to avoid it saying too much or too little.

Summarize in one sentence...

Write an introduction of about 300 words...

Detailed explanation, at least 500 characters...

Specified tone and style

Tell the AI what tone to use, adapting to different communication scenarios.

Formal tone, suitable for presenting to leaders...

Express it in a relaxed and humorous way...

Use plain and easy-to-understand language, suitable for elementary school students...

Stay professional, objective, and neutral...

Chain of Thought

For complex problems, have the AI explain its thinking process instead of directly giving the answer.

This can significantly improve the accuracy of the answer and also makes it easy for you to check its reasoning process.

Please analyze this problem step by step, first explain your approach, then give the answer.

When you encounter uncertainties, please state your assumptions and reasoning process.


Common errors and corrections

Beginners tend to make these mistakes. Let's look at how to fix them.

Error 1: The prompt is too vague.

This is the most common problem.

❌ Vague prompt✅ Improved prompt
"Help me write some copy""Help me write a WeChat Official Account article for a milk tea shop's new product launch. The target readers are young people aged 18-25. The style should be lively and fun, highlighting the 'second cup half price' promotion. Length: 300-500 characters."
"Help me check this code""This is a user registration API written in Python. Help me check whether there are SQL injection risks, whether password encryption is secure, and whether error handling is complete. List the issues and fix suggestions separately."
"Help me make a plan""Help me create a 3-month fitness plan. The goal is to lose 5 kg, exercise 3 times a week, 1 hour each session. The main exercise methods are running and strength training. Please give a specific weekly schedule."

Mistake two: asking for too much at once, can't finish it all in one go.

Don't try to do everything in a single prompt.

Complex tasks should be broken into multiple rounds of conversation, step by step.

❌ Don't do this: "Help me write an e-commerce website with user registration, product display, shopping cart, order management, and payment features, developed with React and Node.js, using MySQL as the database. Give me the complete code."

✅ Do it like this:

You: "I want to build a simple e-commerce website. I'd like to use React + Node.js + MySQL as the tech stack. What should I do first?"

AI: "I suggest starting with the database table design. We can begin with the user table and the product table..."

You: "OK, help me design the structure of the user table and the product table. What fields should they include?"

...(go deeper step by step)

Mistake 3: No feedback, making mistakes all the way.

AI's first output may not be perfect.

That's okay, tell it what's wrong and let it revise.

You: "This article is too long and too technical. My readers are beginners and won't understand it."

AI: "Sorry, let me rewrite it to be more concise and easier to understand..."

You: "Much better, but the second part is still a bit complex. Can you use an analogy to explain this concept?"

AI: "Sure, let's use 'sending a package' as an analogy for this network communication process..."

Remember: prompt writing is an iterative process. It's rare to get it perfect on the first try.


Practical Exercise: 10 High-Frequency Usage Scenario Templates

Here are 10 of the most commonly used prompt templates that you can apply directly.

ScenarioPrompt Template
Email WritingYou are a professional business writing assistant. Please help me write an email to {recipient's identity} with the subject {email subject} and main content {specific content}. The tone should be {formal/friendly/tactful/direct}, and the word count should be within {number} words.
Article SummaryPlease read the following article and generate a {number}-word summary covering the following key points: 1) {core point 1}; 2) {core point 2}; 3) {core point 3}. Please summarize in clear and concise language.
Code ExplanationYou are a patient programming teacher. Please help me explain what this {programming language} code does, explain the function of key statements line by line, and point out the code's strengths, weaknesses, and possible directions for improvement.
TranslationYou are a professional {source language}-to-{target language} translator specializing in {domain} translation. Please translate the following content into {target language}. Requirements: 1) Maintain accuracy of professional terminology; 2) Conform to the expression habits of {target language}; 3) Style: {formal/colloquial}.
Meeting MinutesPlease compile meeting minutes based on the following meeting notes, including: 1) Meeting time, location, and attendees; 2) Main topics discussed; 3) Resolutions made; 4) Action items and responsible persons. Please present it in concise and clear language.
Resume OptimizationYou are a senior HR consultant. Please help me optimize this resume description to make it more professional and persuasive. Please rewrite it using the "verb + achievement" format, quantify work achievements, use industry keywords, and highlight personal contributions.
Learning PlanI want to learn {knowledge/skill}. My current foundation is {foundation description}, my goal is {specific goal}, and my available time is {time schedule}. Please help me create a {duration} learning plan, listing learning content, recommended resources, and assessment methods by stage.
BrainstormingI'd like to brainstorm on {topic/problem}. Please help me come up with {number} creative ideas. Requirements: 1) Go beyond conventional thinking; 2) Consider feasibility; 3) Each idea should explain the core concept and possible implementation approach in one sentence.
TroubleshootingI encountered a problem: {problem description}. I have tried {methods tried}, but none of them worked. Please help me analyze possible causes, list them from highest to lowest likelihood, and provide corresponding troubleshooting steps and solutions.
Content rewritingPlease help me rewrite the following content. The target readers are {audience}, the style requirement is {style description}, and the word count is {word count requirement}. Please retain the core information, but express it in a more {plain/professional/concise/detailed} way.

These templates can be flexibly adjusted according to specific situations.

The key is:Break down vague requirements into specific elements and fill them into the template one by one.。


Example of calling AI with code.

Besides entering prompts in the chat interface, you can also call the AI API through code.

Let's demonstrate with Python:

Example

# ============================================
# Use Python to call the AI API to send prompts
# This example shows how to structure your prompt
# ============================================

import json
from typing import Dict, Optional


class PromptBuilder:
    """Prompt builder to help you organize prompts structurally"""

    def __init__(self):
        self.role = None          # Role setting
        self.task = None          # Task description
        self.context = None       # Background information
        self.format = None        # Output format
        self.examples = []        # Example
        self.constraints = []     # Constraints

    def set_role(self, role: str) -> "PromptBuilder":
        """Set the role of the AI"""
        self.role = role
        return self

    def set_task(self, task: str) -> "PromptBuilder":
        """Set the task"""
        self.task = task
        return self

    def set_context(self, context: str) -> "PromptBuilder":
        """Set background information"""
        self.context = context
        return self

    def set_format(self, format_spec: str) -> "PromptBuilder":
        """Set output format"""
        self.format = format_spec
        return self

    def add_example(self, input_example: str, output_example: str) -> "PromptBuilder":
        """Add examples"""
        self.examples.append({"input": input_example, "output": output_example})
        return self

    def add_constraint(self, constraint: str) -> "PromptBuilder":
        """Add constraints"""
        self.constraints.append(constraint)
        return self

    def build(self) -> str:
        """Build the final prompt"""
        parts = []

        if self.role:
            parts.append(f"Role: {self.role}")

        if self.context:
            parts.append(f"Background: {self.context}")

        if self.task:
            parts.append(f"Task: {self.task}")

        if self.examples:
            parts.append("Examples:")
            for i, example in enumerate(self.examples, 1):
                parts.append(f" Input {i}: {example['input']}")
                parts.append(f" Output {i}: {example['output']}")

        if self.format:
            parts.append(f"Output format: {self.format}")

        if self.constraints:
            parts.append("Constraints:")
            for constraint in self.constraints:
                parts.append(f"  - {constraint}")

        return "\n".join(parts)


def simulate_ai_call(prompt: str, api_key: Optional[str] = None) -> Dict:
    """
Simulate AI API call (replace with real API call in actual projects)
This only demonstrates how to use structured prompts
    """

    print("=" * 60)
    print("Prompt sent to AI:")
    print("-" * 60)
    print(prompt)
    print("=" * 60)

    # This is for demonstration only; in actual projects, a real API will be called
    # For example: OpenAI API, Anthropic API, etc.

    return {
        "status": "success",
        "prompt_sent": prompt,
        "message": "This is a simulated response from AI (will be replaced with real API response in actual use)",
        "tips": In actual example projects, configure your API Key and call the real API
    }


# ============================================
# Usage Example 1: Writing an Email
# ============================================

print("\n【Example 1: Writing an Email】)

prompt1 = (PromptBuilder()
           .set_role(You are a professional business writing assistant, skilled in English email writing.)
           .set_context(I am the marketing manager at example and need to write a follow-up email to a client.)
           .set_task(Write an email to ask the client for feedback on our product proposal and schedule a meeting next week.)
           .set_format(Email format, including: subject, salutation, body, sign-off.)
           .add_constraint(Friendly but professional tone.)
           .add_constraint(No more than 200 words.)
           .build())

result1 = simulate_ai_call(prompt1)
print(fAPI status: {result1['status']})


# ============================================
# Usage Example 2: Code Optimization
# ============================================

print("\n【Example 2: Code Optimization】)

prompt2 = (PromptBuilder()
           .set_role(You are an experienced senior Python engineer, skilled in code review.)
           .set_task(Optimize the code below to make it more efficient and more readable.)
           .set_context(This is a piece of code for processing student grade data; the running speed is a bit slow.)
           .set_format(Output the optimized code and explain the reasons for changes in comments.)
           .add_constraint(Keep the original functionality unchanged.)
           .add_constraint(Compatible with Python 3.8+)
           .build())

result2 = simulate_ai_call(prompt2)
print(fAPI status: {result2['status']})

Run this code and you will see how structured prompts are constructed.

In actual projects, you need to replace it with real API calls (such as OpenAI, Anthropic, or other vendors' APIs).

Other Extensions