Tutorial: Working Safely
Claude Code's approach to AI safety is very good. However, just like a human programmer, it can make mistakes, and when it does they happen very fast. This chapter explains how to keep any agent mistakes contained and recoverable.
Isolation
It is best to run Claude Code in an isolated environment, from which it cannot gain access to sensitive information such as customer data, and from which it cannot access your server infrastructure. In general, you should also not allow Claude Code to push to a remote revision control repository. Keep all its changes local, until fully reviewed and ready to be accepted. Then push manually.
Options for isolating Claude Code include:
- A virtual machine dedicated to agent work, with snapshots made before risky operations.
- A dedicated host if VM overhead isn't acceptable.
- A dedicated user account on your normal machine so the agent doesn't have access to your other credentials and configuration.
Recoverability
Two things make agent mistakes recoverable:
- Continuous backup -- something like Dropbox or iCloud, configured automatically. When you want to revert, you can.
- Revision control with a remote repository the agent can't push to. Set up a VCS-only SSH key for the remote and do remote operations (hg push, git push) manually. This way, even if the agent rewrites local history, the remote is intact.
Asking Claude for help with this is a reasonable approach – the agent is good at suggesting concrete environment setups suited to your needs and risk tolerance. The risks from using AI agents mostly do not stem from the agent being malicious, but rather simply as a natural side-effect of mistakes and misunderstandings that may occur during the development process.
