Writing Your First Prompt using Claude Code
A prompt is the message you type to Claude Code. It tells Claude Code what you want done. Writing a good prompt is the most important skill you build as a Claude Code user — a clear prompt gets you a useful result fast, while a vague prompt leads to guessing and back-and-forth.
This topic teaches you how to write prompts that actually work, using plain examples from real coding situations.
What Makes a Prompt Different from a Search Query
When you search Google, you type a few keywords: "python read csv file". Google matches those words to pages.
Claude Code is different. It reads your full sentence, understands intent, looks at your project files, and takes action. So you get far better results when you write a real sentence instead of keywords.
Compare these two prompts:
Weak: "read csv" Strong: "Read the file sales_data.csv and show me the first 5 rows."
The strong version tells Claude Code the file name, the action, and the expected output — all in one sentence.
The Anatomy of a Good Prompt
Every effective prompt has three parts. You do not need to label them — just include all three naturally in your sentence.
Part 1 – The Action
What do you want Claude Code to do? Use a clear verb: read, create, fix, explain, add, remove, rename, test, refactor.
Part 2 – The Target
What file, function, or piece of code are you referring to? Name it directly. Do not say "the file" — say "config.json" or "the login function in auth.py".
Part 3 – The Expected Output
What should the result look like? A code change? An explanation? A list? A new file? Tell Claude Code what you expect to receive.
Prompt Diagram
[ Action ] + [ Target ] + [ Expected Output ] Example: "Fix" + "the calculate_tax function in billing.py" + "so it handles zero values without crashing"
Your First Real Prompt
Open your terminal, navigate to any project folder, and type claude to start. When the prompt line appears, type this:
"List all the files in this project and give me a one-line description of what each one does."
Claude Code scans your project folder and returns a structured list. This is a safe first prompt — it reads but changes nothing.
Types of Prompts You Will Use Often
Explanation Prompts
Use these when you want to understand something.
"Explain what the process_payment function in checkout.py does, step by step."
Action Prompts
Use these when you want Claude Code to make a change.
"Add input validation to the register_user function in users.py so it rejects empty email fields."
Question Prompts
Use these when you want a specific answer.
"Which files import the database module?"
Fix Prompts
Use these when something is broken.
"I get a TypeError on line 42 of parser.py when the input is None. Fix it."
Common First-Prompt Mistakes
Mistake 1 – Too Vague
Prompts like "help me with my code" give Claude Code nothing to work with. It will ask follow-up questions rather than act. Save time by being specific from the start.
Mistake 2 – Too Many Things at Once
Asking Claude Code to "refactor the whole project, add tests, update the README, and fix the login bug" in one prompt spreads attention too thin. Break large work into smaller prompts, one task at a time.
Mistake 3 – Assuming Claude Code Knows Your Context
If you are working on a very specific feature, mention it. Do not assume Claude Code knows which part of the project matters most right now.
Mistake 4 – Forgetting the File Name
Claude Code works across many files. If you say "fix the bug in the function" without naming the file, Claude Code must guess. Always name the file and function.
A Prompt Quality Checklist
| Question | If No, Fix It |
|---|---|
| Does my prompt include a clear action verb? | Add: fix, create, explain, list, add, remove |
| Does my prompt name a specific file or function? | Replace "the file" with the actual filename |
| Does my prompt describe the expected output? | Add what you want to see as a result |
| Is my prompt focused on one task? | Split into two separate prompts |
How Claude Code Responds to Your Prompt
After you press Enter, Claude Code goes through a short internal process before replying:
[ Read your prompt ]
|
v
[ Identify the files relevant to your request ]
|
v
[ Plan the action ]
|
v
[ Ask permission if a change is involved ]
|
v
[ Show you the result ]
For read-only prompts like "explain this function," Claude Code skips the permission step and replies immediately.
Prompts That Involve Multiple Steps
Sometimes one task needs several steps. Claude Code handles multi-step instructions well when you describe the goal rather than each micro-step.
Good: "Refactor the get_user_data function in api.py to use async/await and handle network errors gracefully."
Claude Code figures out the steps needed — you describe the destination, not the route.
Using Context from Previous Messages
Claude Code remembers the current conversation. After asking about a function, you can follow up naturally:
Message 1: "Explain the validate_email function in utils.py." Message 2: "Now add a check for domains that are less than two characters long."
Message 2 does not repeat the file or function name because Claude Code already knows which function you are discussing.
Key Points
- Every good prompt has three parts: action, target, and expected output.
- Name the specific file and function — never say "the file" without a name.
- Focus each prompt on one task for the cleanest results.
- Read-only prompts (explain, list, describe) get instant responses with no permission step.
- Claude Code remembers conversation history, so follow-up messages can be short.
- Use plain English sentences, not keyword fragments.
