Codex can help you write code, fix bugs, understand projects, and run commands directly from the VS Code sidebar.
1. Preparation
Before you start, make sure:
- VS Code is updated to a recent stable version.
- You can access OpenAI services normally.
- Your project is opened locally (preferably in a Git repository).
2. Install the Extension
- Open the VS Code Extensions panel.
- Search and install:
Codex - Codex - OpenAI's coding agent. - Complete the sign-in/authorization flow.
3. Open the Codex Sidebar
You can open it in either way:
- Click
Open Codex Sidebarin the top-right area of the editor. - Use Command Palette (
Ctrl + Shift + P), searchCodex, and open it.
After opening, Codex reads the current workspace context and becomes ready for chat.
4. Common Usage Patterns
4.1 Ask It to Explain Code
Example prompt:
|
|
Great for quickly understanding legacy code.
4.2 Ask It to Implement Features
Example prompt:
|
|
If you clearly state constraints and acceptance criteria, output quality is usually much more stable.
4.3 Ask It to Fix Issues
Example prompt:
|
|
“Diagnose first, then fix” helps reduce accidental over-refactoring.
5. High-Quality Prompt Template
You can reuse this template directly:
|
|
This is especially useful for large projects and team collaboration.
6. FAQ
6.1 About Free Quota
Type \ in the input box, then choose status to view quota/reset-time related information.
6.2 Changes Are Not as Expected
After changes are generated, open the review panel to inspect details. If not satisfied, use undo/revert. You can split large requirements into smaller steps and execute incrementally. Use Git and keep small commits for easier rollback.