DEV Community

Jonas Prenissl
Jonas Prenissl

Posted on • Originally published at ainews.q-sci.org

How to Write Better ChatGPT Prompts (2026)

The 4-part framework + copy-paste templates

Practical techniques • 7 min read

TL;DR

Great prompts have four things: context (who/what), task (specific action), format (how to output), and examples (when possible). Iterate 2-3 times to refine.

The 4-Part Prompt Framework

1. Context

Tell the AI who it is and what it's dealing with.
You are a senior technical writer for a SaaS company.
The audience is engineers evaluating our API.

2. Task

State exactly what you want.
Write a 300-word intro for our webhooks documentation.

3. Format

Specify structure, length, tone.
Use H2/H3 headings. Include one code example.
Tone: friendly but technical. Avoid marketing language.

4. Examples (Optional but Powerful)

Show what good looks like.
Example intro style:
"Webhooks let you..." (calm, direct, no hype)

Advanced Techniques

Chain-of-Thought

Add "Think step by step" or "First, list your considerations, then answer." Improves reasoning on complex tasks by 20-40%.

Few-Shot Learning

Show 2-3 input/output pairs before the real question.
`Q: What's the capital of France?
A: Paris

Q: What's the capital of Japan?
A: Tokyo

Q: What's the capital of Ghana?
A:`

Role Prompting

Assigning an expert role improves quality: "As a nutritionist..." or "As a database administrator..."

Delimiters

Use triple backticks, XML tags, or dashes to separate input from instructions:
`Summarize the following text in one sentence:

<text>
[your content here]
</text>`

Constraints First

Put "must" and "must not" at the top, not buried at the end. Models read prompts sequentially and give more weight to early instructions.

Common Prompt Mistakes

  • Being too vague: "Make it better" → "Make it more concise, cut 30% of words, use active voice"
  • Asking for opinion when you need fact: "Is Python good?" → "Compare Python vs Rust for CLI tools"
  • No output format: Always specify structure if you'll process the output
  • Multi-question overload: Break complex asks into steps
  • Ignoring the temperature: Use 0 for factual, 0.7-1.0 for creative

Prompt Templates You Can Steal

For Writing

Role: You are a [role].
Task: Write [content type] about [topic].
Audience: [description].
Length: [word count].
Tone: [tone].
Must include: [3 key points].
Must avoid: [what to skip].

For Coding

`Write a [language] function that:

  • Input: [signature]
  • Output: [signature]
  • Constraints: [performance/style]
  • Handle edge cases: [list] Include type hints and docstring. Skip comments in code.`

For Analysis

`Analyze this data: [data]
Steps:

  1. Identify key patterns
  2. Explain each pattern's likely cause
  3. Suggest one actionable insight Format: Markdown with H3 headers per section.`

How Prompts Differ Across Models

  • Claude: Responds well to XML tags for structure and long context
  • GPT-4: Handles more casual prompts, benefits from "step by step"
  • Gemini: Long context strong; explicit format instructions help

Related: ChatGPT vs Claude · Claude API Guide · AI Glossary


🎧 Get Daily AI News in 5 Minutes

Stay current on AI with a 5-minute daily podcast:

Original: https://ainews.q-sci.org/how-to-write-chatgpt-prompts.html

Top comments (0)