# Keep coding agents safe: production, secrets, packages, permissions

> A practical safety checklist for Claude Code, Codex and other coding agents: keep them away from production and secrets, stop risky deletes, block malicious packages, and get fewer prompts without yolo mode.

Updated November 8, 2026 · https://usecoral.app/guides/agent-safety

To keep coding agents safe, make sure they can’t reach production, never see your real secrets, can’t delete or force push without asking, and can’t install a brand new package unreviewed. Rules in the agent catch most mistakes; the hard limits come from outside it: production keys the agent’s machine doesn’t have, branch protection, and a sandbox.

This is the short version. Each section links to a full guide with settings to paste, as of November 2026. The ready files are in the [coral-safety-kit](https://github.com/lior-pesoa/coral-safety-kit) on GitHub.

## The checklist

| Risk | Do this first |
|---|---|
| Agent touches production | No production keys on dev machines; deploy only from CI |
| Agent deletes your work | A worktree per task, commit first, deny `rm -rf` and force push |
| Agent leaks secrets | Deny reading production env files, `~/.ssh` and cloud credentials |
| Agent installs malware | No install scripts, a 7-day release age, ask before every install |
| Prompts pile up, so you turn on yolo | Auto mode plus the sandbox, not `--dangerously-skip-permissions` |
| Someone on the team turns on yolo | `disableBypassPermissionsMode` in managed settings |

Every public incident so far, with what would have stopped it, is in [When AI coding agents deleted data](https://usecoral.app/guides/ai-coding-agent-incidents). To see what your own settings allow, paste them into the [settings checker](https://usecoral.app/tools/settings-check).

## Production

The agents that deleted production databases, at [Replit in 2025](https://fortune.com/2025/07/23/ai-coding-tool-replit-wiped-database-called-it-a-catastrophic-failure/) and [in a Cursor session in 2026](https://decrypt.co/365897/ai-agent-deletes-startup-database-9-seconds-founder-says), had production access they didn’t need. Separate development and production credentials, keep production keys off the machine the agent runs on, protect `main` with a required review, and deploy from CI after merge. Then deny or ask for deploy commands like `vercel --prod` and `terraform apply` as a second line.

Full guide: [Stop Claude Code from deleting files or touching production](https://usecoral.app/guides/stop-claude-code-deleting-files).

## Deletes and force pushes

Claude Code already asks before deleting critical paths like your home folder, in every mode. For everything else, add deny rules and a `PreToolUse` hook that checks every part of a command, give each task its own git worktree, and commit before big tasks so nothing is more than a `git restore` away.

Full guide: [Stop Claude Code from deleting files or touching production](https://usecoral.app/guides/stop-claude-code-deleting-files).

## Secrets

An agent can read what your account can read. Deny its Read tool on production env files, `~/.ssh` and cloud credentials, add the same folders to the sandbox’s `denyRead`, and start agents from a shell without production secrets in the environment. Commands in the sandbox inherit your environment variables.

Full guide: [Claude Code sandbox: what it covers and what it doesn’t](https://usecoral.app/guides/claude-code-sandbox).

## Packages

npm worms like Shai-Hulud spread through install scripts, and agents install packages without thinking twice, sometimes under names they made up. Turn off install scripts, wait 7 days for new versions (`min-release-age=7`), install from the lockfile, and make every `npm install` and `npx` ask.

Full guide: [Keep AI coding agents from installing malicious npm packages](https://usecoral.app/guides/ai-agents-malicious-npm-packages).

## Permissions and yolo mode

`--dangerously-skip-permissions` runs everything without asking and, in Anthropic’s words, “offers no protection against prompt injection”. Use auto mode for fewer prompts, the sandbox to fence commands in, and allow rules for the commands you approve all day. Save skip-permissions for a container or VM with nothing to lose. For big changes, start in plan mode so nothing is edited until you approve the approach; note that a session started with the bypass flag doesn’t enforce plan mode’s blocks. See [Claude Code plan mode](https://usecoral.app/guides/claude-code-plan-mode).

Full guides: [Is --dangerously-skip-permissions safe?](https://usecoral.app/guides/claude-code-dangerously-skip-permissions), [How Claude Code auto mode works](https://usecoral.app/guides/claude-code-auto-mode) and [Stop babysitting permission prompts](https://usecoral.app/guides/claude-code-permission-prompts).

## For a team

Put shared rules in the repo’s `.claude/settings.json` so everyone gets them, and the rules nobody may loosen in managed settings: `permissions.deny`, `disableBypassPermissionsMode`, and `allowManagedPermissionRulesOnly` if you want only your rules to count. Review changes to `.claude/` in pull requests like code.

## What agent rules can and can’t do

Rules and hooks in Claude Code match what a command says, so `bash -c`, a script or a renamed binary can get past them. They stop the common mistakes, which is most of what goes wrong. They don’t stop a determined attacker. For that you need limits outside the agent: no production keys, branch protection, the sandbox, a container.

## Where Coral fits

Safe settings mean more questions from your agents, and each question waits until you notice it. [Coral](https://usecoral.app/features) shows every permission request from Claude Code, Codex and other agents in your Mac’s notch, with the full command, and you answer with one key. Free on your Mac; answering from your iPhone straight to the agent is [Pro](https://usecoral.app/pricing).

Coming in Coral Terminal: a production fence, Guard for risky commands with the real impact in plain words, and package rules per agent.

## Questions

### Is it safe to let AI coding agents run commands?

With limits, yes. Keep the agent away from production and real secrets, make it ask before deleting, pushing or installing, and run long unattended tasks in a sandbox or container.

### How do I stop an AI agent from deleting my production database?

Don’t give the machine it runs on a production credential. Use separate development keys, deploy from CI, and keep backups the app’s own token can’t delete. Then add deny rules for deploy and database commands.

### What is the safest way to run Claude Code?

Auto mode or Manual mode, the sandbox on, deny rules for production files and force pushes, a git worktree per task, and no production keys on the machine. Use `--dangerously-skip-permissions` only inside a container or VM.

### Do these settings work for Codex too?

The ideas do: no production keys, branch protection, no install scripts and a release age apply to any agent. The exact settings in these guides are for Claude Code; Codex has its own, covered in [Codex sandbox and approval modes](https://usecoral.app/guides/codex-sandbox).
