Getting Started with Claude Code: A Complete Tutorial

Claude Code is Anthropic's AI coding assistant that runs in your terminal and operates directly on your codebase. Unlike a chatbot you paste code into, Claude Code can read your files, make edits, run shell commands, and work across multiple files in a single session — all from the command line. This tutorial covers everything you need to know to use it effectively from day one.
If you have not yet installed Claude Code, follow the installation guide first, then return here to get started.
Starting a Session
Navigate to your project's root directory in the terminal and run:
claude
Claude Code opens an interactive session and immediately has access to your project. It can browse your directory structure, read source files, and understand the context of your codebase without you needing to paste anything. You can type instructions in plain English and Claude will respond with actions, explanations, or code.
What Claude Code Can Do
Claude Code is not limited to answering questions — it is a full agent that can take actions on your behalf:
Read and edit files — Ask it to fix a bug in a specific file, refactor a function, or update a config value. Claude reads the file, makes the change, and shows you a diff before writing.
Run shell commands — Claude can run commands in your terminal, such as running tests, installing dependencies, or checking git status. It asks for your permission before executing any command.
Search across your codebase — Ask "where is the authentication logic?" or "which files use this function?" and Claude will search and summarise the relevant code for you.
Write and run tests — Give Claude a function and ask it to write unit tests. It will create the test file and can run the test suite to verify they pass.
Work with Git — Claude can stage files, write commit messages, create branches, and summarise recent changes — all from within the session.
Essential Slash Commands
Claude Code has built-in slash commands that control the session. Type any of these at the prompt:
/help— Lists all available commands and a summary of what Claude Code can do./clear— Clears the current conversation history. Useful when starting a new task and you want a fresh context without residual instructions from earlier in the session./compact— Compresses the conversation history to free up context space while retaining a summary. Helpful on large projects where long sessions can hit context limits./status— Shows the current model, token usage, and session information./exit— Ends the Claude Code session and returns you to your normal terminal prompt.
Tips for Getting the Best Results
Claude Code is powerful, but the quality of its output depends heavily on how you frame your requests. These habits will make a significant difference:
Be specific about the file or function. Instead of "fix the login bug", say "the login function in src/auth/login.js is not returning the JWT token correctly — fix it." The more context you give, the more precise the output.
Ask for one thing at a time. Claude handles focused tasks better than large multi-step requests in a single prompt. Chain tasks across multiple messages rather than bundling them all together.
Review before approving. Claude shows you proposed file changes and commands before executing them. Always review the diff — Claude is highly capable but not infallible, and you are the final authority on what goes into your code.
Use a CLAUDE.md file. You can place a
CLAUDE.mdfile at the root of your project containing project-specific instructions — your tech stack, coding conventions, testing approach, and anything else Claude should know. It reads this file automatically at the start of every session.Iterate in the same session. Claude retains context throughout the session. If its first attempt is not quite right, follow up with corrections rather than starting over — it will refine its output based on your feedback.
Running a One-Off Command
If you want Claude to perform a task without entering the interactive session, pass your prompt directly as a command-line argument:
claude "write a summary of what this project does based on the README and src/ directory"
This is useful for scripting, CI pipelines, or quick one-shot tasks where you do not need a back-and-forth conversation.
Working with Large Codebases
On large projects, Claude Code's context window can fill up over the course of a long session. A few strategies help manage this:
Use
/compactregularly to summarise and compress prior conversation history.Focus each session on a specific feature or module rather than the whole codebase at once.
Keep your
CLAUDE.mdconcise and focused on the most important conventions, so Claude spends context on your code rather than re-reading long instructions.
Claude Code represents a meaningful shift in how developers interact with AI tools — moving from copy-paste chatbots to a genuine agentic assistant that works alongside you in your actual development environment. The more you use it, the more fluent and effective your sessions will become.