Building a CLI Tool in One Evening with Codex: A Real Session
By MobileVibe Team · August 30, 2026 · 9 min read
Building a CLI Tool in One Evening with Codex: A Real Session
Quick answer
You can build and ship a working CLI tool in a single evening using Codex CLI by starting a conversation in your project folder, directing the agent through approval loops, and letting it handle scaffolding, logic, and testing while you monitor progress—even from your phone when you step away.
Key takeaways
- Codex CLI excels at fast prototyping: it scaffolds projects, writes boilerplate, and iterates quickly without leaving the terminal
- One conversation, one folder: start a Codex session in your project directory and let the agent own the build from setup to tests
- Approval loops keep you in control: review diffs, approve file changes, and redirect when Codex drifts off scope
- Mobile monitoring matters: check progress, unblock quota hits, and approve changes from your phone using MobileVibe while the agent runs on your real desktop
- Ship before bedtime: with clear scope and tight iteration, you can go from idea to working CLI in 3-4 hours
Why Codex CLI Is the Right Tool for Fast Prototyping
When you want to build cli with codex in a single evening, the CLI is the right surface. Codex CLI runs headless in your terminal, handles file operations natively, and doesn’t require an IDE window open. It’s built for developers who want to start a task, approve changes as they come, and let the agent handle the repetitive work—scaffolding, dependency management, error handling, and test setup.
Codex CLI shines when:
- You have a clear, bounded scope: “build a CLI that parses JSON logs and outputs markdown summaries”
- You want the agent to own the file tree: Codex reads your folder, proposes changes, and applies them after approval
- You’re comfortable with approval loops: you review diffs, say yes or no, and redirect when needed
- You might step away: the session keeps running on your desktop, and you can check in from your phone to unblock it
Codex CLI is not a magic wand—it needs direction, clear constraints, and occasional course correction. But for a codex cli tool tutorial that ships real code in hours, it’s hard to beat.
Setting Up Codex CLI on Your Desktop
Before you start your first conversation, install and authenticate Codex CLI on macOS or Windows.
macOS (Apple Silicon or Intel):
brew install openai/tap/codex-cli
codex auth login
Windows 10+:
Download the installer from OpenAI’s Codex CLI releases page, run it, then open PowerShell or Command Prompt:
codex auth login
The auth login command opens a browser to authenticate with your OpenAI account. Once authenticated, Codex CLI stores a token locally and you’re ready to start conversations.
Check your setup:
codex --version
codex auth status
If you see your account email, you’re good to go. Codex CLI uses your OpenAI API quota—check your usage limits before starting a long session.
Starting Your First Conversation: Folder, Agent, and Scope
A Codex conversation is tied to a folder. Navigate to your project directory (or create one) and start the agent:
mkdir my-cli-tool
cd my-cli-tool
codex start "Build a CLI that reads JSON log files and outputs markdown summaries. Use Node.js, support stdin and file paths, include tests."
That single command:
- Creates a new conversation in the current folder
- Sends your prompt to Codex
- Starts the agent, which will propose file changes, run commands, and ask for approval
Scope matters. A tight, specific prompt gets you to a working tool faster than “build a CLI for logs.” Include:
- Language/runtime: Node.js, Python, Go, Rust
- Core behavior: what the tool does, what inputs it accepts
- Output format: JSON, markdown, plain text
- Testing expectation: “include unit tests” or “add a test script”
Codex will scaffold a project structure, write initial files, and present a diff for approval. Review it, approve if it looks right, or ask for changes.
Directing Codex Through Approval Loops and Iteration
Codex CLI works in approval loops. The agent proposes changes, you review the diff, and you approve or reject. This is where you stay in control and keep the build on track.
Typical loop:
- Codex proposes a file change (new file, edit, or delete)
- You see a diff in the terminal
- You type
yto approve,nto reject, oreto edit the prompt and redirect
Example:
Codex: I'll create src/parser.js to handle JSON parsing.
Diff:
+ const fs = require('fs');
+ function parseLog(filePath) { ... }
Approve? (y/n/e):
Type y and Codex applies the change. Type n and it skips that file. Type e and you can refine the instruction: “use async/await instead of callbacks.”
When to redirect:
- Codex adds dependencies you don’t want (e.g., a heavy framework for a simple script)
- The code structure drifts from your mental model
- Tests are missing or incomplete
- Error handling is too generic
Redirection is cheap—just type e, clarify the constraint, and let Codex iterate. A codex command line project moves fastest when you catch drift early and steer back.
Parallel work: if you need multiple features, start separate conversations in different folders (or use git worktrees). Codex CLI doesn’t share state across conversations, so each one is independent.
Testing and Shipping Your CLI Before Bedtime
Once Codex has scaffolded the tool and written the core logic, direct it to add tests and a runnable script.
Prompt for tests:
Add unit tests for the parser and CLI entry point. Use Jest. Include a test script in package.json.
Codex will create a __tests__ folder, write test cases, and update package.json. Review the diff, approve, and run the tests:
npm test
If tests fail, paste the error back into the conversation:
Tests failed with "TypeError: parseLog is not a function". Fix the import in the test file.
Codex will propose a fix, you approve, and tests pass.
Shipping checklist:
- CLI entry point works:
node src/index.js --helpornpm start - Tests pass:
npm testexits 0 - README exists: Codex can write one if you ask: “Add a README with usage examples”
- Dependencies are minimal: review
package.jsonand remove anything unused
By the time you’ve iterated through 3-4 approval loops, you should have a working CLI. If you started at 7pm, you’re shipping by 10pm.
Monitoring Your Build from Mobile While You Step Away
Real life happens—you step away for dinner, a call, or to put kids to bed. Your Codex session keeps running on your desktop, but you want to know if it’s blocked, hit a quota, or needs approval.
This is where MobileVibe fits. Install the Desktop Connector on your Mac or Windows machine, pair it with your MobileVibe account, and your Codex conversations become reachable from your phone.
What you can do from mobile:
- Check conversation status: see if Codex is waiting for approval, still working, or hit a rate limit
- Approve changes: review diffs and approve file operations from your phone
- Unblock quota hits: if Codex pauses due to API limits, you’ll get a notification and can resume or adjust scope
- Start a new conversation: email a task to a folder and Codex starts working while you’re away from your desk
Example flow:
- You start a Codex conversation at your desk: “Build a CLI that converts CSV to JSON”
- You step away for 30 minutes
- MobileVibe notifies you: “Codex needs approval for src/converter.js”
- You open the conversation on your phone, review the diff, approve
- Codex continues; by the time you’re back at your desk, the tool is done
This is the ship cli tool with ai workflow that makes evening builds realistic. You don’t need to babysit the terminal—just check in when the agent needs you.
Common Codex CLI Pitfalls and How to Avoid Them
1. Vague prompts lead to generic scaffolding
If you say “build a CLI,” Codex will create a basic structure but won’t know what the tool should do. Be specific: “Build a CLI that reads JSON logs from stdin, filters by log level, and outputs markdown tables.”
2. Approving too fast without reading diffs
It’s tempting to type y on every prompt, but that’s how you end up with bloated dependencies or off-scope features. Read the diff, especially for package.json and entry points.
3. Not redirecting when Codex drifts
If Codex starts adding features you didn’t ask for (e.g., a web UI for a CLI tool), stop and redirect: “Remove the web server. This is a CLI-only tool.”
4. Ignoring quota limits
Codex CLI uses your OpenAI API quota. Long sessions can hit rate limits or monthly caps. Check your usage at platform.openai.com before starting, and set a budget if needed. If you hit a limit mid-session, MobileVibe will notify you so you can resume later.
5. Skipping tests until the end
Ask for tests early—after the core logic is written but before you add polish. Tests catch bugs while the code is fresh in Codex’s context, and you avoid a “works on my machine” surprise at 11pm.
6. Not using version control
Run git init before starting your Codex conversation. Commit after each major approval loop. If Codex makes a change you regret, git reset --hard and redirect.
FAQ
Can I use Codex via CLI instead of the IDE extension?
Yes. Codex CLI is a standalone tool that runs in your terminal without requiring VS Code or any IDE. It’s designed for developers who want to start conversations, approve changes, and let the agent handle file operations from the command line. The CLI and IDE extension are separate surfaces—they don’t share conversation history by default, though you can manually sync context if needed.
How do I set up Codex CLI on macOS or Windows?
On macOS, install via Homebrew: brew install openai/tap/codex-cli, then authenticate with codex auth login. On Windows 10+, download the installer from OpenAI’s Codex CLI releases page, run it, and authenticate via PowerShell or Command Prompt with codex auth login. Both platforms store your API token locally and use your OpenAI account quota.
What’s the difference between Codex CLI and the Codex IDE extension?
Codex CLI runs headless in your terminal and is optimized for file-based workflows—scaffolding, scripting, and automation. The Codex IDE extension runs inside VS Code and integrates with the editor’s UI, inline suggestions, and debugging tools. They are separate surfaces with independent conversation histories. If you start a project in the CLI, you can open it in VS Code later, but the conversation won’t automatically carry over unless you manually provide context.
Can I approve Codex CLI tasks from my phone while building?
Yes, if you use MobileVibe. Install the Desktop Connector on your Mac or Windows machine, pair it with your MobileVibe account, and your Codex conversations become accessible from your phone. You can review diffs, approve file changes, check status, and unblock quota hits from anywhere. The agent keeps running on your real desktop—MobileVibe just makes it reachable and controllable from mobile.
How do I handle Codex rate limits or quota hits during a long session?
If Codex hits an API rate limit or monthly quota, the session pauses and you’ll see an error in the terminal. Check your usage at platform.openai.com and wait for the limit to reset (usually minutes for rate limits, or upgrade your plan for quota). If you’re using MobileVibe, you’ll get a notification when Codex is blocked, so you can resume the conversation once the limit clears or adjust your scope to reduce API calls.
Is it better to build a CLI with Codex or Claude?
Both work, but they have different strengths. Codex CLI is faster for pure scaffolding and file operations—it’s built for terminal workflows and handles dependencies, tests, and project structure well. Claude (via CLI or IDE) is better for complex logic, nuanced error handling, and iterative reasoning. For a simple CLI you want to ship in one evening, Codex CLI is often faster. For a CLI with tricky edge cases or domain-specific logic, Claude’s reasoning may save you debugging time. You can also start with Codex for scaffolding and switch to Claude for refinement.
If you want to build cli with codex in one evening—from idea to working tool—start with a tight prompt, stay in the approval loop, and let the agent handle the repetitive work. When you step away, MobileVibe keeps you connected so you can unblock progress from your phone and ship before bedtime. Try MobileVibe free and turn your next CLI idea into a real tool tonight.