How to prompt Claude Code: habits that get better results

Seven prompting habits for Claude Code with before and after examples: name the files, give it a check to run, plan first, and correct course early.

· 5 min read

Most bad Claude Code sessions have one of two causes: Claude did not know something it could not see in the code, or it had no way to check its own work. Good prompts fix both. Here are the habits that matter, with prompts you can adapt, drawn from what works in practice and from Anthropic's own best-practices page.

#How specific should a Claude Code prompt be?

Specific about what only you know. Claude reads your repository very well, so don't explain the file layout. Do tell it the symptom, the place to look, and what "done" means.

Instead ofTry
fix the login bugusers report login fails after the session times out. look at token refresh in src/auth/, write a failing test that reproduces it, then fix it
add a calendar widgetfollow the pattern in HotDogWidget.php and build a calendar widget that lets you pick a month and page between years. no new libraries

The second row also names a preference between two reasonable approaches ("no new libraries"). Claude cannot read that from the code, so say it up front. When you are only exploring, a loose prompt like what would you improve in this file? is fine; you will just correct a bit more as you go.

#How do you give Claude the context it can't find itself?

Hand it the thing instead of describing it.

  • A file: type @ and the path to include its contents in your message.
  • A screenshot: paste the image of the design or the error.
  • Output: pipe it from your shell, for example cat error.log | claude -p "what's going on here".

Keep the standing facts in CLAUDE.md, and keep that short: the exact test, typecheck and lint commands, the places where the code is misleading, decisions that are not in the repo, and anything you had to correct twice. How to write a CLAUDE.md goes through it. If a line in it is ignored even when you shout, it probably belongs in a hook instead.

#Why should you give Claude a check to run?

Claude stops when the work looks done. If it has nothing to run that says whether the work is done, "looks done" is all it has, and you become the test suite. Give it something that returns pass or fail: a test file, a build's exit code, a linter, a script that diffs output against a fixture.

implement the CSV export, then run the tests in tests/export and keep going until they pass. show me the command you ran and its output.

Two parts of that prompt matter. The check closes the loop, and asking for the command and its output gives you evidence instead of a bare "all tests pass". For a stricter version, Claude Code has /goal to set a condition that is checked after every turn, and a Stop hook that refuses to let the turn end until a script passes. See test-driven development with Claude Code for the pattern at its best: write the failing test first, then the code.

#When should you plan before coding?

When the change touches several files, or you are not sure about the approach. Plan mode makes Claude read and propose without editing anything, so you can fix the plan, which costs a sentence, before it becomes a diff, which costs a review. For a small change you could describe in one sentence, skip it.

When you do not yet know what you want, let Claude interview you:

I want to add rate limiting to the public API but haven't thought it through yet. Interview me until you could write the spec, then write it to SPEC.md.

It comes back with multiple-choice questions about the parts you have not pinned down: per user or per key, what happens over the limit, what is out of scope. Once SPEC.md exists, start a fresh session to build from it, so the build begins with a clean context and a written definition of done.

#How do you ask for more than the minimum?

Claude tends to read a request conservatively and build the smallest thing that satisfies it. If you want the fuller version, say so, and say what "fuller" means:

build the settings page from the mockup. be ambitious: empty and error states, the save flow wired up, keyboard navigation, not just the layout

That is information about scope, which only you have. Phrases like "think step by step" or "be thorough" are ordinary text, not switches; how hard Claude thinks is controlled by the effort level, not by wording.

#How do you correct course without wasting the session?

Watch the first minute. Most wrong turns are visible early.

  • Esc stops Claude mid-action and keeps everything so far, so you can redirect without losing work.
  • /rewind, or Esc twice on an empty prompt, opens a menu to roll the code, the conversation, or both back to an earlier prompt. That makes it cheap to try the bolder approach first.
  • /clear starts over. If you have corrected the same thing twice and it is still wrong, a third correction adds to a conversation that already contains two failed attempts. Clear, and write one new prompt that folds in what you learned.

Use /clear between unrelated tasks too. A focused context gives better answers and costs less; why the context fills up explains the mechanics.

#What should you stop doing?

Some old advice has aged out with newer models:

  • Don't describe your architecture and file layout in CLAUDE.md. Claude reads the repo itself.
  • Don't add "loop until done" or "don't be lazy". Giving a check to pass is different, and still worth it.
  • Don't pile on IMPORTANT and capitals. A rule that truly cannot have exceptions is a hook or a deny rule.
  • Don't paste whole files you could reference with @.

#Which prompts are worth saving?

If you type the same prompt every week, save it. A slash command or a skill turns "review the diff against SPEC.md, report correctness gaps and skip style" into /review-spec. And keep one more line in your habits: when you ask for a review, add skip style. A reviewer asked to find problems always finds something, and fixing every finding ends in extra layers and tests for cases that cannot happen.

#In Relais

Several of these habits have a button in Relais. The Answers panel shows one line per turn beside the conversation, with the Markdown files Claude wrote under each, so a long session stays readable. Quick ask (⌘J) lets you put a side question to the session while Claude works, without adding it to the conversation. Edits come with their diff and plans with their own card, inside the chat. See the features page.

Claude Code,
better organized.

$14.99 a month, everything included. Mac and Linux, on your Claude Pro or Max plan. Cancel any time.