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.

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:
- Open a new terminal and run
claude --versionto check it installed. If the command isn't found, the install folder isn't on your PATH yet. - Move into a project folder with
cdand typeclaude. - Log in when asked. It opens your browser; credentials are stored, so you only do this once.
- Type
/helpto 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:
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:
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.
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:
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.
/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 commandssummarises the rest. - /usage and /context: see where your usage went and what is filling the context window.
- Resume instead of re-explaining:
claude -ccontinues the latest session in that folder;/renameplusclaude --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
/helpare 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.



