Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Codex Getting Started

Codex Getting Started

Launch Codex

Codex's interface uses a standard three-column layout: the task list on the left, the conversation window in the middle, and a multi-function area on the right.

After launching the Codex app, we can add projects in the left menu and enter our requirements in the input box in the middle column:

You can set the model or upload files, among other options:

Launch Codex CLI

After installation and account setup, open a terminal in the project directory and type codex to launch the interactive interface:

# 进入你的项目目录

cd ~/my-project



# Start Codex interface

codex



# Start with initial prompt

codex "帮我分析这个项目的结构"



# Specify model at startup

codex --model gpt-5

💡 Tip: Start Codex in the project root directory so it can fully read the project file structure.

The Codex interface is simple; the input box is where the cursor is, so just type your requirements directly.

For example, we enter the codex-runoob-test directory and then start it with the codex command:



cd codex-runoob-test

# Start Codex interface

codex

Then you can enter your requirements directly in the interactive interface, such as asking it to explain the code in the test.py file. The result is as follows (these records also appear in the Codex App):

Three Approval Modes (Approval Mode)

Codex CLI offers three operation permission modes at different levels; you can choose the appropriate mode based on your task needs:

Mode Description Applicable scenarios
ask(default) Read-only mode: can read files and formulate plans, but requires your confirmation before performing any action Exploring unfamiliar codebases, risk assessment
auto-edit Auto-edit: can read and modify files in the current directory, but network operations still require confirmation Daily code development, refactoring tasks
full-auto Full auto: runs fully automatically in a sandbox with networking disabled, with no confirmation needed Batch tasks, CI/CD automation
# 指定审批模式启动

codex --approval-mode ask        # 默认只读模式

codex --approval-mode auto-edit  # 自动编辑模式(缩写 -a auto-edit)

codex --approval-mode full-auto  # 完全自动模式



# Switch in the interactive interface

/approvals  # 输入此命令切换审批模式

Your First Conversation

Example 1: Analyze the Project Structure

codex "分析这个项目的目录结构,告诉我主要文件的作用"



# Codex automatically reads files, outputting something like:

# ✓ Read package.json

# ✓ Scan src/ directory (23 files)

#   Project structure analysis:

# - src/index.ts: Application entry point, initializes Express server

# - src/routes/: API route definitions (5 endpoints total)

# ...

Example 2: Fix a Bug

codex "我的 login 函数有 bug,用户登录后 token 没有正确保存,帮我找出问题并修复"



# Codex will:

# 1. Read relevant files

# 2. Analyze code logic

# 3. Propose modification plan

# 4. Execute modification after your confirmation

Example 3: Generate a New Feature

codex "给我的 Express 应用添加一个用户注册接口,需要验证邮箱格式,密码至少8位,并把用户信息存入数据库"



# Pass image context

codex -i design.png "按照这个设计图,实现对应的 React 组件"

Image input

Codex CLI supports images as context input, which is especially useful in the following scenarios:

# 方法一:命令行传入图片路径

codex -i screenshot.png "解释这个报错信息,并告诉我如何修复"



# Method two: passing multiple images

codex --image img1.png,img2.jpg "对比这两个界面的区别,实现图一的设计"



# Method three: Paste image in the interactive interface (macOS)

# After copying the image, paste it directly into the Codex input box using Cmd+V



# Method four: Shift + drag image to terminal window