Lesson 18. Prompt optimization: short and precise
A good prompt doesn't mean a long prompt. Many think: the more I write, the better the model will understand. In reality, unnecessary words distract the model, increase API costs, and slow down responses. In this lesson we'll cover how to shorten a prompt without losing quality.
Topic breakdown
A token is the minimum unit the model counts. In commercial models (GPT, Claude, and others) pricing is determined by tokens. Every request and response is measured in tokens.
Unnecessary tokens: excessive descriptions, repeated instructions, unnecessary pleasantries, and irrelevant background information — removing them reduces cost and improves results.
Optimization means shortening a prompt without degrading the result. It's a skill: understanding which information the model truly needs and which is extra.
Prompt caching (available in Claude and GPT-4o): caching unchanged parts of the prompt in advance. Especially useful for system prompts used constantly.
What you'll learn
- understand what a token is and how it's counted
- find and remove unnecessary information from prompts
- write shorter and more efficient prompts with the same result
- know about prompt caching and template structure
Lesson plan
What is a token and why does it matter?
Every request and response is measured in tokens. In commercial models, pricing is determined by tokens. Fewer tokens = lower costs.
How to find unnecessary tokens
Check each sentence: if you remove it, would the result change? If not — remove it.
Prompt caching
In Claude and GPT-4o, unchanged parts of the prompt can be cached. Especially useful for system prompts and long context.
Template optimization
Separate constant and variable parts. The constant part is stored once, the variable is filled each time. This preserves both quality and efficiency.
Weak vs strong prompt
Please help me, think really carefully and write a very good marketing post. I've tried a lot but nothing works. Thanks in advance!
You are a copywriter. Write an Instagram post for a clothing store. Audience: women aged 20-35. Format: headline + 3 sentences + CTA. 100 words.
The second prompt removes pleasantries and unnecessary details, leaving only what's needed. The result is aimed directly at the goal.
Ready prompt template
Copy and adaptYou are a [role]. [One clear sentence: task]. Context: [only what's needed for the solution]. Output: [format]. [Most important constraint — one sentence].
Why it works
Unnecessary pleasantries, excessive descriptions, and repeated instructions are the main sources of extra tokens.
Check every word: does the model actually need it? If not — remove it.
Prompt caching (Claude and GPT-4o): caching unchanged parts significantly reduces costs.
In template structure, separate constant and variable parts: the constant part is stored once, the variable is filled each time.
Practice
- Take any long prompt you regularly use.
- Read each sentence and ask: 'Without it, would the result change?'
- Remove unnecessary sentences and write a shortened version.
- Test both versions — was quality preserved?
Mini-project
Mini-project: prompt audit
Take a prompt you use regularly and conduct a token audit. Goal: shorten the prompt without losing quality.
Tasks
- Write down a prompt you use regularly.
- Check each sentence and mark what's unnecessary.
- Write a shortened version.
- Test both versions on the same task and compare results.
Deliverables
- original and shortened prompt
- list of removed elements and reasons
- comparison of results: was quality preserved?
Checklist
Common mistakes
- adding 'please', 'thank you', 'think carefully' — they spend tokens without benefit
- repeating the same instruction 2-3 times in one prompt
- adding irrelevant background information
- optimizing at the expense of quality — the goal isn't brevity but efficiency
Lesson FAQ
Won't shortening worsen the result?
If you only remove unnecessary tokens — no. Key elements (role, task, context, format) must remain. Removing excess sometimes even improves the result.
What's needed to use prompt caching?
In Claude — the 'cache_control' parameter in the Anthropic API. In GPT-4o, caching works automatically. These features are available when working directly through the API.