Prompt Claude 4 sonnet better and save your $$$

A template for implementing features quickly with Cursor Composer.

Prompt Claude 4 sonnet better and save your $$$
prompting claude-4 sonnet ai

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:

  1. Understand types of prompts
  2. Be Direct and avoid negation
  3. Use Examples and Demonstrations
  4. 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!

Resources

  1. Claude 4 Best Practices
Last updated: June 7, 2025

Have questions on how to get your AI Product built?

Book a free discovery call to discuss your AI product requirements today!

Deepak - AI Product Developer

Worked on 5+ AI products in last year