VibeSecurity

Platform checklist

Securing code written with Claude Code: a review checklist

Claude Code is an agent that edits files and runs commands in your own repository. That gives you two things to review: what the agent is allowed to do on your machine, and whether the code it wrote is safe to ship. This checklist covers both and ends with settings you have read and tests you have run.

By the VibeSecurity team7 min read

What Claude Code does and where the trust boundary is

Claude Code does not host your app or choose your stack. It works in the folder where you start it, reads your files, proposes edits and runs shell commands. Anthropic's security documentation describes a permission-based design: in Manual mode it starts with read-only permissions and asks before editing files or running commands that can change your system, and it can only write inside the folder where it was started and its subfolders. Other permission modes change which actions prompt you, so confirm which mode your sessions actually start in.

There are two trust boundaries. The first is between the agent and your machine: every command you approve runs with your user account's access to files, credentials and the network. The second is the normal one for any app: whatever the generated code ships to a browser is public, and only server-side checks protect data. Claude Code can write either kind of code well or badly, and nothing about the tool moves the boundary for you.

The documentation states the responsibility plainly. Claude Code only has the permissions you grant it, and you are responsible for reviewing proposed code and commands for safety before approval. It also says that while its protections reduce risk, no system is completely immune to all attacks.

The review checklist

Run every row against your own repository and record the result.
AreaWhat to verifyHow to test on your own projectPass condition
Permission rulesAllow rules are narrow and you know what each one permits.Run /permissions in a session and read every allow, ask and deny rule, including those in checked-in settings.No broad allow rule for shell commands you would not run unread, such as network or cloud CLI commands.
Sensitive filesEnv files and credential folders are covered by deny rules.Open .claude/settings.json and compare it with the example below.Deny rules exist for your env files and secret folders, and you understand their limits.
Skipping promptsSessions that skip permission prompts run only in an isolated environment.Check how you and your team launch Claude Code, including scripts and CI.bypassPermissions mode is used only inside a container or VM, or is disabled in settings.
MCP serversEvery configured MCP server is one you chose and trust.List the MCP servers in your project and user settings and remove any you cannot account for.Each server has a known owner and a reason to be there.
Secrets in the repositoryNo secret was written into source, config or history during a session.Search the working tree and git history with the commands below.No hits, or every hit has been rotated.
Authorisation in generated codeEvery route and server function checks who is calling and whether they own the record.Call each endpoint with no session, then as a second test user with the first user's record id.Anonymous calls are refused and the second user gets nothing of the first user's.
Review of changesSecurity-relevant diffs were read by a person before merge.Read the diff for auth, payments, file upload and database code. Optionally run /security-review on the branch.A named person has read those diffs, and findings were fixed or consciously accepted.
DependenciesPackages the agent added are real, maintained and free of known vulnerabilities.Read the lockfile diff and run your package manager's audit command.Every new package is one you recognise, and the audit shows nothing unaddressed.

Keep secrets out of the agent's reach

Claude Code reads permission rules from settings files, and the documentation says rules are evaluated in the order deny, then ask, then allow, so a deny rule cannot be overridden by a narrower allow rule. A Read deny rule blocks Claude's file tools from reading a path. The example below follows the documented pattern syntax. Put it in .claude/settings.json so it is shared with everyone who clones the repository.

.claude/settings.json
{
  "permissions": {
    "deny": [
      "Read(.env)",
      "Read(.env.*)",
      "Read(secrets/**)"
    ]
  }
}

Commands to run on your own repository

The first two lines are typed inside a Claude Code session. Anthropic documents /security-review as an on-demand security pass over the changes on your current branch, and notes that it reads source code rather than a running site. The rest run in your normal terminal. Adjust the secret patterns to the providers you use and the audit command to your package manager.

Session commands and repository searches
/permissions
/security-review

git ls-files | grep -E "\.env|\.pem$|credentials"
grep -rnE "sk_live_|sb_secret_|service_role|BEGIN PRIVATE KEY" --exclude-dir=node_modules --exclude-dir=.git .
git log --all -p -S"sk_live_" | head -50
npm audit

Judging the code it writes

An agent optimises for the task you gave it. If you asked for a working dashboard, you will get one, and the question of who else can load that data may never have come up. Read generated code for three habits: the server checks the session before doing anything, the user id comes from the verified session and never from the request body, and queries are scoped to the current user or their organisation. OWASP describes the missing version of that last check as an insecure direct object reference.

Anthropic publishes a security guidance plugin that has Claude review its own changes for common vulnerabilities during a session. Its documentation is careful about limits: none of its layers block writes or commits, the review model can miss issues, and it should be treated as one layer of defence in depth, not a complete security solution. Use it if it suits you, and keep the outside-in tests regardless.

Be careful with untrusted input. The documentation's advice for prompt injection includes reviewing suggested commands before approval, avoiding piping untrusted content directly to Claude, and verifying proposed changes to critical files. A web page, an issue comment or a dependency's README can all contain instructions aimed at the agent.

Common mistakes with this workflow

  • Approving commands without reading them because the last twenty were fine.
  • Choosing always allow for a broad shell pattern to stop the prompts.
  • Running with permission prompts skipped on a laptop that holds cloud credentials. The docs say to use that mode only in isolated environments like containers or VMs.
  • Pasting a live API key into the chat so the agent can test something. Rotate any key that has been in a prompt, a file or a commit.
  • Letting the agent fix a failing test by loosening an authorisation check, a database policy or a CORS rule.
  • Adding an MCP server from an unknown source. Anthropic says it does not security-audit or manage any MCP server.
  • Treating a clean automated review as proof. It reads code, not your deployed app.

Keep it working

Review permission settings whenever they change in a pull request, since they are part of your security configuration. Repeat the secret searches and the two-account test before each release. Pass condition: the agent cannot read your secret files through its file tools, no secret appears in the repository or its history, and the finished app refuses anonymous and cross-user requests.

Frequently asked questions

Is Claude Code safe to use on my codebase?

It is as safe as the permissions you grant and the commands you approve. Anthropic's documentation says Claude Code only has the permissions you grant it and that you are responsible for reviewing proposed code and commands. Use deny rules for sensitive files and consider a sandbox or dev container for extra isolation.

Does Claude Code write secure code?

Not by guarantee. It can write careful code and it can also leave out an authorisation check, like any author. Anthropic's own documentation for its security guidance plugin says the review model can miss issues and that it is not a complete security solution. Test the running app from outside.

Can Claude Code read my .env file?

Yes, unless you stop it. Files inside the working directory are readable by default. A Read deny rule blocks Claude's file tools from a path, but the documentation warns that such rules do not cover every way a shell command or script could read a file. Use the sandbox for stronger enforcement and keep production secrets elsewhere.

Should I skip permission prompts to work faster?

Only in an isolated environment. The permissions documentation says bypassPermissions mode skips permission prompts and should only be used in isolated environments like containers or VMs where Claude Code cannot cause damage. It can also be disabled in settings.

Does /security-review replace a security test?

No. Anthropic describes it as a one-time security pass over the changes on your current branch, and says the review reads the source code in your checkout, not a running site or deployed service. Combine it with tests against your own deployed app.

Sources

  1. 1.Claude Code docs: Security
  2. 2.Claude Code docs: Configure permissions
  3. 3.Claude Code docs: Sandboxing
  4. 4.Claude Code docs: Security guidance plugin
  5. 5.OWASP Cheat Sheet: Insecure Direct Object Reference Prevention
  6. 6.OWASP Cheat Sheet: Secrets Management