Sub topic 1
What a terminal coding agent is
Prerequisites
This chapter assumes you can use a shell and run your project's tests and build from the terminal. You should know basic git (commit, branch, diff) and have Node.js and npm installed. You should also have a rough idea of what a large language model (LLM) is.
Definition
A terminal coding agent is a program that runs in your shell and uses an LLM to work on a code repository. You give it a task in plain language. It reads files, proposes or makes edits, and runs commands such as tests and git. It repeats these steps until the task is done or it needs your input.
This chapter covers three tools:
- Claude Code, started with
claude - Codex CLI, started with
codex - Copilot CLI, started with
copilot
All three install as npm packages and start in the directory of your project.
How it differs from other AI coding help
A chat window answers questions, and you copy the code across yourself. Editor autocomplete suggests the next few lines. A terminal agent does more. It acts on your real files and runs real commands, so it can check its own work. For example, it can edit a function, run npm test, read the failure, and try again.
That ability is the benefit, and it is also the risk. The agent can change files and run shell commands with your user account's access. Much of this tutorial covers how to control that access.
What the three tools share
The tools differ in details, but they share the same parts:
| Part | What it does |
|---|---|
| Model | Decides what to do next |
| Built-in tools | Read and edit files, run shell commands, search the code |
| Instruction files | `CLAUDE.md` or `AGENTS.md` give project commands and conventions |
| Permissions and approvals | Control which actions need your consent |
| Sandboxing | Limits what the agent can touch |
| Non-interactive mode | Runs a single prompt from a script |
| MCP | Connects external tools through the Model Context Protocol |
Later chapters cover each part. The next chapter explains the loop that connects them.
A first look
After installing a tool, you start it from your project directory.
cd my-project
claude # start Claude Code
codex # start Codex CLI
copilot # start Copilot CLIYou then type a task, such as "explain how the build script works". The agent reads the relevant files and answers. Asking it to explain code is a safe first task because it needs no edits.
Exercise
Name two things a terminal coding agent can do that a chat window alone cannot.
Show answer
It can act on your real files, for example by editing them, and it can run commands such as tests or git. That lets it check its own work and retry after a failure.
Exercise
Why is it riskier to run an agent than to ask a chatbot a question?
Show answer
The agent can change files and run shell commands with your account's access. A chatbot only returns text that you choose whether to use.