No history yet

Introduction to Prompt Engineering

What Is a Prompt?

A prompt is simply the instruction you give to an artificial intelligence. Think of it like ordering a coffee. If you just say "Give me coffee," you'll get something, but it might not be what you wanted. If you say, "I'd like a large iced latte with oat milk and one pump of vanilla syrup," you're much more likely to get the drink you're imagining. The same is true for AI.

Prompt engineering is the practice of crafting a prompt for generative AI that produces a quality response.

The AI is incredibly powerful, but it can't read your mind. The quality of the answer you get is directly tied to the quality of the question you ask. This process of carefully crafting your instructions is called prompt engineering. It’s the skill of communicating clearly with an AI to get the most accurate, relevant, and useful results.

Lesson image

Learning a few basic principles can transform the AI from a novelty into a genuinely helpful tool for writing, brainstorming, coding, and more.

Crafting Effective Prompts

A good prompt has a few key ingredients. It’s clear, provides context, and tells the AI what kind of output you want.

First, be specific. Vague prompts lead to generic answers. Instead of asking the AI to "Write about cars," try something much more focused: "Write three paragraphs about the impact of the Ford Model T on American society in the 1920s."

This level of detail guides the AI toward the exact topic you're interested in.

Bad Prompt: Tell me about space. Good Prompt: Explain the concept of a black hole to a 12-year-old, using a simple analogy.

Next, provide all the necessary context. If you want the AI to summarize an article, you have to give it the article. If you're asking it to write an email, tell it who the email is for and what its purpose is. The more background information the AI has, the better it can tailor its response to your needs.

Supplying up-to-date documentation or detailed custom rules turns your prompt into a “mini reference manual,” grounding the AI’s output in your real-world needs.

Finally, define the output format you want. Do you need a bulleted list, a poem, a JSON object, or a table? Just ask for it directly. This saves you the time of having to reformat the AI’s response later.

For example, you could ask: "Compare the key differences between Python and JavaScript for web development. Present the information in a markdown table with columns for 'Feature,' 'Python,' and 'JavaScript.'"

FeaturePythonJavaScript
Primary UseServer-side web development, data scienceClient-side and server-side web development
TypingStrongly typedWeakly typed
Learning CurveGenerally considered easier for beginnersCan be complex due to asynchronous nature

Types of Prompts

Prompts come in many shapes and sizes, depending on the task. While the possibilities are endless, most fall into a few general categories.

Instructional Prompt

other

The most common type of prompt. It gives a direct command to the AI.

Instructional prompts are straightforward and useful for a huge range of tasks, from drafting an email to writing a piece of code.

Lesson image

Another common type is the completion prompt. Here, you provide the beginning of a text and ask the AI to continue it.

Prompt: The sun began to set, casting long shadows across the valley. In the distance, a lone wolf howled. The traveler pulled his cloak tighter and...

AI Completion: ...quickened his pace, his eyes scanning the darkening woods for any sign of movement.

This is great for creative writing, brainstorming, or when you get stuck and need a little help moving forward.

There are also role-playing prompts, where you ask the AI to adopt a specific persona. For example: "You are a skeptical pirate. Explain why I should invest in your treasure-hunting expedition." This can make the interaction more engaging and produce answers in a specific tone or style.

By combining these basic prompt types and principles, you can start to unlock the AI's full potential.

Quiz Questions 1/5

What is the primary goal of prompt engineering?

Quiz Questions 2/5

Which of these prompts best demonstrates the principle of being specific and providing context?

Mastering these fundamentals is the first step in learning how to communicate effectively with AI.