AI_FOR_CYNICAL_DEVS
← Back to The Grind
Module 19 // 15 minutes // Reference

Prompt Templates That Actually Work

I spent 45 minutes crafting the perfect prompt.

Did it work?

None of it worked. But boy was it beautiful

— The Prompt Engineer

Table of Contents


Stop reinventing the wheel. Here are battle-tested prompts for common development scenarios. Copy them. Modify them. Make them yours.

Each template includes:

  • The prompt itself (copy-paste ready)
  • When to use it
  • Variables to customize (in {brackets})
  • Pro tips for better results

Code Generation

The Specific Function Generator

Write a {language} function that {specific task}.

Requirements:
- Input: {describe input type and format}
- Output: {describe output type and format}
- Handle these edge cases: {list edge cases}
- Use {library/framework} conventions

Do not:
- Include external dependencies unless specified
- Add features I didn't ask for
- Skip error handling

When to use: Any time you need a specific function with clear inputs/outputs.

Pro tip: The “Do not” section prevents the most common AI over-engineering mistakes.


The Boilerplate Generator

Generate boilerplate for a {type of component/module} in {language/framework}.

Context:
- Project uses {relevant libraries/patterns}
- Follow {style guide or conventions}
- This will be used for {purpose}

Include:
- Basic structure
- Standard imports
- Type definitions (if applicable)
- Placeholder comments for implementation

Skip:
- Actual implementation logic
- Tests (I'll add those separately)

When to use: Starting new files, components, or modules.

Pro tip: Be explicit about what to skip, or you’ll get 500 lines when you wanted 50.


The Test Generator

Write tests for this {language} code:

[paste your code here]

Requirements:
- Use {testing framework}
- Cover: happy path, edge cases, error conditions
- Follow AAA pattern (Arrange, Act, Assert)
- Use descriptive test names that explain the scenario

Focus on:
- {specific behaviors to test}

Don't test:
- Private methods directly
- Implementation details that might change

When to use: After writing implementation, need comprehensive tests.

Pro tip: Specifying what NOT to test prevents brittle tests tied to implementation.


Debugging & Error Analysis

The Error Translator

Explain this error message and how to fix it:

{paste error message and stack trace}

Context:
- Language/Framework: {language}
- What I was trying to do: {brief description}
- Relevant code (if helpful):

{paste relevant code}

Please provide:
1. What this error means in plain English
2. The most likely cause in my situation
3. Step-by-step fix
4. How to prevent this in the future

When to use: Any confusing error message.

Pro tip: Including what you were trying to do helps the AI give contextual advice instead of generic explanations.


The Bug Hunter

Help me debug this issue:

**Expected behavior**: {what should happen}
**Actual behavior**: {what actually happens}
**Steps to reproduce**: {numbered steps}

**Code**:

{paste relevant code}

**What I've already tried**:
- {list what you've tried}

**Environment**:
- {language version, OS, relevant dependencies}

Please:
1. Identify the most likely cause
2. Explain why this causes the observed behavior
3. Provide a fix with explanation
4. Suggest how to verify the fix works

When to use: Bugs you’ve spent more than 15 minutes on.

Pro tip: The “what I’ve already tried” section prevents the AI from suggesting things you’ve ruled out.


The Performance Analyzer

Analyze this code for performance issues:

{paste code}

Context:
- This code runs {frequency - once, per request, in a loop, etc.}
- Typical input size: {size/volume}
- Current performance: {if known}
- Target performance: {if known}

Please identify:
1. Time complexity (Big O)
2. Space complexity
3. Obvious inefficiencies
4. Specific improvements with expected impact
5. Any premature optimization I should avoid

When to use: Before optimizing, to know where to focus.

Pro tip: The “premature optimization” question saves you from over-engineering.


Code Review & Refactoring

The Code Reviewer

Review this code as a senior developer would:

{paste code}

Context:
- This is a {type of component} for {purpose}
- The codebase uses {patterns/conventions}

Check for:
1. Bugs or logic errors
2. Security vulnerabilities
3. Performance concerns
4. Readability issues
5. Missing error handling
6. Violations of {specific patterns/standards}

Format your response as:
- 🔴 Critical (must fix)
- 🟡 Important (should fix)
- 🟢 Suggestions (nice to have)

When to use: Before submitting PRs, or reviewing your own code.

Pro tip: The emoji categories make it easy to prioritize feedback.


The Refactoring Guide

Suggest refactoring for this code:

{paste code}

Goals:
- {primary goal: readability, performance, testability, etc.}

Constraints:
- Must maintain same public interface
- Cannot add new dependencies
- {any other constraints}

Please provide:
1. Overview of suggested changes
2. Refactored code
3. Explanation of each significant change
4. Any trade-offs I should be aware of

When to use: When code works but feels wrong.

Pro tip: Always specify constraints, or you’ll get suggestions requiring major architectural changes.


The Legacy Code Archaeologist

Help me understand this legacy code:

{paste code}

I need to:
- {what you need to do with it: modify, extend, replace}

Please explain:
1. What this code does (high-level purpose)
2. How it works (step by step)
3. Any non-obvious behavior or gotchas
4. Dependencies and side effects
5. Risks if I modify it
6. Suggested approach for my task

When to use: Inheriting code from someone who left the company.

Pro tip: Mentioning your specific task helps the AI focus on relevant parts.


Documentation & Explanation

The Documentation Generator

Write documentation for this code:

{paste code}

Include:
- Brief description of purpose
- Parameters with types and descriptions
- Return value description
- Example usage
- Edge cases or important notes

Format: {JSDoc, docstring, markdown, etc.}

Tone: {technical, beginner-friendly, etc.}

When to use: Any code that will be used by others (including future you).

Pro tip: Specifying format ensures you get documentation you can actually use.


The Concept Explainer

Explain {concept} to me.

My background:
- I'm a {role} with {X} years of experience
- I'm familiar with: {related concepts you know}
- I'm not familiar with: {concepts you don't know}

Please:
1. Start with a one-sentence summary
2. Explain how it works (not too academic)
3. Give a concrete example
4. Explain when I would use it vs alternatives
5. Common mistakes to avoid

When to use: Learning new concepts at the right level.

Pro tip: The background section prevents explanations that are too basic or too advanced.


The “Explain Like I’m Presenting”

I need to explain {concept/decision/architecture} to {audience: team, stakeholders, executives}.

Context:
- {relevant background}

Their concerns are probably:
- {list likely concerns}

Help me create:
1. A one-sentence summary (the headline)
2. A 30-second version (elevator pitch)
3. A 3-minute version (with key points)
4. Anticipated questions and answers

When to use: Preparing for meetings, demos, or presentations.

Pro tip: The layered approach (1 sentence → 30 seconds → 3 minutes) helps you adapt to different situations.


Learning & Research

The Technology Evaluator

I'm evaluating {technology/library/framework} for {use case}.

Current stack: {what you're using now}
Team experience: {relevant skills}
Constraints: {timeline, budget, team size, etc.}

Please provide:
1. What it's actually good for (not marketing claims)
2. What it's NOT good for
3. Learning curve estimate
4. Comparison to {alternatives}
5. Hidden costs or gotchas
6. Your honest recommendation for my situation

When to use: Before adopting new technology.

Pro tip: Asking specifically for “not marketing claims” helps get honest assessments.


The Quick Start Guide

I need to get started with {technology} quickly.

My goal: {specific thing you want to build/do}
Time available: {hours/days}
My background: {relevant experience}

Please provide:
1. Minimal viable setup (fastest path to "hello world")
2. Key concepts I must understand
3. Concepts I can skip for now
4. One practical example relevant to my goal
5. Resources for when I need to go deeper

When to use: Learning new tech under time pressure.

Pro tip: Specifying time available helps the AI calibrate depth appropriately.


The “What Should I Learn” Advisor

I want to get better at {skill/area}.

Current level: {beginner/intermediate/advanced}
Available time: {per week}
Learning style: {reading, videos, hands-on, etc.}
Goal: {why you want to learn this}

Please suggest:
1. Specific subtopics to focus on (prioritized)
2. What to skip (not worth the time)
3. Practical projects to build
4. How to know when I've "gotten it"

When to use: Planning your learning path.

Pro tip: Including your goal helps prioritize what matters for your situation.


General Productivity

The Meeting Summarizer

Summarize these meeting notes:

{paste notes}

Extract:
1. Key decisions made
2. Action items (with owners if mentioned)
3. Open questions
4. Next steps

Format as bullet points I can paste into Slack/email.

When to use: After meetings with messy notes.

Pro tip: “Format as bullet points I can paste” ensures you get usable output.


The Email Drafter

Help me write an email about {topic}.

Context:
- Recipient: {who and their role}
- Relationship: {formal, collegial, etc.}
- Goal: {what you want them to do}
- Tone: {professional, friendly, urgent, etc.}

Key points to include:
- {list points}

Keep it under {X} sentences.

When to use: Emails that need to be carefully worded.

Pro tip: Always specify a length limit, or you’ll get an essay.


The Commit Message Generator

Write a commit message for these changes:

{paste git diff or describe changes}

Format: {conventional commits, simple, etc.}

Include:
- Type of change (feat, fix, refactor, etc.)
- Brief summary (50 chars or less)
- Body explaining why (if complex)

When to use: When you’ve been staring at the commit message box for too long.

Pro tip: Paste the actual diff for accurate messages.


The PR Description Writer

Write a PR description for these changes:

**Summary of changes**:
{brief description}

**Files changed**:
{list key files}

**Context**:
{why this change is needed}

Please generate:
1. Clear title
2. Description of what changed and why
3. Testing notes
4. Any migration or deployment notes
5. Checklist items to verify

When to use: When you need a proper PR description but don’t want to write prose.


Meta-Prompts

The Prompt Improver

Help me improve this prompt:

{paste your prompt}

I'm trying to get: {desired output}
I'm currently getting: {what's wrong with current output}

Please:
1. Identify what's missing or unclear
2. Suggest a better version
3. Explain what you changed and why

When to use: When prompts aren’t giving you good results.


The “Ask Me Questions” Prompt

I want to {goal}, but I'm not sure how to describe what I need.

Ask me clarifying questions to help me give you a better prompt.

When to use: When you don’t know how to start.

Pro tip: This is surprisingly effective when you’re stuck.


Tips for All Prompts

  1. Be specific: Vague prompts get vague answers
  2. Include context: The AI doesn’t know your codebase
  3. Specify format: Tell it exactly how you want the output
  4. Include constraints: What to NOT do is often more important
  5. Iterate: First prompt rarely perfect, refine based on results

Copy freely. Modify ruthlessly. No attribution needed.