Sub topic 1
What a terminal coding agent is
Prerequisites
This chapter assumes you can do the following:
- Use a shell and common command-line tools.
- Run
gitbasics: commit, branch, and diff. - Run a project's tests and build from the terminal.
- Install packages with Node.js and npm.
- Describe in a sentence what a large language model (LLM) is: a model that predicts text from the text it is given.
You do not need prior experience with any of the three tools covered here.
The definition
A terminal coding agent is a program that runs in your shell and uses a language model to carry out software tasks in your repository. You describe a goal in plain language. The program reads files, proposes or makes edits, runs commands such as tests and git, and uses the results to decide what to do next.
This tutorial covers three tools:
- Claude Code, started with
claude. - Codex CLI, started with
codex. - Copilot CLI, started with
copilot.
All three are installed as npm packages and start from your project directory:
npm install -g @anthropic-ai/claude-code
npm install -g @openai/codex
npm install -g @github/copilot
cd my-project
claude # start Claude Code
codex # start Codex CLI
copilot # start Copilot CLIPackage names and commands can change between releases. Check each tool's current documentation before you install.
How it differs from other coding assistance
The agent is not the only way to use a model for code. The table compares it with two common alternatives.
| Approach | What the model sees | What it can do | Who runs the code |
|---|---|---|---|
| Chat in a browser | Only what you paste in | Produce text | You copy, paste, and run it |
| Editor autocomplete | The open file and nearby context | Suggest the next lines | You accept each suggestion |
| Terminal coding agent | Files and command output it reads itself | Edit files, run commands, react to results | The agent runs commands, within permissions you set |
The key difference is the feedback loop. A chat model cannot run your tests. An agent can run them, read the failures, change the code, and run them again. It works from real output instead of guesses about your project.
The shared design
The three tools differ in details, but they share a structure. Later chapters cover each part in depth. This section names them so you can see how they connect.
- A model. Each tool sends your prompt and the conversation so far to a hosted language model and receives a reply.
- Tools the model can call. The model cannot touch your files directly. It asks the program to read a file, edit a file, search, or run a shell command. The program performs the action and returns the result.
- A loop. The program repeats the cycle of model call, tool call, and observation until the model decides the task is done or you stop it.
- Context. The model only knows what is in its context window, which is the limited amount of text it can consider at once. Your prompt, file contents, and command output all consume it.
- Instruction files. Files such as
CLAUDE.mdorAGENTS.mdgive the agent your build commands and conventions at the start of each session. - Permissions and sandboxing. The program decides which actions run automatically, which need your approval, and which are blocked. A sandbox adds operating-system limits on what a command can reach.
- Extension points. Model Context Protocol (MCP) servers, custom commands, hooks, and subagents add capabilities.
The permission check is the part to remember. The model proposes actions, but the program decides whether each one runs.
A first look at the work
Here is a typical interaction. You start the tool in a project and type a request:
> The date parser fails on ISO week dates like 2026-W05-3. Find the cause and fix it.The agent might then do the following without further prompting:
- Search the repository for the parser and its tests.
- Read the relevant source and test files.
- Run the existing tests to see the current failure.
- Edit the parser, which usually triggers an approval prompt.
- Run the tests again and report the result.
Each step is a tool call. You can see them, and in the default settings you approve the ones that change things or run commands.
Where the tools differ
Most differences are in naming and defaults, not in the basic idea.
| Area | Claude Code | Codex CLI | Copilot CLI |
|---|---|---|---|
| Command | `claude` | `codex` | `copilot` |
| Typical instruction file | `CLAUDE.md` | `AGENTS.md` | Repository instruction files; check its documentation |
| One-shot prompt | `claude -p "..."` | `codex exec "..."` | `copilot -p "..."` |
| Vendor | Anthropic | OpenAI | GitHub |
The chapter on choosing a tool compares them in detail. For now, treat them as three implementations of one pattern. Skills you build with one carry over to the others.
Limits and failure modes
Knowing what an agent gets wrong is part of using one well.
- Plausible but wrong changes. The model can write code that looks right and fails in cases the tests do not cover. Tests and review remain your responsibility.
- Lost context. In a long session, early instructions and details can be dropped or summarized away. Keeping sessions focused avoids this.
- Overreach. Given a vague goal, an agent may edit many files. Narrow tasks produce smaller, easier-to-review diffs.
- Untrusted input. The agent reads files, web pages, and tool output. Text in them can try to steer it. This is prompt injection, covered in a later chapter.
- Cost and variability. Each model call uses quota or billing. The same prompt can produce different results on different runs.
A safe starting habit
Before you give an agent real work, work on a branch so git records exactly what changed:
git switch -c agent/fix-date-parsing
# ...run the agent on a narrowly scoped task...
git diff
npm test
git add -p
git commit -m "Fix date parsing for ISO week dates"This habit, a branch, a narrow task, your own test run, and a staged review, runs through the rest of the tutorial.
Exercise
A colleague says a terminal coding agent is just a chatbot with access to your files. Name two concrete capabilities beyond reading files that separate it from a browser chat, and say why the loop matters.
Show answer
It can edit files and run shell commands such as tests and git, with approval rules deciding which actions run. The loop matters because the agent feeds each result, such as a failing test, back to the model, which then adjusts its next step. A browser chat cannot observe the outcome of its suggestions.
Exercise
In the shared design, which component decides whether a command the model requested actually runs, and which component limits what that command can reach at the operating-system level?
Show answer
The permission and approval system in the agent program decides whether the command runs. The sandbox limits what the command can reach once it runs.