A request like "tidy up the login page and add a password reset feature" can make a coding agent touch twenty files in just a few minutes. If the result works, great. If the application fails to open, the question remains: how do you revert to the last stable version?
There are three layers of protection. Each one patches a different hole.
Checkpoint in Claude Code: fast, but limited
Claude Code saves the state of files before each prompt you send. Type /rewind, or press Esc twice when the input field is empty, then select the target point. You can restore the code only, the conversation only, or both.
The limits are often exceeded. According to its official documentation:
- Files changed only via Bash commands are not tracked and are left as is.
- Changes you make outside of Claude Code, or from other concurrent sessions, are usually not captured.
- Sub-agent edits generally do not get restored.
- Actions on remote systems, such as databases, APIs, and deployments, cannot be checkpointed.
Anthropic itself refers to checkpoints as quick recovery at the session level, not a substitute for version control like Git.
Codex: sandbox, approvals, and review panel
OpenAI's Codex puts the brakes on. Through sandbox mode (read-only, workspace-write, danger-full-access) and approval policies, you limit the agent's actions before it starts working. For folders already using Git, the documentation recommends the Auto preset: the agent can edit in the working folder but must ask first before touching files outside that folder or using the network. For folders without version control, the recommendation is read-only.
In the Codex application, the review panel displays the diff from your Git repository, including changes not made by Codex. You can accept some through staging, or discard per file, even per code snippet, through revert. This panel only works if your project is already a Git repository.
The Codex documentation is also clear: Codex works best with version control workflows, and you are advised to commit often so you can roll back gradually.
Git: the real safety net
Both tools above rely on Git. The basic habits are straightforward:
- Commit before major requests. Run
git statusto ensure there are no pending changes, thengit add .andgit commit -m "before password reset feature". - See what has changed.
git diffshows changes that are not yet staged, whilegit diff HEADshows all changes since the last commit. If you are not used to reading it, ask the agent to explain the diff in simple terms. - Revert safely.
git revertundoes the effects of an old commit by creating a new commit, so your history remains intact. To discard all uncommitted changes, Git documentation points togit reset --hard. Be careful, this command deletes those changes permanently.
Code can roll back, data cannot
Restoring files does not restore database contents. If the agent has run migrations that delete columns, the data in those columns is lost. Neither rewind nor git revert will bring it back.
For deployed databases, Supabase recommends a forward approach: restore the schema file, then create a new migration containing the opposite. Supabase also warns that such rollback SQL is usually destructive, so it must be carefully checked, and production versions should not be reset. Prisma documentation gives a similar message: dropped columns lose their contents forever, so back up the data first if it is still needed.
Checklist before hitting Enter
- The project is already a Git repository and
git statusis clean. - There is a clearly worded commit right before the major request.
- The request is broken down into small parts, one feature per commit.
- You know when the agent uses Bash, sub-agents, or touches the database. That part is not covered by checkpoints.
- Migration files are read first before running, and important data has been backed up.
- The diff has been reviewed before the next commit.
Checkpoints and review panels speed up the rollback process. Git ensures you always have a place to return.
Sources
- Checkpointing, Claude Code Docs (Anthropic): https://code.claude.com/docs/en/checkpointing
- How Claude Code works, Claude Code Docs (Anthropic): https://code.claude.com/docs/en/how-claude-code-works
- Agent approvals & security, OpenAI Codex Docs: https://developers.openai.com/codex/agent-approvals-security
- Review, OpenAI Codex Docs: https://developers.openai.com/codex/app/review
- git-diff Documentation, Git: https://git-scm.com/docs/git-diff
- git-revert Documentation, Git: https://git-scm.com/docs/git-revert
- Declarative database schemas, Supabase Docs: https://supabase.com/docs/guides/local-development/declarative-database-schemas
- Rollbacks and recovery in Prisma ORM, Prisma Docs: https://www.prisma.io/docs/orm/migrations/rollbacks-and-recovery