Best Practices for Clear Communication
At this point, you know how to give Claude context, how to assign personas, and how to format your output. But there's a subtle art to communicating clearly with an AI that separates power users from beginners.
It all comes down to ambiguity. A human developer can read between the lines; Claude cannot.
The 'Do Not Do X' Rule
AI models are generally better at doing what you tell them to do, rather than not doing what you tell them to avoid.
Bad Prompt:
"Write a sorting function but don't use any external libraries, and don't mutate the array, and don't use a standard for-loop."
When you stack negative constraints, the AI often gets confused and accidentally breaks one of the rules. It's much better to phrase constraints positively.
Good Prompt:
"Write a sorting function using pure, native JavaScript. Return a new array instead of mutating the original. Use functional array methods like
.mapor.reduceinstead of traditional loops."
Positive constraints give the AI a direct path to follow.
Use Examples (Few-Shot Prompting)
If you want data formatted in a very specific, quirky way, trying to explain it with words is painful. Just show it.
Prompt:
"Parse this list of users. Format the output exactly like this example:
Example: Input: John Doe, 30, USA Output: [JD] - 30yo (United States)
Here is the list to parse..."
Providing examples is called "Few-Shot Prompting." It is arguably the most reliable way to guarantee Claude outputs data in the exact structure you need.
Break Big Tasks Down
Don't ask Claude to build an entire e-commerce backend in one prompt. It will fail.
Instead, act as a project manager.
- First prompt: "Let's design the database schema for an e-commerce backend."
- Second prompt: "Great. Based on this schema, write the Express route for creating a new user."
- Third prompt: "Now write the Express route for adding an item to the cart."
Step-by-step communication ensures high-quality code at every stage.