fork command creates a new session based on an existing one, allowing you to explore different approaches while preserving the original conversation.
Usage
Description
Forking creates a copy of a previous session’s history and starts a new interactive session from that point. This is useful when you want to:- Try a different approach to solving a problem
- Explore alternative implementations
- Experiment without affecting the original session
- Branch off from a specific point in a conversation
Options
Fork the most recent session without showing the picker.
Examples
Interactive Picker
Show a picker to select which session to fork:Fork Latest
Automatically fork your most recent session:How It Works
- Codex loads the selected session’s history
- Creates a new thread ID
- Copies all conversation history to the new thread
- Opens the interactive TUI with the forked session
- You can now continue in a different direction
Use Cases
- A/B testing approaches: Try two different solutions to the same problem
- Experimentation: Test ideas without losing your original work
- Decision points: Fork when you reach a critical architectural choice
- Learning: Explore “what if” scenarios with the same context
Comparison: Fork vs Resume
| Feature | Fork | Resume |
|---|---|---|
| Original session | Unchanged | Continued |
| New thread ID | Yes | No |
| History | Copied | Shared |
| Use case | Try alternatives | Continue work |
Related Commands
codex resume
Resume an existing session
codex
Start a new interactive session