3 Essential AI Prompting Techniques for Coding

Effective communication with AI can significantly boost your coding skills. Here are three essential techniques to fully leverage AI in your software development:


1๏ธโƒฃ๐—•๐—ฒ ๐—ฆ๐—ฝ๐—ฒ๐—ฐ๐—ถ๐—ณ๐—ถ๐—ฐ:

Provide detailed context about your coding problem. The clarity of your prompt directly influences the accuracy of the code you receive.

๐˜Œ๐˜น๐˜ข๐˜ฎ๐˜ฑ๐˜ญ๐˜ฆ: Instead of "Write a sorting function," try "Write a Python function to sort an array of integers using the merge sort algorithm."


2๏ธโƒฃ๐—˜๐—ป๐—ด๐—ฎ๐—ด๐—ฒ ๐—œ๐˜๐—ฒ๐—ฟ๐—ฎ๐˜๐—ถ๐˜ƒ๐—ฒ๐—น๐˜†:

Continuously refine your prompts based on the responses you get. This iterative process enhances results and leads to better outcomes.


3๏ธโƒฃ๐—Ÿ๐—ฒ๐˜ƒ๐—ฒ๐—ฟ๐—ฎ๐—ด๐—ฒ ๐—ฅ๐—ผ๐—น๐—ฒ๐˜€:

๐Ÿ”น ๐˜ผ๐™จ๐™จ๐™ž๐™œ๐™ฃ ๐™– ๐™Ž๐™ฅ๐™š๐™˜๐™ž๐™›๐™ž๐™˜ ๐™๐™ค๐™ก๐™š: Tailor the AI's output by assigning it a specific role. ๐˜Œ๐˜น๐˜ข๐˜ฎ๐˜ฑ๐˜ญ๐˜ฆ: "As my Python mentor, please write a function to calculate a factorial and explain how it works."

๐Ÿ”น๐™€๐™ญ๐™ฅ๐™š๐™ง๐™ฉ ๐™๐™ค๐™ก๐™š ๐™‹๐™ก๐™–๐™ฎ: Have LLM act as an expert to critic and enhance your work. ๐˜Œ๐˜น๐˜ข๐˜ฎ๐˜ฑ๐˜ญ๐˜ฆ: "As an NLP expert, suggest improvements to this text summarization feature to enhance its functionality and accuracy."

๐Ÿ”น๐™ˆ๐™ช๐™ก๐™ฉ๐™ž๐™ฅ๐™ก๐™š ๐™๐™ค๐™ก๐™š ๐™‹๐™ก๐™–๐™ฎ: For comprehensive feedback, assign multiple roles. ๐˜Œ๐˜น๐˜ข๐˜ฎ๐˜ฑ๐˜ญ๐˜ฆ: "As both a software architect and a security expert, evaluate this Python script for a web application and suggest architectural improvements and security enhancements."


To deep dive into your coding skills with AI, I recommend the Coursera course - Generative AI for Software Development.