SpyBara
Go Premium

Documentation 2026-08-18 13:01 UTC to 2026-08-19 21:01 UTC

7 files changed +301 −48. View all changes and history on the product overview
2026
Wed 19 21:01 Tue 18 13:01 Mon 17 23:58 Sat 15 01:01 Fri 14 22:00 Thu 13 22:59 Wed 12 19:59 Tue 11 22:59 Mon 10 22:00 Sat 8 03:02 Fri 7 18:59 Thu 6 23:58 Wed 5 19:00 Tue 4 22:00 Mon 3 23:00 Sun 2 21:00
Details

2 2 

3> For the complete documentation index, see [llms.txt](https://learn.chatgpt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.3> For the complete documentation index, see [llms.txt](https://learn.chatgpt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

4 4 

5In the ChatGPT desktop app, worktrees let Codex run multiple independent chats in the same project without interfering with each other. For Git repositories, [scheduled tasks](https://learn.chatgpt.com/docs/automations) can run on dedicated background worktrees so they don't conflict with your ongoing work. In non-version-controlled projects, scheduled tasks run directly in the project directory. You can also start chats in a worktree manually and use Handoff to move a chat between Local and Worktree.5Worktrees let Codex run multiple independent chats in the same project without interfering with each other. The repository, worktree, and commands remain on the computer or remote development environment that contains the project. You can work directly in the ChatGPT desktop app, or use [Remote](https://learn.chatgpt.com/docs/remote) in the ChatGPT mobile app to start, guide, approve, and review worktree chats on a connected computer.

6 6 

7Worktrees are available only in Codex in the ChatGPT desktop app. Select7For Git repositories, [scheduled tasks](https://learn.chatgpt.com/docs/automations) can run on dedicated background worktrees so they don't conflict with your ongoing work. In non-version-controlled projects, scheduled tasks run directly in the project directory. You can also start chats in a worktree manually and use Handoff to move a chat between Local and Worktree.

8 **Codex** before you start a chat in a worktree.8 

9Worktrees don't run locally on your phone. With Remote, the mobile app

10 controls Codex on your connected computer, where the repository and worktree

11 remain, or in the remote development environment that computer uses. The

12 desktop-specific instructions below apply on the connected computer.

9 13 

10## What's a worktree14## What's a worktree

11 15 

codex-manual.md +141 −20

Details

2137At other intelligence levels, ask for subagents explicitly when you want work2137At other intelligence levels, ask for subagents explicitly when you want work

2138delegated in parallel.2138delegated in parallel.

2139 2139 

2140If you don't pin a model or `model_reasoning_effort`, Codex can choose a setup2140If you don't configure a subagent model or `model_reasoning_effort`, the

2141that balances intelligence, speed, and price for the task. It may favor `gpt-5.6-terra` for fast scans or a higher-effort `gpt-5.6` configuration for more demanding reasoning. When you want finer control, steer that choice in your prompt or set `model` and `model_reasoning_effort` directly in the agent file.2141subagent inherits the parent agent's model and reasoning effort. If an explicit

2142spawn request or an `[agents]` default selects a model without an

2143explicit or configured reasoning effort, the subagent uses that model's default

2144reasoning effort. To balance intelligence, speed, and price for each task,

2145request a specific model or reasoning effort in your prompt,

2146configure `[agents]` defaults in `config.toml`, or set `model` and

2147`model_reasoning_effort` directly in the custom agent file.

2148For example, use `gpt-5.6-terra` for fast scans or a higher-effort `gpt-5.6` configuration for more demanding reasoning.

2142 2149 

2143For most tasks in Codex, start with2150For most tasks in Codex, start with

2144`gpt-5.6`. Use2151`gpt-5.6`. Use


2265- `developer_instructions`2272- `developer_instructions`

2266 2273 

2267If a custom agent file sets `model` or `model_reasoning_effort`, the value in2274If a custom agent file sets `model` or `model_reasoning_effort`, the value in

2268the file takes precedence. Otherwise, Codex resolves each setting independently:2275the file takes precedence. Before applying the file, Codex resolves each setting

2269an explicit spawn value, then the corresponding `[agents]` default, then the2276from an explicit spawn value, then the corresponding `[agents]` default, then

2270parent's value. If a spawn selects a different model and neither an explicit nor2277the parent's value. If an explicit spawn request or an `[agents]` default

2271configured effort is present, Codex uses that model's default effort. Other2278selects a model and neither supplies a reasoning effort, Codex uses

2272session settings, such as `sandbox_mode`, `mcp_servers`, and `skills.config`,2279that model's default effort. A custom agent file that sets only `model`

2273inherit from the parent when the custom agent file omits them.2280preserves this previously resolved effort. Set `model_reasoning_effort` in the

2281file too if the selected model doesn't support that effort or you want a

2282different one. Other session settings, such as `sandbox_mode`, `mcp_servers`,

2283and `skills.config`, inherit from the parent when the custom agent file omits

2284them.

2274 2285 

2275#### Global settings2286#### Global settings

2276 2287 


4001npx @openai/codex-security info --json4012npx @openai/codex-security info --json

4002```4013```

4003 4014 

4015See the [CLI and SDK releases](https://github.com/openai/codex-security/releases)

4016for package changes.

4017 

4004List the available commands:4018List the available commands:

4005 4019 

4006```bash4020```bash


4097plain progress lines instead. CI and terminals without an interactive session4111plain progress lines instead. CI and terminals without an interactive session

4098use plain progress automatically.4112use plain progress automatically.

4099 4113 

4114The dashboard also shows live session details. These can contain source code

4115or credentials, so review them before sharing.

4116 

4100By default, the CLI writes scan progress and its completion summary to stderr.4117By default, the CLI writes scan progress and its completion summary to stderr.

4101It doesn't print the full scan result to stdout. A completed scan prints a4118It doesn't print the full scan result to stdout. A completed scan prints a

4102summary like this:4119summary like this:


4132 --effort high4149 --effort high

4133```4150```

4134 4151 

4135Supported effort levels are `minimal`, `low`, `medium`, `high`, and `xhigh`.4152Supported effort levels are `minimal`, `low`, `medium`, `high`, `xhigh`, and

4153`max`.

4136 4154 

4137#### Review the results4155#### Review the results

4138 4156 


4162The [CLI reference](https://learn.chatgpt.com/docs/security/cli/reference#scan-artifacts) describes4180The [CLI reference](https://learn.chatgpt.com/docs/security/cli/reference#scan-artifacts) describes

4163the full artifact and output contract.4181the full artifact and output contract.

4164 4182 

4183#### Review and patch findings

4184 

4185After a complete interactive scan with findings, the CLI offers a finding

4186browser. Review the evidence and choose which findings to fix. You can find

4187the saved tasks in the Codex desktop app.

4188 

4189To patch high and critical findings without the browser:

4190 

4191```bash

4192npx @openai/codex-security scan "$REPOSITORY" \

4193 --patch --patch-severity high --json

4194```

4195 

4196Add `--create-pr` to commit verified patches and open a GitHub pull request.

4197 

4198You can also patch saved findings or import Linear issues. See the

4199[`validate` and `patch` reference](https://learn.chatgpt.com/docs/security/cli/reference#codex-security-validate-and-codex-security-patch).

4200 

4165#### Choose the next scan4201#### Choose the next scan

4166 4202 

4167Use a path scan when a repository contains separate services or packages:4203Use a path scan when a repository contains separate services or packages:


4514 [--subagents N] [--stop-after-no-new N]4550 [--subagents N] [--stop-after-no-new N]

4515 [--max-discovery-runs N] [--max-time-hours HOURS]4551 [--max-discovery-runs N] [--max-time-hours HOURS]

4516 [--model MODEL]4552 [--model MODEL]

4517 [--effort {minimal,low,medium,high,xhigh}]4553 [--effort {minimal,low,medium,high,xhigh,max}]

4518 [--output-dir DIR]4554 [--output-dir DIR]

4519 [--archive-existing]4555 [--archive-existing]

4520 [--plugin-path PATH] [--python PATH]4556 [--plugin-path PATH] [--python PATH]

4521 [--codex KEY=VALUE] [--fail-on-severity LEVEL]4557 [--codex KEY=VALUE] [--fail-on-severity LEVEL]

4558 [--patch] [--patch-severity {critical,high,medium,low}]

4559 [--create-pr]

4522 [--max-cost USD] [--dry-run] [--headless] [--verbose]4560 [--max-cost USD] [--dry-run] [--headless] [--verbose]

4523 [--json] [--format {toon,json,yaml,jsonl}]4561 [--json] [--format {toon,json,yaml,jsonl}]

4524 [--full-output] [repository]4562 [--full-output] [repository]


4733| `--output-dir DIR` | Write scan artifacts to a private directory outside the enclosing Git worktree. Defaults to persistent Codex Security state. |4771| `--output-dir DIR` | Write scan artifacts to a private directory outside the enclosing Git worktree. Defaults to persistent Codex Security state. |

4734| `--archive-existing` | Move existing results to `DIR.previous--` and start with an empty output directory. Requires `--output-dir`. |4772| `--archive-existing` | Move existing results to `DIR.previous--` and start with an empty output directory. Requires `--output-dir`. |

4735| `--fail-on-severity LEVEL` | Return exit `1` when a completed scan reports a finding at or above `critical`, `high`, `medium`, or `low`. |4773| `--fail-on-severity LEVEL` | Return exit `1` when a completed scan reports a finding at or above `critical`, `high`, `medium`, or `low`. |

4774| `--patch` | Fix and verify selected findings after a complete scan. |

4775| `--patch-severity LEVEL` | Patch findings at or above `critical`, `high`, `medium`, or `low`. Defaults to `low`. |

4776| `--create-pr` | Commit verified patch files and open a GitHub pull request. Requires `--patch`. |

4736| `--max-cost USD` | Stop a scan when its estimated model cost exceeds the specified USD amount. |4777| `--max-cost USD` | Stop a scan when its estimated model cost exceeds the specified USD amount. |

4737| `--dry-run` | Check the repository, target, knowledge base, output directory, and Codex configuration without starting a scan. |4778| `--dry-run` | Check the repository, target, knowledge base, output directory, and Codex configuration without starting a scan. |

4738| `--headless` | Show plain-text progress instead of the interactive scan dashboard. |4779| `--headless` | Show plain-text progress instead of the interactive scan dashboard. |


4802| `--auth {auto,chatgpt,api-key}` | Select the scan credentials. The default is `auto`. |4843| `--auth {auto,chatgpt,api-key}` | Select the scan credentials. The default is `auto`. |

4803| `--provider {openai,openrouter,fireworks,amazon-bedrock}` | Select the inference provider. The default is `openai`. |4844| `--provider {openai,openrouter,fireworks,amazon-bedrock}` | Select the inference provider. The default is `openai`. |

4804| `--model MODEL` | Select the model. The default is `gpt-5.6-sol`. Required for OpenRouter, Fireworks, and Amazon Bedrock. |4845| `--model MODEL` | Select the model. The default is `gpt-5.6-sol`. Required for OpenRouter, Fireworks, and Amazon Bedrock. |

4805| `--effort {minimal,low,medium,high,xhigh}` | Select the model's reasoning effort. The default is `xhigh`. |4846| `--effort {minimal,low,medium,high,xhigh,max}` | Select the model's reasoning effort. The default is `xhigh`. |

4806| `--plugin-path PATH` | Use a Codex Security plugin directory or ZIP to override the bundled plugin. |4847| `--plugin-path PATH` | Use a Codex Security plugin directory or ZIP to override the bundled plugin. |

4807| `--python PATH` | Select the Python interpreter for the plugin runtime. |4848| `--python PATH` | Select the Python interpreter for the plugin runtime. |

4808| `--codex KEY=VALUE` | Override an isolated Codex configuration value. Values use TOML syntax. Repeat the flag for more values. |4849| `--codex KEY=VALUE` | Override an isolated Codex configuration value. Values use TOML syntax. Repeat the flag for more values. |


4851 [--workers N] [--mode {standard,deep}]4892 [--workers N] [--mode {standard,deep}]

4852 [--provider {openai,openrouter,fireworks,amazon-bedrock}]4893 [--provider {openai,openrouter,fireworks,amazon-bedrock}]

4853 [--model MODEL]4894 [--model MODEL]

4854 [--effort {minimal,low,medium,high,xhigh}]4895 [--effort {minimal,low,medium,high,xhigh,max}]

4855 [--knowledge-base PATH]4896 [--knowledge-base PATH]

4856 [--scan-prompt-file FILE]4897 [--scan-prompt-file FILE]

4857 [--post-scan-prompt-file FILE]4898 [--post-scan-prompt-file FILE]


5197 "Missing authorization check in src/routes.ts:18"5238 "Missing authorization check in src/routes.ts:18"

5198```5239```

5199 5240 

5200Each argument can contain literal text or point to a file. Both commands work5241Each positional argument accepts literal text or a file path. These inputs use

5201against the current directory. Use `validate` to directly recheck an original5242the current directory. Use `validate` to recheck a finding after a fix or when a

5202finding after a fix or when a later scan no longer reports it. A scan5243later scan no longer reports it. Comparing scans alone doesn't prove that a fix

5203comparison alone doesn't prove that a fix worked. External tools can use these5244worked.

5204commands without rebuilding the scanner.

5205 5245 

5206Use `--effort` to select reasoning effort for either command:5246Use `--effort` to select reasoning effort for either command:

5207 5247 


5209npx @openai/codex-security validate "Possible SQL injection" --effort high5249npx @openai/codex-security validate "Possible SQL injection" --effort high

5210```5250```

5211 5251 

5252#### Patch findings after a scan

5253 

5254Use `scan --patch` to fix findings after a complete scan. This requires

5255`@openai/codex-security` 0.1.15 or later. The default severity threshold is

5256`low`. This command selects high and critical findings:

5257 

5258```bash

5259npx @openai/codex-security scan . --patch --patch-severity high --json

5260```

5261 

5262Verified and already-fixed findings don't trigger `--fail-on-severity`.

5263 

5264#### Patch saved findings

5265 

5266Pass a finding or occurrence ID to patch its original repository, or select

5267findings from a saved scan:

5268 

5269```bash

5270npx @openai/codex-security patch OCCURRENCE_ID

5271npx @openai/codex-security patch --scan SCAN_ID --severity high --json

5272npx @openai/codex-security patch --scan latest --severity medium

5273```

5274 

5275`--scan latest` selects the latest completed scan for the current repository.

5276Saved-finding commands support `--json`; literal-text and file inputs don't.

5277 

5278Add `--create-pr` to commit only verified patch files and open a pull request

5279with the GitHub CLI:

5280 

5281```bash

5282npx @openai/codex-security patch --scan SCAN_ID --severity high --create-pr

5283```

5284 

5285If the push or pull request fails, run the printed `patch --resume-pr BRANCH`

5286command from the same repository to retry.

5287 

5288#### Patch Linear issues

5289 

5290Set `CODEX_SECURITY_LINEAR_API_KEY` or `LINEAR_API_KEY` for a personal API key,

5291or `LINEAR_ACCESS_TOKEN` for an OAuth token. Prefer an environment variable to

5292`--linear-api-key KEY` to keep the key out of shell history.

5293 

5294Import an issue by ID or URL. Repeat `--linear-issue` to select more than one

5295issue:

5296 

5297```bash

5298npx @openai/codex-security patch --linear-issue SEC-123 --linear-issue SEC-124

5299```

5300 

5301Use `--linear-project` to select a project's open issues. Add `--linear-filter`

5302to narrow the selection:

5303 

5304```bash

5305npx @openai/codex-security patch --linear-project "Security backlog" \

5306 --linear-filter '{"labels":{"name":{"eq":"security"}}}'

5307```

5308 

5309The CLI excludes completed and canceled issues unless the filter sets `state`.

5310It doesn't change the Linear issues.

5311 

5212#### `codex-security login`, `logout`, and `info`5312#### `codex-security login`, `logout`, and `info`

5213 5313 

5214Sign in interactively:5314Sign in interactively:


5271npx @openai/codex-security scan . --headless5371npx @openai/codex-security scan . --headless

5272```5372```

5273 5373 

5374The dashboard also shows live session details. They aren't redacted and can

5375contain source code or credentials. Review them before sharing.

5376 

5274#### Verbose diagnostics5377#### Verbose diagnostics

5275 5378 

5276Add `--verbose` to print redacted lifecycle, authentication, progress, and cost5379Add `--verbose` to print redacted lifecycle, authentication, progress, and cost


5328 usage5431 usage

5329```5432```

5330 5433 

5434When [patching](#patch-findings-after-a-scan), JSON output also includes patch

5435results and any created pull request.

5436 

5331Progress, completion summaries, archive notices, and errors remain on stderr.5437Progress, completion summaries, archive notices, and errors remain on stderr.

5332A completed scan still prints the full JSON result when a severity policy5438A completed scan still prints the full JSON result when a severity policy

5333returns exit `1` or incomplete coverage returns exit `2`.5439returns exit `1` or incomplete coverage returns exit `2`.


6486}6592}

6487```6593```

6488 6594 

6595Findings can include optional `codeEvidence`, `rootCause`, `validation`,

6596`attackPath`, `remediationTests`, and `preventiveControls` fields.

6597 

6489For repository-wide findings, `confirmedInLatestScan` distinguishes findings6598For repository-wide findings, `confirmedInLatestScan` distinguishes findings

6490seen in the latest scan from earlier findings that remain open:6599seen in the latest scan from earlier findings that remain open:

6491 6600 


6520 onWorkerStatus(status) {6629 onWorkerStatus(status) {

6521 console.log(status.kind, status);6630 console.log(status.kind, status);

6522 },6631 },

6632 onSessionEvent(session) {

6633 console.log(session.threadId, session.worker, session.event["type"]);

6634 },

6523 onReconnect(attempt, maxAttempts) {6635 onReconnect(attempt, maxAttempts) {

6524 console.log(`Reconnect attempt ${attempt} of ${maxAttempts}`);6636 console.log(`Reconnect attempt ${attempt} of ${maxAttempts}`);

6525 },6637 },


6573| `onActivity(activity)` | A command, tool, reasoning step, or message updates. |6685| `onActivity(activity)` | A command, tool, reasoning step, or message updates. |

6574| `onProgress(progress)` | The scan phase or reviewed file count changes. |6686| `onProgress(progress)` | The scan phase or reviewed file count changes. |

6575| `onWorkerStatus(status)` | Worker preflight or dispatch status changes. |6687| `onWorkerStatus(status)` | Worker preflight or dispatch status changes. |

6688| `onSessionEvent(session)` | A scan or worker session emits an event. |

6576| `onCost(cost)` | An updated estimated scan cost is available. |6689| `onCost(cost)` | An updated estimated scan cost is available. |

6577| `onWarning(warning)` | The scan reports a warning. |6690| `onWarning(warning)` | The scan reports a warning. |

6578| `onObserverError(observer, error)` | Another scan lifecycle callback raises an error. |6691| `onObserverError(observer, error)` | Another scan lifecycle callback raises an error. |


6580Trusted Access status is `granted`, `not_granted`, or `unknown`. Missing or6693Trusted Access status is `granted`, `not_granted`, or `unknown`. Missing or

6581unknown access also triggers `onWarning`.6694unknown access also triggers `onWarning`.

6582 6695 

6696`onSessionEvent` receives events that aren't redacted and can contain source

6697code or credentials. Filter them before sending them to shared logs or other

6698services.

6699 

6583#### Configure the runtime and credentials6700#### Configure the runtime and credentials

6584 6701 

6585Pass runtime configuration when you need a specific plugin, interpreter, or6702Pass runtime configuration when you need a specific plugin, interpreter, or


17931 18048 

17932Source: [Worktrees](https://learn.chatgpt.com/docs/environments/git-worktrees.md)18049Source: [Worktrees](https://learn.chatgpt.com/docs/environments/git-worktrees.md)

17933 18050 

17934In the ChatGPT desktop app, worktrees let Codex run multiple independent chats in the same project without interfering with each other. For Git repositories, [scheduled tasks](https://learn.chatgpt.com/docs/automations) can run on dedicated background worktrees so they don't conflict with your ongoing work. In non-version-controlled projects, scheduled tasks run directly in the project directory. You can also start chats in a worktree manually and use Handoff to move a chat between Local and Worktree.18051Worktrees let Codex run multiple independent chats in the same project without interfering with each other. The repository, worktree, and commands remain on the computer or remote development environment that contains the project. You can work directly in the ChatGPT desktop app, or use [Remote](https://learn.chatgpt.com/docs/remote) in the ChatGPT mobile app to start, guide, approve, and review worktree chats on a connected computer.

18052 

18053For Git repositories, [scheduled tasks](https://learn.chatgpt.com/docs/automations) can run on dedicated background worktrees so they don't conflict with your ongoing work. In non-version-controlled projects, scheduled tasks run directly in the project directory. You can also start chats in a worktree manually and use Handoff to move a chat between Local and Worktree.

17935 18054 

17936Worktrees are available only in Codex in the ChatGPT desktop app. Select18055Worktrees don't run locally on your phone. With Remote, the mobile app

17937**Codex** before you start a chat in a worktree.18056controls Codex on your connected computer, where the repository and worktree

18057remain, or in the remote development environment that computer uses. The

18058desktop-specific instructions below apply on the connected computer.

17938 18059 

17939#### What's a worktree18060#### What's a worktree

17940 18061 

Details

154 154 

155<ContentModeSwitch group="codex-surface" ids="app,cli,ide">155<ContentModeSwitch group="codex-surface" ids="app,cli,ide">

156 156 

157If you don't pin a model or `model_reasoning_effort`, Codex can choose a setup157If you don't configure a subagent model or `model_reasoning_effort`, the

158that balances intelligence, speed, and price for the task. It may favor `gpt-5.6-terra` for fast scans or a higher-effort `gpt-5.6` configuration for more demanding reasoning. When you want finer control, steer that choice in your prompt or set `model` and `model_reasoning_effort` directly in the agent file.158subagent inherits the parent agent's model and reasoning effort. If an explicit

159spawn request or an `[agents]` default selects a model without an

160explicit or configured reasoning effort, the subagent uses that model's default

161reasoning effort. To balance intelligence, speed, and price for each task,

162request a specific model or reasoning effort in your prompt,

163configure `[agents]` defaults in `config.toml`, or set `model` and

164`model_reasoning_effort` directly in the custom agent file.

165For example, use `gpt-5.6-terra` for fast scans or a higher-effort `gpt-5.6` configuration for more demanding reasoning.

159 166 

160For most tasks in Codex, start with 167For most tasks in Codex, start with

161 `gpt-5.6`. Use 168 `gpt-5.6`. Use


342- `developer_instructions`349- `developer_instructions`

343 350 

344If a custom agent file sets `model` or `model_reasoning_effort`, the value in351If a custom agent file sets `model` or `model_reasoning_effort`, the value in

345the file takes precedence. Otherwise, Codex resolves each setting independently:352the file takes precedence. Before applying the file, Codex resolves each setting

346an explicit spawn value, then the corresponding `[agents]` default, then the353from an explicit spawn value, then the corresponding `[agents]` default, then

347parent's value. If a spawn selects a different model and neither an explicit nor354the parent's value. If an explicit spawn request or an `[agents]` default

348configured effort is present, Codex uses that model's default effort. Other355selects a model and neither supplies a reasoning effort, Codex uses

349session settings, such as `sandbox_mode`, `mcp_servers`, and `skills.config`,356that model's default effort. A custom agent file that sets only `model`

350inherit from the parent when the custom agent file omits them.357preserves this previously resolved effort. Set `model_reasoning_effort` in the

358file too if the selected model doesn't support that effort or you want a

359different one. Other session settings, such as `sandbox_mode`, `mcp_servers`,

360and `skills.config`, inherit from the parent when the custom agent file omits

361them.

351 362 

352### Global settings363### Global settings

353 364 

security/cli.md +26 −1

Details

33npx @openai/codex-security info --json33npx @openai/codex-security info --json

34```34```

35 35 

36See the [CLI and SDK releases](https://github.com/openai/codex-security/releases)

37for package changes.

38 

36List the available commands:39List the available commands:

37 40 

38```bash41```bash


129plain progress lines instead. CI and terminals without an interactive session132plain progress lines instead. CI and terminals without an interactive session

130use plain progress automatically.133use plain progress automatically.

131 134 

135The dashboard also shows live session details. These can contain source code

136or credentials, so review them before sharing.

137 

132By default, the CLI writes scan progress and its completion summary to stderr.138By default, the CLI writes scan progress and its completion summary to stderr.

133It doesn't print the full scan result to stdout. A completed scan prints a139It doesn't print the full scan result to stdout. A completed scan prints a

134summary like this:140summary like this:


164 --effort high170 --effort high

165```171```

166 172 

167Supported effort levels are `minimal`, `low`, `medium`, `high`, and `xhigh`.173Supported effort levels are `minimal`, `low`, `medium`, `high`, `xhigh`, and

174`max`.

168 175 

169## Review the results176## Review the results

170 177 


194The [CLI reference](https://learn.chatgpt.com/docs/security/cli/reference#scan-artifacts) describes201The [CLI reference](https://learn.chatgpt.com/docs/security/cli/reference#scan-artifacts) describes

195the full artifact and output contract.202the full artifact and output contract.

196 203 

204## Review and patch findings

205 

206After a complete interactive scan with findings, the CLI offers a finding

207browser. Review the evidence and choose which findings to fix. You can find

208the saved tasks in the Codex desktop app.

209 

210To patch high and critical findings without the browser:

211 

212```bash

213npx @openai/codex-security scan "$REPOSITORY" \

214 --patch --patch-severity high --json

215```

216 

217Add `--create-pr` to commit verified patches and open a GitHub pull request.

218 

219You can also patch saved findings or import Linear issues. See the

220[`validate` and `patch` reference](https://learn.chatgpt.com/docs/security/cli/reference#codex-security-validate-and-codex-security-patch).

221 

197## Choose the next scan222## Choose the next scan

198 223 

199Use a path scan when a repository contains separate services or packages:224Use a path scan when a repository contains separate services or packages:

Details

118 [--subagents N] [--stop-after-no-new N]118 [--subagents N] [--stop-after-no-new N]

119 [--max-discovery-runs N] [--max-time-hours HOURS]119 [--max-discovery-runs N] [--max-time-hours HOURS]

120 [--model MODEL]120 [--model MODEL]

121 [--effort {minimal,low,medium,high,xhigh}]121 [--effort {minimal,low,medium,high,xhigh,max}]

122 [--output-dir DIR]122 [--output-dir DIR]

123 [--archive-existing]123 [--archive-existing]

124 [--plugin-path PATH] [--python PATH]124 [--plugin-path PATH] [--python PATH]

125 [--codex KEY=VALUE] [--fail-on-severity LEVEL]125 [--codex KEY=VALUE] [--fail-on-severity LEVEL]

126 [--patch] [--patch-severity {critical,high,medium,low}]

127 [--create-pr]

126 [--max-cost USD] [--dry-run] [--headless] [--verbose]128 [--max-cost USD] [--dry-run] [--headless] [--verbose]

127 [--json] [--format {toon,json,yaml,jsonl}]129 [--json] [--format {toon,json,yaml,jsonl}]

128 [--full-output] [repository]130 [--full-output] [repository]


337| `--output-dir DIR` | Write scan artifacts to a private directory outside the enclosing Git worktree. Defaults to persistent Codex Security state. |339| `--output-dir DIR` | Write scan artifacts to a private directory outside the enclosing Git worktree. Defaults to persistent Codex Security state. |

338| `--archive-existing` | Move existing results to `DIR.previous-<timestamp>-<id>` and start with an empty output directory. Requires `--output-dir`. |340| `--archive-existing` | Move existing results to `DIR.previous-<timestamp>-<id>` and start with an empty output directory. Requires `--output-dir`. |

339| `--fail-on-severity LEVEL` | Return exit `1` when a completed scan reports a finding at or above `critical`, `high`, `medium`, or `low`. |341| `--fail-on-severity LEVEL` | Return exit `1` when a completed scan reports a finding at or above `critical`, `high`, `medium`, or `low`. |

342| `--patch` | Fix and verify selected findings after a complete scan. |

343| `--patch-severity LEVEL` | Patch findings at or above `critical`, `high`, `medium`, or `low`. Defaults to `low`. |

344| `--create-pr` | Commit verified patch files and open a GitHub pull request. Requires `--patch`. |

340| `--max-cost USD` | Stop a scan when its estimated model cost exceeds the specified USD amount. |345| `--max-cost USD` | Stop a scan when its estimated model cost exceeds the specified USD amount. |

341| `--dry-run` | Check the repository, target, knowledge base, output directory, and Codex configuration without starting a scan. |346| `--dry-run` | Check the repository, target, knowledge base, output directory, and Codex configuration without starting a scan. |

342| `--headless` | Show plain-text progress instead of the interactive scan dashboard. |347| `--headless` | Show plain-text progress instead of the interactive scan dashboard. |


406| `--auth {auto,chatgpt,api-key}` | Select the scan credentials. The default is `auto`. |411| `--auth {auto,chatgpt,api-key}` | Select the scan credentials. The default is `auto`. |

407| `--provider {openai,openrouter,fireworks,amazon-bedrock}` | Select the inference provider. The default is `openai`. |412| `--provider {openai,openrouter,fireworks,amazon-bedrock}` | Select the inference provider. The default is `openai`. |

408| `--model MODEL` | Select the model. The default is `gpt-5.6-sol`. Required for OpenRouter, Fireworks, and Amazon Bedrock. |413| `--model MODEL` | Select the model. The default is `gpt-5.6-sol`. Required for OpenRouter, Fireworks, and Amazon Bedrock. |

409| `--effort {minimal,low,medium,high,xhigh}` | Select the model's reasoning effort. The default is `xhigh`. |414| `--effort {minimal,low,medium,high,xhigh,max}` | Select the model's reasoning effort. The default is `xhigh`. |

410| `--plugin-path PATH` | Use a Codex Security plugin directory or ZIP to override the bundled plugin. |415| `--plugin-path PATH` | Use a Codex Security plugin directory or ZIP to override the bundled plugin. |

411| `--python PATH` | Select the Python interpreter for the plugin runtime. |416| `--python PATH` | Select the Python interpreter for the plugin runtime. |

412| `--codex KEY=VALUE` | Override an isolated Codex configuration value. Values use TOML syntax. Repeat the flag for more values. |417| `--codex KEY=VALUE` | Override an isolated Codex configuration value. Values use TOML syntax. Repeat the flag for more values. |


455 [--workers N] [--mode {standard,deep}]460 [--workers N] [--mode {standard,deep}]

456 [--provider {openai,openrouter,fireworks,amazon-bedrock}]461 [--provider {openai,openrouter,fireworks,amazon-bedrock}]

457 [--model MODEL]462 [--model MODEL]

458 [--effort {minimal,low,medium,high,xhigh}]463 [--effort {minimal,low,medium,high,xhigh,max}]

459 [--knowledge-base PATH]464 [--knowledge-base PATH]

460 [--scan-prompt-file FILE]465 [--scan-prompt-file FILE]

461 [--post-scan-prompt-file FILE]466 [--post-scan-prompt-file FILE]


801 "Missing authorization check in src/routes.ts:18"806 "Missing authorization check in src/routes.ts:18"

802```807```

803 808 

804Each argument can contain literal text or point to a file. Both commands work809Each positional argument accepts literal text or a file path. These inputs use

805against the current directory. Use `validate` to directly recheck an original810the current directory. Use `validate` to recheck a finding after a fix or when a

806finding after a fix or when a later scan no longer reports it. A scan811later scan no longer reports it. Comparing scans alone doesn't prove that a fix

807comparison alone doesn't prove that a fix worked. External tools can use these812worked.

808commands without rebuilding the scanner.

809 813 

810Use `--effort` to select reasoning effort for either command:814Use `--effort` to select reasoning effort for either command:

811 815 


813npx @openai/codex-security validate "Possible SQL injection" --effort high817npx @openai/codex-security validate "Possible SQL injection" --effort high

814```818```

815 819 

820### Patch findings after a scan

821 

822Use `scan --patch` to fix findings after a complete scan. This requires

823`@openai/codex-security` 0.1.15 or later. The default severity threshold is

824`low`. This command selects high and critical findings:

825 

826```bash

827npx @openai/codex-security scan . --patch --patch-severity high --json

828```

829 

830Verified and already-fixed findings don't trigger `--fail-on-severity`.

831 

832### Patch saved findings

833 

834Pass a finding or occurrence ID to patch its original repository, or select

835findings from a saved scan:

836 

837```bash

838npx @openai/codex-security patch OCCURRENCE_ID

839npx @openai/codex-security patch --scan SCAN_ID --severity high --json

840npx @openai/codex-security patch --scan latest --severity medium

841```

842 

843`--scan latest` selects the latest completed scan for the current repository.

844Saved-finding commands support `--json`; literal-text and file inputs don't.

845 

846Add `--create-pr` to commit only verified patch files and open a pull request

847with the GitHub CLI:

848 

849```bash

850npx @openai/codex-security patch --scan SCAN_ID --severity high --create-pr

851```

852 

853If the push or pull request fails, run the printed `patch --resume-pr BRANCH`

854command from the same repository to retry.

855 

856### Patch Linear issues

857 

858Set `CODEX_SECURITY_LINEAR_API_KEY` or `LINEAR_API_KEY` for a personal API key,

859or `LINEAR_ACCESS_TOKEN` for an OAuth token. Prefer an environment variable to

860`--linear-api-key KEY` to keep the key out of shell history.

861 

862Import an issue by ID or URL. Repeat `--linear-issue` to select more than one

863issue:

864 

865```bash

866npx @openai/codex-security patch --linear-issue SEC-123 --linear-issue SEC-124

867```

868 

869Use `--linear-project` to select a project's open issues. Add `--linear-filter`

870to narrow the selection:

871 

872```bash

873npx @openai/codex-security patch --linear-project "Security backlog" \

874 --linear-filter '{"labels":{"name":{"eq":"security"}}}'

875```

876 

877The CLI excludes completed and canceled issues unless the filter sets `state`.

878It doesn't change the Linear issues.

879 

816## `codex-security login`, `logout`, and `info`880## `codex-security login`, `logout`, and `info`

817 881 

818Sign in interactively:882Sign in interactively:


875npx @openai/codex-security scan . --headless939npx @openai/codex-security scan . --headless

876```940```

877 941 

942The dashboard also shows live session details. They aren't redacted and can

943contain source code or credentials. Review them before sharing.

944 

878### Verbose diagnostics945### Verbose diagnostics

879 946 

880Add `--verbose` to print redacted lifecycle, authentication, progress, and cost947Add `--verbose` to print redacted lifecycle, authentication, progress, and cost


932 usage999 usage

933```1000```

934 1001 

1002When [patching](#patch-findings-after-a-scan), JSON output also includes patch

1003results and any created pull request.

1004 

935Progress, completion summaries, archive notices, and errors remain on stderr.1005Progress, completion summaries, archive notices, and errors remain on stderr.

936A completed scan still prints the full JSON result when a severity policy1006A completed scan still prints the full JSON result when a severity policy

937returns exit `1` or incomplete coverage returns exit `2`.1007returns exit `1` or incomplete coverage returns exit `2`.

security/sdk.md +11 −0

Details

307}307}

308```308```

309 309 

310Findings can include optional `codeEvidence`, `rootCause`, `validation`,

311`attackPath`, `remediationTests`, and `preventiveControls` fields.

312 

310For repository-wide findings, `confirmedInLatestScan` distinguishes findings313For repository-wide findings, `confirmedInLatestScan` distinguishes findings

311seen in the latest scan from earlier findings that remain open:314seen in the latest scan from earlier findings that remain open:

312 315 


341 onWorkerStatus(status) {344 onWorkerStatus(status) {

342 console.log(status.kind, status);345 console.log(status.kind, status);

343 },346 },

347 onSessionEvent(session) {

348 console.log(session.threadId, session.worker, session.event["type"]);

349 },

344 onReconnect(attempt, maxAttempts) {350 onReconnect(attempt, maxAttempts) {

345 console.log(`Reconnect attempt ${attempt} of ${maxAttempts}`);351 console.log(`Reconnect attempt ${attempt} of ${maxAttempts}`);

346 },352 },


394| `onActivity(activity)` | A command, tool, reasoning step, or message updates. |400| `onActivity(activity)` | A command, tool, reasoning step, or message updates. |

395| `onProgress(progress)` | The scan phase or reviewed file count changes. |401| `onProgress(progress)` | The scan phase or reviewed file count changes. |

396| `onWorkerStatus(status)` | Worker preflight or dispatch status changes. |402| `onWorkerStatus(status)` | Worker preflight or dispatch status changes. |

403| `onSessionEvent(session)` | A scan or worker session emits an event. |

397| `onCost(cost)` | An updated estimated scan cost is available. |404| `onCost(cost)` | An updated estimated scan cost is available. |

398| `onWarning(warning)` | The scan reports a warning. |405| `onWarning(warning)` | The scan reports a warning. |

399| `onObserverError(observer, error)` | Another scan lifecycle callback raises an error. |406| `onObserverError(observer, error)` | Another scan lifecycle callback raises an error. |


401Trusted Access status is `granted`, `not_granted`, or `unknown`. Missing or408Trusted Access status is `granted`, `not_granted`, or `unknown`. Missing or

402unknown access also triggers `onWarning`.409unknown access also triggers `onWarning`.

403 410 

411`onSessionEvent` receives events that aren't redacted and can contain source

412code or credentials. Filter them before sending them to shared logs or other

413services.

414 

404## Configure the runtime and credentials415## Configure the runtime and credentials

405 416 

406Pass runtime configuration when you need a specific plugin, interpreter, or417Pass runtime configuration when you need a specific plugin, interpreter, or

subagents.md +19 −8

Details

154 154 

155<ContentModeSwitch group="codex-surface" ids="app,cli,ide">155<ContentModeSwitch group="codex-surface" ids="app,cli,ide">

156 156 

157If you don't pin a model or `model_reasoning_effort`, Codex can choose a setup157If you don't configure a subagent model or `model_reasoning_effort`, the

158that balances intelligence, speed, and price for the task. It may favor `gpt-5.6-terra` for fast scans or a higher-effort `gpt-5.6` configuration for more demanding reasoning. When you want finer control, steer that choice in your prompt or set `model` and `model_reasoning_effort` directly in the agent file.158subagent inherits the parent agent's model and reasoning effort. If an explicit

159spawn request or an `[agents]` default selects a model without an

160explicit or configured reasoning effort, the subagent uses that model's default

161reasoning effort. To balance intelligence, speed, and price for each task,

162request a specific model or reasoning effort in your prompt,

163configure `[agents]` defaults in `config.toml`, or set `model` and

164`model_reasoning_effort` directly in the custom agent file.

165For example, use `gpt-5.6-terra` for fast scans or a higher-effort `gpt-5.6` configuration for more demanding reasoning.

159 166 

160For most tasks in Codex, start with 167For most tasks in Codex, start with

161 `gpt-5.6`. Use 168 `gpt-5.6`. Use


342- `developer_instructions`349- `developer_instructions`

343 350 

344If a custom agent file sets `model` or `model_reasoning_effort`, the value in351If a custom agent file sets `model` or `model_reasoning_effort`, the value in

345the file takes precedence. Otherwise, Codex resolves each setting independently:352the file takes precedence. Before applying the file, Codex resolves each setting

346an explicit spawn value, then the corresponding `[agents]` default, then the353from an explicit spawn value, then the corresponding `[agents]` default, then

347parent's value. If a spawn selects a different model and neither an explicit nor354the parent's value. If an explicit spawn request or an `[agents]` default

348configured effort is present, Codex uses that model's default effort. Other355selects a model and neither supplies a reasoning effort, Codex uses

349session settings, such as `sandbox_mode`, `mcp_servers`, and `skills.config`,356that model's default effort. A custom agent file that sets only `model`

350inherit from the parent when the custom agent file omits them.357preserves this previously resolved effort. Set `model_reasoning_effort` in the

358file too if the selected model doesn't support that effort or you want a

359different one. Other session settings, such as `sandbox_mode`, `mcp_servers`,

360and `skills.config`, inherit from the parent when the custom agent file omits

361them.

351 362 

352### Global settings363### Global settings

353 364