◆ AI All-in-One

Level 2 Agentic Coding · Agentic Coding

Setting Up a Coding Agent

Everything you need before your first agentic coding session. The few terminal commands that matter, installing a terminal agent such as Claude Code (or Codex CLI, Gemini CLI, or an editor agent), choosing a permission mode, and a first session on a small project, step by step.

Level
●●●●● Beginner
Reading
13 min
To learn it well
40 minutes to read, an hour to set up
↗ Plan a path here

Read first

What Is Agentic Coding?Setting Up Your Environment

This leads to

Git for Agent WorkTests as Guardrails
The full path from zero — 8 concepts before this one
  1. What Is AI?
  2. Python for AI
  3. How Machines Learn
  4. Setting Up Your Environment
  5. Large Language Models, Explained Simply
  6. AI Fluency: Working Well with AI
  7. Asking Well: Everyday Prompting
  8. What Is Agentic Coding?
  9. Setting Up a Coding Agent

Read them roughly in this order. See it on the concept map →

Why it matters

A coding agent is a program that acts on your computer. Before it can do anything useful, three things must be in place: a project folder it can work in, the tools it needs to run your code (a language such as Python, plus git), and a decision about how much it may do without asking you. Most early frustrations with agents come from getting one of these wrong. The agent can't run the tests because Python isn't set up. It edits files you didn't expect because the permissions are too loose. Or it asks permission forty times for the same harmless command because they are too tight.

This chapter gets you from nothing to a working first session on tally, the small expense tracker this part of the guide grows chapter by chapter. It assumes you have read What Is Agentic Coding? and have Python installed as described in Setting Up Your Environment.

The idea

Picture your setup as three layers (see the figure below). At the bottom is your computer, with all your files, passwords and network access. Inside it is a project folder, the one place you want the agent to work. On top is the agent, a program you start in that folder. The agent sends what it reads to a language model running in the provider's data centre, and the model sends back its next action: read this file, edit that one, run this command. The agent carries the action out on your machine.

Your computer The agent (claude, codex, gemini…) runs in your terminal, with your permissions Project folder tally.py, test_tally.py .git/ (your undo button) .venv/ (Python packages) CLAUDE.md / AGENTS.md .claude/settings.json the agent works here Everything else other projects, home folder ~/.ssh keys, .env secrets git push, the internet installed programs also reachable: guard with permissions The model in the provider's data centre sent to the model: files it reads, command output, your messages sent back: text, or the next action (read, edit or run)
Fig. 1 Where things run. The agent runs on your computer with your permissions and works in the project folder. What it reads is sent to the model provider, and the model's next action is carried out locally. Everything outside the project folder is also reachable, which is what permissions are for.

Two facts follow from that picture.

  1. Whatever the agent reads leaves your machine. Code, file contents and command output go to the provider as part of the conversation. Read the provider's data policy, and don't point an agent at files you are not allowed to share.
  2. The agent can do anything you can do, unless something stops it. That something is the permission mode: the setting that decides which actions the agent may take on its own and which need your approval.

Permission modes

Every serious agent has a ladder of permission modes, from cautious to hands-off. Claude Code's are the clearest example (as of late 2026):

safer faster Read files Edit files Run commands plan look and propose only free blocked read-only* default ("manual") ask before acting free asks asks acceptEdits edit freely, ask to run free free asks* auto a classifier checks commands free free checked bypassPermissions ask nothing: sandbox only free free free * plan: read-only commands run, others ask or are checked; acceptEdits also auto-approves mkdir, touch, mv, cp
Fig. 2 Claude Code's permission modes, from safest to fastest, and what each lets the agent do without asking. Reading files in your project is always allowed. The further down the ladder, the more you rely on something other than your own eyes: a classifier, or a sandbox.
  • plan: the agent can read and explore, and must present a plan. It cannot edit your files until you approve the plan. Use it to understand a codebase or design a change.
  • default, which the docs now call manual mode: the agent shows you each edit and each command and waits for an approval prompt, your yes or no. This is the best mode for learning, because you see everything.
  • acceptEdits: file edits in the project go through without asking. Commands still need approval, except simple file operations such as mkdir, touch, mv and cp. Good once you review changes with git rather than one by one.
  • auto: file edits in the project go through, and a second model, a classifier, reviews each command and other risky actions and blocks the dangerous ones, so you are rarely interrupted. Since version 2.1.283 this is the mode Claude Code starts in, when your plan and model support it.
  • bypassPermissions: nothing is checked. Use it only inside a container or virtual machine that holds nothing you would mind losing.

There is also dontAsk, which silently refuses anything that would need a prompt. It is meant for scripts and automated pipelines.

Other tools use the same ideas with different names. Codex CLI separates what the sandbox allows (--sandbox read-only, workspace-write or danger-full-access) from when to ask (--ask-for-approval on-request or never), and keeps network access off by default. Gemini CLI has default, auto_edit, plan and a --yolo flag. Cursor and VS Code offer an Agent, Plan and Ask mode in their chat panels and let you allow or deny terminal commands. ("YOLO" is the community's name for the no-approvals end of the ladder. It stands for "you only live once", which tells you what people think of it.)

Key idea Choose the permission mode by asking: if the agent misunderstands, what is the worst thing it could do without me noticing? Start in the mode where the answer is "nothing I can't undo", which means manual mode, or acceptEdits inside a git repository.

Allow rules: fewer prompts, same safety

Manual mode gets tedious when the agent asks for the tenth time whether it may run the tests. The fix is an allow rule: a pattern for commands that are always fine. In Claude Code, rules live in a settings file. A project's shared settings go in .claude/settings.json, which you commit so everyone gets them. Personal ones go in .claude/settings.local.json, and global ones in ~/.claude/settings.json. Here is a sensible file for a Python project:

{
  "permissions": {
    "allow": [
      "Bash(python -m pytest *)",
      "Bash(git status)",
      "Bash(git diff *)",
      "Bash(git log *)"
    ],
    "deny": [
      "Read(./.env)",
      "Read(./.env.*)",
      "Bash(git push *)"
    ]
  }
}

Bash(python -m pytest *) allows the test command with any arguments. The deny list always wins over allow. Here it stops the agent reading the .env file where secrets usually live, and stops it pushing to GitHub. You can also add rules from inside a session: when an approval prompt offers "Yes, and don't ask again" for a command, choosing it writes the rule for you. Type /permissions to see and edit the current rules.

In practice

1. The terminal in ten commands

A terminal (also called a shell or command line) is a window where you type commands instead of clicking. On macOS it is the Terminal app, on Windows use PowerShell or WSL, and on Linux any terminal. You need only a handful of commands to work with an agent:

pwd                      # print the folder you are in
ls                       # list its files (on Windows PowerShell, ls works too)
cd projects              # move into the folder "projects"
cd ..                    # move up one folder
mkdir tally              # make a new folder
cat tally.py             # print a file's contents
python3 tally.py report  # run a Python program with arguments
git status               # what has changed since the last commit?
# Up arrow recalls the previous command. Tab completes file names.
# Ctrl+C stops whatever is running.

If any of this is new, MIT's free Missing Semester course spends its first lecture on exactly this. The agent will run most commands for you, but you need to be able to read what it ran.

2. Install the agent

As of late 2026, Claude Code's recommended installer on macOS, Linux and WSL is:

curl -fsSL https://claude.ai/install.sh | bash

On Windows PowerShell it is irm https://claude.ai/install.ps1 | iex. Alternatives are Homebrew (brew install --cask claude-code) and npm (npm install -g @anthropic-ai/claude-code, which needs Node.js 22 or later). It needs a paid Claude plan (Pro or above) or an Anthropic Console account billed per use; the free plan doesn't include it. Check the install worked:

claude --version
claude doctor          # diagnoses installation problems

The alternatives install in a similar way. Check their pages for the current commands before you copy these:

npm install -g @openai/codex        # Codex CLI, then run: codex
npm install -g @google/gemini-cli   # Gemini CLI, then run: gemini

Codex signs in with a ChatGPT plan or an API key. Gemini CLI moved to paid access in June 2026. Editor agents need no terminal install: download Cursor, or open the Chat view in VS Code with GitHub Copilot. Everything in this part still applies, because the ideas are the same.

3. Prepare a project folder

Never start an agent in your home folder. Give it a project folder that is a git repository, so every change can be seen and undone:

mkdir tally && cd tally
git init -b main                 # start version control, main branch
python3 -m venv .venv            # a private Python environment
source .venv/bin/activate        # Windows: .venv\Scripts\activate
pip install pytest               # the test runner the agent will use
printf ".venv/\n__pycache__/\nexpenses.csv\n.env\n" > .gitignore
git add .gitignore && git commit -m "Start tally"

The .gitignore file lists things git should never save: the virtual environment, Python's cache, your personal expense data and any secrets file. Git for Agent Work explains commits properly.

4. Start a session

claude

The first time, it opens a browser to log in. A session is one conversation with the agent, with its own memory of what was said and done. It lasts until you exit (type /exit or press Ctrl+D twice). Inside a session, anything starting with / is a slash command that controls the agent rather than talking to the model. The ones to learn first:

Command or key What it does
/help list commands
/init have the agent read the project and write a starter CLAUDE.md (Project Context and Memory Files)
/clear start a fresh conversation in the same folder (use between tasks)
/compact summarise the conversation so far to free up context
/context show how full the context window is
/permissions view and edit allow and deny rules
/rewind go back to an earlier point, restoring code and conversation
/usage show token use and cost for the session
Shift+Tab cycle permission modes (manual, accept edits, plan, and auto if available)
Esc interrupt the agent mid-step; Esc twice on an empty prompt opens rewind

To come back later, claude -c continues the most recent session in this folder and claude -r lets you pick an older one.

Worked example: tally's first session

You have an empty, committed repository. Press Shift+Tab until the status line shows manual mode, so you see every step. Then describe the program:

> Create a small Python command-line expense tracker called tally.
  - `python tally.py add 12.50 lunch` appends date, amount and category
    to expenses.csv. Accept an optional £, $ or € sign. Reject zero,
    negative or non-numeric amounts with a clear error.
  - Use Decimal for money, not float. Standard library only.
  - Put the logic in small functions and write pytest tests in
    test_tally.py that never touch the real expenses.csv.
  Run the tests when you're done.

● Write(tally.py)
  ╭───────────────────────────────────────────────────────╮
  │ Create file tally.py                                  │
  │   1 """tally: a tiny command-line expense tracker.""" │
  │   ...                                                 │
  │ Do you want to create tally.py?                       │
  │ ❯ 1. Yes                                              │
  │   2. Yes, allow all edits during this session         │
  │   3. No, and tell Claude what to do differently       │
  ╰───────────────────────────────────────────────────────╯

The prompt shows the proposed file, so you can read it before saying yes. (The exact wording of prompts varies between versions.) You approve, the agent writes the test file the same way, and then asks to run a command:

● Bash(python -m pytest -q)
  Do you want to proceed?
  ❯ 1. Yes
    2. Yes, and don't ask again for python -m pytest commands in ~/tally
    3. No, and tell Claude what to do differently

  ⎿ .....                                    [100%]
    5 passed in 0.01s

  Created tally.py with parse_amount(), add_expense() and main(), and
  test_tally.py with 5 tests (currency symbols, rejecting 0, -3, "abc"
  and empty input). All pass.

Choosing option 2 creates an allow rule, so the agent won't ask about pytest again in this project. Now do your part, outside the agent, in a second terminal window:

python tally.py add £12.50 Lunch
# Added 12.50 to lunch
python tally.py add -3 coffee
# usage: tally [-h] {add} ...
# tally: error: amount must be positive: '-3'
cat expenses.csv
# date,amount,category
# 2026-11-30,12.50,lunch
git status --short
# ?? tally.py
# ?? test_tally.py

It behaves as specified, and it saves the category in lower case, a choice the agent made on its own. That is fine here, but notice it: agents fill gaps in your instructions with their own decisions. Read the two files (they are about 50 and 15 lines), then commit:

git add tally.py test_tally.py
git commit -m "Add tally: record expenses from the command line"

Finally, let the agent describe the project for its future self. Type /init. It reads the repository and writes a CLAUDE.md with the commands it found (how to run tally and the tests) and the conventions it noticed (Decimal for money, tests use tmp_path). Review it, trim anything wrong, and commit it too. Project Context and Memory Files shows how to make that file really useful.

Common mistakes

  • Starting in the wrong folder. Launched from your home folder, an agent can read and edit everything in it. Always cd into the project first. pwd tells you where you are.
  • No git repository. Without one you can't see exactly what changed or undo it. git init and a first commit take ten seconds.
  • Approving without reading. Approval prompts only protect you if you read them. If you find yourself pressing Enter blindly, switch to acceptEdits and review the diff at the end instead. That is more honest and just as safe.
  • Skipping the environment. If python -m pytest fails because pytest isn't installed, the agent may "fix" it by installing packages globally or rewriting your tests. Set up the virtual environment yourself and tell the agent which one to use.
  • Pasting secrets into the chat. Anything you type is sent to the provider and may stay in session logs. Put API keys in a .env file, keep it out of git, and deny the agent read access to it.
  • One endless session. Use /clear between unrelated tasks. A fresh context is cheaper and gives better answers.

Watch out --dangerously-skip-permissions (Claude Code), --yolo (Codex, Gemini CLI) and their equivalents turn every check off. The agent can then delete files outside the project, read your SSH keys or push to production, and a prompt injection in a file it reads could make it do so on someone else's behalf. Use these modes only in a disposable container or virtual machine with no secrets in it.

Where it leads

Try it

  1. Install one terminal agent, create the tally project as above, and run the worked example yourself. Count how many approval prompts you answered. Which ones would you turn into allow rules?
  2. Write a .claude/settings.json (or the equivalent for your tool) that allows running tests and git diff, and denies reading .env and running git push. Start a new session and ask the agent to "show me what's in .env". What happens?
  3. Ask the agent, in plan mode, "How would you add a report command?" Then switch to manual mode and let it implement the plan. Compare what it planned with what it did.

Hint for 2: create a .env file containing a fake line such as API_KEY=not-a-real-key first. A Read deny rule blocks the agent's file-reading tool and shell commands that name the file, such as cat .env. It is not a complete sandbox: according to Claude Code's docs it does not stop, for example, a Python script that opens the file itself. Operating-system sandboxing, covered in From Prototype to Production, closes that gap.

Check your understanding

5 quick questions. Pick an answer to see whether you were right and why. Your best score is saved on this device.

  1. You are about to try a coding agent for the first time on a project that is safely in git. Which permission mode does the chapter recommend for learning?

  2. The agent asks for the tenth time whether it may run python -m pytest -q. What is the cleanest fix?

  3. Your settings allow Bash(git *) and deny Bash(git push *). The agent tries git push origin main. What happens?

  4. You start a coding agent from your home folder instead of the project folder. Why is that a problem?

  5. Halfway through a long session the agent's answers are getting worse, and you are about to start an unrelated task. What should you do?

Finished this chapter?

Learn more

Hand-picked courses, books, videos and tutorials for going deeper. See all resources →

Docs

Claude Code quickstart

Anthropic · Beginner · Free

Install Claude Code, log in, and walk through a first session: asking about a codebase, making a change, using git, fixing a bug and the essential commands.

Docs

Claude Code: permission modes

Anthropic · Beginner · Free

What each permission mode lets Claude do without asking (manual, acceptEdits, plan, auto, dontAsk, bypassPermissions), how to switch, and which to use when.

Tool

Codex CLI

OpenAI · Beginner · open source; needs a ChatGPT plan or API key

OpenAI's open-source terminal coding agent. Reads AGENTS.md, runs in a sandbox with configurable approval policies, and has a non-interactive codex exec mode.

Docs

Cursor documentation

Anysphere · Beginner · Free

Docs for the AI code editor Cursor: its agent, project rules in .cursor/rules, AGENTS.md support, MCP, cloud agents and the command-line agent.

Docs

GitHub Copilot documentation

GitHub · Beginner · Free

Copilot in the editor, its agents in VS Code, the cloud agent that turns an assigned issue into a pull request, and custom instruction files.

Course

Claude Code in Action

Anthropic (Anthropic Academy) · Beginner · Free

Anthropic's free course on using Claude Code day to day: context, planning, custom commands, hooks, MCP servers and GitHub integration.

Facts checked as of 30 November 2026. Fast-moving details (products, prices, laws) change often. · Source: content/entries/agentic/setting-up-a-coding-agent.md