Relay365Multi-model API relay desk
← All desk bulletins
Agent shift notesEN655 desk reads

Using Claude Code for Safe Overnight Migrations

#1 · Define the migration boundary

Before Claude Code changes anything, write down exactly what the batch migration should touch. Identify the source files or records, the target format, the expected number of items, and the directories or services that must remain unchanged. A narrow boundary makes review and rollback possible.

Describe the desired result in plain language, then turn it into acceptance checks. For example: every affected configuration file must parse successfully, no production credentials may change, and the migration must be safe to run twice. Claude Code performs better when the task has explicit constraints instead of a broad instruction such as “upgrade the project.”

#2 · Start from a clean, recoverable workspace

Use a dedicated branch or a disposable working copy. Record the current commit, confirm that the working tree is clean, and make sure the repository can be restored from version control or a tested backup. Do not begin an unattended migration with uncommitted user work mixed into the same directory.

Run the existing test suite and capture its result before making changes. This gives you a baseline for distinguishing pre-existing failures from migration regressions.

#3 · Prepare a precise Claude Code prompt

Give Claude Code a staged request. Ask it to inspect the repository first, summarize the affected files, identify risks, and propose commands. Then require it to wait for approval before editing. Include the migration rules, forbidden paths, validation commands, and the definition of success.

For an overnight batch, explicitly prohibit destructive commands, credential changes, network uploads, and unrelated refactoring. Ask the agent to create a migration log containing each changed path, the reason for the change, and any item it could not process confidently.

#4 · Separate discovery from execution

Have Claude Code produce a dry-run report before applying changes. The report should include the number of candidate files, representative samples, skipped files, and any ambiguous cases. Review this output during the day, when you can investigate unexpected matches.

If the migration depends on a model, choose one that matches the work. Claude Haiku 4.5 may suit straightforward classification or formatting, while Claude Sonnet 5.5 can be appropriate for more involved code reasoning. Keep prompts deterministic where possible, and make the agent preserve an audit record rather than silently guessing.

#5 · Add checkpoints and bounded batches

Do not process an unlimited repository in one session. Divide the work into small, independently verifiable batches. After each batch, run parsing checks, targeted tests, and a diff review. Persist a checkpoint so a restart continues from the last confirmed item instead of repeating the entire job.

Set practical limits for runtime, changed files, retries, and API spending. A batch that exceeds those limits should stop and report the condition. Automatic continuation is useful only when the stopping rules are clear.

#6 · Protect the overnight environment

Use a service account with the minimum permissions needed for the migration. Store credentials outside the repository, redact secrets from logs, and disable access to unrelated production systems. Pin the intended repository revision and configuration before starting.

Run the job in a controlled environment such as a container or isolated worker. Capture standard output, errors, exit codes, timestamps, and the final commit or artifact identifier. Configure the scheduler to fail closed: a lost dependency, malformed response, or unexpected file type should stop the batch rather than trigger broad fallback behavior.

#7 · Monitor without requiring constant attention

Set up alerts for process failure, repeated retries, unusually large diffs, validation failures, and inactivity. A successful process exit is not enough; the post-run checks must confirm that the output is correct. Keep a compact status file that records completed, skipped, failed, and pending items.

#8 · Review the results in the morning

Start with the summary, then inspect the complete diff and migration log. Run the full test suite, format and lint checks, schema validation, and any application-level smoke tests. Compare counts against the dry-run report. Treat skipped or uncertain items as a review queue, not as successful migrations.

#9 · Use a measured rollback path

Before accepting the changes, verify that reverting the branch or restoring the generated artifact returns the system to the known baseline. For data migrations, test the rollback procedure on a representative copy first. Never rely on an untested assumption that the migration can be reversed.

#10 · Choose a reliable model access path

When the migration needs Claude Code and predictable pay-as-you-go access across model families, Relay365 can be a practical option. It supports Claude Code, Codex, Gemini CLI, and OpenAI SDK clients through the API base https://api.api365relay.com; OpenAI clients add /v1. You can select models such as Claude Sonnet 5.5 or compare another supported family without redesigning the workflow. Members can also earn a referral bounty when invited users pay. Create a Relay365 account once the safety plan, limits, and review process are ready, then keep the migration itself governed by the checkpoints above.

Further desk bulletins

Curious how it runs on your own code? Sign up →