Claude Not Following Instructions — How to Fix It
Claude sometimes ignores specific formatting rules, skips parts of your prompt, or produces output that doesn't match what you asked for. This is one of the most common frustrations for both new and experienced Claude users. The good news is that a few simple prompt structure changes can dramatically improve instruction-following behavior.
Why does this error happen?
How to fix it
Use XML Tags to Structure Your Prompt
Wrap distinct sections of your prompt in descriptive XML tags such as <instructions>, <context>, and <task>. This creates clear boundaries that help Claude distinguish between background information and actionable directives. Claude is specifically trained to recognize and respect XML-style structure, making this one of the most effective techniques available.
Add Explicit Output Format Examples
Show Claude exactly what your expected output should look like by including a concrete example inside your prompt. For instance, if you want JSON output, paste a sample JSON block and label it as the desired format. Demonstrating the format is far more reliable than describing it in prose alone.
Use the System Prompt in the API for Persistent Instructions
If you are using the Claude API, move your formatting rules and behavioral instructions into the system prompt field rather than the human turn. The system prompt is given higher priority and persists across the conversation, making it ideal for constraints you want Claude to always follow. This prevents user messages from accidentally overriding your core instructions.
Break Complex Instructions into Numbered Steps
When you have multiple requirements, list them as a numbered or bulleted list rather than writing them as a paragraph. Numbered steps are easier for Claude to track and less likely to be partially skipped. Keep each instruction to a single, unambiguous action for best results.
Code example
// Better prompt structure using XML tags
const prompt = `
<instructions>
Format output as JSON only.
No preamble or explanation.
Follow this exact schema: { "cities": [string] }
</instructions>
<task>List 5 cities in France</task>
`;
// Expected output from Claude:
// {
// "cities": ["Paris", "Lyon", "Marseille", "Toulouse", "Nice"]
// }Pro tip
Always place your most critical formatting or behavioral constraints at the very beginning of your prompt inside an <instructions> tag — Claude gives more weight to instructions that appear early and are visually separated from the rest of the content.