Skip to content

Running a coding agent

Coding with agents · topic coding-with-agents/first-session

A coding agent works inside your repository with your tools. This topic gets a first session going: installing and configuring the agent, letting it read and explain the codebase, making a first small change, understanding what it asks permission for, where the sandbox around it ends, how to handle the API keys it uses without leaking them, and managing the session so its context stays useful.

Concepts

Install and setup
Getting a coding agent running in a terminal or editor: installing the tool, authenticating to a model provider, opening it in a repository and checking it can run the project's own commands. Setup is also where you decide what the agent may reach, so do it in a repository you can afford to have touched and with a clean working tree. glossary
Codebase understanding
Using the agent to orient in unfamiliar code before changing it: ask where a feature lives, how a request flows, what a module depends on. The agent reads files and searches faster than you can, and its explanation is a fast first map. Verify the map against the code on anything you will act on, since agents summarize confidently. glossary
First change
A small, well-bounded edit done with the agent to learn how it works: a fix with a failing test, a rename, a documentation update. Brief it, watch which files it reads, read the diff it proposes and run the tests yourself. The point is to calibrate how it behaves in your project before trusting it with something larger. glossary
Permissions
What the agent may do without asking: read files, edit files, run commands, reach the network. Coding agents prompt for approval on risky actions by default and let you widen or narrow that. Approving everything for convenience turns a mistake in a command into a mistake in your repository or system, so widen access per project and per task. glossary
Sandbox
An isolated environment the agent runs in so that a wrong command damages only what is inside it: a container, a virtual machine or a separate user account. The sandbox limits which files, network destinations and credentials the agent can reach. It is a control you set up before the session, and a coding agent with no sandbox has exactly the access you have. glossary
Trust boundary
The line between what the agent may decide on its own and what is enforced from outside it. Instructions in a prompt are requests the model can ignore or be tricked out of, so a control that matters is enforced by the harness, the operating system or the network. Knowing what the agent sends to its provider, from file contents to command output, is part of drawing that line. glossary
Secrets hygiene
Handling the API keys and tokens an agent needs so a leak stays small. Use a personal key, never a shared one, and keep it in a password manager or an environment variable. A key never goes into a file the agent can commit. If a key may have been exposed, revoke it first and investigate afterwards, because rotation is cheap and a leaked key is used by someone else quickly. glossary
Session and context
A session is one conversation with the agent and its context window is the session's memory. Every file read and command output lands in it, so long sessions fill up and the agent starts forgetting earlier instructions. Keep one task per session, start fresh for unrelated work, and ask for a summary before compacting or handing off. glossary

Lessons

Your reference

Each lesson above adds its takeaways and its example here once you finish it. Your reference lists every lesson you have finished.

Your first session with a coding agent

Unlocks when you finish Your first session with a coding agent.

Keeping API keys out of the agent's reach

Unlocks when you finish Keeping API keys out of the agent's reach.

Sandboxing a coding agent

Unlocks when you finish Sandboxing a coding agent.

Sources