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
- Builds on
- 8 concepts →
- Quiz
- 5 questions ↓
The full path from zero — 8 concepts before this one
- What Is AI?
- Python for AI
- How Machines Learn
- Setting Up Your Environment
- Large Language Models, Explained Simply
- AI Fluency: Working Well with AI
- Asking Well: Everyday Prompting
- What Is Agentic Coding?
- 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.
Two facts follow from that picture.
- 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.
- 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):
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 asmkdir,touch,mvandcp. 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
acceptEditsinside 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
cdinto the project first.pwdtells you where you are. - No git repository. Without one you can't see exactly what changed or undo it.
git initand 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
acceptEditsand review the diff at the end instead. That is more honest and just as safe. - Skipping the environment. If
python -m pytestfails 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
.envfile, keep it out of git, and deny the agent read access to it. - One endless session. Use
/clearbetween 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
- Git for Agent Work: commits, branches and diffs, the safety net under every agent session.
- Project Context and Memory Files: turn the
CLAUDE.mdfrom/initinto a short, accurate briefing. - Planning and Specs: Telling an Agent What to Build: use plan mode properly, and write task descriptions the agent can't misread.
- Extending Your Agent: Skills, Hooks, MCP and Subagents: hooks and settings that enforce rules automatically instead of relying on you to watch.
- Setting Up Your Environment: virtual environments, uv and editors in more depth.
Try it
- 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?
- Write a
.claude/settings.json(or the equivalent for your tool) that allows running tests andgit diff, and denies reading.envand runninggit push. Start a new session and ask the agent to "show me what's in .env". What happens?- Ask the agent, in plan mode, "How would you add a
reportcommand?" Then switch to manual mode and let it implement the plan. Compare what it planned with what it did.Hint for 2: create a
.envfile containing a fake line such asAPI_KEY=not-a-real-keyfirst. AReaddeny rule blocks the agent's file-reading tool and shell commands that name the file, such ascat .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.
Learn more
Hand-picked courses, books, videos and tutorials for going deeper. See all resources →
Claude Code quickstart
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.
Claude Code: permission modes
What each permission mode lets Claude do without asking (manual, acceptEdits, plan, auto, dontAsk, bypassPermissions), how to switch, and which to use when.
The Missing Semester of Your CS Education
Short lectures on the shell, editors, version control and other everyday tools that courses assume you already know.
Codex CLI
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.
Cursor documentation
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.
GitHub Copilot documentation
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.
Claude Code in Action
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