0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Codex をCLIで試してみた。

Last updated at Posted at 2025-10-07

(https://openai.com/ja-JP/codex/)

CLIモードであればchatgptの使用料だけでよいので、コスト的にはうれしい。
vscodeはCopilot経由となりgitのCopilotの使用料が別途かかる


🪜 Step 1 Codex CLI セットアップ手順(初回準備)

(Ubuntu/Linux環境前提)


sudo apt update
sudo apt install -y nodejs npm
npm install -g @openai/codex

これで codex コマンドが使えるようになります。


🪜 Step 2:OpenAI アカウントでログイン

初回は認証を通す必要があります。

codex login

するとブラウザが開いて OpenAI アカウントでログイン。
→ 成功すると CLI に自動でトークンが登録されます。

🪜 Step 3:簡単な実行結果

以下は次の命令の実行ログ
› pythonでhello world 作って
› 実行して
› 出力を日本語にして

hy@hy-pc:~/workspace/p011_sandbox/p011_sandbox_Vault/S010_codex$ codex 
╭────────────────────────────────────────────────────────╮
│ >_ OpenAI Codex (v0.45.0)                              │
│                                                        │
│ model:     gpt-5-codex   /model to change              │
│ directory: ~/workspace/…/p011_sandbox_Vault/S010_codex │
╰────────────────────────────────────────────────────────╯

  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
  /approvals - choose what Codex can do without approval
  /model - choose what model and reasoning effort to use
  /review - review any changes and find issues


› pythonでhello world 作って


• Explored
  └ List ls

• Added ~/workspace/p011_sandbox/p011_sandbox_Vault/S010_codex/hello.py (+1 -0)
    1     +print("Hello, world!")

─ Worked for 7s ────────────────────────────────────────────────────────────────

• Created a simple script that prints Hello World in Python (hello.py:1). Run
  python hello.py if you want to see the output.


› 実行して


• Ran python hello.py
  └ bash: 行 1: python: コマンドが見つかりません

• Ran python3 hello.py
  └ Hello, world!

─ Worked for 3s ────────────────────────────────────────────────────────────────

• Ran python3 hello.py and got Hello, world! as expected. Let me know if you’d
  like any tweaks or next steps.


› 出力を日本語にして


• Edited ~/workspace/p011_sandbox/p011_sandbox_Vault/S010_codex/hello.py (+1 -1)
    1     -print("Hello, world!")
    1     +print("こんにちは、世界!")

 
› Improve documentation in @filename
 
  ? for shortcuts

とりあえず、お試しで使うぶんには簡単

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?