Codex: Codex Workflow Modes
Last updated: 2026-08-31
Codex supports multiple workflow modes. Choose the right one based on task complexity and desired autonomy level.
📋 Prerequisites: Understanding Codex basic operations
1. What You Will Learn
- Three workflow modes
- Appropriate scenarios for each mode
- Mode switching methods
- Workflow design principles
2. Three Workflow Modes
| Mode | Autonomy Level | Human Involvement | Best For |
|---|---|---|---|
| Question Mode | Low | High | Consulting, analysis, learning |
| Task Mode | Medium | Medium | Specific development tasks |
| Agent Mode | High | Low | Complex multi-step tasks |
3. Question Mode
(1) Characteristics
- Codex only answers questions, doesn't modify code
- Acts as an intelligent search engine + technical advisor
- Highest security
(2) Usage
TEXT
📖 Display only
> Explain React useEffect's cleanup mechanism
> What does this regex match? /\d{3}-\d{4}/
> What's the difference between type and interface in TypeScript?
> How to implement graceful shutdown in Node.js?
▶ Example 1: Alice Uses Question Mode to Learn
TEXT
📖 Display only
# Alice takes over a Rust project, uses Question Mode to quickly understand
> Explain the AST structure in src/parser/mod.rs
> What error handling pattern does this project use?
> Why is Arc<Mutex<T>> used here instead of RefCell<T>?
> Draw me a module dependency diagram
4. Task Mode
(1) Characteristics
- Codex executes specific tasks with step-by-step confirmation
- Most commonly used mode
- Balances autonomy with safety
(2) Usage
TEXT
📖 Display only
> Add JWT support to the auth module
> Fix the failing test_user_login test
> Convert this.state to React Hooks
> Add rate limiting to the API
(3) Task Decomposition Principles
| Principle | Description |
|---|---|
| Single Responsibility | One task at a time |
| Clear Boundaries | Specify modification scope |
| Include Verification | Specify how to verify completion |
| Reference Existing | Specify style references |
▶ Example 2: Bob's Task Decomposition
TEXT
📖 Display only
# Bob needs to add user registration, decomposed into:
Step 1: "Create User model with email, password_hash, created_at fields"
Step 2: "Implement registration API endpoint POST /api/register with email format validation"
Step 3: "Add password hashing using bcrypt"
Step 4: "Write integration tests for the registration flow"
Step 5: "Add email verification flow"
5. Agent Mode
(1) Characteristics
- Codex autonomously plans and executes multi-step tasks
- Human only needs to review final results
- Most efficient but also highest risk
(2) Usage
BASH
# Full Auto mode
codex --full-auto "Migrate the entire project from JavaScript to TypeScript"
# Or switch during conversation
/mode full-auto
(3) Agent Work Loop
graph TB
A[Receive Task] --> B[Analyze & Understand]
B --> C[Plan Steps]
C --> D[Execute Step 1]
D --> E[Verify Result]
E --> F{Success?}
F -->|No| G[Fix & Retry]
G --> D
F -->|Yes| H[Execute Step 2]
H --> I[Continue...]
I --> J[Aggregate Results]
J --> K[Report Complete]
▶ Example 3: Alice's Agent Mode
TEXT
📖 Display only
# Alice uses Agent Mode for a large refactoring
> Migrate the Express project to Fastify:
> 1. Replace all route definitions
> 2. Update middleware syntax
> 3. Modify startup scripts
> 4. Ensure all tests pass
> 5. Update package.json
# Codex executes autonomously:
→ Scanning 45 files...
→ Converting routes (32 routes)...
→ Updating middleware (8 files)...
→ Test run: 89/89 passed ✓
→ Updating dependencies...
→ Final test: 89/89 passed ✓
→ Migration complete!
6. Mode Selection Strategy
(1) Decision Tree
TEXT
📖 Display only
Task type?
├── Only need information → Question Mode
├── Need to modify code
│ ├── Single clear task → Task Mode
│ └── Complex multi-step task
│ ├── Controllable risk → Agent Mode
│ └── High risk → Task Mode (step-by-step)
(2) Selection Matrix
| Task | Mode | Reason |
|---|---|---|
| Explain code logic | Question | No modification needed |
| Fix a single Bug | Task | Single and clear |
| Add a feature | Task | Needs step-by-step confirmation |
| Full project refactoring | Agent | Many steps but pattern-based |
| Database migration | Task | High risk, needs step-by-step confirmation |
| Batch generate tests | Agent | Repetitive work |
7. Hybrid Workflows
In practice, the three modes are often combined:
TEXT
📖 Display only
# Alice's hybrid workflow
1. [Question] "What's the auth architecture of this project?"
2. [Question] "What are the best practices for JWT refresh tokens?"
3. [Task] "Add a JWT refresh token endpoint"
4. [Task] "Write unit tests for refresh tokens"
5. [Agent] "Review the entire auth module, fix all security issues"
❓ FAQ
Q Can I switch modes within one session?
A Yes. Use
/mode command or adjust your interaction style — question-style is Question Mode, task-style is Task Mode.Q Is Agent Mode safe?
A Depends on task risk and approval policy. Pair with Git safety net — commit before operations, rollback on errors. High-risk tasks should use Task Mode.
Q How do I judge if a task is suited for Agent Mode?
A Ask yourself three questions: 1) Are the steps predictable? 2) Are errors reversible? 3) Does it require human judgment? All yes → Agent; otherwise → Task Mode.
Q Does Question Mode consume context?
A Yes. Each question and answer uses context window space. After extensive questioning, use
/compact or /new.Q Which mode saves the most tokens?
A Question Mode is most economical — only outputs text, no operations. Agent Mode is most expensive — requires multiple rounds of execution and verification.
📖 Summary
- Three modes: Question (safe) / Task (balanced) / Agent (efficient)
- Question Mode: consulting & analysis, no code modification
- Task Mode: step-by-step confirmation, single responsibility
- Agent Mode: autonomous execution, pair with Git safety net
- Hybrid usage yields the best results
📝 Exercises
- Basic (⭐): Complete different tasks on the same topic using all three modes, record experience differences.
- Intermediate (⭐⭐): Use Task Mode to complete a medium-complexity feature, practice task decomposition.
- Advanced (⭐⭐⭐): Design a hybrid workflow — Question Mode for analysis, Task Mode for implementation, Agent Mode for review.