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.
Basic Prompting Techniques
These are fundamental, and you should make them a habit:
Be Specific & Clear: Don’t just say “write a function.” Specify the programming language, framework (and version!), and any specific requirements. Example:
2. Provide Context: Include relevant details about your project and existing architecture. The more context the AI has, the better its output. Example:
3. Ask Direct Questions / Be Explicit: Clearly state what you need the AI to do. Don’t make it guess. Example:
4. Specify Format: If you need the output in a particular format (e.g., JSON, a specific class structure), ask for it. Example:
Advanced Prompting Techniques
Once you’ve mastered the basics, you can explore more advanced strategies:
Few-shot Prompting: Provide multiple examples of what you want. This helps the AI understand the desired pattern or style. Example:
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:
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:
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.
Example:
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!).
Further Reading and Viewing
🎥 Agentic AI Coding, Next-Gen Models & Prompt Engineering Explained
📖 An Inside Look at the Best AI Coding Models: Claude Opus 4, Gemini 2.5, OpenAI’s o-Series
🎥 Spring Boot AI Chat App: Integrate OpenAI, Gemini, and DeepSeek APIs
📖 Spring Boot AI Chat App: Integrate OpenAI, Gemini, and DeepSeek APIs
🎁 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!
🔥 Modern Software Engineering: Architecture, Cloud & Security
Discount coupon RAKIA_SOFT_ENG_2🔐 Secure Software Development: Principles, Design, and Gen-AI
FREE coupon RAKIA_SECURE_APPS_2FREE coupon RAKIA_API_DESIGN_2
🐳 Getting Started with Docker & Kubernetes + Hands-On
FREE coupon RAKIA_DOCKER_K8S_2⚡ Master Web Performance: From Novice to Expert
FREE coupon RAKIA_WEB_PERF_2
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.
Share this post