How to Talk to Claude Code — Writing Your First Prompt

You open Claude Code for the first time, stare at the blinking cursor, and freeze. What do you actually type? You know it’s supposed to help you write code, but it’s not Google — you can’t just type “fix my website.” Or can you? The truth is that talking to Claude Code is a skill, and like any skill, it gets dramatically easier once someone shows you the basics.

This is part of our complete How Claude Code Works — A Beginner’s Deep Dive.


TL;DR

  • Claude Code understands plain English — you don’t need special syntax to get started
  • The best prompts are specific about what, where, and why
  • You can give Claude Code context by mentioning files, functions, or goals directly
  • Bad prompts are fixable — you can refine mid-conversation
  • You’ll write your first working prompt by the end of this guide

What Is a Prompt, Exactly?

A prompt is simply what you type to Claude Code to tell it what you want done. Think of it like leaving instructions for a contractor who will be working on your house while you’re away. The more specific and clear your note, the better the job they do. A note that says “fix the thing in the kitchen” leaves a lot of room for error. “Replace the leaking faucet under the left sink” is much harder to misinterpret.

Claude Code reads your prompt, looks at your codebase, thinks about the best approach, and then acts. What you type directly shapes what it does.


Step 1: Start With a Goal, Not a Method

Most beginners make the same mistake: they tell Claude Code how to do something instead of what they want to happen.

Here’s the difference:

Too method-focused:


# Telling Claude Code the implementation — it doesn't need this
Add a useEffect hook that calls fetchData() when the component mounts

Goal-focused (better):


# Describing the outcome — Claude Code figures out the how
When this page loads, automatically fetch the latest products from the API and display them in the grid

The second version is better because Claude Code can see your code. It knows what hooks you’re already using, what your API looks like, and what naming conventions you follow. When you describe the goal, it can make smarter decisions than when you micromanage the method.

This doesn’t mean you can never specify a method. If you have a strong reason — “use a class component because this project doesn’t support hooks” — say it. But make the goal primary.


Step 2: Be Specific About Where

“Fix the bug” is not a prompt. “Fix the bug in the login form” is better. “Fix the bug in the login form on src/components/Auth/LoginForm.tsx where the password field clears when the user tabs away” is a good prompt.

Location matters. Claude Code can read your entire codebase, but it still helps when you narrow the focus. You have a few ways to do this:

Mention the file name:


# Referencing a specific file by name
In the file `utils/dateFormatter.js`, the formatDate function is returning the wrong timezone. Fix it to always return UTC.

Describe the feature or component:


# Describing the feature area instead of the file
The checkout summary component is showing the wrong total when a discount code is applied. Find and fix the calculation error.

Use @-mentions (if you know them): You can type @filename to explicitly attach a file to your prompt. This is covered in detail in How to Use @-Mentions in Claude Code.


Step 3: Include the “Why” When It Matters

Claude Code is not just a code generator — it makes decisions. And decisions are better when there’s context behind them.

Compare these two:

No context:


# Prompt without context — Claude Code will make assumptions
Add input validation to the registration form

With context:


# Prompt with context — Claude Code can make better decisions
Add input validation to the registration form. We're seeing a lot of bot signups, so we need to validate that the email is a real format and the username doesn't contain special characters. Don't change the UI — just add the validation logic.

The second version tells Claude Code what problem you’re solving, what constraints you have (“don’t change the UI”), and what the end goal is. You’ll get a much more targeted result.


Step 4: Give Claude Code One Task at a Time

It’s tempting to dump everything into a single prompt. Resist that.

Overloaded prompt:


# Too many tasks at once — results will be unpredictable
Add validation to the form, fix the date bug in utils, update the API endpoint from v1 to v2, and refactor the navbar component to use Tailwind classes

Claude Code can handle complex tasks — but when you mix four unrelated changes in one prompt, a few things happen: it’s harder to review what changed, mistakes in one area can bleed into another, and if something goes wrong you can’t easily undo just one piece.

Better approach: do them one at a time. Finish one, review it, accept or reject, then move to the next. How to Accept or Reject Claude Code’s Changes explains the review process.

💡 Pro Tip: If you genuinely have multiple related tasks, group only the ones that must happen together. “Add a loading state to the form AND disable the submit button while loading” is fine because they’re tightly coupled. “Fix the form AND refactor the navbar” are separate.


Step 5: Write Your First Real Prompt

Let’s put this all together. Here’s a framework you can use:


# Prompt framework — fill in the brackets
[What you want to happen] in [where / which file or component].
[Why, if it's not obvious].
[Any constraints or things to avoid].

Example using the framework:


# A real, complete prompt using the framework
Add error handling to the `fetchUser` function in `src/api/users.js`.
Right now it crashes silently when the API is down.
Show a user-friendly error message instead of crashing. Don't change the function signature.

This prompt is specific, has a location, explains the current problem, defines the desired outcome, and adds a constraint. Claude Code will know exactly what to do.


Step 6: Iterate When the First Result Isn’t Right

Here’s something beginners don’t realize: you don’t have to get it right in one shot. Claude Code remembers the conversation. If the first result misses the mark, just tell it what’s wrong.

Follow-up prompts that work:


# Narrowing the result
That works, but it's only validating the email field. Apply the same validation to the phone field too.

# Correcting a misunderstanding
The error message appears in the console, but I need it to show in the UI — in a red box below the form.

# Undoing something
Actually, let's go back. Remove the changes you just made to the loading state — I want to handle that differently.

This back-and-forth is normal. Professional developers using Claude Code iterate constantly. Your first prompt is a starting point, not a final order.


Common Mistakes and How to Fix Them

Mistake 1: Being Too Vague

Problem: “Make the app faster.”

Fix: “The product listing page takes 4 seconds to load. Profile the component and remove any unnecessary re-renders.”

Vague prompts get vague results. Always ask yourself: if a new developer read this, would they know exactly what to do?

Mistake 2: Forgetting to Mention Constraints

Problem: You ask for a new feature and Claude Code adds it using a library you can’t use.

Fix: Tell Claude Code your constraints upfront. “We’re not using any new npm packages for this — only what’s already installed.”

Mistake 3: Mixing Bug Fixes With New Features

Problem: You ask Claude Code to “fix the broken button and also add a dark mode toggle.” It does both, something breaks in the dark mode code, and now the button fix is buried in the same change.

Fix: Separate them. Fix the button first. Then add dark mode. Smaller, focused changes are easier to review and easier to undo.

Mistake 4: Expecting Claude Code to Know Unstated Business Logic

Problem: You ask Claude Code to “update the pricing” but don’t explain that pricing depends on the user’s subscription tier.

Fix: Spell out the rules. “Update the pricing display so that Pro users see $0 for features marked as ‘included’ and Free users see the regular price.” Don’t assume Claude Code knows your business logic — it only knows what it can read in the code.

Mistake 5: Not Reviewing Before Accepting

Problem: You accept Claude Code’s changes immediately without reading them.

Fix: Always read the diff before accepting. Claude Code is good, but it can make assumptions. A 30-second review catches most issues before they become problems.

⚠️ Warning: Never blindly accept changes to authentication code, database queries, or anything that handles user data. These areas deserve an extra-careful review.


Key Takeaways

  • A good prompt has a clear goal, a location, and when relevant, a reason
  • Give Claude Code one focused task at a time — not a laundry list
  • Your first prompt doesn’t have to be perfect — iterate with follow-up messages
  • State your constraints explicitly: libraries, patterns, things not to touch
  • Always review changes before accepting them

Next Steps

Now that you can write solid prompts, the next thing to understand is how Claude Code actually reads and understands your project:

Return to How Claude Code Works — A Beginner’s Deep Dive for the full picture.