CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-openai--codex

OpenAI Codex CLI is a lightweight coding agent that runs locally, providing multimodal inputs, rich approvals workflow, and terminal-based AI-assisted development

Overview
Eval results
Files

execution-mode.mddocs/

Execution Mode

The execution mode allows running Codex non-interactively with a single prompt, ideal for CI/CD pipelines and scripted workflows.

Usage

codex exec [OPTIONS] <PROMPT>
codex e [OPTIONS] <PROMPT>

Arguments

<PROMPT>    # The prompt text to execute

Options

-m, --model <MODEL>                          # Specify AI model to use
--oss                                        # Use open source models
-p, --profile <PROFILE>                      # Use specific config profile
-c, --config <KEY=VALUE>                    # Runtime configuration overrides
-s, --sandbox <MODE>                         # Set sandbox mode
--full-auto                                  # Enable full automation mode
--dangerously-bypass-approvals-and-sandbox  # Bypass safety controls (dangerous)
-C, --cd <DIRECTORY>                         # Set working directory
--skip-git-repo-check                        # Allow running outside Git repository
--color <WHEN>                               # Color settings (always, never, auto)
--json                                       # Print events to stdout as JSONL
--output-last-message <FILE>                 # File to write last agent message
-i, --image <FILE>                           # Include image files (comma-separated)
[PROMPT]                                     # Prompt text (or "-" for stdin)

Subcommands

Resume

Resume a previous session in exec mode.

codex exec resume [OPTIONS] [SESSION_ID]
codex e resume [OPTIONS] [SESSION_ID]

Resume Arguments

[SESSION_ID]                                 # Session UUID to resume (optional)
--last                                       # Resume most recent session
[PROMPT]                                     # Additional prompt after resuming

Examples

# Basic non-interactive execution
codex exec "Fix the TypeScript errors in src/components"

# Use short alias
codex e "Create a README file for this project"

# Execute with full automation
codex exec --full-auto "Run tests and fix any failing tests"

# Execute with specific model and sandbox
codex exec -m gpt-4 -s workspace-write "Refactor the database layer"

# Execute with images and context
codex exec -i "wireframe.png,current-ui.png" "Implement the UI shown in wireframe.png"

# Execute in specific directory
codex exec -C /path/to/project "Add error handling to all API calls"

# Execute with JSON output
codex exec --json "Analyze the codebase structure" > analysis.jsonl

# Execute with colored output
codex exec --color always "Review code quality"

# Execute from stdin
echo "Fix all TypeScript errors" | codex exec -

# Resume exec session
codex exec resume --last "Continue with the implementation"

# Resume specific session with new prompt
codex exec resume 550e8400-e29b-41d4-a716-446655440000 "Add unit tests"

Automation Modes

Full Auto Mode

# Enable full automation (minimal prompts)
codex exec --full-auto "Deploy the application to staging"

Full auto mode:

  • Minimizes approval prompts
  • Automatically applies suggested changes
  • Suitable for trusted environments and well-scoped tasks

Sandbox Modes

# Different sandbox levels
codex exec -s none "Review code quality"
codex exec -s network-none "Process local data files"
codex exec -s workspace-read "Analyze project structure"
codex exec -s workspace-write "Fix linting issues"

Configuration Examples

# Use production config profile
codex exec -p production "Deploy to production"

# Override multiple config values
codex exec -c model=gpt-4 -c sandbox_mode=workspace-write -c approval_policy=never "Automated code cleanup"

# Complex execution with all options
codex exec \
  -m gpt-4 \
  -s workspace-write \
  --full-auto \
  --json \
  -C /path/to/project \
  -i "requirements.txt,architecture.md" \
  --output-last-message result.txt \
  "Implement the features described in architecture.md according to requirements.txt"

CI/CD Integration

Execution mode is designed for integration with automated workflows:

# In a CI/CD pipeline
codex exec --full-auto -s workspace-write "Run all tests and fix any failures"

# With exit code handling
if codex exec "Check code quality and suggest improvements"; then
    echo "Code quality check passed"
else
    echo "Code quality issues found"
    exit 1
fi

Output Handling

  • Standard output contains the execution results
  • Errors are written to standard error
  • Exit codes indicate success (0) or failure (non-zero)
  • Token usage information is printed at the end of successful executions

Best Practices

  1. Scope prompts clearly: Be specific about what you want to accomplish
  2. Use appropriate sandbox modes: Choose the minimum required permissions
  3. Enable full-auto carefully: Only in trusted environments with well-defined tasks
  4. Include relevant context: Use -i for images and -C for working directory
  5. Set appropriate approval policies: Balance automation with safety

Install with Tessl CLI

npx tessl i tessl/npm-openai--codex

docs

authentication.md

development-utilities.md

execution-mode.md

index.md

interactive-mode.md

mcp-management.md

protocol-mode.md

session-management.md

tile.json