Open5
Codex CLI利用整備

Codex CLIのインストール
codex cliのインストールコマンドは以下。
# オーソドックスなnpmでのインストール
npm install -g @openai/codex
# bunをパッケージ管理に利用してる場合
bun add -g @openai/codex
DevContainer使っていれば、Dockerfileに上記を入れておけば、コンテナ作成すると利用できる。
コンテナをリビルドした後、以下のコマンドでcodexのインストールを確認する。
codex --version
Codexの起動はコンソールに「codex」と入力するだけ。
# codex起動
codex
以下の処理の承認について質問される。私は2にした。
> You are running Codex in /workspaces/xxxx
Since this folder is version controlled, you may wish to allow Codex
to work in this folder without asking for approval.
> 1. Yes, allow Codex to work in this folder without asking for approval
2. No, ask me to approve edits and commands
Press Enter to continue
初回なので、「/init」コマンドを入力。
>_ You are using OpenAI Codex in /workspaces/xxxx
To get started, describe a task or try one of these commands:
/init - create an AGENTS.md file with instructions for Codex
/status - show current session configuration and token usage
/approvals - choose what Codex can do without approval
/model - choose what model and reasoning effort to use
▌ Summarize recent commits
⏎ send Ctrl+J newline Ctrl+T transcript Ctrl+C quit
initを実行するとAGENT.mdが作成される。
途中でAGENT.mdを作るか承認を求められれば「Yes」を選択(左右の矢印で選択できる)。
その後、AGENT.mdについての調整をいろいろと聞かれるので適宜対応する。

VSCodeにCodexの拡張を追加する方法(DevContainer)
DevContainerの拡張にするには、以下のように拡張管理画面でdevcontainer.jsonに追加を選択する。
上記でdevcontainer.jsonに以下の項目が追加される。
"customizations": {
"vscode": {
"extensions": [
... 省略 ....
"openai.chatgpt"
],
... 省略 ....
}
}

Codexの拡張利用
Codexの拡張アイコンを押して、「Sign in with ChatGPT」ボタンを押す。
ログインするためにWebサイトを開く。
アカウントのメールアドレスをいれて続行。
サインインをする。
IDEに戻り、何度か「Next」ボタンを押す。
チャットダイアログが表示される。

プランごとの利用制限

MCPサーバの利用