BuildUtilities

Prompt Engineering Guide

What Is Prompt Engineering?

Prompt engineering is the practice of crafting effective instructions for AI models. A well-written prompt can be the difference between a vague, unhelpful response and a precise, actionable one.

Core Principles

1. Be Specific and Direct

Tell the AI exactly what you want, in what format, and how long it should be.

❌ "Write about dogs"
✅ "Write a 200-word blog introduction about the benefits of adopting rescue dogs, targeting first-time pet owners"

2. Provide Context

Give the AI background information it needs to produce relevant results.

❌ "Fix this code"
✅ "This React component should render a sortable table but the sort function mutates state directly. Fix the bug and explain the change."

3. Specify the Format

Tell the AI how you want the output structured.

"Generate 5 commit messages in Conventional Commits format (type(scope): description) for these changes: ..."

4. Use Examples (Few-Shot Prompting)

Show the AI what you want by providing 1–3 examples of ideal output.

5. Set Constraints

Define boundaries: word count, character limit, language, tone, or excluded topics.

Common Patterns

Role Assignment

Assign a persona to get domain-specific responses:

"You are a senior security engineer. Review this code for vulnerabilities..."

Chain of Thought

Ask the AI to think step by step for complex reasoning tasks:

"Explain step by step how this recursive function works and what it returns for input [3, 1, 4, 1, 5]"

Template Variables

Keep prompts you reuse as templates with {{variable}} placeholders you fill in per run. This is especially useful for repetitive tasks like generating product descriptions or review emails, and it makes a prompt easy to version and diff as you refine it.

Know What Prompting Cannot Fix

Some failures are not prompt problems and no amount of rewording will help, because the model is being asked for something it structurally cannot do. It has no entropy source, so a UUID or password it "generates" is drawn from patterns rather than randomness. It cannot compute a SHA-256, so it produces a plausible-looking one. Asked whether a regex matches, it reasons about the pattern instead of executing it.

The fix is to give the model a tool rather than a better prompt. That is what the MCP server is for — it hands an AI agent real implementations of exactly these operations, running locally, so the answer is computed instead of predicted.

Anti-Patterns to Avoid

  • Vague instructions: "Make it better" gives unpredictable results
  • Overloading: Asking for too many things in one prompt reduces quality
  • No format specification: The AI may choose an inconvenient output format
  • Ignoring iteration: Refining your prompt based on results is part of the process

Try These Tools

Related Documentation

Tip Jar