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 Plugin for Claude Code、常駐コストは449トークンだった

0
Last updated at Posted at 2026-07-19

はじめに

Claude Codeでプラグインを1つ入れるたび、「これで毎回のコンテキストがどれだけ重くなるか」は使うまで分からない。README には機能一覧が並ぶだけで、常駐コストやフック構成までは書かれていないことが多いからだ。

2026年7月、OpenAIが公式に「Codex Plugin for Claude Code」(openai/codex-plugin-cc)を公開した。Claude Codeの中から /codex:review 一発でOpenAI Codexにコードレビューをやらせたり、面倒なタスクを丸ごと委譲したりできるプラグインだ。Apache-2.0ライセンスで公開後1ヶ月弱ながら約2.9万スターを集めている。

「公式プラグインなら安心して入れられるだろう」と思う一方、実際にインストールしてセットアップからレビュー実行まで通してみないと、常駐コストもレビューの守備範囲も分からない。実際にインストールし、claude plugin details でコスト内訳を出し、認証なしの状態からログインまで持っていき、意図的にバグを仕込んだdiffでレビューを走らせてみた。

TL;DR

  • claude plugin marketplace add openai/codex-plugin-ccclaude plugin install codex@openai-codex の2コマンドで導入できる
  • プラグインの中身は 11 Skills・1 Agent・3 Hooks。常駐コストは claude plugin details 実測で 約449トークン
  • Stop(セッション終了)フックに タイムアウト900秒(15分) の「レビューゲート」機構が仕込まれているが、デフォルトは無効
  • OPENAI_API_KEY があっても自動では認証されない。codex login --with-api-key を明示的に叩く必要がある
  • 実際にCodexへレビューを投げると、diffに含まれない既存バグは「スコープ外」として無視 される(全文精査ではなく差分ベース)

前提環境

  • Claude Code CLI: 2.1.211
  • Node.js: v22.22.2 / npm: 10.9.7
  • codex-cli: 0.144.6npm install -g @openai/codex で導入)
  • codex-plugin-cc: 1.0.6

中身を覗く — 11 Skills・1 Agent・3 Hooks

インストール前に、まずマーケットプレイスを追加する。

$ claude plugin marketplace add openai/codex-plugin-cc
Adding marketplace…Cloning via HTTPS: https://github.com/openai/codex-plugin-cc.git
Refreshing marketplace cache (timeout: 120s)…
Clone complete, validating marketplace…
√ Successfully added marketplace: openai-codex (declared in user settings)

$ claude plugin install codex@openai-codex
Installing plugin "codex@openai-codex"...
√ Successfully installed plugin: codex@openai-codex (scope: user)

インストール自体は2コマンドで一瞬だが、気になるのは「このプラグインが常時どれだけコンテキストを食うか」だ。Claude Codeには claude plugin details というコマンドがあり、コンポーネント別のトークン見積もりまで出してくれる。

$ claude plugin details codex@openai-codex
codex 1.0.6
  Use Codex from Claude Code to review code or delegate tasks.

Component inventory
  Skills (11)  adversarial-review, cancel, codex-cli-runtime, codex-result-handling,
               gpt-5-4-prompting, rescue, result, review, setup, status, transfer
  Agents (1)  codex-rescue
  Hooks (3)  SessionStart, SessionEnd, Stop  (harness-only — no model context cost)
  MCP servers (0)
  LSP servers (0)

Projected token cost
  Always-on:   ~449 tok   added to every session

MCPサーバーは0個。Codexとの連携は全部スラッシュコマンド(/codex:review 等)とスクリプト呼び出しで完結している設計だ。常駐コストは449トークンで、他の重いMCP連携プラグイン(1コンテキストで数千トークン食うものもある)に比べればかなり軽い部類に入る。

Hooksが3つ登録されている点は見落としやすい。実体は hooks/hooks.json で、SessionStart/SessionEndは5秒タイムアウトの軽い処理だが、Stopフックだけタイムアウトが900秒(15分) に設定されている。

{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/stop-review-gate-hook.mjs\"",
            "timeout": 900
          }
        ]
      }
    ]
  }
}

stop-review-gate-hook.mjs の中身を読むと、これは「セッションを終了する前に、直前の変更をCodexにレビューさせてから止める」ためのゲート機構だった。ただし実装は config.stopReviewGatetrue の時だけ動く設計で、有効化するには /codex:setup --enable-review-gate を明示的に叩く必要がある。デフォルトはfalseなので、インストールしただけでセッション終了がブロックされることはない。ただし有効化すると、最大15分間セッションの終了が止まる可能性がある ことは覚えておいたほうがいい。

セットアップ — OPENAI_API_KEY があっても自動ログインはされない

プラグインには /codex:setup というヘルスチェックコマンドがあり、内部で codex-companion.mjs setup --json を叩いている。実際にインストール直後の状態で実行するとこうなる。

$ node "$PLUGIN_ROOT/scripts/codex-companion.mjs" setup --json
{
  "ready": false,
  "node": { "available": true, "detail": "v22.22.2" },
  "npm": { "available": true, "detail": "10.9.7" },
  "codex": { "available": false, "detail": "not found" },
  "auth": { "available": false, "loggedIn": false, "detail": "not found" },
  "nextSteps": [
    "Install Codex with `npm install -g @openai/codex`.",
    "Optional: run `/codex:setup --enable-review-gate` to require a fresh review before stop."
  ]
}

npm install -g @openai/codex でCodex CLI本体(codex-cli 0.144.6)を入れて再実行すると、codex.availabletrue になったが auth.loggedIn は依然 false

{
  "ready": false,
  "codex": { "available": true, "detail": "codex-cli 0.144.6; advanced runtime available" },
  "auth": {
    "available": true,
    "loggedIn": false,
    "detail": "The active provider requires OpenAI authentication",
    "requiresOpenaiAuth": true
  },
  "nextSteps": [
    "Run `!codex login`.",
    "If browser login is blocked, retry with `!codex login --device-auth` or `!codex login --with-api-key`."
  ]
}

環境変数に OPENAI_API_KEY が設定済みでも、codex-cliはそれを自動では拾わない。明示的にログインコマンドを通す必要がある。

$ printenv OPENAI_API_KEY | codex login --with-api-key
Reading API key from stdin...
Successfully logged in

$ codex login status
Logged in using an API key - sk-proj-***lX94A

この状態で setup --json を再実行すると、ようやく "ready": true になった。

{
  "ready": true,
  "auth": {
    "loggedIn": true,
    "detail": "API key configured (unverified)",
    "authMethod": "apiKey"
  },
  "reviewGateEnabled": false,
  "nextSteps": [
    "Optional: run `/codex:setup --enable-review-gate` to require a fresh review before stop."
  ]
}

環境変数があるからといって「入れればすぐ動く」わけではない、という当たり前だが見落としがちな挙動を、この段階を踏むことで確認できた。

実際にレビューを回してみた — diffの外は見ていなかった

セットアップが終わったところで、隔離した検証用リポジトリに意図的なバグを仕込み、/codex:review の実体である codex-companion.mjs review を直接叩いてみた。

まず「a - b を返す add 関数」をコミット済みの状態にしておき、そこに新たに multiply 関数を追加する変更だけを未コミットで作る。つまり 修正対象のdiffには add 関数のバグは含まれない

$ node "$PLUGIN_ROOT/scripts/codex-companion.mjs" review --wait
[codex] Starting Codex review thread.
[codex] Thread ready (019f785c-3d82-74c3-a2fc-a8497c98f05f).
[codex] Reviewer started: current changes
[codex] Running command: git status --short && git diff --no-ext-diff && git diff --cached --no-ext-diff
[codex] Running command: find . -maxdepth 3 -type f ...; cat add.js
[codex] Review output captured.
[codex] Turn completed.

# Codex Review
Target: working tree diff

The new multiply function is correctly implemented and exported.
The existing add bug predates this change and is outside the review scope.

Codexはファイル全体(cat add.js で中身を読んでいるにもかかわらず)を精査したうえで、add のバグは今回のdiffより前から存在するのでレビュー対象外」と明示的に判定して見送った。つまりこのレビューは「ファイルの品質チェック」ではなく「差分の品質チェック」として設計されている。

これは実運用上重要な意味を持つ。既存コードに潜むバグは /codex:review では拾えないということだ。レビューさせたいなら、そのコード自体を変更対象のdiffに含める必要がある。

著者視点の発見ポイント

READMEやコマンド一覧だけを読んでいた段階では、「Claude CodeからCodexを呼べる便利プラグイン」としか理解していなかった。実際に手を動かして分かったのは、①常駐コストが449トークンとMCP連携プラグインとしては軽量に設計されている点、②OPENAI_API_KEY を置くだけでは動かず明示ログインが要る点、③レビューの対象がdiffに限定され「ファイル全体の監査」ではない点、の3つだった。特に③は、既存のセキュリティホールや品質問題を洗い出す目的で導入すると期待外れになる可能性がある。あくまで「これから書くdiff」の品質ゲートとして使うのが向いている。

まとめ

  • claude plugin marketplace addclaude plugin install の2コマンドで導入できる公式プラグイン
  • 常駐コストは449トークン、MCPサーバーは使わずスクリプト直叩きで完結する軽量設計
  • Stopフックに15分タイムアウトのレビューゲートが仕込まれているが、デフォルトは無効
  • OPENAI_API_KEY があっても自動ログインはされない。codex login --with-api-key が必要
  • レビューはdiffスコープ限定。既存バグの監査目的では使えない

Claude CodeとCodexを併用している人は、まず claude plugin details でコストを確認してから導入するとよさそうだ。

関連記事

参考リンク

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?