Skip to content
Coding

How to Use Claude Code: Plan, Prompt and Stay in Control

Claude Code reads your project, edits files, runs tests and commits, asking permission as it goes. How to install it, explore a codebase, plan before it writes code, prompt it well, keep it on track with CLAUDE.md and know where it falls short.

Illustration of Claude Code: a terminal window with three dots in its title bar, a prompt chevron, a blinking cursor and a four-point sparkle

Most people meet Claude in a chat window: you paste some code, get an answer, copy it back and hope it fits. Claude Code works differently. It runs inside your project, reads the files itself, makes the edits, runs your tests and commits the result, asking for permission along the way. That makes it far more useful than a chatbot for real software work, and far easier to misuse. This guide covers how to use Claude Code properly: installing it, your first session, planning before it writes anything, prompts it can act on, the setup that keeps it on track and the limits worth knowing before you hand it your codebase.

What Claude Code is (and what it isn't)

Claude Code is Anthropic's agentic coding tool. "Agentic" means it doesn't just suggest code: it works in a loop, choosing its next step, using tools and checking the result until the task is done. In practice it can search your repository, read and edit files across the project, run shell commands such as your test suite or linter, use git and connect to outside tools. If you want the general idea behind that loop, our guide to what AI agents are explains it.

It runs in several places, all on the same engine, so your project settings carry across:

  • The terminal: the full command-line version, and the one this guide focuses on.
  • VS Code and JetBrains IDEs: extensions with inline diffs and the ability to share your current selection.
  • The desktop app: the Code tab in the Claude app, with visual diff review and several sessions side by side.
  • The web and mobile apps: at claude.ai/code, for long-running tasks on repositories you don't have locally.

What it isn't: an autocomplete that finishes the line you're typing, or a replacement for knowing what your code should do. It's closer to a fast, tireless colleague who has just joined the team. It can read everything quickly, but it only knows what's in the repository and what you tell it. If you mostly want answers, explanations or a second opinion on a snippet, the ordinary chat in our guide to how to use Claude is simpler.

How to install Claude Code and start a session

You need a paid Claude plan (Pro, Max, Ultra, Team or Enterprise), a Claude Console account with API credits, or access through a supported cloud provider such as Amazon Bedrock. The free plan doesn't include it.

The recommended installer is one command. On macOS, Linux or WSL, open a terminal and run curl -fsSL https://claude.ai/install.sh | bash. In Windows PowerShell the command is irm https://claude.ai/install.ps1 | iex. Homebrew (brew install --cask claude-code) and WinGet (winget install Anthropic.ClaudeCode) also work, but unlike the native installer they don't update themselves. On native Windows, install Git for Windows as well so Claude Code can use a Bash shell.

Then:

  1. Open a new terminal and run claude --version to check it installed. If the command isn't found, the install folder isn't on your PATH yet.
  2. Move into a project folder with cd and type claude.
  3. Log in when asked. It opens your browser; credentials are stored, so you only do this once.
  4. Type /help to see the available commands. Typing / on its own lists commands and skills as you type.

Prefer not to touch the terminal? Install the VS Code extension or open the Code tab in the desktop app instead. Everything below applies there too, with buttons in place of some keyboard shortcuts.

Your first session: explore, then make a small change

Don't start with "build me a feature". Start by letting Claude Code read the project and tell you what it found. You'll learn how it reasons, and you'll spot misunderstandings before they turn into edits. Simple questions work: "what does this project do?", "where is the main entry point?" or "explain the folder structure". For a codebase you don't know, ask for a proper tour:

I'm new to this codebase. Before we change anything, give me a tour: - what the project does and who uses it - the main folders and what lives in each - how a request flows from [ENTRY POINT, E.G. THE API ROUTE] to the database - how to run it locally and how to run the tests - anything that looks fragile, unusual or undocumented Read whatever files you need, but don't edit anything yet. Keep it under [NUMBER] words.

Then make one small, low-risk change, such as a typo in the README, a missing test or a clearer error message. Watch what it does. Claude Code shows each edit as a diff, and depending on the session's permission mode it either asks before applying it or goes ahead and tells you. Select Yes when the change looks right; say what's wrong when it doesn't.

Git works conversationally too: "what files have I changed?", "create a branch called fix/login-timeout" or "commit my changes with a descriptive message". Work on a branch from the start, so every experiment is easy to throw away.

Plan first, then let it code

For anything bigger than a small fix, the most useful habit is to separate thinking from typing. Plan mode lets Claude Code read files and explore, but it won't edit your source code until you approve a written plan. Press Shift+Tab to cycle into it (the status line shows "plan mode on"), or start a single prompt with /plan.

A good planning prompt describes the outcome, the constraints and how you'll know it works:

/plan I want to add [FEATURE, E.G. RATE LIMITING TO THE LOGIN ENDPOINT]. Context: [WHY IT'S NEEDED AND WHO IT AFFECTS]. Constraints: - follow the existing patterns in [FOLDER OR FILE] - no new dependencies unless you explain why - don't change [PUBLIC API / DATABASE SCHEMA / OTHER NO-GO AREA] Done means: [TEST COMMAND] passes and [OBSERVABLE BEHAVIOUR]. Explore the relevant code first, then give me a step-by-step plan, the files you'll touch and any questions you need answered.

When the plan is ready, Claude Code offers to approve it and carry on, approve it but review each edit, or keep planning. Read it properly. This is the cheapest moment to catch a wrong assumption, such as editing a generated file or skipping a caller elsewhere in the code. You can press Ctrl+G to open the plan in your editor and change it before approving.

Tip: Always give Claude Code a check it can run itself: a test command, a type check, a linter or a script that reproduces the bug. With a way to verify its own work it keeps going until the check passes; without one, "done" just means it stopped typing.

How to write prompts Claude Code can act on

Claude Code can read your repository, but it can't read your mind or see your screen. The official advice comes down to telling it what it can't find on its own. Name the file, describe the symptom and say what "fixed" looks like. "Fix the bug" sends it hunting; "fix the login bug where users see a blank screen after entering the wrong password" gets it straight to work.

A few ways to hand over context directly:

  • Reference files with @: typing @ followed by a path, such as @src/auth/session.ts, includes that file in your message.
  • Paste the real error: the full stack trace or failing test output beats a paraphrase.
  • Paste screenshots: useful for layout bugs or a design you want matched.
  • Break big jobs into numbered steps: create the table, then the endpoint, then the page that uses it.

For bugs, this structure works well:

Bug: [WHAT HAPPENS], expected [WHAT SHOULD HAPPEN]. Steps to reproduce: [STEPS]. Error output: [PASTE STACK TRACE OR FAILING TEST] It started after [RECENT CHANGE, IF KNOWN]. First find the root cause and explain it in a few sentences before changing anything. Then write a test that fails because of this bug, fix the code so it passes, and run the full test suite. Don't silence the error or change the test to make it pass.

That last line matters. Under pressure to make a test pass, any coding model may be tempted to edit the test or catch and hide the error. Saying so up front avoids it. Our AI prompts for coding has more templates for reviews, refactors and documentation, and the Claude prompt generator can turn a rough request into a structured prompt like the ones above.

CLAUDE.md, permissions and undo: staying in control

CLAUDE.md is a plain Markdown file in your project root that Claude Code reads at the start of every session. Run /init and it drafts one from your codebase; your job is mostly deleting lines. Keep it short (the documentation suggests under 200 lines) and include only what Claude can't work out from the code: the exact build and test commands, conventions your team agreed on, the deploy step that lives in someone's head, folders it should never touch. If your repository already has an AGENTS.md for other coding agents, Claude Code can read that instead. Writing these instructions is very like writing a system prompt; our system prompt generator helps you structure them.

Permission modes decide what runs without asking. Shift+Tab cycles through them:

  • Manual: Claude reads freely but asks before editing files or running commands.
  • Accept edits: file edits and common file commands in your project folder go ahead; other commands still ask.
  • Plan: exploration and a written plan, no source edits.
  • Auto, where available: everything runs, with a separate classifier model reviewing risky actions first.

Two things the documentation is clear about. First, CLAUDE.md is guidance, and Claude may decide a line doesn't apply. Anything that must happen every time belongs in a deny rule (for example, blocking reads of .env files) or a hook, a script Claude Code runs at fixed points such as before each edit or when Claude tries to finish. Second, never use the bypass-all mode outside a disposable container or virtual machine.

When it goes the wrong way, press Esc to stop it mid-action and redirect. Press Esc twice on an empty prompt, or type /rewind, to roll the code, the conversation or both back to an earlier point. These checkpoints only cover files Claude edited with its own editing tools, not changes made by shell commands, so keep committing to git as well.

Tip: If you've corrected the same mistake twice and it's still wrong, stop correcting. Run /clear and write one new prompt that includes what you've learned. A fresh start beats a conversation full of failed attempts that Claude keeps rereading.

Long sessions, costs and automation

Every message resends the conversation so far, so long sessions use more of your plan's allowance or API budget. Most current Claude models have a context window of a million tokens, and Claude Code compacts older history automatically, so running out is rare. The issue is paying for, and being distracted by, history you no longer need. The habits that help:

  • /clear between unrelated tasks: it costs nothing. /clear [NAME] also names the session you're leaving so you can return to it.
  • /compact with a focus: /compact keep the API changes and the test commands summarises the rest.
  • /usage and /context: see where your usage went and what is filling the context window.
  • Resume instead of re-explaining: claude -c continues the latest session in that folder; /rename plus claude --resume [NAME] picks up named work days later.

Once the basics feel natural, Claude Code extends well beyond chat. claude -p "[TASK]" runs a single prompt and exits, which lets you pipe logs into it or call it from scripts and CI; there are ready-made integrations for GitHub Actions and GitLab. MCP servers connect it to tools such as issue trackers, databases and design files. Skills package repeatable procedures, such as a release checklist, that Claude loads only when needed, and subagents handle side tasks in parallel without cluttering your main conversation.

What Claude Code can't do

  • Know what isn't written down: business rules, the reason behind odd code or a deploy process nobody documented. If it isn't in the repo, CLAUDE.md or your prompt, Claude will guess.
  • Guarantee correct code: it can write plausible code that passes weak tests and still mishandles edge cases, security or performance. Review diffs as you would a colleague's pull request, especially anything touching authentication, payments or data deletion.
  • Make you understand your own system: letting it write everything without reading it is vibe coding, fine for prototypes and risky for anything you'll maintain.
  • Resist hostile instructions on its own: web pages, issues, dependencies or files it reads can contain text written to manipulate it. Permission prompts, deny rules and the sandbox (/sandbox) exist partly for this; see our explainer on prompt injection.
  • Run free: it needs a paid plan or API credits, and heavy sessions use up plan limits quickly. Check current pricing before you build it into a team workflow.
  • Stay the same for long: features, commands and defaults change often. If a command in this guide behaves differently, the official documentation and /help are the authority.

Used well, Claude Code takes the slow parts of programming off your hands: finding your way around unfamiliar code, writing the tests you'd have skipped, chasing a bug through six files. The pattern that works is consistent. Explore first, plan before editing, give it a check to run, keep CLAUDE.md short and true, and review what it hands back. You stay the engineer; it does the typing.

References

Put this into practice. Apply what you just read with our free tool: Claude Prompt Generator →
By AI enthusiast & advanced user

Jordi Benitez has been using AI tools day to day for years. No researcher, no academic title — just an advanced user who has spent enough hours prompting ChatGPT, Claude, Gemini and image models to know what actually works, and built GetEasyPrompt to share it in plain language.

FAQ

Frequently asked questions

No. Claude Code needs a paid Claude plan (Pro, Max, Ultra, Team or Enterprise), a Claude Console account with API credits, or access through a supported cloud provider such as Amazon Bedrock. The free Claude plan doesn't include it. On subscription plans its usage counts towards your plan's limits; on the API you pay per token.
Not to start: you can describe what you want in plain English and it will write and run the code. But you need enough understanding to judge the result, because it can produce code that looks right and still has bugs or security problems. Beginners get the most from it by asking it to explain its plan and every change before approving.
In the Claude chat app you paste code in and copy answers out. Claude Code works inside your project: it reads files itself, edits them, runs commands such as your tests, uses git and asks permission for risky actions. Chat suits questions and snippets; Claude Code suits changes across a real codebase.
CLAUDE.md is a Markdown file in your project that Claude Code reads at the start of every session. Use it for things Claude can't work out from the code: build and test commands, team conventions, deploy steps and areas it shouldn't touch. Run /init to draft one, keep it short, and use deny rules or hooks for rules that must never be broken.

Write your next prompt in seconds

Turn a rough idea into a clear, structured prompt any AI can follow. Free, private, and no account needed.

Open the Prompt OptimizerSee all tools