はじめに
Codex CLIを導入して会話を試したメモです。最初はCodex CLIを試すというテーマで幅広く触れていくつもりでしたが、やっているうちに凄い長さになっていきゴールが見えなくなったので、まずは導入と会話に絞っています。
前提
- macOS Sequoia 15.3.1
- ChatGPT Plus
- mise 2026.2.11 macos-arm64 (2026-02-12)
Codex CLIのインストール
miseを使ってインストールします。
mise use --global npm:@openai/codex
無事にインストールされていることの確認の意味も込めて、codex-cliのバージョンを見ておきます。
codex --version
codex-cli 0.101.0
初期設定
Codexを起動します。
codex
以下のように選択肢が出ました。ChatGPTでのログインで問題ないのでそのままEnterキーを押下します。
Welcome to Codex, OpenAI's command-line coding agent
Sign in with ChatGPT to use Codex as part of your paid plan
or connect an API key for usage-based billing
> 1. Sign in with ChatGPT
Usage included with Plus, Pro, Team, and Enterprise plans
2. Sign in with Device Code
Sign in from another device with a one-time code
3. Provide your own API key
Pay for what you use
Press Enter to continue
すると、ブラウザでChatGPTのログイン画面が表示されます。自分のアカウントでログインします。ログインに成功すると以下のようになったので、Enterキーを押下します。
✓ Signed in with your ChatGPT account
Before you start:
Decide how much autonomy you want to grant Codex
For more details see the Codex docs
Codex can make mistakes
Review the code it writes and commands it runs
Powered by your ChatGPT account
Uses your plan's rate limits and training
data preferences
Press Enter to continue
ディレクトリを信頼するか?という確認です。問題ないのでそのままEnterキーを押下します。
Do you trust the contents of this directory? Working with untrusted contents
comes with higher risk of prompt injection.
› 1. Yes, continue
2. No, quit
Press enter to continue
gpt-5.3-codexが出たばかりだからか、5.3と5.2のどっちを使うか聞かれました。5.3がいいのでそのままEnterキーを押下します。
Codex just got an upgrade. Introducing gpt-5.3-codex.
Codex is now powered by gpt-5.3-codex, our most capable agentic coding model
yet. It's built for long-running, project-scale work, with mid-turn steering +
frequent progress updates so you can collaborate while it runs (and it's
faster too).
Learn more: https://openai.com/index/introducing-gpt-5-3-codex/
You can keep using gpt-5.2-codex if you prefer.
Choose how you'd like Codex to proceed.
› 1. Try new model
2. Use existing model
Use ↑/↓ to move, press enter to confirm
こちらの指示を待機してる感じになったので、準備は完了したようです。
╭───────────────────────────────────────────────────────╮
│ >_ OpenAI Codex (v0.101.0) │
│ │
│ model: gpt-5.3-codex /model to change │
│ directory: ~/Desktop/GitHub/vite-react-mui-sample-app │
╰───────────────────────────────────────────────────────╯
Tip: New Try the Codex App with 2x rate limits until April 2nd. Run 'codex
app' or visit https://chatgpt.com/codex
› Run /review on my current changes
? for shortcuts 100% context left
Codexとの会話
とりあえず挨拶してみます。
› こんにちは
• こんにちは!今日は何を進めますか?
返事きました。会話できてますね。
/new で新しい会話を開始できるとのことなのでやってみます。
› 新しい会話を開始する実験です
• 了解しました。新しい会話として進めましょう。
やりたいことをそのまま書いてくれれば、すぐ対応します。
/resume で保存されている会話のセッションを選択して再開できます。保存は自動でされるようです。
Resume a previous session Sort: Created at
Type to search
Created at Updated at Branch Conversation
> 1 minute ago 1 minute ago main 新しい会話を開始する実験です
24 minutes ago 5 minutes ago main こんにちは
今は「新しい会話を〜」のセッションにいるので、「こんにちは」のセッションを選択してEnterキーを押下します。
› こんにちは
• こんにちは!今日は何を進めますか?
セッションの切り替えができました。
一旦 /quit でCodexを終了し、再起動してもセッションが残っているのか見てみます。/resume を実行すると先ほどと同じセッションが並んでおり、Codexを終了してもセッションが残ることを確認できました。
こうなると、逆に会話のセッションは消さない限り保持し続けるのでしょうか。Codex本人に聞いてみます。
› 今CLIで会話しているあなたとの会話のセッションに保存期間はありますか?
• 短く言うと、このCLIセッションの保存期間は「無期限固定」ではありません。
保持は次の2つで決まります。
1. ローカル側(CLIの履歴/ログ設定)
2. 接続先サービス側(API/組織のデータ保持ポリシー)
なので、正確な期間は環境設定しだいです。
また削除可否も分かれていて、ローカル履歴は削除可能なことが多いですが、サービス
側ログはその管理画面や組織ポリシーに依存します。
必要なら、この環境で実際にどこに履歴が残る設定かを一緒に確認できます。
無期限ではないとの回答でした。しかしこの回答だと、〇〇日で消えるという感じではなさそうです。会話のセッションを削除する方法はあるのか聞いてみます。
› CLIでの会話のセッションを削除する方法を教えて
• この環境での実際の削除手順に合わせるため、まず ~/.codex 配下に会話ログやセッ
ション保存先があるかを確認します。見つかった場所ベースで、安全な削除手順を具体
化します。
• Ran ls -la ~/.codex && echo '---' && rg --files ~/.codex | head -n 200
└ total 384
drwxr-xr-x 13 xxx staff 416 Feb 15 20:59 .
… +22 lines
rollout-2026-02-15T21-02-56-019c612e-b561-7d63-a819-50be97837b33.jsonl
/Users/xxx/.codex/shell_snapshots/019c612e-b561-7d63-a819-50be97837b33.sh
────────────────────────────────────────────────────────────────────────────────
• 保存先は ~/.codex にあり、history.jsonl と sessions/...jsonl が会話データで
す。次に設定ファイルで自動削除や保持期間の項目があるか確認します。
• Explored
└ Read config.toml
────────────────────────────────────────────────────────────────────────────────
• CLIの設定には保持期間の自動削除設定は見当たりませんでした。最後に、CLI側に履歴
削除コマンドがあるか codex --help で確認します。
• Ran codex --help
└ WARNING: proceeding, even though we could not update PATH: Operation not
permitted (os error 1)
… +113 lines
-V, --version
Print version
────────────────────────────────────────────────────────────────────────────────
• Codex CLI なら、会話データはローカルの ~/.codex にあります。
この環境では主に以下です。
- セッション本体: ~/.codex/sessions/.../*.jsonl
- 入力履歴: ~/.codex/history.jsonl
削除方法:
1. 現在のCLIを終了(Ctrl+C か exit)
2. 必要な範囲を削除
# 1セッションだけ削除
rm ~/.codex/sessions/2026/02/15/rollout-xxxxxxxx.jsonl
# セッションを全削除
rm -rf ~/.codex/sessions
# 入力履歴をクリア
rm ~/.codex/history.jsonl
# (ファイルだけ残したいなら: : > ~/.codex/history.jsonl)
補足:
- 認証情報も消すなら codex logout(~/.codex/auth.json 相当)。
- 完全初期化したいなら ~/.codex 配下をまとめて削除できますが、auth.json や設定
も消えます。
書かれている通りにファイルがあり、中身もそれっぽかったのであってそうです。試しに1セッションだけ削除してみます。「新しい会話を〜」の方にいる状態で、「こんにちは」のセッションファイルを消して /resume を実行します。
Resume a previous session Sort: Created at
Type to search
Created at Updated at Branch Conversation
> 39 minutes ago 10 minutes ago main 新しい会話を開始する実験です
最初に挨拶した「こんにちは」のセッションが想定通り削除されました。
スラッシュコマンド
ここまでの流れでも使用していましたが、Codex CLIは /{キーワード} の形式で用意された指示を実行できます。これをスラッシュコマンドといいます。
developers.openai.com
Codex起動中に / を入力すると候補が出てきます。
/model choose what model and reasoning effort to use
/permissions choose what Codex is allowed to do
/experimental toggle experimental features
/skills use skills to improve how Codex performs specific tasks
/review review my current changes and find issues
/rename rename the current thread
/new start a new chat during a conversation
/resume resume a saved chat
今回のテーマはあくまで導入と会話なので、ここまでに使った3つのコマンドと、追加で4つのコマンドを確認します。
/new
新しい会話を開始できます。
/resume
セッションの一覧が表示され、選択することで会話を再開できます。
/quit
Codex CLIを終了します。
/fork
現在の会話から分岐して別の会話を開始できます。例えば以下のセッションにいる状態で実行します。
› こんにちは
• こんにちは!何を手伝いましょうか?
ここで /fork を実行すると、会話の履歴をそのまま引き継いで、新しい会話になりました。元のセッションはそのままです。
/model
使用するモデルを切り替えることができます。実行すると以下のように選択できるモデルが並びます。
Select Model and Effort
Access legacy models by running codex -m <model_name> or in your config.toml
› 1. gpt-5.3-codex (current) Latest frontier agentic coding model.
2. gpt-5.2-codex Frontier agentic coding model.
3. gpt-5.1-codex-max Codex-optimized flagship for deep and fast
reasoning.
4. gpt-5.2 Latest frontier model with improvements across
knowledge, reasoning and coding
5. gpt-5.1-codex-mini Optimized for codex. Cheaper, faster, but less
capable.
Press enter to select reasoning effort, or esc to dismiss.
モデルを選択すると、推論レベルの選択になります。
Select Reasoning Level for gpt-5.3-codex
1. Low Fast responses with lighter reasoning
› 2. Medium (default) Balances speed and reasoning depth for everyday tasks
3. High Greater reasoning depth for complex problems
4. Extra high Extra high reasoning depth for complex problems
Press enter to confirm or esc to go back
推論レベルという知らない概念が出てきました。Codex本人に聞いてみます。
› Codexにおける推論レベル(Reasoning Level)とは何か教えてください。
• Codex における推論レベル(Reasoning Level)は、速さ と 思考の深さ のトレードオ
フを調整する設定です。
同じ依頼でも、レベルによって「どれだけ段階的に検討してから実行・回答するか」が
変わります。
- 低:応答が速い。単純な修正・定型作業向け
- 中:速度と精度のバランス
- 高:複雑な実装・設計判断・難しいデバッグ向け(時間とコストは増えやすい)
使い分けの目安は「ミスの影響が大きいほど高くする」です。
例: 依存関係更新や大規模リファクタは高め、軽微な文言修正は低め。
› 自動で調整されるわけではなく、指定したレベルで実行されるのですか?
• 基本は「指定したレベルで実行される」と考えてよいです。
つまり、明示的に設定した Reasoning Level が優先されます。
実運用では、UI/環境側の既定値や上限・下限がある場合もあるので、最終的にはその
実行環境の設定仕様に従います。
ということだそうです。とりあえずMediumにしておきます。これを変えると何がどれぐらい変化するのか?は気になるところです。
/status
コマンドの名前通り、ステータスを確認することができます…という説明だとそのまますぎるので、公式ドキュメントから説明を引用しておきます。
Display session configuration and token usage.
(セッション構成とトークンの使用状況を表示します。)
Confirm the active model, approval policy, writable roots, and remaining context capacity.
(アクティブなモデル、承認ポリシー、書き込み可能なルート、および残りのコンテキスト容量を確認します。)
実行すると以下のような出力になりました。
╭─────────────────────────────────────────────────────────────────────────╮
│ >_ OpenAI Codex (v0.101.0) │
│ │
│ Visit https://chatgpt.com/codex/settings/usage for up-to-date │
│ information on rate limits and credits │
│ │
│ Model: gpt-5.3-codex (reasoning medium, summaries auto) │
│ Directory: ~/Desktop/GitHub/vite-react-mui-sample-app │
│ Permissions: Default │
│ Agents.md: <none> │
│ Account: xxx@xxx.com (Plus) │
│ Collaboration mode: Default │
│ Session: 019c897e-8bb3-7691-a743-dd29eb8dc304 │
│ │
│ Context window: 94% left (26K used / 258K) │
│ 5h limit: [████████████████████] 100% left │
│ (resets 03:43 on 26 Feb) │
│ Weekly limit: [████████████████████] 99% left │
│ (resets 16:57 on 2 Mar) │
╰─────────────────────────────────────────────────────────────────────────╯
/exit
Codex CLIを終了します。/quit と何が違うのかな?と思って公式ドキュメントを見てみたら、 /quit と同じと書いてありました。
おわりに
今回はCodex CLIの導入と、会話を中心とした基本操作を確認しました。記事内ではまだコードを触らせてないので、ChatGPTの延長に留まっていますが、少し実際にコードを触らせたり、ゼロから生成するところも試しているところです。今後も記事を書くかは未定ですが、引き続き試していきたいと思います。