Use AI coding agents well
An AI coding agent is a program that works on your code for you - it reads files, edits them and runs commands such as your tests in a loop, deciding each next step from what the last one showed, until the task is done. This guide shows how to set one up and use it well, one topic at a time, starting with Claude Code.
Each topic is one page with a direct answer at the top, our own worked examples and the questions people ask most. Where a topic is a list, such as the slash commands or the settings, the page has a search over every entry. Everything is written from the agent maker's own documentation, which each page links.
What a coding agent is
A chat assistant answers and stops. A coding agent keeps going: given a task such as "fix the failing login test", it searches the code, reads the files that matter, makes a change, runs the test, reads the result and tries again until the test passes. Each step uses a tool, and the model chooses the next tool from what the last one returned. This loop is what makes it an AgentAgentA model that uses tools in a loop, deciding each next step from what the last one returned, until the task is done..
Because it acts on your machine, the skills that matter are not only prompting. You decide what it may do without asking (permissions), what it knows about your project before it starts (CLAUDE.md), how much of the conversation it carries (sessions and context) and what it can reach beyond your files (MCP). The topics below take these one at a time.
To see the same loop from the inside, with the tool calls and the Context WindowContext WindowEverything a model can see at once while it writes an answer, counted in tokens. When the window is full, something has to be left out. filling up step by step, follow a request through How AI agents work.
Claude Code, topic by topic
Start
Install it, run a first session, and see what happens inside one.
- Install and sign inHow to install Claude Code on macOS, Windows or Linux, sign in with a Claude plan or an API key, check it works, and keep it up to date.
- Your first sessionA first session with Claude Code on a real project, in order - ask about the code, point at files, make one change, review it, run the tests, commit, and undo when it goes wrong.
- How it worksWhat happens inside Claude Code when you give it a task - the loop of gathering context, acting and checking, the tools it uses, what it can reach, and how its context window fills and compacts.
Daily use
The habits, commands and keys you use every day.
- Best practicesThe habits that make Claude Code reliable - give it a check it can run, plan before big changes, be specific, clear between tasks, keep CLAUDE.md short, use subagents for research, and review with a fresh session.
- Slash commandsEvery Claude Code slash command in plain words, with an example of each - /clear, /compact, /context, /model, /plan, /rewind, /resume, /code-review, /init, /mcp and the rest - and the 12 to learn first.
- Keyboard shortcutsEvery Claude Code keyboard shortcut - Esc to stop, Esc twice to rewind, Shift+Tab for permission modes, Shift+Enter for a new line, Ctrl+V to paste an image, ! for shell mode, @ for files - and how to change them.
- CLI flagsEvery Claude Code command-line flag and subcommand in plain words - -p, -c, -r, --model, --permission-mode, --allowedTools, --output-format, --worktree, --append-system-prompt - with an example of each.
- Sessions and contextHow Claude Code keeps your conversations - claude -c and -r to resume, /rename to name a session, /rewind and Esc Esc to undo, /branch to try another way, and claude -w to run several sessions at once in Git worktrees.
Control
What it knows about your project, what it may do, and which model does it.
- CLAUDE.md and memoryWhat CLAUDE.md is, where to put it, what to write in it and what to leave out, with an example - plus CLAUDE.local.md, .claude/rules/ for rules that apply to some files, AGENTS.md, @imports, and the auto memory Claude writes itself.
- PermissionsHow Claude Code decides what it may do without asking - the 6 permission modes (Manual, Accept edits, Plan, Auto, dontAsk, bypass), allow, ask and deny rules with Bash and file patterns, where rules are saved, and what rules cannot stop.
- SettingsWhere Claude Code's settings files are (~/.claude/settings.json, .claude/settings.json, .claude/settings.local.json), which one wins when they disagree, how to change a setting with /config, and a searchable list of the settings worth knowing.
- ModelsWhich model to use in Claude Code and how to switch - the opus, sonnet, haiku and fable aliases, /model and --model, effort levels from low to max, ultrathink, opusplan, the 1 million token context window, and fast mode.
Extend
Give it new tools, packaged know-how, helpers and your own scripts.
- MCP serversHow to connect MCP servers to Claude Code with claude mcp add - remote HTTP servers, local stdio servers, the 3 scopes and .mcp.json, signing in with /mcp, environment variables, @ resources, MCP prompts as commands, and the risks to check first.
- SkillsHow to make your own Claude Code skill - a folder with a SKILL.md file that becomes a /command and that Claude can also use on its own - with the frontmatter fields, arguments, live command output, supporting files, and when to use a skill instead of CLAUDE.md.
- SubagentsWhat subagents are in Claude Code, the built-in Explore, Plan and general-purpose agents, how to write your own in .claude/agents/ with tools, model and permissions, how to call one with @, background subagents, forks with /subtask, and when not to use one.
- HooksHow Claude Code hooks work - the events such as PreToolUse, PostToolUse and Stop, matchers, exit code 2 to block an action, the JSON a hook receives, examples for formatting, protecting files and notifications, and what to check before you trust a repository's hooks.
- PluginsWhat a Claude Code plugin is, how to install one with /plugin, marketplaces and install scopes, keeping plugins updated, what a plugin costs in context, how to check one before you trust it, and how to package your own skills, subagents, hooks and MCP servers as a plugin.
Automate
Run it from scripts and CI with no one at the keyboard.
Cost
What it costs and how to spend less.
Questions
- What is an AI coding agent?
- A program that uses an AI model to work on code by itself in a loop - it reads files, edits them and runs commands such as tests, and decides each next step from the result of the last, until the task is done. Claude Code is one; you give it a task in plain words and it works in your project folder.
- How is a coding agent different from code completion?
- Code completion suggests the next lines as you type, and you stay in control of every change. A coding agent takes a whole task, such as fixing a bug or adding a feature, and carries it out across many files, running commands to check its work. You review what it did rather than writing each line.
- Is it safe to let an AI agent run commands on my computer?
- It can be, with the right limits. Claude Code asks before it edits files or runs commands unless you allow them, keeps checkpoints so you can undo its edits, and can run commands in a sandbox. Start in the default mode, allow only the commands you trust, and read changes before you commit them.
- Which topic should I read first?
- Install and sign in, then Your first session, then CLAUDE.md and memory. Those 3 cover getting started, the everyday loop and giving the agent what it needs to know about your project. Permissions and Best practices come next.
Sources