インフラエンジニアのPC環境

インフラエンジニアは常に効率環境を目指している

ユーザ用ツール

サイト用ツール


サイドバー

目次

ホーム

AI
OS


CUIソフト

今はほぼ未使用

操作を覚える必要のあるおすすめソフト

ai:codexcli


Codex CLIの利用方法

インストール

Linux/Mac

curl -fsSL https://chatgpt.com/codex/install.sh | sh

Windows

# 最新へのバージョンアップも同じコマンド
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"


インストール画面

  Welcome to Codex, OpenAI's command-line coding agent

✓ Signed in with your ChatGPT account

> You are in /home/yamada/myapp

  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

現在のカレントフォルダに怪しいコード・悪意を持ったコードが存在していないかの確認です。
問題ない場合は 1. を選択してください。

インストール時に聞かれますが、ホームディレクトリなら、「2. No, quit」でよい。
改めて実行したいディレクトリに移動して、「codex」を実行すると、再度聞かれますので、「1. Yes, Continue」にします。


ブラウザーのないLinuxサーバでの認証方法

codex login --device-auth
  • ターミナルにURLと一時コードが表示される
  • 手元のWindows PCのブラウザでURLを開く
  • ChatGPT Plusを契約しているアカウントでログイン
  • 表示された一時コードを入力
  • Linuxサーバ側の認証が完了


起動と初期設定

codex    #codexを起動
/status
/model
/permissions
/status

/new
/resume

/quit   終了


設定

> model

› 1. gpt-5.6-sol (current)  Latest frontier agentic coding model.
  2. gpt-5.6-terra          Balanced agentic coding model for everyday work.
  3. gpt-5.6-luna           Fast and affordable agentic coding model.
  4. gpt-5.5                Frontier model for complex coding, research, and real-world work.
  5. gpt-5.4                Strong model for everyday coding.
  6. gpt-5.4-mini           Small, fast, and cost-efficient model for simpler coding tasks.

  Press enter to confirm or esc to go back
> /permissions

  Update Model Permissions

  1. Read Only                 Codex can read files in the current workspace. Approval is required to edit files or access the internet.
  2. Ask for approval          Codex can read and edit files in the current workspace, and run commands. Approval is required to access the internet or edit
                               other files.
› 3. Approve for me (current)  Only ask for actions detected as potentially unsafe.
  4. Full Access               Codex can edit files outside this workspace and access the internet without asking for approval. Exercise caution when using.

  Press enter to confirm or esc to go back


CLIコマンド

https://www.tohoho-web.com/ai/codex.html

終了:
  /quit                  Codex を終了します。
  /exit                  Codex を終了します(/quit と同義)。
  /logout                Codex からログアウトします。

状態:
  /status                現セッションの設定・モデル・使用量などを表示します。
  /ps                    バックグラウンド実行中のタスク/エージェント状況を表示します。
  /debug-config          現在有効な設定値を表示します。

会話管理:
  /new                   新しい会話を始めます(コンテキストをリセット)。
  /resume                過去の会話を再開します。
  /fork                  過去の会話を分岐して新しい流れを作ります。
  /compact               会話を要約してコンテキスト使用量を圧縮します。
  /rename                現在の会話タイトルを変更します。
  /clear                 画面表示をクリアします(会話履歴は削除しません)。
  /clean                 古い/不要なセッション情報を掃除します。

設定:
  /model                 使用モデルを変更します。
  /approvals             コマンド実行時の承認ポリシーを変更します。
  /permissions           ファイル/実行権限ポリシーを確認・変更します。
  /setup-default-sandbox デフォルトのサンドボックス設定を行います。
  /statusline            ステータスライン表示項目を変更します。
  /theme                 UI テーマを変更します。
  /settings              設定画面(設定メニュー)を開きます。
  /personality           応答スタイル(人格設定)を変更します。
  /plan                  Plan モード(計画重視モード)を切り替えます。
  /collab                Collaboration モード設定を切り替えます。

指示・作業:
  /mention               指定ファイルを文脈に追加して読むよう指示します。
  /diff                  変更差分(git diff)を表示します。
  /copy                  直近の出力をコピーしやすい形で表示します。
  /review                変更点をレビューして問題を検出します。
  /init                  AGENTS.md を作成します。

拡張・連携:
  /mcp                   構成済み MCP サーバー/ツールを管理します。
  /skills                インストール済み Skills を確認・管理します。
  /apps                  連携アプリ機能を表示/管理します。
  /agent                 マルチエージェント機能を管理します。
  /experimental          実験的機能の有効化/確認をします。
  /realtime              Realtime 機能の利用モードを切り替えます。

その他:
  /feedback              Codex メンテナーへフィードバックを送信します。

メモ

CLIだと、間違えて、ESCを押してして、中断してしまいがちです。
中断してしまったら、「中断したところから再開してください。」で再開します。


実行例

> pythonでhello world 作って


長い文の実行例

ファイルから読み込ませる。

~/git/project/
├── prompt/
│   ├── 20260708_add-features.md
│   ├── 20260809_update-architecture.md
│   └── 20260915_review-design.md
codex "$(cat prompt/add-features.md)"

##非対話の場合
codex exec "$(cat prompt.txt)"


関連ページ



ai/codexcli.txt · 最終更新: by kurihara

ページ用ツール