Library · Setting up Claude Code

Claude Code built-in commands

Confident user40 minUpdated: October 2026
10 of 105 in the library

Module: Tokens and context | Time: about 20 min theory + 20 min practice


The gist

Claude Code's built-in commands are a pilot's control panel. Most people fly on autopilot and never look at the instruments. But once you know what every switch does, you're the pilot, not a passenger.


Key concepts

  • Built-in commands control how the agent behaves; they don't change your project files
  • Work modes shift the balance between autonomy and control
  • The right mode for the task = fewer unnecessary questions and less risk

Theory

Diagnostic commands

🎨 Picture this: built-in commands are the pedals and levers in the cockpit. Gas, brake, gearshift. Most drivers only ever press the gas. A pilot knows every switch, and that's exactly what makes them a pilot.

/clear

What it does: clears the history of your current conversation with the agent.

What it does NOT do: it doesn't delete project files, workflows or tools. Nothing on your file system is touched.

When to use it:

  • The conversation has gotten long and the agent is starting to "forget" context
  • You're switching to a fundamentally different task
  • /context shows the history taking up 70%+ of the context window
  • The agent has started giving strange answers, and a "fresh start" helps

If you change your mind: you can bring back the previous conversation with /resume. You can give the command a name (/clear name) so the old conversation is easier to find in the list.

Example:

Code
/clear

You spent 2 hours on a newsletter workflow and now want to build a new workflow for SEO analysis. You type /clear, the agent "forgets" the newsletter and starts with a clean slate. The newsletter files are still right where they were.


/compact

🎨 Picture this: /compact is like lecture notes. The lecture was 2 hours, the notes are 2 pages. Everything important is there, the filler is gone. You keep studying from the notes, not from the recording.

What it does: smart compression of the conversation history. It keeps key decisions and context and drops the details.

How it differs from /clear: /clear starts a new conversation with an empty context. /compact compresses: Claude remembers what you were working on but frees up most of the context. You can tell it what to keep: /compact keep the database decisions.

When to use it:

  • /context shows the window is 60%+ full
  • You want to continue the current task, not start over
  • The agent is getting a little "slow on the uptake," the first sign of overflow

Example:

Code
/compact

Before: the context window is 78% full. After: about 22%. You keep working with a fresh head.


/context

What it does: shows a map of token usage in the current session.

What you see: a color map of how full the window is: what's taking up space (system prompt, MCP tools, memory files, conversation history) and tips on what you could lighten.

When to use it:

  • The session feels slow and you're looking for what's overloading the context
  • You're planning to add an MCP server and want to check there's room
  • Regular checkups during long sessions (> 1 hour of work)

More on tokens and context in the lesson Tokens and context management.


/statusline

What it does: sets up a status line that stays at the bottom of the screen and shows the metrics you care about. You describe in words what you want to see, or run it with no arguments and Claude builds a line based on how your terminal looks.

What you can show: the model in use, how full the context is, the git branch and other session data.

When it helps: when you work in one session for a long time and want to see context usage without typing extra commands. For cost and plan limits there's /usage (/cost is a synonym).


Commands for managing components

/init

What it does: automatically analyzes the structure of an existing project and creates a CLAUDE.md based on what it sees.

When to use it:

  • You're joining someone else's project that has no CLAUDE.md
  • You want to generate a basic CLAUDE.md and refine it later
  • You're starting a new project from scratch and want a starter template

Important: /init creates a draft, not a finished CLAUDE.md. You need to review it and tailor it to your needs (the agent's role, project-specific instructions).


/agents

What it does: reminds you how to manage subagents. The command used to open a creation wizard; there's no wizard anymore.

How to create a subagent now:

  • Ask Claude: "create a subagent for proofreading text"
  • Or put a file in your project's .claude/agents/ folder (or ~/.claude/agents/ for all projects)
  • To see which background sessions are running, use the claude agents command in the terminal

More on subagents in the lesson Subagents.


/plugin and /skills

What they do: /skills shows a list of available skills (you can filter them by name). /plugin manages plugins, the bundles that package skills, hooks, subagents and MCP servers.

Main actions:

  • /skills: show all available skills
  • /plugin: open the plugin menu
  • /plugin list: show installed plugins
  • /plugin install <name>: install a plugin from the marketplace
  • /plugin enable <name> and /plugin disable <name>: turn a plugin on and off

More on skills in the lessons What are Skills, Building a skill from scratch and Skill architecture.


/loop

What it does: runs a task repeatedly at a set interval.

Syntax: /loop <interval> <command>

Examples:

Type this into the chat
/loop 5m /check-server-health
/loop 1h /daily-digest
/loop 10m check whether the deploy has finished

When to use it:

  • Monitoring a process that takes a while (deployment, batch processing)
  • Regular checks while you're busy with something else
  • Testing a schedule before moving it to the cloud

Important: /loop runs only while your Claude Code session is open. If you don't give an interval, Claude picks the pause between repeats itself. For a permanent schedule that keeps running when your computer is off, there are routines in the cloud (the /schedule command) or outside services like Trigger.dev. More in the lesson Loop vs Scheduled Tasks.


Agent work modes

This is probably the most practically important part of the lesson. Permission modes change how the agent makes decisions and what it does without your involvement. You switch between them with Shift+Tab (it cycles through them) or with a flag at launch: claude --permission-mode <mode>. The names in the interface and in the settings differ a little; both are given below. For the current list of modes, check the Claude Code documentation, since it changes from version to version.


Plan Mode

🎨 Picture this: Plan Mode is the architect drawing the blueprint before construction. The builders (the other modes) will work from it later. Without a blueprint, the builders do their own thing. With one, they build what you need.

How to turn it on: Shift+Tab (until you reach plan mode), the /plan command (you can add the task right away: /plan fix the login) or launch with claude --permission-mode plan

What happens: the agent analyzes the task and writes a detailed plan, without carrying it out. You see the list of steps, the files that will change, and possible risks.

When to use it:

  • A complex task you want to understand before it runs
  • Risky operations (data migration, a big refactor)
  • Learning: you want to see how the agent will approach things
  • You need to explain to a client exactly what will be done

Example: "Build a sales analytics system connected to Google Sheets with automatic daily reports" → the agent writes a 12-step plan with a description of each step. You look it over, adjust it, then say "go ahead."


Manual (confirmation mode; in settings it's default)

How to turn it on: Shift+Tab or claude --permission-mode default

What happens: the agent reads files freely, but before changing a file or running a command it shows you exactly what it's about to do and asks for confirmation.

When to use it:

  • You're working on a production project where mistakes are expensive
  • You're learning and want to understand every step
  • An important refactor where you need control
  • Your first time working with unfamiliar code

When it's overkill: routine work on well-understood tasks. The mode slows things down without adding value.


acceptEdits (automatically accept edits)

How to turn it on: Shift+Tab

What happens: the agent edits files and runs simple file commands (create a folder, move, copy) without asking. Other commands still need confirmation. You see the result.

When to use it:

  • A clear task and an agent you trust
  • Iterations once you already understand what the agent is doing
  • Content tasks (writing text, creating files)
  • A routine process you've done many times

auto (automatic mode with checks)

How to turn it on: Shift+Tab. In newer versions of Claude Code (starting with 2.1.283, as of October 2026) it's the starting mode in the terminal and in VS Code, so it's often already on

What happens: the agent works without asking, and instead of you, a second classifier model checks each action. It stops the dangerous ones.

When to use it:

  • Long tasks where you'd get tired of confirming every step
  • When you want to move forward but full freedom feels scary

Important: auto mode needs a supported model, and an organization can turn it off. If your plan doesn't have it, you still have Manual and acceptEdits.


dontAsk (only what's pre-approved)

What happens: the agent does only what you've approved in advance in the settings; everything else is silently declined, and it asks no questions.

When to use it: scripts and CI, where no human is around and the list of allowed actions is known exactly.


Bypass Permissions (full trust)

🎨 Picture this: Bypass Permissions is like giving a construction crew the keys to your apartment and leaving on vacation. If the crew is proven and the job is clear, fine. If the crew is new to you and the job is vague, you come home to chaos.

How to turn it on: the launch flag --dangerously-skip-permissions (same as --permission-mode bypassPermissions)

What happens: the agent gets full rights to every operation with no confirmations. Including potentially destructive ones.

When to use it:

  • Only inside an isolated environment: a container or virtual machine with nothing to break
  • Automated pipelines with no human involved (there's also the stricter dontAsk mode for those)
  • When you fully understand what the agent is doing

Warning: don't use this mode for experiments or unfamiliar tasks on your own computer. The agent can delete files, overwrite data, and do things that can't be undone.


Summary table of modes

Mode Control Speed Risk When
Plan Maximum Slow (you review the plan) Zero (nothing gets done) Complex/risky tasks
Manual (confirmation) High Slower than usual Low Learning, production
acceptEdits Medium Normal Medium When you review file edits yourself
auto Medium (a classifier checks) High Medium Long tasks without constant questions
dontAsk Set in advance High Low CI with a strict allowlist
Bypass Permissions Zero Maximum High Only isolated containers and VMs

Practice

Exercise: a tour of the modes

Take a simple task: "Create a README.md file for the newsletter-automation project with a short description of what the project does and how to run it."

  1. Run it in Plan Mode: study the plan and see what the agent intends to do
  2. Approve the plan: Claude will leave plan mode and start working
  3. Look at the result. Now say "now add an FAQ section with 3 questions"
  4. Switch to Manual (Shift+Tab) and ask it to add one more section. Watch how the agent asks for permission
  5. Run /context and see how many tokens have been used
  6. Run /clear and start a clean session

Goal: feel the difference between modes in practice, not just in theory.


Full table of built-in commands

Command Purpose When to use it
/clear Reset the conversation history Switching tasks, context overflow
/compact Smart compression of history (keeps the essentials; you can set a focus) Context 60%+ full and you want to keep working
/context Audit of tokens and the context window Every 30-40 minutes, or when the agent slows down
/statusline Set up a status line with the metrics you want You want to see context and model at all times
/usage (synonym /cost) Session cost, plan limits, statistics You're keeping an eye on spending
/agents Tips on creating subagents (the wizard is gone) Creating subagents by asking Claude or with a file
/skills List of available skills Seeing what's installed
/plugin Manage plugins (install, enable, disable) Adding new capabilities
/loop <interval> <request> Repeating tasks while the session is open Monitoring, periodic checks
/help Help on commands When you forget the syntax
/config Claude Code settings (model, theme) Changing the model, tuning behavior
/review (synonym /code-review) Review current changes, with depth levels Before a commit, quality check
/init Create a CLAUDE.md from the project structure First-time setup of a new project

Tools and resources

  • Claude Code command list: full documentation on commands
  • Permission modes: which mode allows what
  • Claude Code settings: configuring behavior and permissions
  • /clear: a new conversation with an empty context
  • /compact: smart compression (better than /clear when you want to keep going)
  • /context: token audit
  • /statusline: status line
  • /init: generate a CLAUDE.md
  • /agents: subagent tips
  • /plugin and /skills: plugins and skills
  • /loop: repeating tasks
  • Plan Mode: planning before doing

Current prices and versions: What's current.


Common mistakes

Mistake 1: Not knowing about /compact You only use /clear and start from zero every time. /compact compresses the history and keeps the key decisions. Use /compact at 60% full, and /clear only when switching to a different task.

Mistake 2: Bypass Permissions for experiments --dangerously-skip-permissions on a working project, and the agent accidentally deleted important files. This mode is only for an isolated environment (a container, a virtual machine) where no human is involved and there's nothing to lose.

Mistake 3: Skipping Plan Mode on complex tasks Jumping straight to "do it" instead of "show me the plan first." The agent went the wrong way, spent 15 minutes, and the result isn't what you wanted. Plan Mode is free: 2 minutes on a plan saves 30 minutes of redoing.

🎨 Picture this: skipping Plan Mode on a complex task is like asking builders to "make something nice" without a sketch. They will make something nice. Just not what you wanted.



Key takeaways

Work modes aren't just settings, they're a risk management tool. Plan Mode before complex tasks = insurance that costs nothing.

/clear isn't scary. Your files aren't going anywhere; the history is only the context of the conversation. Clearing it is useful and necessary.

Bypassing permissions is for machines, not people. Use it only when you fully understand what you're automating.


Next lesson

→ RAG: Retrieval Augmented Generation: how to teach Claude Code to work with your internal data

The mark stays in this browser only and is never sent anywhere. My progress