Vibe Coding
Back to Codex

Codex / Use Codex

Codex command line

CLI is suitable for local repositories, real commands and reproducible verification.

Codex command line key concepts infographic
Codex command line key concepts infographic

CLI basic usage

Codex CLI is the most direct entry point for local repository work. Start in the project root directory so that Codex can read real files, run real commands, and be controlled by the local sandbox.

cd your-project
codex
codex "Explain the project structure first, don't change the files"

Key parameters

Common key CLI parameters include --sandbox, --ask-for-approval, --cd, --search, model/inference settings, and non-interactive exec. Permission-related parameters should be written explicitly.

codex --sandbox workspace-write --ask-for-approval on-request
codex --sandbox read-only --ask-for-approval on-request
codex exec --sandbox workspace-write "Run tests and fix failures"

Commonly used slash commands

In a session, use /permissions to adjust permissions, /status to view status, /resume to restore, /compact to manage context, and /help to find commands.

  • /permissions: Switch executable capabilities.
  • /status: View model, sandbox, approval, context, etc.
  • /resume: Resume session.
  • /compact: Compress long context.

Complete usage points

Supplement the core concepts, operation sequences, permission boundaries and verification requirements that are easily compressed and missed in official documents, making it easier for English readers to learn completely by page.

CLI usage details

Codex CLI is the closest entry to the real engineering environment. It runs in the current working directory, can read files, edit files, execute commands, and is subject to sandbox and approval policy restrictions. Confirm the current directory, Git status, and branch before starting.

  • Read-only exploration: Use more conservative permissions and let Codex explain projects and plans.
  • Workspace editing: workspace-write is allowed, but production, key, deployment, and deletion still need to be approved.
  • Non-interactive execution: specify output format, timeout and failure policy in advance.
  • Session management: Use status, resume, compact, permissions and other commands to control status.

The power of CLI comes from real commands, which also means that the risk comes from real commands. Any deletion, reset, migration, network installation, push, or deploy should first understand the impact.

Study Checklist

Put the content on this page into real tasks and use the five dimensions of entry, context, permissions, verification and team rules to check whether you have truly mastered it.

Study Checklist

After reading this page, do not just remember the concept name. You should be able to place "Codex command line" back into a real Codex engineering workflow: where the task starts, what context the system loads, which actions need approval, how the result is verified, and how to roll back when it fails.

If this is a portal or platform page, specifically confirm what contexts this portal can access: local files, cloud repositories, browser logins, team messages, external tools, and whether these contexts are sufficient to complete the verification.

  • Be able to describe in your own words the specific problem this page solves, rather than just reciting the title.
  • Able to write a minimal example task with goals, scope, prohibitions, and acceptance criteria.
  • Be able to determine which information should be put into the current prompt and which should be captured as project rules or configurations.
  • Be able to explain which long-term rules should go into AGENTS.md, and which runtime behavior should be handled by config.toml, permission profile, skills and MCP.
  • Ability to check diffs, command output, test results, screenshots or PR notes after a task is completed instead of just trusting the natural language summary.

If this page is used for team training, ask learners to complete a small task with Codex: read and explain first, submit a plan, make the smallest useful change, and close with real verification commands plus human diff review.

Codex practical notes

Fill in the most overlooked execution details of Codex usage around local environments, privilege escalation, remote entry, automation failures, and rollbacks.

Codex Practical Notes

This page is the entrance to Codex. When landing, confirm whether the task is executed locally, in the cloud, or in a collaboration tool, and check whether the entrance can access the real repository, dependencies, network, browser status, and verification commands.

When handling tasks related to "Codex command line", always confirm the current Git status and working directory first. Codex can make changes quickly, but it does not automatically know which uncommitted edits came from the user, which files are off limits, or which commands may affect production.

  • Prioritize using low-risk branches or working trees for local tasks, and review them with git diff after completion.
  • When it comes to installation dependencies, networking, databases, deployment, push, deletion, and reset, Codex must first be asked to explain the impact before approval.
  • Results generated by remote or collaborative portals must also be confirmed back to PR, CI, build logs and test evidence.
  • Automated tasks must define failure output and exit conditions in advance to avoid Codex repeatedly trying in the wrong direction.

Think of Codex as an engineering teammate who can execute commands, rather than an assistant who can only write text. The closer you get to a real system, the greater the need for clear boundaries, evidence, and rollbacks.