Sub topic 5
Working in an interactive session
An interactive session is a running conversation between you and the agent inside your terminal. This chapter assumes you have installed one of the tools, signed in, and can run your project's tests from the shell. It also assumes you know the agent loop from earlier chapters: model call, tool call, observation.
Starting a session
Start the session from the project root, because the agent treats the current directory as its workspace.
cd my-project
claude # Claude Code
codex # Codex CLI
copilot # Copilot CLIEach tool shows a prompt box. You type a request in plain language and press Enter. The agent then runs its loop and shows each step as it happens.
What you see during a turn
One request and the agent's full response is called a turn. During a turn the agent may read files, search the code, propose edits, and run commands. Before it does anything that changes your machine, the tool usually pauses and asks for approval. You then choose to allow it, deny it, or change the request.
Interacting well
A few habits make sessions more predictable.
- Give one task per request. "Fix the date parsing bug in
src/dates.ts" works better than "clean up the project". - Name files and commands. Pointing at
src/dates.tsandnpm testsaves the agent a search. - Read each proposed diff before approving. A diff is a list of the lines the agent wants to add or remove.
- Interrupt when the agent heads the wrong way. Pressing Esc in Claude Code stops the current turn. Check each tool's help for its exact key.
- Correct it in the next message. The agent keeps the earlier conversation, so "Use the existing
parseDatehelper instead" is enough.
Tools also accept shortcuts inside the prompt box. In Claude Code, @ followed by a path adds a file to the request, and a leading ! runs a shell command directly. Codex CLI and Copilot CLI offer similar @ file mentions. Slash commands, which start with /, control the session itself. A later chapter covers them.
Common errors
| Problem | Likely cause | Fix |
|---|---|---|
| The agent edits the wrong files | You started it in the wrong directory | Exit, `cd` to the project root, and start again |
| It keeps asking for approval | Default permissions are strict | Pre-approve safe commands in settings, covered in a later chapter |
| It forgets earlier decisions | The conversation grew long | Start a fresh session or summarize the decisions |
| The result looks right but fails tests | The agent did not run the tests | Ask it to run `npm test` and fix failures |
Ending a session
Exit with Ctrl+C twice or with the tool's exit command. The agent's changes remain in your working tree. Run git diff to see them all in one place.
Exercise
You asked the agent to fix a bug, and it proposes a shell command you do not recognize. What should you do before approving, and what can you do if the agent has already started down the wrong path?
Show answer
Deny the command and ask the agent to explain what it does and why it is needed, or look the command up yourself. If the agent is heading the wrong way, interrupt the turn (for example with Esc in Claude Code) and send a correction in the next message. The session keeps its history, so the agent can use your correction.