Overview
Use Codex for tightly scoped code refactors in a local repository and for maintenance chores on a server you reach over SSH, with command approvals kept on.
Problem or Objective
More in Coding and Code Review
AI Agents and Models
Tools and Integrations
- Tools
- Codex CLI · ChatGPT desktop app · OpenSSH
- Prerequisites
- A ChatGPT account with Codex (included across ChatGPT plans; usage limits vary by plan). For host work: the ChatGPT desktop app, an SSH host in your SSH config, and Codex installed and signed in on that host. Check that remote connections are available on your plan and workspace.
How It Works
Install Codex CLI on your computer and open the repository you want changed. Give Codex one narrow refactor at a time (one module, one rename, one pattern), ask it to run the existing tests, and review the diff before you commit anything yourself. Before the first run, use the permissions setting to make Codex ask before it edits files or runs commands. For server chores, add the machine to your SSH config, confirm a plain SSH login works, install and sign in to Codex on that host, then add it under Settings > Connections in the ChatGPT desktop app and choose a project folder there. Describe the chore (for example rotating logs or updating a package), ask Codex to explain each command first, and approve each one before it runs. Use a least-privilege account on the host rather than root.
Implementation Workflow
Steps assembled from the agents, tools and prompt of this entry. Adapt them to your own setup.
- Choose the agentSet up Codex CLI.
- Connect the toolsConnect the tools this workflow relies on: Codex CLI, ChatGPT desktop app, OpenSSH.
- Check the prerequisitesA ChatGPT account with Codex (included across ChatGPT plans; usage limits vary by plan). For host work: the ChatGPT desktop app, an SSH host in your SSH config, and Codex installed and signed in on that host. Check that remote connections are available on your plan and workspace.
- Gather your detailsCollect what the prompt asks for: Repository folder, The one refactor to make, SSH host alias from your SSH config, Maintenance chore.
- Run the starter promptPaste the starter prompt below into Codex CLI and adapt it to your case.
- Check against the documentationCompare what you get with the documentation at github.com before you rely on it.
Practical Starter Prompt: Run one scoped refactor and one host chore
Fill the fields to adapt the prompt. Empty fields stay as visible [placeholders].
Work in [Repository folder]. Refactor only [The one refactor to make]; do not touch other files. Run the existing tests and show me the diff and test output, then stop: I will commit myself. Next, on the SSH host [SSH host alias from your SSH config], plan this chore: [Maintenance chore]. List each command you intend to run and what it changes, then wait for my approval before running each one. Stop and report if anything fails.Set Codex to ask before editing files or running commands before the first run. Approve each host command only after reading it, and commit the refactor yourself after reviewing the diff and tests.
Expected Results and Benefits
This is a suggested workflow, not a reported result. The points below are what the cited documentation says the tools can do.
This is a suggested workflow, not a reported outcome. The Codex docs support running a local coding agent, choosing when it may edit files or run commands without asking, and opening a project on an SSH host where chats run commands and write changes on that host. They do not promise that any particular refactor or maintenance chore succeeds, and nothing here measured how often it does.
Limitations and Considerations
Keep approvals on for any command that changes a server: restarting services, deleting files or changing packages can take a machine offline. The remote connections page asks you to keep the host on trusted keys, least-privilege accounts and no unauthenticated public listeners. Have a backup or snapshot and a way back in before you let Codex touch a production host. Usage limits vary by plan; check whether the remote connection features are available on your plan and workspace. Review every diff yourself before committing. Results depend on your setup and were not independently reproduced by Top 200 Repos.
GitHub Repositories
AI Agent Repository
Source code of the agent that does the work.
Official Website
The official site of the main tool or project in this use case.
Visit Website (opens in a new tab)developers.openai.com
Related Videos
About openai/codex
Meet the New Codex CLI (opens in a new tab)
Published by the project’s official channel.
Watch on YouTube (opens in a new tab)Independent creators. Listing a video implies no endorsement, sponsorship or partnership.
Sources
- openai/codex README (opens in a new tab)
Project documentation · github.com · Undated · Source checked 25 Nov 2026, 11:59 UTC
What this source supports
- Codex CLI is a coding agent from OpenAI that runs locally on your computer.
- Codex CLI | ChatGPT Learn (opens in a new tab)
Project documentation · developers.openai.com · Undated · Source checked 25 Nov 2026, 12:11 UTC
What this source supports
- Choose when Codex can edit files or run commands without asking, and inspect the active sandbox and writable roots before you continue.
- Remote connections | ChatGPT Learn (opens in a new tab)
Project documentation · developers.openai.com · Undated · Source checked 27 Nov 2026, 10:59 UTC
What this source supports
- Remote project chats run commands, read files, and write changes on the remote host.
- Keep the remote host configured with the same security expectations you use for normal SSH access: trusted keys, least-privilege accounts, and no unauthenticated public listeners.
- Using Codex with your ChatGPT plan | OpenAI Help Center (opens in a new tab)
Project documentation · help.openai.com · Undated · Source checked 26 Nov 2026, 17:27 UTC
What this source supports
- Codex is included across ChatGPT plans, including Free and Go.
