Login / Register ID | EN
This page has no official English version. It was translated automatically and may contain errors. Read the original in Indonesian →
Agen Coding Mengubah Puluhan Berkas Sekaligus: Cara Mundur Kalau Hasilnya Rusak
Foto: Pexels
IT AI

Coding Agent: Changing Multiple Files at Once: How to Roll Back if the Results are Damaged

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:

  1. Commit before major requests. Run git status to ensure there are no pending changes, then git add . and git commit -m "before password reset feature".
  2. See what has changed. git diff shows changes that are not yet staged, while git diff HEAD shows all changes since the last commit. If you are not used to reading it, ask the agent to explain the diff in simple terms.
  3. Revert safely. git revert undoes the effects of an old commit by creating a new commit, so your history remains intact. To discard all uncommitted changes, Git documentation points to git 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 status is 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