MobileVibe MobileVibe Blog
Agents

Refactoring 10k Lines with Codex: Running Large Tasks Unattended

By · August 25, 2026 · 11 min read

Refactoring 10k Lines with Codex: Running Large Tasks Unattended

Refactoring 10k Lines with Codex: Running Large Tasks Unattended

Quick answer

You can start a large refactor with Codex CLI on your desktop, let it run overnight, and monitor progress from your phone. MobileVibe keeps the Codex conversation reachable so you can approve changes, handle rate limits, and review diffs without sitting at your machine—your code and history stay on your own computer.

Key takeaways

  • Codex CLI is built for unattended work: it runs headless, handles long tasks, and keeps a local conversation history you can resume.
  • MobileVibe makes the session mobile: start the refactor on your desktop, check progress from your phone, approve changes, and handle blockers remotely.
  • Rate limits and re-auth happen: Codex may pause for quota or credentials; MobileVibe notifies you so you can unblock it without rushing back to your desk.
  • Review before committing: a 10k-line diff needs a real desktop review; use your phone to triage what’s safe to merge and what needs closer inspection.
  • Parallel lanes for multi-folder refactors: run separate Codex conversations in git worktrees or clones to refactor related projects simultaneously.

Why Codex CLI Excels at Whole-Codebase Refactors

Codex CLI is designed for developers who want to direct an AI agent through a large, multi-step task and let it run without constant supervision. Unlike interactive IDE extensions that expect you to stay in the editor, the CLI runs in a terminal, writes changes to disk, and maintains a conversation history you can resume later. This makes it ideal for codex refactor overnight scenarios: you describe the refactor, approve the plan, and let Codex work through thousands of lines while you’re away.

A typical whole-codebase refactor might involve renaming a core abstraction, migrating a deprecated API, or restructuring a module hierarchy. Codex reads your existing code, proposes changes file by file, and applies them incrementally. Because it runs on your own machine with your real filesystem and terminal, it has access to your build tools, test suite, and git history—no cloud sandbox or remote desktop required.

The CLI’s conversation model is persistent: each exchange is saved locally, so if Codex pauses (rate limit, needs approval, or you stop it), you can resume exactly where it left off. This is the foundation for overnight agent task workflows: start the refactor before bed, check progress from your phone, and wake up to a completed (or nearly completed) changeset ready for review.


Setting Up a Codex Refactor Task That Runs Overnight

To run a large refactor with ai unattended, you need a clear prompt, a clean working directory, and a way to reach the session remotely.

1. Prepare the folder and branch
Create a dedicated branch or git worktree for the refactor. This isolates the changes and makes it easy to review the diff later. Ensure your dependencies are installed and your tests pass on the current code—Codex will use those tests to validate its changes.

2. Start the Codex CLI conversation
Open a terminal in the project folder and run codex. Describe the refactor in detail: what needs to change, which files or patterns to target, and any constraints (e.g., “preserve public API signatures” or “update tests to match”). Codex will propose a plan; review it and approve. The agent will begin applying changes, running tests, and iterating.

3. Pair your desktop with MobileVibe
Install the MobileVibe Desktop Connector (a lightweight native tray app for macOS or Windows). Sign in and pair your machine. The connector creates a private, per-desktop tunnel secured by a short-lived token, making your Codex conversation reachable from your phone or browser. Your code and conversation history stay on your local machine; MobileVibe’s cloud only stores routing metadata.

4. Let it run
Once Codex is working, you can step away. The CLI will continue applying changes, running tests, and logging progress. If it needs approval or hits a blocker, MobileVibe will notify you (push or email, depending on your settings).


Monitoring and Approving Changes from Your Phone

MobileVibe’s mobile UI is a conversation-first inbox: you see which agents need attention, which are still working, and which have finished. Each Codex conversation is tied to a folder, so you can quickly identify the refactor task and check its status.

Real-time progress
Open the conversation on your phone to see Codex’s latest messages: files changed, tests run, errors encountered. The UI shows diffs inline (for small changes) or summarizes large changesets. You can scroll through the history to understand what Codex has done and what it’s planning next.

Approval flows
Codex often pauses to ask for approval before applying a risky change or moving to the next phase. MobileVibe surfaces these prompts in the conversation view. Tap to approve, reject, or send a follow-up instruction. For tasks you trust, you can enable auto-approve (where supported) to let Codex proceed without manual confirmation—useful for overnight runs where you don’t want to wake up to a blocked agent.

Notifications
If Codex hits a rate limit, needs re-authentication, or encounters an error, MobileVibe sends a notification. You can open the conversation, read the blocker, and decide whether to fix it immediately or let it wait until morning. This autonomous refactoring model means you’re not tied to your desk, but you’re never completely out of the loop.


Handling Blockers: Rate Limits, Re-Auth, and Manual Fixes

Even a well-planned codex refactor overnight can hit obstacles. The three most common blockers are rate limits, authentication expiry, and edge cases Codex can’t resolve automatically.

Rate limits
Codex (like most AI coding agents) has usage quotas. If you hit the limit mid-refactor, Codex pauses and logs the error. MobileVibe notifies you. From your phone, you can see how much work is left and decide whether to wait for the quota to reset (usually hourly or daily) or upgrade your Codex plan. Once the limit lifts, resume the conversation with a simple “continue” message—Codex picks up where it stopped.

Re-authentication
If your Codex API token expires or your session times out, the CLI will pause and prompt for credentials. MobileVibe surfaces this in the conversation. You’ll need to return to your desktop to re-authenticate (entering credentials on a phone is not secure or practical). Once you’ve re-authed, the conversation resumes. To minimize this, ensure your Codex credentials are fresh before starting a long task.

Manual fixes
Occasionally, Codex encounters a file it can’t parse, a test it can’t fix, or a merge conflict it doesn’t know how to resolve. It will log the issue and ask for help. From your phone, you can read the error, decide if it’s blocking the rest of the refactor, and send a clarifying instruction (“skip that file for now” or “use this pattern instead”). For complex fixes, you may need to open the file on your desktop, make the change manually, and tell Codex to continue.

These blockers are part of any large refactor with ai. The key is that MobileVibe makes them visible and actionable from anywhere, so a paused agent doesn’t mean a wasted night.


Resuming a Paused Refactor Without Losing Progress

Codex CLI stores conversation history locally in your project folder (typically in a .codex directory or similar). This means you can stop a refactor, close the terminal, restart your machine, and resume exactly where you left off—no lost context, no re-explaining the task.

From your desktop
Open a terminal in the same folder and run codex. The CLI loads the existing conversation and shows the last few messages. Type “continue” or ask Codex to proceed with the next step. It will pick up the plan and keep working.

From your phone
If you’re away from your desktop, open the conversation in MobileVibe and send a message: “continue the refactor” or “apply the next batch of changes.” Codex resumes on your machine, and you see the progress in real time. This is the core of overnight agent task workflows: you don’t need to babysit the terminal, but you can steer the agent remotely when needed.

Handling interruptions
If your machine sleeps or loses network, the Codex CLI pauses. When the machine wakes and reconnects, MobileVibe re-establishes the tunnel, and you can resume the conversation. The local history ensures no work is lost. This resilience is critical for unattended refactors that span hours or overnight.


Reviewing the Diff Before Committing to Main

A 10k-line refactor is too large to review on a phone. Use your mobile device to triage the changes—identify what’s safe, what needs closer inspection, and what might be broken—then do the detailed review on your desktop.

Triage from your phone
MobileVibe shows a summary of files changed, tests passed, and any errors Codex logged. Scroll through the conversation to see Codex’s reasoning: why it changed each file, what patterns it applied, and which tests it ran. Look for red flags: failing tests, unexpected file deletions, or changes to critical modules. If something looks wrong, you can ask Codex to revert a specific change or explain its reasoning.

Desktop review
Once you’re confident the refactor is mostly correct, open the branch on your desktop. Use git diff or your IDE’s diff viewer to inspect the changes file by file. Run the full test suite (Codex may have run a subset). Check that public APIs are preserved, documentation is updated, and edge cases are handled. This is where you catch subtle bugs or style issues that an AI agent might miss.

Iterative fixes
If you find problems, you can ask Codex to fix them: “the tests in auth.test.js are failing—update them to match the new API” or “this function signature changed but the docstring is stale.” Codex will apply the fixes, and you review again. This loop—triage on mobile, review on desktop, iterate with Codex—is how you safely land a large refactor with ai.

Commit and merge
Once the diff is clean, commit the changes with a clear message describing the refactor. Merge to main (or open a pull request if your team requires review). The entire process—start, monitor, fix, review—can span a day or more, but you’re never blocked waiting at your desk.


Multi-Folder Refactors: Running Parallel Lanes

If your refactor spans multiple related projects (a monorepo, a set of microservices, or a library and its examples), you can run parallel Codex conversations in separate folders. MobileVibe calls these “workstreams” or “lanes”—each is a distinct conversation tied to a folder and an agent.

Why parallel lanes
Refactoring a shared library and its dependent services simultaneously ensures consistency: the library’s new API and the services’ updated calls land together. Running them in parallel (rather than sequentially) saves time and reduces the risk of merge conflicts.

Set up with git worktrees or clones
Use git worktree add to create separate working directories for each project, or clone related repos into sibling folders. Start a Codex CLI conversation in each folder, describing the refactor for that project. Each conversation is independent: Codex in folder A doesn’t see folder B’s changes unless you explicitly tell it.

Monitor all lanes from your phone
MobileVibe’s dashboard shows all active conversations. You can see which lanes are progressing, which are blocked, and which have finished. Tap into a conversation to approve changes, handle a blocker, or check the diff. This autonomous refactoring model scales to multiple agents working in parallel, all reachable from a single mobile inbox.

Coordinate changes
If one lane depends on another (e.g., the library must finish before the service can update), you can pause the dependent lane until the first is done. Or, if the changes are independent, let both run overnight and review them together in the morning. MobileVibe’s conversation-first UI makes it easy to juggle multiple lanes without losing track of what each agent is doing.


FAQ

Can I start a Codex refactor on my desktop and check progress from my phone?

Yes. Install the MobileVibe Desktop Connector on your machine (macOS or Windows), pair it, and start your Codex CLI conversation in the project folder. The conversation becomes reachable from your phone, tablet, or browser. You can see Codex’s progress, approve changes, and handle blockers remotely. Your code and conversation history stay on your own computer; MobileVibe’s cloud only stores routing metadata.

What happens if Codex hits a rate limit or needs re-authentication mid-refactor?

Codex pauses and logs the error. MobileVibe notifies you (push or email). From your phone, you can see the blocker and decide whether to wait for the quota to reset or take action. For re-authentication, you’ll need to return to your desktop to enter credentials (never send passwords through email or mobile). Once unblocked, send a “continue” message and Codex resumes exactly where it stopped.

How do I safely review a 10k-line refactor before merging it?

Use your phone to triage: check the conversation summary, see which files changed, and look for failing tests or unexpected changes. Then, open the branch on your desktop and review the full diff with git diff or your IDE. Run the complete test suite. If you find issues, ask Codex to fix them and review again. Only commit and merge once you’re confident the refactor is correct.

Can I run refactors on multiple folders or branches at the same time?

Yes. Start separate Codex CLI conversations in different folders (use git worktree add or clone related repos). Each conversation is independent. MobileVibe’s dashboard shows all active conversations, so you can monitor and control multiple lanes from your phone. This is useful for refactoring a library and its dependent services in parallel.

Does MobileVibe keep a copy of my refactored code in the cloud?

No. Your code and Codex conversation history stay on your own machine. MobileVibe’s cloud stores desktop routing and session metadata (which conversation is active, which folder it’s tied to), but not your project files or raw conversation content. The phone reaches your desktop through a private, per-desktop tunnel secured by a short-lived token.

What’s the difference between using Codex CLI and the Codex IDE extension for large refactors?

Codex CLI runs headless in a terminal and is designed for long, unattended tasks. It saves conversation history locally, so you can resume after interruptions. The Codex IDE extension runs inside an editor and expects you to stay in the UI. For codex refactor overnight workflows, the CLI is the better choice: it’s built to run without supervision, and MobileVibe makes it reachable from your phone. The IDE extension is better for interactive, short-lived tasks where you want inline suggestions and immediate feedback.


Running a large refactor with ai doesn’t mean you’re stuck at your desk. With Codex CLI and MobileVibe, you can start a 10k-line refactor, let it run overnight, and check progress from your phone—approving changes, handling blockers, and reviewing diffs on your own schedule. Your code stays on your machine, your agent keeps working, and you stay in control from anywhere. Ready to try it? Start free at MobileVibe and refactor your next codebase from your phone.

Related

Ship real work from your phone

Start tasks, monitor AI agents, and stay in control from anywhere.

Start for Free →