Prompt Claude 4 sonnet better and save your $$$
A template for implementing features quickly with Cursor Composer.

So in this blog, I’ll be sharing some tips and tricks to prompt Claude 4 sonnet better and note these notes are from the wonderful blog from Anthropic’s docs, you can find the original blog here.
I’ll be covering the following topics:
- Understand types of prompts
- Be Direct and avoid negation
- Use Examples and Demonstrations
- Use XML Tags
1. Two Types of Prompts: Declarative vs. Imperative:
Declarative prompts -> Tell what you need. For ex, “Help me improve the behavior ofthe scroll issue”
Imperative prompts -> Tell how you want it solved. For ex, “Fix this scroll issue using JS and CSS, here are 3 files for reference”
2. Be Direct and avoid negation:
Clearly state what you want Claude to do, instead of spending your tokens on telling what not to do. LLM’s encode meaning in vector spaces based on word occurrence patterns.
Logical operations like negation are hard to represent in this framework.
3. For example instead of saying, “Don’t give me results in html” -> tell what you need, for ex, “Write in markdown”
Use Examples and Demonstrations
Include a few examples to guide Claude’s response. This is particularly effective for few-shot prompting.
4. Use XML tags
Employ XML tags to steer the structure of Claude’s output, like <output_format_example> Content </output_format_example>.
Tags help Claude differentiate between different parts of the prompt and help in getting more reliable and organized outputs.
To wrap things up
Keep the below rule of thumb in mind when prompting with Claude
What You Want + Why You Need It + Desired Format = Better Results.
let me know your thoughts and experiences!