How to let an AI edit your code without losing work
· 4 min read
An AI coding assistant can write a function in seconds, and an AI agent can go further: edit several files, run the tests, and fix what fails. The speed is real. So is the ability to damage a project quickly, which is why a few habits matter more here than almost anywhere else.
Start with a safety net
- Use version control. Commit your work before the assistant touches anything. If a change goes wrong, one command returns you to a known state.
- Work on a branch. Keep the assistant's changes away from your main line until you have read them.
- Keep backups of anything not in version control, such as data files and local configuration.
- Run it somewhere disposable when you can. A separate folder, a container, or a virtual machine limits what a mistake can reach.
Keep each task small
Large requests produce large changes that are hard to review. "Add input validation to this one function and a test for it" is reviewable in minutes. "Refactor the project to use a new architecture" is not. If a task is big, ask for a plan first, read it, correct it, and then have the assistant do one step at a time.
Review the change, not the claim
An assistant's summary of what it did is a description, not proof. Read the actual diff.
- Does it change only what you asked about? Unrequested edits to other files deserve a question.
- Does it remove anything? Deleted code, tests, or checks are a red flag, especially a removed test that was failing.
- Does it add dependencies? A new package is code you now rely on. Check that it exists, is maintained, and is what you meant. Assistants sometimes name packages that do not exist.
- Does it handle the edge cases? Empty input, large input, and errors are where generated code is often thin.
- Is anything sensitive in it? Keys, passwords, and internal addresses should not appear in code or logs.
Let tests do the checking
Run the tests yourself, and add one for the behavior you wanted before you accept the change. If the assistant writes both the code and its tests, read the tests too, since a test can pass without checking anything useful. Where there are no tests, a short manual check of the exact scenario you asked for is the minimum.
Control what it can do
- Approve commands one at a time. The approval should show the exact command and its arguments. "Allow terminal access" is too broad to be a decision.
- Keep production credentials out of reach. Use test keys and a copy of the data. An assistant that cannot reach production cannot break it.
- Limit the folder. Give access to the project directory, not your home directory.
- Be wary of anything that runs unattended. Commands that delete, overwrite, deploy, or message other people deserve a person in the loop.
When the assistant is wrong
It will be, sometimes, and with confidence. If the same fix fails twice, stop and look at the cause yourself or start a fresh conversation with the error and a clear description. Long, tangled conversations push the original instructions out of the context window, as explained in what a context window is, and a clean start often beats another correction.
Quick answers
Should an AI commit straight to my main branch? No. Have it work on a branch, read the diff, run the tests, and merge it yourself.
How do I stop it deleting tests to make them pass? Read the diff for removed lines, and require tests to run before anything is merged. Say plainly that failing tests must be fixed, not removed.
Is it safe to give it my API keys? Use scoped, revocable test keys, keep them in the environment instead of in code, and never hand over production credentials.
Do I need to understand generated code? Yes. Treat it like code from any unfamiliar source: understand it, test it, and follow your organization's policy on using it.
Where NAMELESS stands
NAMELESS is an AI model that is still in training. Its agent workspace includes a code mode designed around these habits: shell commands and writes to a connected device wait for your approval, the approval is tied to the exact call, and an uncertain result is reported as a failure instead of being run again automatically. The workspace is for accepted early-access accounts and needs a connected model service, so this is a description of the design, not a measured result. Path checks and a reduced environment are not an operating-system sandbox, so for stronger isolation use a dedicated virtual machine.
You can join the waitlist to follow progress. For the general principles, read why an AI agent should ask before it acts, and for how agents differ from chatbots, AI agents vs. chatbots.