DEV Community

Cover image for Top 10 Codex CLI Tips Every Developer Should Know
Emmanuel Mumba
Emmanuel Mumba

Posted on

Top 10 Codex CLI Tips Every Developer Should Know

Codex CLI has quickly become a go-to tool for developers looking to streamline workflows, automate repetitive tasks, and bring AI assistance directly into their development environment. Whether you’re fixing bugs, generating code, or running commands in your repo, Codex lets you stay in flow while reducing cognitive load.

But like any powerful tool, its efficiency depends on how you use it. Over the last few months, developers have uncovered practical ways to get the most out of Codex CLI. These aren’t theoretical tips they come from real-world usage, tested in both professional projects and side hustles.

Before we get into Codex CLI tips, one quick note: if your project involves APIs, a tool like Apidog can complement Codex. While Codex helps with automation and code, Apidog makes testing and documenting endpoints simple, giving you a complete workflow.

In this guide, we’ll walk through the Top 10 Codex CLI Tips that will make your development smoother, faster, and more productive.

1. Use Aliases for Faster Startup

Typing long commands every time you start Codex is inefficient. Instead, set up an alias so you can launch Codex with your preferred configuration in one short command.

For example, in macOS or Linux, you can add this to your ~/.zshrc or ~/.bashrc:

alias codex='codex -m gpt-5-codex -c model_reasoning_effort="high" -c model_reasoning_summary_format=experimental --search --dangerously-bypass-approvals-and-sandbox'
Enter fullscreen mode Exit fullscreen mode

This way, every time you type codex, it automatically loads your preferred model, reasoning settings, and search enabled.

Once saved, just reload your shell with:

source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

Result: you skip the repetitive setup and dive straight into work.

2. Master Shortcut Commands

Codex CLI supports built-in slash commands that speed up common operations. Instead of hunting through docs, you can type / in a session to see all supported shortcuts.

Some essentials include:

  • /model → Switch models and inference levels.
  • /approvals → Change authorization mode.
  • /new → Start a fresh session.
  • /compact → Compress context to fit longer histories.
  • /diff → View git diffs directly in Codex.
  • /status → See token usage and current config.

Learning these commands is like learning keyboard shortcuts in an editor — small habits that add up to major productivity.

3. Quick Line Breaks for Cleaner Prompts

When prompts get long, readability suffers. Codex supports quick line breaks so you can format prompts neatly.

  • On macOS: Option + Enter
  • On Windows/Linux: Ctrl + J

This doesn’t send the request — it just moves you to a new line. Clean prompts help you and Codex stay on the same page.

4. Interrupt or Exit on the Fly

Sometimes Codex takes a request in the wrong direction, or you realize you need to reframe your input. Instead of waiting, you can interrupt execution anytime.

  • Press Esc to cancel the current request.
  • Press Ctrl + C twice or type /quit to exit the session completely.

This saves time, especially when you’re iterating quickly.

5. Switch Between API and ChatGPT Authentication

Codex can be used with either your ChatGPT account or via the OpenAI API. If your account credits run out, you don’t need to stop working — just switch authentication modes.

To enable API authentication, edit your config file:

~/.codex/config.toml
preferred_auth_method = "apikey"
Enter fullscreen mode Exit fullscreen mode

Or override it temporarily from the CLI:

codex --config preferred_auth_method="apikey"
Enter fullscreen mode Exit fullscreen mode

Switch back anytime with:

codex --config preferred_auth_method="chatgpt"
Enter fullscreen mode Exit fullscreen mode

This flexibility ensures you always have a backup method to keep working.

6. Use AGENTS.md to Guide Codex

Codex ships with support for AGENTS.md, a simple guidance file you can place in your project. Think of it as a specialized README that tells Codex how to behave in your repo.

For example, you might include:

# AGENTS.md
- Always use TypeScript for new files
- Follow ESLint rules from .eslintrc
- Use Jest for testing
- Prefix all environment variables with "APP_"
Enter fullscreen mode Exit fullscreen mode

This gives Codex context and consistency across sessions, reducing the need to re-explain your setup.

Pro Tip: Fix Outdated GitHub Docs On Autopilot

If you’ve ever shipped code faster than you’ve updated the README, you know the pain of stale documentation. That’s where DeepDocs comes in. It’s a GitHub-native AI agent that automatically keeps docs READMEs, API references, SDK guides, examples, and tutorials in sync with your codebase. Pair it with Codex, and you’ll eliminate the manual effort of chasing down outdated docs after every change.

7. Fine-Tune Authorization Modes

Codex is powerful, but with great power comes risk. Its authorization modes let you decide how much freedom it has:

  • Auto (default): Can read/edit files and run commands in the working directory but asks permission for external actions.
  • Read-Only: Only reads files, never edits or executes.
  • Full Access: Reads, edits, and executes anywhere — without asking (not recommended unless you fully trust your environment).

Switch modes quickly using:

/approvals
Enter fullscreen mode Exit fullscreen mode

Or configure them with flags like:

codex --sandbox read-only --ask-for-approval never
Enter fullscreen mode Exit fullscreen mode

Pro tip: Use Auto for most cases, but drop to Read-Only when you just want to brainstorm without risking changes.

8. Enable Web Search for Fresh Context

By default, Codex relies on its training data and local context. But sometimes you need the latest info from the web.

Enable search with:

codex --search
Enter fullscreen mode Exit fullscreen mode

Codex will then pull in real-time web results before generating a response, complete with sources. This is especially useful for referencing new APIs, recent libraries, or up-to-date best practices.

9. Reference Files Directly

Instead of pasting file contents into your prompt, you can reference files directly.

For example:

@src/app.js
Enter fullscreen mode Exit fullscreen mode

Codex will pull in the file’s contents without cluttering your input. This works even better when using the VSCode or Cursor IDE extensions, where you can right-click and reference files seamlessly.

10. Compress Context When Sessions Get Long

One limitation of any AI model is context length. Long conversations can hit the cap, causing Codex to lose track of earlier inputs.

Use the /compact command to shrink the conversation history while retaining key details. Codex will summarize the session and free up tokens for future interactions.

You can also check your current token usage with:

/status
Enter fullscreen mode Exit fullscreen mode

This ensures you don’t run into unexpected cutoffs during deep work.

Bonus: Explore

Codex supports integration with the Model Context Protocol (MCP), letting you connect external services and tools into your workflow. While setup requires editing ~/.codex/config.toml, it opens the door to automating browser actions, connecting APIs, or adding custom agents.

It’s still early days for MCP with Codex, but developers are already experimenting with integrations like Puppeteer for browser automation or Context7 for advanced context management.

Conclusion

Codex CLI is more than just a way to chat with AI in your terminal it’s a full productivity layer for modern development. By mastering aliases, shortcuts, file references, and context management, you can cut hours off your workflow each week.

These 10 tips are battle-tested in real-world projects, from solo prototyping to enterprise-level repos. Start small set up an alias, learn a few commands, or try out AGENTS.md. Over time, you’ll build a personal workflow that feels like an extension of your editor.

Remember: tools are only as good as the habits you form around them. Codex CLI gives you the power  these tips help you wield it effectively.

Top comments (12)

Collapse
 
garysvenson profile image
Gary Svenson

Very good tips. Hopes to read more content from you, Emmanuel!

Collapse
 
therealmrmumba profile image
Emmanuel Mumba

Thanks a lot, Gary! I’ll definitely keep sharing more Codex and dev productivity content.

Collapse
 
klaudia_kovov_bf17561f profile image
Klaudia Kováčová

So we collectively decided that CodeX is the way to go now, instead of Claude Code, right?

Collapse
 
therealmrmumba profile image
Emmanuel Mumba

Haha, it does feel like the momentum is moving toward Codex lately.

Collapse
 
ananya330 profile image
Ananya Balehithlu

Excellent work! However as a beginner dev I still want to learn more by doing everything myself instead of totally relying on AI!

Collapse
 
therealmrmumba profile image
Emmanuel Mumba

That’s a great approach. Using Codex as a complement to your own coding process (instead of replacing it) is honestly the best way to learn.

Collapse
 
ralphsebastian profile image
Ralph Sebastian

Brilliant!

Collapse
 
therealmrmumba profile image
Emmanuel Mumba

Appreciate it, Ralph! Glad you found it useful.

Collapse
 
kristen69 profile image
Kristen

Any cursor tips? Please share with us!

Collapse
 
therealmrmumba profile image
Emmanuel Mumba

Cursor has some handy tricks too. I’ll put together a roundup on that soon

Collapse
 
ashford_ai profile image
Dylan Ashford

That’s a solid roundup—really like the AGENTS.md idea. Having a simple guidance file in the repo feels way more practical than constantly re-explaining setup.

Collapse
 
therealmrmumba profile image
Emmanuel Mumba

Exactly! AGENTS.md really reduces friction for onboarding and consistency. It’s one of those small things that makes a big difference.