Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 

Repository files navigation

🎯 Prompt Engineering Playbook β€” From Beginner to Advanced

A complete, practical, daily-reusable system for getting dramatically better results from AI β€” built for developers, learners, and anyone who wants to think like a prompt engineer instead of a casual user.

This isn't a theory document. Every technique here comes with a copy-paste-ready prompt and a real developer use case. Bookmark it, reuse it, and refer back to it daily.


πŸ“‹ Table of Contents

  1. What is Prompt Engineering?
  2. Core Principles
  3. Complete List of Techniques
  4. Technique Deep Dive
  5. Daily Usage Playbook
  6. Developer Use Cases
  7. Prompt Templates Library
  8. Anti-Patterns β€” What NOT to Do
  9. Pro Tips & Advanced Hacks
  10. Reusable Personal Prompt System
  11. πŸ”₯ Top 10 Prompt Engineering Habits
  12. Conclusion

1. What is Prompt Engineering?

Prompt engineering is the practice of designing inputs to AI systems that reliably produce the outputs you want. It's not about "magic words" β€” it's about clear communication, structured thinking, and iterative refinement.

The quality of what you get out of an AI is almost entirely determined by the quality of what you put in. Two people can ask an AI the "same question" and get wildly different results because one person gave context, structure, and constraints β€” and the other didn't.

πŸ’‘ Key mindset shift: Stop thinking of AI as a search engine you ask questions to. Start thinking of it as a highly capable collaborator you need to brief properly.


2. Core Principles

These five principles underlie every technique in this playbook:

Principle Meaning
Clarity Be specific about exactly what you want β€” vague input produces vague output
Context Give the AI the background it needs β€” audience, purpose, constraints, prior attempts
Structure Organize complex requests into clear parts rather than one dense paragraph
Iteration Treat your first prompt as a draft β€” refine based on what comes back
Verification Never trust output blindly β€” check it, especially for facts, code, and numbers

3. Complete List of Techniques

# Technique One-Line Summary
1 Role-Based Prompting Assign the AI a specific persona/expertise
2 Zero-Shot Prompting Ask directly with no examples
3 Few-Shot Prompting Provide examples to guide the output format/style
4 Chain-of-Thought Prompting Ask the AI to reason step-by-step before answering
5 Step-by-Step Reasoning Explicitly number the reasoning stages you want
6 Instruction Tuning (Prompt) Give precise, imperative instructions instead of questions
7 Constraint-Based Prompting Set explicit boundaries (length, format, tone, exclusions)
8 Output Formatting Control Dictate exact structure of the response (JSON, table, bullets)
9 Context Injection Feed relevant background data directly into the prompt
10 Iterative Prompting Refine through multiple rounds of feedback
11 Self-Reflection Prompting Ask the AI to critique its own answer before finalizing
12 Multi-Step Prompting Break one big task into sequential prompts
13 Decomposition Split a complex problem into smaller sub-problems explicitly
14 Socratic Prompting Ask the AI to question assumptions or explore via guided questions
15 Prompt Chaining Feed one prompt's output as the next prompt's input
16 Meta Prompting Ask the AI to help you write a better prompt
17 Reverse Prompting Give the AI the answer/output and ask it to infer the ideal prompt
18 Evaluation Prompting Ask the AI to score/evaluate a piece of content against criteria
19 Critique & Refine Ask for a critique pass, then a revision pass
20 Tree-of-Thought Explore multiple reasoning branches before converging on an answer
21 Tool Usage Prompting Instruct the AI on when/how to use available tools
22 System Prompt Design Set persistent behavior rules at the start of a session

4. Technique Deep Dive


πŸ”Ή 1. Role-Based Prompting

What it is: Assigning the AI a specific persona, expertise level, or professional identity before giving it a task.

When to use: Whenever you want domain-appropriate tone, depth, or vocabulary β€” especially for code review, writing, or specialized advice.

Why it works: Framing shifts the AI's response patterns toward the conventions, priorities, and depth typical of that role, rather than a generic answer.

Example prompt:

Act as a senior backend engineer with 10 years of experience in distributed systems.
Review this API design and point out scalability risks I might have missed.

[paste API design here]

Real-world use case: Getting a code review that focuses on production concerns (race conditions, N+1 queries, scaling) instead of surface-level style comments.


πŸ”Ή 2. Zero-Shot Prompting

What it is: Asking the AI to perform a task directly, with no examples provided β€” relying entirely on its pretrained knowledge.

When to use: Simple, well-defined tasks where the AI likely already understands the format you want (e.g., "translate this to Spanish").

Why it works: Modern LLMs are trained on enormous amounts of task-diverse data, so common tasks often don't need examples to get a correct structure.

Example prompt:

Convert this SQL query to use a JOIN instead of a subquery:

SELECT * FROM orders WHERE customer_id IN (SELECT id FROM customers WHERE country = 'India');

Real-world use case: Quick, one-off code transformations or explanations where you're confident about the expected format.


πŸ”Ή 3. Few-Shot Prompting

What it is: Providing 1–3 examples of input/output pairs before your actual request, to guide the AI toward a specific style or structure.

When to use: When output format matters a lot, or the task is ambiguous/unusual enough that zero-shot results are inconsistent.

Why it works: Examples anchor the AI's output pattern far more reliably than description alone β€” it's easier to show than to explain.

Example prompt:

Classify the sentiment of each review as positive, negative, or neutral.

Review: "The product broke after two days." β†’ negative
Review: "Best purchase I've made this year!" β†’ positive
Review: "It arrived on time." β†’ neutral

Review: "Customer support never responded to my ticket." β†’

Real-world use case: Building consistent, structured outputs for data labeling, log classification, or generating repetitive content in a fixed style (commit messages, test case names).


πŸ”Ή 4. Chain-of-Thought Prompting

What it is: Explicitly instructing the AI to reason through a problem step-by-step before producing a final answer.

When to use: Math, logic, multi-step reasoning, debugging, or any task where jumping straight to an answer risks skipped steps or errors.

Why it works: Forcing intermediate reasoning steps reduces careless errors and makes the AI's logic inspectable β€” you can catch a wrong assumption before it reaches the final answer.

Example prompt:

Think step-by-step before answering.

A user reports that our API returns a 500 error only when uploading files larger than 10MB.
Walk through the possible causes in order of likelihood, then suggest the most probable root cause.

Real-world use case: Debugging production issues where the cause isn't obvious β€” the reasoning trail itself often reveals the fix.


πŸ”Ή 5. Step-by-Step Reasoning

What it is: A stricter variant of chain-of-thought where you explicitly number the exact stages of reasoning you want covered.

When to use: Complex tasks where you know the shape of the reasoning process and want to enforce it (avoiding the AI skipping a stage).

Why it works: Numbered structure acts as a checklist β€” the AI is far less likely to skip a step when each one is explicitly named.

Example prompt:

Design a database schema for a ticket booking system. Follow these steps in order:
1. List all entities involved
2. Define relationships between entities
3. Identify primary/foreign keys
4. Note any denormalization needed for performance
5. Output the final schema as SQL CREATE TABLE statements

Real-world use case: System design tasks, architecture reviews, or any process with a known methodology you want followed precisely.


πŸ”Ή 6. Instruction Tuning (Prompt-Level)

What it is: Phrasing your request as a precise, imperative instruction rather than a vague question.

When to use: Always β€” this is a foundational habit, not a special-occasion technique.

Why it works: Imperative instructions ("Write...", "Refactor...", "List...") remove ambiguity about what action is expected, compared to open questions ("What do you think about...").

Example prompt:

Refactor this function to reduce cyclomatic complexity below 5. Keep the function signature unchanged.
Return only the refactored code, no explanation.

[paste function]

Real-world use case: Any time you want a specific deliverable rather than open-ended discussion.


πŸ”Ή 7. Constraint-Based Prompting

What it is: Explicitly stating boundaries β€” length, tone, format, things to avoid β€” as part of the prompt.

When to use: Whenever the "default" AI output tends to be too long, too generic, or stylistically off from what you need.

Why it works: Constraints narrow the solution space, preventing the AI from defaulting to a generic, unfocused answer.

Example prompt:

Explain what a race condition is in under 100 words, using a single concrete coding example.
Do not use analogies. Assume the reader already knows what threads are.

Real-world use case: Writing documentation, README sections, or interview answers where length and precision both matter.


πŸ”Ή 8. Output Formatting Control

What it is: Explicitly dictating the exact structure of the response β€” JSON, table, numbered list, code block only, etc.

When to use: Whenever the output needs to be parsed programmatically, or pasted directly into a document/spreadsheet.

Why it works: Without explicit formatting instructions, AI defaults to prose β€” which is harder to reuse than structured data.

Example prompt:

Return the following as a JSON array of objects with keys "name", "endpoint", and "method". No explanation, only the JSON.

List all REST endpoints implied by this user story: "As a user, I want to create, view, update and delete my saved addresses."

Real-world use case: Generating data you'll feed directly into code, a config file, or an automated pipeline.


πŸ”Ή 9. Context Injection

What it is: Feeding relevant background information β€” code, logs, documents, prior conversation β€” directly into the prompt.

When to use: Any task-specific request where the AI can't reasonably be expected to know your specific codebase, data, or situation.

Why it works: AI has no access to your environment by default β€” without injected context, it can only guess or generalize, which is where hallucinations creep in.

Example prompt:

Here is my current database schema:
[paste schema]

Here is the slow query I'm trying to optimize:
[paste query]

Suggest an index strategy specific to this schema and query pattern.

Real-world use case: Debugging, code review, or any task grounded in your actual project rather than generic best practices.


πŸ”Ή 10. Iterative Prompting

What it is: Treating your first prompt as a starting point, then refining based on the AI's response across multiple turns.

When to use: Whenever the first output isn't quite right β€” which is most of the time for non-trivial tasks.

Why it works: Prompting is fundamentally a search process β€” you rarely specify everything perfectly on the first attempt, and refinement converges faster than trying to write the "perfect" prompt upfront.

Example prompt sequence:

Turn 1: "Write a Python function to validate email addresses."
Turn 2: "Good, but also reject addresses with consecutive dots. Show the updated function only."
Turn 3: "Add type hints and a docstring."

Real-world use case: Any real coding or writing task β€” expect 2-4 rounds of refinement as the norm, not a failure state.


πŸ”Ή 11. Self-Reflection Prompting

What it is: Asking the AI to review and critique its own previous answer before finalizing.

When to use: High-stakes outputs (production code, important documents) where a second pass catches errors the first pass missed.

Why it works: Asking the model to re-examine its own output activates a different "mode" of evaluation, similar to how humans catch more mistakes reading their own work aloud.

Example prompt:

Review your previous answer for correctness, edge cases, and security issues.
List any problems you find, then provide a corrected version.

Real-world use case: Security-sensitive code (auth logic, payment handling) where a second self-check meaningfully reduces risk.


πŸ”Ή 12. Multi-Step Prompting

What it is: Deliberately splitting one large task into a sequence of smaller, separate prompts rather than one giant request.

When to use: Complex tasks where cramming everything into one prompt causes the AI to under-deliver on some parts.

Why it works: Each prompt gets focused attention rather than competing for "budget" against other requirements in a single massive prompt.

Example prompt sequence:

Prompt 1: "List the key entities needed for a blogging platform backend."
Prompt 2: "Now design the database schema for these entities."
Prompt 3: "Now write the FastAPI CRUD endpoints for the Post entity."

Real-world use case: Building out a full feature or project where quality matters more than speed of a single response.


πŸ”Ή 13. Decomposition

What it is: Explicitly asking the AI to break a complex problem into named sub-problems before solving any of them.

When to use: Ambiguous, large-scope problems where it's unclear what the actual sub-tasks even are.

Why it works: Naming the sub-problems first prevents the AI (and you) from jumping to a solution that misses a key piece of the puzzle.

Example prompt:

Before writing any code, break down the problem "build a real-time chat application" into
its distinct technical sub-problems (e.g., connection handling, message persistence, etc.).
Do not solve them yet β€” just list and briefly describe each.

Real-world use case: System design interviews and early-stage project planning, where scoping the problem correctly matters more than rushing to code.


πŸ”Ή 14. Socratic Prompting

What it is: Asking the AI to respond with guiding questions rather than direct answers, to deepen your own understanding.

When to use: Learning a new concept, or when you want to strengthen your own reasoning rather than just receive an answer.

Why it works: Being asked questions forces active recall and reasoning, which builds retention far better than passively reading an explanation.

Example prompt:

I'm learning about database indexing. Instead of explaining it directly, ask me a series of
guiding questions that will help me arrive at the concept myself. Wait for my answer before
asking the next question.

Real-world use case: Studying for interviews or exams where genuine understanding matters more than a quick answer.


πŸ”Ή 15. Prompt Chaining

What it is: Structurally feeding the output of one prompt directly as the input to the next prompt, building a pipeline.

When to use: Multi-stage workflows where each stage's output naturally becomes the next stage's input (summarize β†’ translate β†’ format).

Why it works: Each link in the chain is a focused, single-responsibility task β€” the same principle as function decomposition in code.

Example prompt sequence:

Prompt 1: "Summarize this changelog into 3 bullet points." β†’ [output A]
Prompt 2: "Rewrite [output A] as a customer-facing release note in a friendly tone."

Real-world use case: Content pipelines β€” research β†’ outline β†’ draft β†’ polish β€” where each stage benefits from being a separate, focused prompt.


πŸ”Ή 16. Meta Prompting

What it is: Asking the AI to help you design or improve your own prompt, rather than asking it to perform the task directly.

When to use: When you're unsure how to phrase a request for the best results, or want to systematize a recurring prompt.

Why it works: The AI has broad exposure to what makes prompts effective β€” using it as a prompt-design partner shortcuts a lot of trial and error.

Example prompt:

I want to ask an AI to review my Python code for security vulnerabilities.
Write me the ideal prompt to get the most thorough, actionable review possible.

Real-world use case: Building reusable prompt templates (like the ones in this playbook) more efficiently.


πŸ”Ή 17. Reverse Prompting

What it is: Giving the AI a finished output/answer and asking it to infer or reconstruct the prompt that would have produced it.

When to use: Reverse-engineering a good example you've seen, or understanding what prompt structure led to a particular style of output.

Why it works: Working backward from a known-good output surfaces the specific instructions/constraints implicit in that output, which you might not have thought to specify yourself.

Example prompt:

Here is a well-written API documentation page: [paste example]
What prompt do you think would have generated this? Write it out in full.

Real-world use case: Learning to replicate a documentation style, code style, or writing voice you admire from an existing example.


πŸ”Ή 18. Evaluation Prompting

What it is: Asking the AI to score or judge a piece of content against explicit criteria, rather than just generate content.

When to use: Comparing multiple options (two API designs, two pieces of copy) or building automated grading/eval pipelines.

Why it works: Naming explicit criteria forces a structured, comparable judgment rather than a vague "this looks good" response.

Example prompt:

Evaluate this function on a scale of 1-10 for: readability, performance, and error handling.
Give a score and one-sentence justification for each category.

[paste function]

Real-world use case: Code review automation, A/B testing content variants, or building your own prompt evaluation pipelines.


πŸ”Ή 19. Critique & Refine

What it is: A two-pass technique β€” first ask for a critique of existing content, then ask for a revision based on that critique.

When to use: Improving existing work (your own code, writing, or a previous AI draft) rather than generating from scratch.

Why it works: Separating critique from revision produces a more thorough review than asking for both simultaneously, since the AI isn't rushing to fix while still identifying problems.

Example prompt:

Step 1: Critique this README for clarity, structure, and completeness. List specific issues.
Step 2: Now rewrite the README addressing every issue you listed.

[paste README]

Real-world use case: Polishing documentation, resumes, or any deliverable where a fresh critical pass adds real value.


πŸ”Ή 20. Tree-of-Thought

What it is: Asking the AI to explore multiple independent reasoning paths or solutions in parallel, then compare and select the best one.

When to use: Complex, open-ended problems where a single reasoning chain risks tunnel vision toward a suboptimal solution.

Why it works: Generating multiple candidate approaches before committing avoids anchoring on the first idea, similar to brainstorming multiple designs before picking one.

Example prompt:

Propose three different architectural approaches for a URL shortener (e.g., different ID generation
strategies). For each, briefly note pros/cons. Then recommend which one you'd choose and why.

Real-world use case: System design decisions where the "obvious" first approach may not be the best one β€” architecture reviews, technology selection.


πŸ”Ή 21. Tool Usage Prompting

What it is: Explicitly instructing the AI on when and how to use available tools (web search, code execution, file access) rather than answering from memory alone.

When to use: Tasks requiring current information, precise calculation, or verification against real data β€” anything where "from memory" risks being outdated or wrong.

Why it works: LLMs have a training cutoff and can be confidently wrong on recent or highly specific facts; directing tool use grounds the answer in verified, current information.

Example prompt:

Search for the current stable version of the FastAPI library before answering.
Then tell me which version I should pin in my requirements.txt for a new project today.

Real-world use case: Checking current library versions, verifying facts before including them in documentation, or any task where "as of my training data" isn't good enough.


πŸ”Ή 22. System Prompt Design

What it is: Setting persistent behavior rules, persona, and constraints once at the start of a session, rather than repeating them in every message.

When to use: Any extended session where you want consistent tone, format, or behavior across many turns (a coding assistant, a writing partner).

Why it works: A well-designed system prompt establishes a stable "operating mode" for the entire conversation, reducing the need to re-specify constraints every single message.

Example prompt:

System: You are a senior code reviewer. For every piece of code I share, respond in this format:
1. Overall assessment (1 sentence)
2. Critical issues (bullet list)
3. Suggested fixes (code block)
Never add unrelated commentary. Never apologize.

Real-world use case: Setting up a consistent "AI code review assistant" persona you reuse across an entire project or work session.


5. Daily Usage Playbook

This is how to actually use prompt engineering every day β€” not as a one-off skill, but as a repeated workflow.

πŸŒ… Morning Workflow (Learning / Planning)

1. "Give me a 5-bullet summary of [topic] I should know before diving deeper today."
2. "Ask me 3 questions to test whether I actually understood yesterday's learning on [topic]." (Socratic)
3. "Based on my goals [describe them], what should today's top 3 priorities be?"

πŸ’» Coding Workflow (Debugging, API Design, SQL, System Design)

Debugging:
"Here's the error: [paste]. Here's the relevant code: [paste].
Think step-by-step about possible causes, ranked by likelihood." (Chain-of-Thought)

API Design:
"Act as a senior backend engineer. Design REST endpoints for [feature].
Follow REST conventions. Output as a table: Method | Endpoint | Description." (Role + Format Control)

SQL Optimization:
"Here's my schema: [paste]. Here's my slow query: [paste].
Suggest indexes and rewrite the query for better performance." (Context Injection)

System Design:
"Break down 'design a notification system' into its core sub-problems before solving any of them." (Decomposition)

🧩 Problem-Solving Workflow

1. "Decompose this problem into smaller sub-problems: [describe problem]"
2. "Propose 2-3 different approaches to sub-problem #1, with pros/cons for each." (Tree-of-Thought)
3. "Critique my proposed solution: [paste]. What am I missing?" (Critique & Refine)

🎀 Interview Preparation Workflow

1. "Ask me a system design interview question at the [company type] level. Wait for my answer before giving feedback."
2. "Here's my answer: [paste]. Evaluate it on: requirements clarity, architecture soundness, and trade-off discussion. Score each 1-10." (Evaluation Prompting)
3. "Now show me how a strong candidate would have answered this differently."

⚑ Productivity Automation

1. "Summarize this email thread into 3 action items with owners." (Format Control)
2. "Draft a reply declining this meeting politely, citing a scheduling conflict, in 2 sentences." (Constraint-Based)
3. "Turn these rough notes into a structured project plan with milestones." (Structure)

6. Developer Use Cases

Use Case Best Technique(s) Example Prompt Snippet
Debugging a stack trace Chain-of-Thought + Context Injection "Here's the traceback and relevant code... walk through likely causes step-by-step"
Code review Role-Based + Evaluation Prompting "Act as a senior reviewer. Score this PR on readability, security, performance"
Writing unit tests Few-Shot + Format Control "Here are 2 example tests... write similar tests for this new function"
API/schema design Decomposition + Step-by-Step "Break this feature into entities, then design the schema in steps"
Refactoring legacy code Constraint-Based + Critique & Refine "Refactor without changing the public interface. Critique your own refactor after."
Learning a new framework Socratic + Iterative "Ask me guiding questions about FastAPI dependency injection instead of explaining directly"
Writing documentation Role-Based + Format Control "Act as a technical writer. Output this as a GitHub-ready README section"
Architecture decisions Tree-of-Thought "Propose 3 approaches to this caching problem, with trade-offs for each"

7. Prompt Templates Library

Copy-paste ready. Fill in the brackets.

πŸ§‘β€πŸ’» "Act as Senior Developer..."

Act as a senior [language/framework] developer with expertise in [domain].
Review/write/refactor the following: [paste code or describe task]
Focus on: [correctness | performance | security | readability]
Output format: [code block only | code + explanation | bullet list of issues]

πŸͺœ "Explain Step-by-Step..."

Explain [concept] step-by-step, assuming I already know [prerequisite knowledge].
Use one concrete example. Keep it under [word/line limit].

⚑ "Optimize This..."

Optimize the following [code/query/algorithm] for [performance | readability | memory usage].
Constraints: do not change [X]. Explain what you changed and why, in bullet points.

[paste code/query]

πŸ› "Debug This..."

I'm getting this error: [paste error]
Here is the relevant code: [paste code]
Here is what I've already tried: [list attempts]
Think step-by-step about the most likely causes, ranked by probability, then suggest a fix.

πŸ—οΈ "Design System For..."

Design a system for [feature/product], following these steps:
1. Clarify functional and non-functional requirements
2. List core components
3. Propose high-level architecture
4. Identify the 1-2 hardest scaling challenges and how to address them
Assume [scale assumption, e.g., "10M daily active users"] unless I specify otherwise.

πŸ“ "Summarize & Extract..."

Summarize the following into [N] bullet points, focused only on [specific angle].
Then list any action items as a separate numbered list.

[paste content]

πŸ” "Critique My Work..."

Critique the following [document/code/design] for [criteria].
List specific issues with reasoning. Do not rewrite it yet β€” critique only.

[paste content]

8. Anti-Patterns β€” What NOT to Do

❌ Anti-Pattern Why It Fails βœ… Do This Instead
Vague requests ("make this better") AI has no criteria to optimize toward Specify exactly what "better" means (faster, cleaner, shorter)
No context ("fix my code" with no code pasted) AI has zero information to work with Always paste the relevant code/error/data
One giant prompt for a complex task Competing requirements get under-served Decompose into multiple focused prompts
Blindly trusting output AI can be confidently wrong (hallucination) Always verify facts, especially numbers and citations
Never iterating First response is rarely perfect for non-trivial tasks Treat the first response as a draft, refine 2-3 times
Asking leading questions Biases the AI toward confirming what you already believe Ask neutrally, then evaluate the answer critically
Ignoring format needs Get prose when you needed structured data Explicitly specify output format (JSON, table, etc.)
Repeating full context every message Wastes tokens and clutters conversation Use a system prompt to set persistent rules once
Not specifying constraints Get overly long or off-tone responses State length, tone, and exclusions upfront
Treating AI as infallible for math/logic LLMs can make arithmetic/logic errors Ask for step-by-step reasoning, verify the final calculation yourself

9. Pro Tips & Advanced Hacks

  • Combine techniques β€” Role-Based + Chain-of-Thought + Format Control in a single prompt is often more powerful than any one alone:

    Act as a senior SRE. Think step-by-step about why this service is timing out under load.
    Output your answer as: Root Cause | Evidence | Fix β€” in a table.
    
  • Use "negative constraints" deliberately β€” telling the AI what NOT to do is often more effective than only saying what to do:

    Do not use external libraries. Do not change the function signature. Do not add comments.
    
  • Ask for confidence levels β€” especially for factual claims:

    For each claim, note your confidence level (high/medium/low) and whether it should be verified.
    
  • Use "explain your reasoning" as a debugging tool for the AI itself β€” if an answer seems off, ask why it arrived there; this often surfaces a wrong assumption you can then correct.

  • Batch similar tasks into one prompt when they share context β€” more efficient than N separate prompts for N similar small tasks.

  • Save your best prompts β€” build a personal prompt library (see Section 10) instead of re-inventing effective prompts from scratch each time.

  • Use meta-prompting to debug your own prompts β€” if you're not getting good results, ask the AI: "Why might this prompt be producing inconsistent results? How would you improve it?"


10. Reusable Personal Prompt System

A 3-layer system to construct high-quality prompts consistently, every time.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  LAYER 1: BASE PROMPT TEMPLATE                β”‚
β”‚  β†’ What do I want done? (the core task)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  LAYER 2: ENHANCEMENT LAYER                   β”‚
β”‚  β†’ Add role, constraints, context             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  LAYER 3: OUTPUT CONTROL LAYER                β”‚
β”‚  β†’ Specify exact format of the response       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Layer 1 β€” Base Prompt Template

[Action verb] + [specific task] + [subject matter]

Example: "Refactor the following Python function to be more readable."

Layer 2 β€” Enhancement Layer (stack onto Layer 1)

Role:        "Act as a [role]..."
Context:     "Given that [relevant background]..."
Constraints: "Do not [X]. Must include [Y]. Keep under [length]."

Layer 3 β€” Output Control Layer (stack onto Layers 1+2)

Format:  "Output as [table | JSON | bullet list | code block only]"
Tone:    "Use a [professional | casual | technical] tone"
Length:  "Keep the response under [N words/lines]"

🧩 Full Combined Example

[Layer 1] Refactor the following Python function to reduce complexity.

[Layer 2] Act as a senior Python developer. Given that this function is part of a
production payment processing service, prioritize safety and readability over cleverness.
Do not change the function signature. Must maintain existing error handling behavior.

[Layer 3] Output only the refactored code in a single code block, followed by a
3-bullet summary of what changed and why. Keep the summary under 50 words.

[paste function]

πŸ’Ύ Save this 3-layer structure as a personal template β€” for any new task, you just fill in the brackets at each layer instead of writing a prompt from scratch.


πŸ”₯ Top 10 Prompt Engineering Habits for Daily Use

  1. Always state the format you want β€” table, JSON, bullets, code-only β€” before you need it
  2. Paste real context β€” actual code, actual errors, actual data β€” never describe vaguely when you can paste directly
  3. Treat the first response as a draft β€” plan for 2-3 rounds of iteration on anything non-trivial
  4. Assign a role when expertise matters β€” "senior X" consistently produces more focused, higher-quality output
  5. Ask for step-by-step reasoning on anything complex β€” debugging, math, architecture decisions
  6. Set constraints explicitly β€” length, tone, exclusions β€” don't leave them to chance
  7. Verify before trusting β€” especially facts, statistics, library versions, and citations
  8. Decompose before you generate β€” break big problems into named sub-problems first
  9. Build and reuse your own template library β€” don't reinvent effective prompts every time
  10. Critique before you accept β€” for important outputs, run a second "critique this" pass before finalizing

12. Conclusion

Prompt engineering isn't about memorizing magic phrases β€” it's about communicating with precision: giving clear context, explicit constraints, structured reasoning requests, and iterating until the output actually meets your bar.

The techniques in this playbook are not mutually exclusive β€” the best prompts often combine 2-3 techniques at once (Role + Chain-of-Thought + Format Control is a particularly powerful combination for developer work).

Use the Daily Usage Playbook (Section 5) as your starting point every morning, lean on the Templates Library (Section 7) when you don't want to write from scratch, and build your own Personal Prompt System (Section 10) as you discover what works best for your specific workflows.

The goal isn't to use AI more β€” it's to communicate with AI better, so that every interaction produces genuinely useful, verified, high-quality results.


⭐ If this playbook improved your prompts, consider starring the repo!

Made with 🎯 by Karthik Boodidha

LinkedIn GitHub Portfolio Kaggle

About

This isn't a theory document. Every technique here comes with a copy-paste-ready prompt and a real developer use case. Bookmark it, reuse it, and refer back to it daily.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors