Codex: Codex Computer Use

最終更新:2026-08-31

Codex の Computer Use 機能は、従来のコーディングツールとの大きな差別化要因です — コードを書くだけでなく、コンピュータを操作できます。

📋 前提条件: Codex の基本操作とパーミッション設定を理解していること

1. 学ぶ内容


2. Computer Use とは

Computer Use により、Codex は人間のようにコンピュータを操作できます:

能力 説明
ブラウザ制御 Web ページを開く、クリック、入力、スクリーンショット
デスクトップアプリ制御 ローカルアプリケーションを操作
ファイル管理 ファイルシステムの閲覧、作成、変更
コマンド実行 ターミナルでコマンドを実行
100%
graph LR
    A[Codex エージェント] --> B[ブラウザ]
    A --> C[ターミナル]
    A --> D[ファイルシステム]
    A --> E[デスクトップアプリ]
    B --> B1[ナビゲーション]
    B --> B2[フォーム入力]
    B --> B3[スクリーンショット分析]
    C --> C1[コマンド実行]
    C --> C2[出力表示]
    D --> D1[ファイル読み書き]
    D --> D2[ディレクトリ操作]

3. ブラウザ制御

(1) 基本操作

TEXT 📖 参照専用
> Open https://example.com and take a screenshot
> Type "Codex tutorial" in the search box and search
> Fill in the registration form with alice@example.com as email
> Click the "Submit" button

(2) Web テスト

TEXT 📖 参照専用
> Open localhost:3000, verify login functionality works
> Screenshot the homepage, check responsive layout
> Test shopping cart flow: add item → checkout → confirm

▶ 例1:Alice が Web ページをテスト

TEXT 📖 参照専用
# Alice が Codex にエンドツーエンドテストを実行させる
> Open http://localhost:8080
> Register a test account test@example.com / password123
> After login, create a new project
> Screenshot to confirm the project list displays correctly
> Delete the test account

# Codex 出力:
# → Opening browser to http://localhost:8080
# → Filling registration form
# → Clicking "Register" button
# → Logging in with test credentials
# → Creating project "Test Project"
# → Taking screenshot of project list
# → Account deleted successfully
# → Test completed ✓

4. デスクトップアプリケーションの制御

(1) 操作例

TEXT 📖 参照専用
> Open VS Code and open the current project
> Run npm start in the terminal
> Open the browser to access localhost:3000
> Screenshot to confirm the page displays correctly

(2) マルチステップ操作

TEXT 📖 参照専用
> Execute the following:
> 1. Start the database in the terminal
> 2. Run database migrations
> 3. Start the development server
> 4. Open the browser to verify
> 5. Screenshot to confirm all functions work

▶ 例2:Bob のデプロイ検証

TEXT 📖 参照専用
> Deploy to staging environment:
> 1. git push origin staging
> 2. Wait for CI to complete
> 3. Open staging.example.com
> 4. Test key functions: login, search, checkout
> 5. Screenshot each step
> 6. Generate test report

5. セキュリティとプライバシー

(1) Computer Use のパーミッション要件

Computer Use には Full-access サンドボックスモードが必要です:

考慮事項 説明
高い権限 Codex は任意のアプリケーションを操作可能
視覚アクセス Codex は画面の内容を見ることができる
入力シミュレーション Codex はキーボードとマウスの操作をシミュレート
ネットワークアクセス Codex は任意の Web サイトにアクセス可能

(2) セキュリティ推奨事項

TEXT 📖 参照専用
⚠️ Computer Use セキュリティチェックリスト:

1. 機密情報を含む画面では使用しない
2. 銀行/決済 Web サイトに Codex をアクセスさせない
3. 常に Codex の操作を監視する
4. 使用後に異常な操作がないか確認する
5. 本番環境の操作には特に注意する

(3) 操作確認

Computer Use モードでも、重要な操作には確認が必要です:

TEXT 📖 参照専用
⚠️ Codex が操作確認を要求:
- Open https://production.example.com
- 操作タイプ:ブラウザナビゲーション
- リスクレベル:高(本番環境)

[Approve] [Reject]

6. Computer Use 設定

TOML
# ~/.codex/config.toml

[computer_use]
enabled = true
browser = "chromium"              # ブラウザエンジン
headless = false                   # ヘッドレスモード
screenshot_interval = 5            # スクリーンショット間隔(秒)
max_operations = 100               # セッションあたりの最大操作数
require_confirmation = true         # 重要操作には確認が必要

7. Computer Use と従来の自動化の比較

次元 Computer Use 従来のスクリプト
柔軟性 高い(AI がページの変更を理解) 低い(固定セレクタに依存)
保守コスト 低い(UI の変更に自動適応) 高い(UI 変更時にスクリプトの更新が必要)
学習コスト 低い(自然言語での記述) 高い(Playwright/Selenium の学習が必要)
信頼性 中程度(AI が誤判断する可能性) 高い(完全一致)
最適な用途 探索的テスト、クイック検証 CI/CD 自動化、回帰テスト

❓ よくある質問

Q Computer Use にはどのパーミッションが必要ですか?
A Full-access サンドボックスモードが必要です。Codex がブラウザとデスクトップアプリケーションを操作する必要があるためです。信頼された環境でのみ使用してください。
Q Codex は任意のブラウザを操作できますか?
A Codex は Chromium エンジンを使用してブラウザを制御します。他のブラウザのサポートは限定的です。
Q Computer Use はビデオを録画しますか?
A Codex は分析と意思決定のために定期的にスクリーンショットを撮りますが、継続的なビデオ録画は行いません。スクリーンショットは一時ディレクトリに保存されます。
Q Computer Use はヘッドレスモードで動作しますか?
A はい。headless = true を設定すると、Codex はヘッドレスブラウザで動作し、サーバー環境に適しています。
Q Computer Use は Playwright に代わるものですか?
A 完全には代わりません。Computer Use はより柔軟ですが信頼性は低く、探索的テストに最適です。Playwright はより精密で信頼性が高く、CI/CD 自動化に向いています。互いに補完し合います。

📖 まとめ


📝 練習問題

  1. 基本 (⭐):Codex に Web ページを開いてスクリーンショットを撮らせる。
  2. 中級 (⭐⭐):Codex に Web フォームの入力フローを自動完了させる。
  3. 上級 (⭐⭐⭐):Computer Use を使ってエンドツーエンドテストを実装する — 登録からログイン、操作まで、テストレポートを生成する。
Web-Tutorial.com

Web-Tutorial 技術チーム

複数の開発者によって共同維持されているプログラミングチュートリアルプラットフォーム。各チュートリアルは専門分野の開発者が執筆・レビューしています。正確で信頼性の高いコンテンツを目指しています — 問題を見つけた場合はお知らせください。

100%