DEV Community

yaya806798160-ai
yaya806798160-ai

Posted on

The 5-section prompt framework that finally made my LLM output "ship it" instead of "almost right"

Most "prompt engineering tips" articles are useless. They say "be specific" without showing you HOW.

Here is the template I now use for every serious prompt. It has five sections, and each one exists because leaving it out causes a specific, predictable failure.

The 5-Section Structure

[Role]
You are a {role} with {years} years of experience in {domain}.

[Context]
Working on {project}. Target audience: {audience}.
Goal: {goal}.

[Output Schema]
Return a JSON object with fields:
- {field1}: {description}
- {field2}: {description}

[Constraints]
- Length: {n} words max
- Tone: {tone}
- Must include: {items}
- Avoid: {forbidden}

[Examples]
Input: {example_input}
Output: {example_output}
Enter fullscreen mode Exit fullscreen mode

Real Example: Writing a Product Intro

Without the framework:

Write a product intro for my SaaS.

Output (GPT, no framework):

Welcome to AcmeCloud, the leading cloud management platform
that helps businesses streamline their operations. Our
cutting-edge solution offers a wide range of features
designed to meet your needs...
Enter fullscreen mode Exit fullscreen mode

Generic. Useless. Could be any SaaS.

With the framework:

[Role]
You are a B2B SaaS marketer with 10 years experience
writing for ops directors at 200-person companies.

[Context]
Product: AcmeCloud (Kubernetes cost optimization)
Audience: Ops directors at Series B SaaS companies
Goal: Generate qualified demo bookings

[Output Schema]
Return JSON with: headline (10 words max),
subheadline (20 words max), 3 bullet benefits
(15 words each), CTA button text (3 words)

[Constraints]
- Tone: confident but not salesy
- Must include: 1 specific number (cost savings %),
  1 specific time saving (hours/week)
- Avoid: "leverage", "synergy", "revolutionize"

[Examples]
Good headline: "Cut your K8s bill by 40% in 30 days"
Bad headline: "Unlock the power of cloud optimization"
Enter fullscreen mode Exit fullscreen mode

Output (GPT, with framework):

{
  "headline": "Cut your K8s bill by 40% in 30 days",
  "subheadline": "AcmeCloud auto-rightsizes your clusters. Ops teams save 12 hrs/week.",
  "bullets": [
    "Average customer saves $18k/year",
    "Setup takes 15 minutes, no code required",
    "SOC 2 compliant, no data leaves your VPC"
  ],
  "cta": "See your savings"
}
Enter fullscreen mode Exit fullscreen mode

Same model, same product, vastly different output.

Why This Works

  1. Role gives the model a "persona" to write from, which calibrates tone and vocabulary.
  2. Output Schema forces structured thinking — the model can't ramble when it has to fill fields.
  3. Constraints prevent common failure modes — banning "leverage" eliminates 80% of corporate-speak.
  4. Examples anchor the quality bar — one good example beats ten rules.

I Built a Tool That Does This Automatically

I got tired of writing this scaffolding manually, so I built PromptOpt.

Paste a rough idea. Get back a structured prompt in this exact format. Feed it to any LLM. Free tier includes 10 optimizations, no card required.

Try It Yourself

Pick a recent prompt you wrote. Add the 5 sections above. Re-run it on the same model. The output difference is usually dramatic.

What's your "always include" section that I missed?

Top comments (0)