0:00
/
0:00

Prompt Engineering 101

How you ask the AI is just as important as what it knows (+ FREE & Discount access to my video courses)

You can have the most powerful AI, but if you don’t know how to talk to it, you won’t get the results you need.

This is where prompt engineering comes in — it’s the art and science of crafting effective prompts.

Common Prompting Pitfalls to Dodge

Be wary of:

  • Vague Prompts: “Make it secure: sanitize user input” is a good start, but it’s still vague. Secure against what? What kind of sanitization? For which language/framework?

  • Missing Context: If the AI doesn’t know what the rest of your application looks like, how can it give you perfectly fitting code?

  • Unclear Requirements: If you don’t fully understand what you need, the AI definitely won’t.

TekForge is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.

Basic Prompting Techniques

These are fundamental, and you should make them a habit:

  1. Be Specific & Clear: Don’t just say “write a function.” Specify the programming language, framework (and version!), and any specific requirements. Example:

Example of a poor vs. clear Prompt
Example of a poor vs. clear Prompt

2. Provide Context: Include relevant details about your project and existing architecture. The more context the AI has, the better its output. Example:

Example of a Prompt that provides context
Example of a Prompt that provides context

3. Ask Direct Questions / Be Explicit: Clearly state what you need the AI to do. Don’t make it guess. Example:

Example of a explicit Prompt
Example of a explicit Prompt

4. Specify Format: If you need the output in a particular format (e.g., JSON, a specific class structure), ask for it. Example:

Example of a Prompt that specifies the needed format
Example of a Prompt that specifies the needed format

Advanced Prompting Techniques

Once you’ve mastered the basics, you can explore more advanced strategies:

  1. Few-shot Prompting: Provide multiple examples of what you want. This helps the AI understand the desired pattern or style. Example:

Example of Few-shot Prompting
Example of Few-shot Prompting

2. Chain of Thought (CoT): For complex tasks, guide the AI by breaking the problem down into logical steps. Ask it to “think step by step.” Example:

Example of Chain of Thought (CoT) Prompting Technique
Example of Chain of Thought (CoT) Prompting Technique

3. Contextual Priming: Provide relevant context or information before you ask for the main task. This “warms up” the AI with the right background. Example:

Example of Contextual Priming Prompting Technique
Example of Contextual Priming Prompting Technique

4. Self-Consistency: This is a neat trick. You ask the AI to generate multiple solutions to the same problem (perhaps with slightly different phrasings of the prompt or by adjusting parameters like “temperature” if the tool allows). Then, you look for the common elements or the majority consensus in the responses. This helps identify the most reliable solution by comparing different implementations.

Self-Consistency Prompting Technique
Self-Consistency Prompting Technique

Example:

Example of a Self-Consistency Prompting Technique
Example of a Self-Consistency Prompting Technique

It’s particularly useful when:

  • You’re dealing with complex tasks,

  • working with models that might produce inconsistent results,

  • You simply need higher confidence in the generated code,

  • Or you want to learn and discover different alternative solutions.

5. Turn the Tables: Make the AI Ask YOU

You know what you want the AI to whip up, but you’re a bit fuzzy on all the super-specific details and context it might need?

No worries, here’s a little trick for your advanced prompting: just slap this golden phrase onto the end of your prompt:

“Don’t make assumptions, ask me questions.”

Et voilà! Instead of your AI buddy taking a wild guess — and potentially building you a digital skyscraper when you just wanted a nice birdhouse, it’ll pause, and ask you for the vital tidbits it’s missing.

This simple addition can transform a monologue into a dialogue, coaxing the AI to work with you to clarify ambiguities. This way, you guide it to a much more accurate and tailored result, especially when you’re wading into complex coding challenges or topics where you’re not the seasoned guru (yet!).

Read more

Master Prompt Engineering
Master Prompt Engineering (picture by author)

Further Reading and Viewing


🎁 Special Gift for You

I’ve got a couple of great offers to help you go even deeper. FREE & Discount access to my video courses - available for a limited time, so don’t wait too long!

Until next time—stay curious and keep learning!

Best,

Rakia


Want more?

💡 🧠 I share content about engineering, technology, and leadership for a community of smart, curious people. For more insights and tech updates, join my newsletter and subscribe to my YouTube channel.

Discussion about this video

User's avatar