AI Agents in the Terminal: How Agentic Coding Tools Work
How terminal-based AI coding agents work: the plan-act-observe loop, tools for files and shell, permissions, sandboxing and instructions files.
Published November 27, 2026
Agentic coding tools that run in your terminal take a different approach from editor autocomplete. You describe a goal, and the agent explores the repository, edits files, runs commands such as your test suite, reads the output and keeps going until the task is done or it needs your input. Understanding the loop behind them helps you use them safely and get much better results.
The concept
At the core is a language model that can call tools. Typical tools include reading and searching files, editing files, running shell commands, and sometimes browsing documentation or calling external services. The model decides which tool to call, sees the result, and decides the next step. This plan-act-observe loop repeats, often dozens of times, for a single task.
Because the agent runs real commands in your environment, permissions matter. Good tools ask before running commands or editing files unless you have allowed them, support allow-lists for safe commands, and can run in sandboxes or containers. Your repository's state is the safety net: start from a clean git working tree so every change is visible in a diff and easy to revert.
The plan-act-observe loop
- Read the goal and project instructions (CLAUDE.md, AGENTS.md, README)
- Explore: search the codebase, read relevant files and tests
- Plan: decide which files to change and how to verify
- Act: edit files, run commands (with permission)
- Observe: read test/lint/build output, fix and repeat
- Report: summarise changes, show the diff, flag open questions
A real loop
Safety controls
| Control | Why it matters |
|---|---|
| Permission prompts / allow-lists | You decide which commands and edits run automatically |
| Clean git state + branches | Every change reviewable and revertible |
| Sandboxes / containers / worktrees | Limit blast radius of commands |
| Project instructions file | Conventions, commands, things never to do |
| No production credentials in the environment | An agent cannot leak or misuse what it cannot access |
| Human review before merge | Final accountability stays with people |
Writing a good instructions file
Agents start each session without memory of your project. A short instructions file in the repo root gives them the essentials: how to build and test, code style, architecture notes, and rules such as "never edit generated files" or "use the SafeHttpClient for outbound requests". Keep it concise and current; it is effectively onboarding documentation for both agents and new teammates.
# AGENTS.md / CLAUDE.md
## Commands
- Install: npm ci - Test: npm test - Lint: npm run lint
## Architecture
- src/modules/<name>/ — each module exposes only index.ts; never import internals across modules
## Rules
- Do not modify migrations that have shipped; add a new one
- All money values are integers in paisePractical examples
Effective task prompts
Specific, bounded, verifiable.
Weak: "Improve the API."
Strong: "In src/modules/orders, add input validation for POST /orders using the existing zod
schemas pattern (see users module). Return 422 with field errors. Add tests for missing
customer_id and negative quantities. Run npm test."Work on a separate branch or worktree
Isolate the agent's changes from your own work in progress.
git switch -c agent/orders-validation
# or a separate working directory for parallel tasks
git worktree add ../app-orders-validation -b agent/orders-validationReview the result like any PR
Read the diff, run tests yourself, check for unintended changes.
git diff --stat main...agent/orders-validation
git diff main...agent/orders-validation -- src/
npm testCommon mistakes
- Running an agent with broad permissions in a directory that contains production secrets.
- Starting from a dirty working tree, making it hard to tell what the agent changed.
- Vague goals with no way to verify success.
- Skipping review because "the tests pass"; tests may be incomplete or the agent may have changed them.
- Letting one long session sprawl across unrelated tasks instead of focused tasks.
Key takeaways
- Terminal agents run a plan-act-observe loop with file and shell tools.
- Permissions, sandboxes and clean git state keep them safe.
- An instructions file is the highest-leverage setup step.
- Give focused, verifiable tasks and review every diff.
FAQ
Can agents work on several tasks in parallel?
Yes, many teams run separate sessions in separate git worktrees or containers, each on its own branch, then review the resulting PRs.
Do agents remember previous sessions?
Generally not unless the tool has a memory feature. Repository instructions files and good commit history provide continuity.
Should agents be allowed to push or deploy?
Most teams keep pushes to protected branches and deployments behind human approval, even when agents open pull requests.