Skip to content
Kamal Benaouija

Search Kamal Benaouija's site

All articles
Artificial IntelligenceAIPrompt EngineeringLLMs

5 Prompt Engineering Patterns I Actually Reuse

Not theory — the exact patterns I copy-paste into new AI-powered features, and why each one works.

KB

Kamal Benaouija

July 5, 2026

2 min read

Most prompt engineering advice is either too abstract to use or too specific to transfer. These five patterns are the ones I've reused across multiple real projects, including 9rabra and my AI study assistant.

1. Structured Output First

Never ask an LLM for free text if you're going to parse it afterward. Ask for the structure you need directly.

Return ONLY valid JSON matching this shape:
{ "summary": string, "keyPoints": string[], "difficulty": "easy" | "medium" | "hard" }

This single habit eliminates an entire category of brittle regex-parsing bugs.

2. Show, Don't Just Tell

Instructions alone underperform instructions plus a concrete example. If output quality matters, include one worked example in the prompt — even a short one.

3. Constrain the Failure Mode

Instead of hoping the model won't hallucinate, explicitly define what it should do when it doesn't know:

"If the answer isn't clearly supported by the provided notes, respond with null for that field instead of guessing."

This turns silent hallucination into a detectable, handleable state in your application code.

4. Separate "Generate" From "Judge"

For anything quality-sensitive, use two passes: one prompt generates, a second prompt (often a smaller/cheaper model) evaluates the output against explicit criteria before it reaches the user.

Pass 1 (generate): Draft the flashcards from these notes.
Pass 2 (judge): Score each flashcard 1–5 for accuracy against the source notes.
                Discard anything below 4.

5. Keep System Prompts Boring and Specific

Vague system prompts ("You are a helpful assistant") produce vague behavior. Specific ones — role, constraints, output format, tone — produce consistent behavior. Boring, explicit instructions beat clever phrasing almost every time.

Why This Matters

None of these patterns are exotic. Their value is that they turn "the AI feature mostly works" into "the AI feature reliably works" — and that gap is the entire difference between a demo and a product.

Share