> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yelu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Codex CLI examples

> Use Codex CLI with Yelu for safe repository exploration, implementation, code review, images, and non-interactive automation.

These examples assume the `yelu` provider is configured as described in the [Codex CLI setup guide](/en/guides/codex-cli). Run them from a Git repository with `YELU_API_KEY` available in the current environment.

## Explore in a read-only sandbox

```bash macOS / Windows / WSL theme={"theme":{"light":"github-light","dark":"github-dark"}}
codex --model gpt-5.4 --sandbox read-only \
  "Explain this repository's architecture, entry points, external dependencies, test coverage, and operational risks. Cite the files you inspected. Do not modify anything."
```

Inside the interactive UI, use `/status` to verify the Yelu provider and `/permissions` to inspect or change execution boundaries.

## Implement and verify a change

```bash macOS / Windows / WSL theme={"theme":{"light":"github-light","dark":"github-dark"}}
codex --model gpt-5.4 --sandbox workspace-write \
  "Add input validation to the user creation endpoint. Preserve the response contract, add focused tests for valid and invalid requests, run the relevant checks, and show the final diff summary."
```

`workspace-write` allows edits inside the workspace while retaining sandbox boundaries. Review the diff and test output before committing.

## Review local changes

Review all staged, unstaged, and untracked work without asking Codex to modify it:

```bash Terminal theme={"theme":{"light":"github-light","dark":"github-dark"}}
codex review --uncommitted \
  "Prioritize correctness, authorization bugs, data loss, concurrency hazards, and missing regression tests. Include file and line references."
```

Review a branch against its base:

```bash Terminal theme={"theme":{"light":"github-light","dark":"github-dark"}}
codex review --base main
```

## Run a non-interactive audit

```bash Terminal theme={"theme":{"light":"github-light","dark":"github-dark"}}
codex exec --model gpt-5.4 --sandbox read-only --ephemeral \
  "Audit authentication and authorization boundaries. Return concrete findings with severity, evidence, and remediation. Do not edit files."
```

`--ephemeral` avoids persisting the session rollout. The final response is written to standard output; progress is written to standard error.

## Save a final report

<CodeGroup>
  ```bash macOS / WSL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  codex exec --model gpt-5.4 --sandbox read-only \
    --output-last-message audit.md \
    "Summarize test gaps and propose the smallest high-value test plan."
  ```

  ```powershell Windows PowerShell theme={"theme":{"light":"github-light","dark":"github-dark"}}
  codex exec --model gpt-5.4 --sandbox read-only `
    --output-last-message audit.md `
    "Summarize test gaps and propose the smallest high-value test plan."
  ```
</CodeGroup>

## Use an image as context

Attach an error screenshot, UI reference, or architecture diagram:

<CodeGroup>
  ```bash macOS / WSL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  codex --model gpt-5.4 --image ./error.png \
    "Diagnose the error in this screenshot, find the responsible code, and propose a minimal fix."
  ```

  ```powershell Windows PowerShell theme={"theme":{"light":"github-light","dark":"github-dark"}}
  codex --model gpt-5.4 --image .\error.png `
    "Diagnose the error in this screenshot, find the responsible code, and propose a minimal fix."
  ```
</CodeGroup>

## Resume the latest session

```bash Terminal theme={"theme":{"light":"github-light","dark":"github-dark"}}
codex resume --last
```

Use the session picker with `codex resume` when several tasks exist for the same repository.

## Add repository instructions

Use `/init` in Codex or commit a reviewed `AGENTS.md`:

```markdown AGENTS.md theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Repository guidance

## Validation
- Run `npm test` for unit tests.
- Run `npm run lint` and `npm run typecheck` before completion.
- Add regression coverage for every fixed bug.

## Boundaries
- Do not read `.env`, credential files, or production exports.
- Do not change lockfiles unless dependencies intentionally change.
- Do not run deployments or irreversible database operations.
- Keep changes focused on the requested task.
```

<Warning>
  Keep sandboxing and approvals enabled for normal local work. Never use `--dangerously-bypass-approvals-and-sandbox` unless the process already runs inside a separately secured disposable environment.
</Warning>
