Skip to content
Docs

Connect Codex

Select Connect Codex on the Overview, then choose Trust all and continue when Codex asks about the new hooks: TokenNibbler then shortens long Codex shell output before the model reads it. Connecting works on every plan, including Free.

  • Install TokenNibbler.
  • Install the Codex CLI and sign in with your ChatGPT account (codex login). Codex runs hooks by default.
  1. On the Overview, find the ChatGPT card and select Connect Codex.

  2. Read the dialog. It shows the file TokenNibbler will change, usually %USERPROFILE%\.codex\hooks.json, or ~/.codex/hooks.json on a Mac. If you set CODEX_HOME, the file in that folder is used instead. Select Connect Codex.

  3. The card’s status line now reads Connected · approve the hooks in Codex. Select Open Codex next to it. A new Codex session opens in its own window.

  4. When Codex asks about the new hooks, choose Trust all and continue.

  5. Run a build or a test in Codex. Codex sessions that were already open need a restart before they use the hooks.

  6. Check the card. Once the first result arrives, its status line reads Connected · last output with the time.

If the Open Codex button isn’t shown, TokenNibbler couldn’t find the codex command. Run codex in a terminal and choose Trust all and continue there.

Open Codex starts Codex in an empty folder of TokenNibbler’s own, trusted for that one session only, so Codex goes straight to the hooks review. It doesn’t change your Codex settings, and your open sessions are left alone. TokenNibbler never approves hooks for you: the choice is always yours, in Codex.

TokenNibbler adds two command hooks to hooks.json, both with the matcher Bash: one PreToolUse hook and one PostToolUse hook.

{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [{ "type": "command", "command": "…", "commandWindows": "…", "timeout": 10 }]
}
],
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [{ "type": "command", "command": "…", "commandWindows": "…", "timeout": 10 }]
}
]
}
}
  • Each hook is a short relay (PowerShell on Windows) that forwards the hook to TokenNibbler’s local service at 127.0.0.1:17841 and hands its reply back to Codex. You can read both in full when Codex asks you to review them. On Windows they don’t depend on where TokenNibbler is installed. On a Mac, keep TokenNibbler in Applications; if you move it, select Reconnect on the card.
  • PostToolUse shortens the output of direct shell calls after the command runs.
  • PreToolUse is there for code-mode models. In the Microsoft Store and Mac versions it lets every command run as typed. See Code mode below.
  • config.toml is never written. TokenNibbler only reads it, to tell you if hooks are turned off there.
  • Your existing hooks stay. Before every change, TokenNibbler saves an exact copy of hooks.json in the backups folder in TokenNibbler’s data folder (%USERPROFILE%\.tokennibbler on Windows, ~/Library/Application Support/TokenNibbler on a Mac), named codex-hooks-<time>.json.

Code-mode models such as gpt-6.1-sol run commands that Codex doesn’t let hooks shorten afterwards. In the Microsoft Store and Mac versions, these commands run exactly as Codex typed them, with their full output. In the Store version, Settings › Optimiser says so under Codex code mode. Everything else is shortened as usual: Claude Code, MCP results in Claude Code, and Codex’s direct shell calls through the PostToolUse hook.

Status lineWhat it means
Not connectedNo TokenNibbler hooks in hooks.json yet.
Connected · approve the hooks in CodexThe hooks are in place. Choose Trust all and continue in Codex, then run a command.
Connected · last output timeResults are arriving and being shortened.
Paused · output passes through unchangedYou paused the optimiser. Select Resume optimiser to start again.
Needs attentionHooks are turned off in config.toml, the hooks point to an older TokenNibbler location (the card offers Reconnect), or hooks.json couldn’t be read.
Codex not found on this PCTokenNibbler found no Codex folder.
  • Pause instead: select Pause optimiser on the Overview. Output passes through unchanged.
  • Disconnect: in Settings › Integrations, select Disconnect next to Codex integration. TokenNibbler removes both of its hooks and leaves your other hooks as they are. Restart open Codex sessions to refresh their hooks. When Codex isn’t connected, the same button reads Connect… (or Reconnect…) and opens the same confirmation.
  • Remove before you uninstall: in Settings › App, select Remove… under Remove from Claude Code and Codex. One confirmed step takes both hooks out of Codex, along with the Claude Code hook. Then uninstall TokenNibbler from Windows Settings, or on a Mac drag it from Applications to the Bin.

See Codex hooks aren’t running. For Claude Code, see Connect Claude Code.