Safeguard
Application Security•

Writing code with a security-aware agent: Safeguard Code and the runner

Safeguard Code is a local coding agent that writes and refactors securely by default. Here is how the runner, permission modes and review commands fit together.

Safeguard Security Team
4 min read

Coding agents write a lot of code quickly. Some of it will pull in an outdated dependency, hardcode a token or skip a check. The sensible response is not to stop using agents. It is to put a security-aware one in the loop and keep a human on the approval button.

Safeguard Code is a local coding agent that writes and refactors securely by default. It runs on your machine through the runner. This post covers how it works as documented, and how to keep control of it. We are not going to claim benchmark numbers, because there are none to cite.

What it is

Safeguard Code runs locally. The agent works on code in your workspace, on your machine, through the same runner that is built into the Safeguard CLI. The CLI is sometimes described as like Claude Code for security, because you can ask it for something in plain language and it uses tools to do the work.

The assistant has tools for your local files and for your Safeguard data, and picks whichever the question needs. Examples from the docs:

how many critical vulns do we have
fix the lodash CVE in this repo

It does not replace code review, and you should still read the diff.

How to use it

Start the agent in a repo

cd your-repo
safeguard

Type /login once. Then ask for the change you want. Attach a file with @ so the agent can read it.

For a one-shot request from a terminal:

safeguard agent "fix the critical CVEs in this repository"

Review the working tree

Before you commit anything an agent wrote, ask Safeguard to review it for correctness and security.

safeguard review --help

Run it on the working-tree changes, and run the usual tests as well. Two reviewers are better than one, and the second is a person.

Choose how much it may do alone

Inside the terminal, /permissions selects the approval mode.

ModeBehavior
AskPrompts before every action
AutoApproves known actions, asks for anything new. The default
YoloApproves everything and never asks

The current mode shows in the bar under the input. Tools that change things, such as writing a file, editing code or running a command, ask before they act unless you have chosen otherwise.

For headless use, safeguard exec runs one turn and exits. It defaults to strict mode: nothing is asked, and anything the policy file has not pre-approved is denied. It also refuses to run outside a git repository unless you pass a flag to skip that check. Being inside git means every change is one command from being undone.

Keep the code on your machine

The agent works locally. Source stays on your machine, and only the SBOM and findings are uploaded. If you do not want any model involved in code analysis, the CLI works in Zero AI mode as well.

Pick the model

The /model command shows or switches the model. With no argument it opens a picker. You can also bring your own model.

Good habits with any coding agent

  1. Work on a branch, so nothing lands on main without review.
  2. Keep the permission mode on Ask or Auto while you learn what it does.
  3. Run a scan after the agent finishes, not just before.
  4. Read every diff that touches dependencies, auth or configuration.
  5. Never paste a real secret into a prompt.

Try it yourself

Create a small branch with a deliberately old dependency in the manifest. Run safeguard, sign in, and ask the agent to fix the critical CVEs. Read the diff before accepting it. Then run a scan again and compare the results.

To see what a code scan finds, click through the demo.

Click through it at your own pace, or open it full screen.

Quick check

Which permission mode does safeguard exec use by default?

Strict. Nothing is asked, and anything the policy file has not pre-approved is denied.

Where does the agent's work happen?

On your machine, through the local runner. Source stays there.

Sources

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.