🧠Writing Better Prompts with GPT-: A Guide from a Developer Who Learned the Hard Way

Tanya KansalTanya Kansal
5 min read

As a software developer working with AI systems over the past few years, I’ve found one truth that keeps resurfacing: The way you ask is just as important as what you ask for.

Recently, I revisited the official OpenAI Cookbook’s GPT-4.1 Prompting Guide, and I have to say — it’s a goldmine of practical advice.

If you’ve ever scratched your head wondering why GPT’s response wasn’t quite what you expected, this one’s for you.

🔍Why Prompting Matters

Prompting is like giving instructions to a really smart intern. If you’re vague or disorganized, the outcome will reflect that. If you’re clear, concise, and intentional — magic happens.

Over time, I’ve realized that not all prompts are created equal. Depending on what you’re trying to do, there are different types of prompting you can use :-

Prompting TechniqueReal-Time Example
Zero-Shot🧾 “Translate this sentence into French: ‘The weather is nice today.” 🔹Straightforward, no example needed.
Few-Shot🧾 “Input: ‘I’m tired’ → Output: ‘I feel exhausted.’Input: ‘I’m stressed’ → Output: ‘I feel overwhelmed. 🔹 GPT learns the tone/style from examples.
Chain-of-Thought🧾 “Explain step-by-step if 153 is an Armstrong number.” 🔹 GPT calculates and explains logic before concluding.
Self-Consistency🧾 Run the same math word problem 5 times, then take the most common answer. 🔹 Used in exams or when factual accuracy matters.
Instruction-Based🧾 “Summarize this blog in 3 bullet points using plain English.” 🔹 Direct, fast, efficient.
Persona-Based🧾 “You are a friendly fitness coach. Motivate me to work out after a long day.” 🔹 Chatbots, UX, marketing tone control.
Contextual Prompting🧾 User: ‘What are the best tools for SEO?’ Follow-up: ‘Which ones are free?’ 🔹 GPT remembers the context of the earlier message.
Multi-Model Chaining🧾 Step 1: Use GPT to extract invoice fields → Step 2: Pass to a finance model to classify expense type → Step 3: Store in database. 🔹 Great for apps with multi-stage processing.

Let me walk you through 7 key takeaways that have drastically improved how I work with Prompting, whether it’s for coding, content, or brainstorming.

1️⃣ Be Clear and Specific

🔧 Real-life scenario: You’re working on product documentation and need help writing feature summaries.

Vague Prompt:
“Tell me about this product feature.”

Clear Prompt:
“Write a two-sentence summary for our ‘Live Chat Support’ feature, emphasizing its 24/7 availability and real-time human interaction.”

🎯 Why it works: The model knows exactly what to emphasize and how long the output should be.

2️⃣ Structure is Your Friend

🔧 Real-life scenario: You’re writing a blog comparing three web frameworks.

Vague Prompt:
“Compare React, Angular, and Vue.”

Clear Prompt:
“List the pros and cons of React, Angular, and Vue in bullet points under each framework. Focus on learning curve, community support, and performance.”

🎯 Why it works: Structured prompt = structured answer = less editing later.

3️⃣ Always Provide Context

🔧Real-life scenario: You’re helping a friend polish their resume.

Prompt:
“You are an HR manager at a tech startup. Rewrite this resume bullet to make it sound more results-driven: ‘Managed social media posts for brand awareness.’”

🎯 Why it works*:* GPT knows its role, the context, and the tone to use.

4️⃣ Use Examples (Few-shot Prompting)

Don’t just say what you want — show it.

Input: The app keeps freezing. ``Output: The user is experiencing frequent app crashes.

Input: It's super slow to load anything. ``Output: The user reports slow performance during app usage.

🎯 Why it works*:* GPT mimics your input-output pattern beautifully.

5️⃣ Ask for Structured Output

🔧 Real-life scenario: You're building an app that stores event data for a calendar.

Prompt:
“Extract and return the following details from this text as a JSON: eventName, date, time, and location.
Text: ‘Team Sync Meeting is scheduled for July 5th at 3:00 PM in Conference Room B.’”

🎯 Why it works: The structured format (JSON) is immediately usable by your backend system to populate calendar events or database entries.

6️⃣ Encourage “Thinking” with Chain-of-Thought

🔧 Real-life scenario: You're building a web scraper in Python, and it crashes when a certain field is missing.

Prompt:
"I'm debugging this Python function that fails when the price field is missing from the HTML.
Please:

1. Explain what each line is doing.

2.Identify what could be going wrong when price is missing.

3.Suggest how to make it more robust.

from bs4 import BeautifulSoup

def extract_price(html):
    soup = BeautifulSoup(html, 'html.parser')
    price = soup.find('span', {'class': 'price'}).text
    return float(price.replace('$', ''))

7️⃣ Iterate and Refine

🔧 Real-life scenario: You’re generating user onboarding emails.

  • Step 1:
    “Write a welcome email for a new user.”
    (Too generic)

  • Step 2:
    “Write a friendly welcome email for a new user of our budgeting app. Include a call to action to set their first goal and link to the mobile app download.”
    (Much better)

🎯 Why it works*:* Iteration improves clarity and relevance every time.

✨ My Go-To Prompt Formula

Here’s a format I now use regularly:

“You are [role]. Your task is to [objective]. Output should follow this format: [bullet list/table/JSON/etc.]. Here is an example: [if needed]. Now, do the same for [your input].”

Simple. Clear. Powerful.

💬 Final Thoughts

If you're using GPT in your day-to-day — whether as a developer, product person, content creator, or founder — you’re already prompt engineering, whether you realize it or not.

The better you get at it, the more leverage you unlock.

If this helped, or if you have your own favorite prompt tips — I’d love to hear from you! Let's share knowledge and get better together. 🚀

0
Subscribe to my newsletter

Read articles from Tanya Kansal directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Tanya Kansal
Tanya Kansal