Course navigation
Claude CodeLesson 7 of 25

Getting Better Results

Claude Code is powerful enough to build almost anything. When results fall short, the cause is almost always the input. A few consistent habits change the quality of every response.

Quality in, quality out

Claude reasons from what you give it. A vague task produces a generic answer. A specific task with context produces precise, correct output. The model does not change — your input does.

Better input = better output. Every time.

Four habits that work

Apply all four and the improvement is dramatic. Even one or two makes a noticeable difference from day one.

HabitWhat to doWhy it helps
Think in featuresBreak every task into one specific, atomic feature per prompt.Smaller scope = fewer assumptions = better code.
Be specificName files, libraries, patterns, expected behaviour, and error states.Clear input removes guesswork about implementation.
Provide contextUse @filename and CLAUDE.md to share conventions once for all sessions.Claude sees what you see without repeated explanations.
Test as you goVerify each feature before requesting the next one.Bugs caught early do not compound across later changes.

See the difference

Same task, two prompts. One leaves Claude to guess, the other gives it everything it needs.

TaskInstead of…Try…
User authentication“add user authentication”
Claude does not know which library, files, or error states to use.
“Add email/password login to @app/api/auth/route.ts. Use NextAuth.js (already in @package.json). On success redirect to /dashboard. Show a red error under the form if credentials are wrong.”
File, library, success path, and error UI are all defined.
Rule of thumb: If you can imagine multiple reasonable ways to implement something, your prompt is not specific enough. Add one more sentence of detail.

Providing context efficiently

The fastest way to improve results is to reduce what Claude has to assume. Two tools do this automatically.

@-mentions

Typing @ in the Claude panel opens a file picker. Claude reads the pinned file automatically. Use Alt+K (Windows) or Option+K (Mac) with selected text to add the exact line range.

Terminal
$ claude
> Refactor the fetchUser function in @src/lib/api.ts
to return null instead of throwing on 404.

CLAUDE.md

A CLAUDE.md file at the project root is read automatically every session. Put your stack, naming conventions, folder structure, and common patterns there.

# CLAUDE.md
Stack: Next.js 15 App Router, TypeScript, Tailwind
API routes: src/app/api/
Components: src/components/, always use 'use client' where needed
Tests: Vitest, colocated with source files
Avoid: any, console.log in production code

Test as you go

Bugs compound quickly when you add new features on top of untested ones. A single verification step after each feature keeps the foundation solid.

  1. Build the feature — ask Claude to implement one specific thing and accept its changes.
  2. Ask Claude to test it — prompt: “Write a test for this that covers the happy path and the error case.” Run it.
  3. Fix before continuing — do not move to the next feature until this one works.
With auto-accept mode on: use checkpoints as your safety net. Let Claude run freely, then rewind to a working checkpoint if something breaks.

When results disappoint

Poor output is feedback about your prompt, not the model's capability. Here is how to course-correct quickly.

SymptomWhat to do
Output is generic or off-topicAdd more specificity — name the file, library, and expected behaviour.
Claude used the wrong libraryAdd a @package.json mention or note in CLAUDE.md which packages are in use.
Changes touched files you didn't wantPin the exact file with @filename and say which files to leave alone.
The feature works but breaks something elseAsk Claude to write a regression test, or rewind to the last checkpoint.
Claude seems to have forgotten earlier contextStart a new conversation and re-attach the relevant file with @filename.

Quick reference

PracticeOne-line rule
One feature per promptSmaller scope = better output
Name the file with @filenameNo guessing which file to edit
Include existing packagesPrevents invented dependencies
Describe the error stateEdge cases get handled correctly
Write CLAUDE.md onceConventions carry across sessions
Verify before continuingBugs caught early, not late

Before you continue

  • One feature per prompt — smaller scope produces better code.
  • Name files, libraries, and error states so Claude does not guess.
  • Use @filename and CLAUDE.md to share context automatically.
  • Verify each feature before stacking the next change on top.
  • Next: connect Claude Code to external tools via MCP.

What's Next

You're getting better results on every run. The next lesson connects Claude Code to your external tools via MCP — GitHub, databases, APIs, and more.