Skip to main content

Codex

Contents

CLI

node -v
v24.13.1

# Install using npm
npm install -g @openai/codex

codex login

codex

Use Git checkpoints

Codex can modify your codebase, so consider creating Git checkpoints before and after each task so you can easily revert changes if needed.

Managing and Reverting Changes

# To go back to a previous state temporarily without rewriting history (best for unshared changes)
# Use 'soft' to keep the changes in your working directory,
# or 'hard' to discard them completely
git reset --hard HEAD~1
# This command moves your branch pointer back one commit.
# You can use the specific commit hash instead of HEAD~1 for more precise control.

# To undo a single commit cleanly after it has potentially been shared with others, use Git revert:
# Replace <commit_hash> with the actual hash of the "Post-task" commit
git revert <commit_hash>
# This creates a new commit that applies the inverse of the changes from the specified commit, preserving project history.