AI Agents and Coding Assistants

Working With a Terminal Coding Agent: Habits That Keep You in Control

Version control, permissions, small tasks and careful review: practical habits for using a command-line coding agent safely.

Key takeaways

  • Start from a clean version control state so you can see and undo every change.
  • Approve commands deliberately, and widen automatic permissions only for harmless ones.
  • Ask for a plan before large edits, and break big goals into reviewable pieces.
  • Keep secrets, production systems and irreplaceable data out of the agent's reach.
  • Judge the result by the diff and by tests you trust, not by the agent's summary.

You stay in control of a terminal coding agent by making every change reversible, limiting what the agent can reach, giving it one well-defined task at a time and reading what it did before you keep it. None of these habits depends on a particular product.

A terminal is a text window where you type commands to your computer. A terminal coding agent is a program you run there that uses an AI model to read your project, edit files and run commands in pursuit of a goal you describe. Because commands can do nearly anything your user account can do, the habits below deserve attention before the first session, not after the first accident.

Set up a way back

Version control is software that records snapshots of your files over time. Git is the most widely used example. With it, you can see exactly which lines changed and return to an earlier state.

Before starting an agent, save your current work as a commit (a named snapshot) and, for anything experimental, create a branch (a separate line of changes). Then whatever happens is easy to compare and discard.

Know the limits of this safety net. Version control covers files it tracks. It does not restore a dropped database, an email already sent, a file excluded from tracking or a change made on another machine. Back those up separately, and prefer working on copies.

Limit what the agent can touch

Most agents ask before running commands or editing files, and many let you pre-approve some actions. Convenience pushes you toward approving everything. Resist that.

A useful way to sort commands is by what they can damage.

Kind of action Example Sensible default
Reading List files, search text Usually safe to allow
Local checks Run tests, check formatting Allow once you know what they do
Changing the project Edit files, install packages Review each time or work in a sandbox
Leaving your machine Upload code, call a live service Require explicit approval
Destroying Delete folders, rewrite history, drop data Refuse unless you truly intend it

Remember that a test or build command runs whatever the project's scripts say, including scripts the agent just edited. For stronger protection, run the agent in a container or virtual machine, which is an isolated environment with its own limited view of files and network. The principle of least access applies fully here.

Keep secrets and live systems away

Passwords, access keys and tokens often sit in configuration files or environment settings. An agent that can read them may include them in what it sends to the model service, print them into a log or copy them into code.

Use test credentials with little power, never production ones. Keep real secrets outside the project folder. Do not leave your terminal logged in to a live server or an administrator cloud account while an agent runs there. And read your provider's current data terms to learn what is sent and retained.

Be cautious with untrusted material. A web page, issue report or downloaded repository can contain text written to steer the agent, a technique called prompt injection. If an agent suddenly wants to fetch an unfamiliar address or run something unrelated to your task, stop and look at what it just read.

Give one clear task at a time

A good request states the goal, the boundaries and how success will be checked. Compare "improve the app" with this:

Goal: the export button should include the date column.
Limits: change only the export module; no new dependencies.
Check: add a test with two rows and one missing date; all tests must pass.
Ask me before changing the database schema.

Smaller tasks produce smaller diffs, and small diffs get read. When the goal is large, ask the agent first to investigate and propose a plan without editing anything. Correct the plan, then have it proceed in stages, committing after each stage you accept.

If you find yourself repeating the same guidance, put it in the project's instruction file. Writing project instructions covers what belongs there.

Follow a repeatable loop

A controlled session with a coding agent
Keep or discard Commit good work, throw away the rest Verify Read the diff and run tests yourself Supervise Approve commands and interrupt when it wanders Snapshot Commit your work and open a fresh branch Describe State goal, limits and how to verify Plan Read the proposed approach before edits 1 2 3 4 5 6 Snapshot Commit your work and open a fresh branch 1 Describe State goal, limits and how to verify 2 Plan Read the proposed approach before edits 3 Supervise Approve commands and interrupt when it wanders 4 Verify Read the diff and run tests yourself 5 Keep or discard Commit good work, throw away the rest 6

Watching matters. You do not need to read every line scrolling past, but notice the direction. Warning signs include repeating a failing fix, editing files unrelated to the task, installing packages to get around a problem or removing a failing test.

Interrupting is normal. Stop the run, say what you saw and restate the goal. After a long, tangled session, it is often better to discard the changes and start fresh with a sharper description that includes what you learned. A model working from a cluttered history can keep returning to a bad idea.

Review the evidence, not the summary

At the end, agents usually report what they did. Treat that report as a claim. It can omit changes or say tests passed when only some ran.

Look at the full diff with your version control tool. Check the list of changed files first, since an unexpected one is the quickest red flag. Run the tests yourself. Try the feature by hand.

Pay particular attention to tests the agent wrote or altered. A test can be made to pass by asserting very little. Honest testing with AI means checking that a test would actually fail if the feature were broken.

If you do not understand a change, ask for an explanation, then confirm it against the code or official documentation. Do not keep code you cannot account for in anything that matters.

Read a command before you approve it

Approval prompts only protect you if you understand what you are approving. Slow down on anything you cannot paraphrase.

A few patterns deserve a second look. Commands that delete recursively remove whole folder trees, and a wrong path or an empty variable can widen the target enormously. Commands that download a script and run it immediately give you no chance to inspect it. Commands run with administrator rights can change the whole machine. Options containing words like "force" usually switch off a protection that exists for a reason.

In version control, be wary of commands that discard uncommitted changes or rewrite shared history, since they can destroy your own or a colleague's work. In databases, look for statements that delete or update without a condition limiting which rows are affected.

When unsure, ask the agent to explain the command and offer a safer or preview version. Many tools have a dry run option that shows what would happen without doing it. Then check the explanation against the tool's documentation if the stakes are high. Saying no costs a minute. Rebuilding lost work can cost days.

A worked example session

Say you maintain a small script that builds a monthly report, and it crashes when a data row is blank. You commit your current files and create a branch.

You tell the agent what happens, paste the error text and give a sample file containing invented data with one blank row. You ask it to find the cause and explain it before changing anything.

It reads the script and reports that the code converts an empty field to a number. You agree, and ask for a test that reproduces the crash, then a fix that skips blank rows and counts how many were skipped. You approve the test command each time it runs.

The first attempt silently turns blanks into zero, which would distort the averages. You notice this in the diff, say that blank means missing and not zero, and ask for a revision. The second version passes. You run the report yourself on a copy of last month's input and compare the totals with the figures you already trust. Only then do you commit.

Nothing here was complicated. The safety came from the snapshot, the invented sample data, the plan before the edit and your own check of the numbers.

Mind cost and attention

Agent sessions can use a lot of model processing, especially when the agent reads large files repeatedly or loops on a stubborn problem. Check how your tool is billed and set limits where it offers them.

Your attention is also limited. Running several agents at once multiplies the diffs waiting for review. If review becomes skimming, reduce the number of parallel tasks.

Habits for shared projects

On a team, make agent-assisted work look like any other work. Put it through the usual review, keep changes small enough for a colleague to follow, and write commit messages that explain why. Agree on which repositories and data agents may be used with, and follow any employer or client rules about disclosure.

When something goes wrong, record what the agent was allowed to do and how the problem got through. The fix is usually a tighter permission, a missing test or a clearer instruction, and each of those protects human mistakes too.

Written for 4ArtificialIntelligence with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 46 articles in AI Agents and Coding Assistants →

Latest news on this topic