Skip to content

CLI Reference

Auto-generated from the registered Click command tree. All commands support --json for machine-readable output.

Core Commands

codex init

Initialize a project for semantic code indexing. Creates a .codex/ directory with default configuration.

bash
codex init [PATH]

codex index

Index a codebase for semantic search. Scans files, extracts chunks, generates embeddings.

bash
codex index .
codex index . --force    # Full re-index
FlagTypeDefaultDescription
--forcebooleanfalseForce full re-index, ignoring cache

codex doctor

Check environment health, dependencies, and project status.

bash
codex doctor
codex doctor --json

Search & Discovery

Search the indexed codebase using a natural language query.

bash
codex search "jwt verification"
codex search "database connection" --mode hybrid
codex search "def\s+authenticate" --mode regex -n
codex search "error handling" --mode keyword --full-section
codex search "TODO" --mode regex -l
codex search "pattern" --jsonl | jq .file_path
FlagTypeDefaultDescription
--top-k, -kintegerNumber of results
--json-output, --jsonbooleanfalseJSON output
--jsonlbooleanfalseOne JSON object per line
--mode, -mchoicesemanticsemantic, keyword, regex, or hybrid
--full-section, --fullbooleanfalseShow full enclosing function/class
--no-auto-indexbooleanfalseDisable automatic indexing
--case-sensitive, -sbooleanfalseCase-sensitive (regex only)
--context-lines, -Cinteger0Context lines around matches
--files-only, -lbooleanfalsePrint only file paths (grep -l)
--files-without-match, -LbooleanfalsePrint paths without matches (grep -L)
--line-numbers, -nbooleanfalsePrefix with line numbers (grep -n)
--path, -pdirectory.Project root path

codex explain

Explain a code symbol or all symbols in a file.

bash
codex explain MyClass -f src/models.py
codex explain --file src/main.py .
codex explain search_codebase --json
FlagTypeDefaultDescription
--file, -fpathSource file containing the symbol
--json-output, --jsonbooleanfalseJSON output
--path, -pdirectory.Project root path

codex context

Generate structured context for external AI pipelines.

bash
codex context query "authentication"
codex context symbol MyClass
codex context file src/main.py
codex context repo

Modes: query (semantic search), symbol (symbol context), file (file context), repo (repo summary).

FlagTypeDefaultDescription
--top-k, -kinteger5Results for query mode
--file-path, -ftextFile path hint (symbol mode)
--json-output, --jsonbooleanfalseJSON output
--path, -pdirectory.Project root path

codex deps

Show the dependency/import map for a file or project.

bash
codex deps src/main.py
codex deps . --json

codex summary

Generate a structured summary of the repository.

bash
codex summary
codex summary --json

AI-Powered Commands

codex ask

Ask a natural-language question about the codebase.

bash
codex ask "How does authentication work?"
codex ask "What does search_codebase do?" --json
FlagTypeDefaultDescription
--top-k, -kinteger5Context snippets to retrieve
--json-output, --jsonbooleanfalseJSON output
--path, -pdirectory.Project root path

codex chat

Multi-turn conversation about the codebase.

bash
codex chat "How does auth work?"
codex chat --session my-session "Follow up"
codex chat --list-sessions
codex chat --stream "Explain the flow"
FlagTypeDefaultDescription
--session, -stextSession ID to resume
--list-sessionsbooleanfalseList all sessions
--max-turns, -tinteger20Max conversation turns
--streambooleanfalseStream tokens
--json-output, --jsonbooleanfalseJSON output
--path, -pdirectory.Project root path

codex investigate

Autonomous multi-step investigation to answer a question.

bash
codex investigate "Find all security vulnerabilities"
codex investigate "How is payment flow implemented?" --max-steps 10
FlagTypeDefaultDescription
--max-steps, -ninteger6Maximum steps before conclusion
--streambooleanfalseStream conclusion tokens
--json-output, --jsonbooleanfalseJSON output
--path, -pdirectory.Project root path

codex review

AI-assisted code review.

bash
codex review src/main.py
codex review src/utils.py --json

codex refactor

AI-powered refactoring suggestions.

bash
codex refactor src/main.py
codex refactor src/utils.py -i "Extract duplicated logic"
FlagTypeDefaultDescription
--instruction, -itextImprove qualityRefactoring instruction
--json-output, --jsonbooleanfalseJSON output

codex suggest

Intelligent suggestions for a symbol, file, or topic.

bash
codex suggest search_codebase
codex suggest "error handling patterns" --json

codex cross-refactor

Find duplicate logic across workspace repos.

bash
codex cross-refactor --threshold 0.70

Quality & Metrics

codex quality

Analyze code quality — complexity, dead code, duplicates, security.

bash
codex quality
codex quality --json
codex quality --safety-only --pipe
codex quality --complexity-threshold 15
FlagTypeDefaultDescription
--complexity-thresholdinteger10Min complexity to report
--safety-onlybooleanfalseSecurity-only fast mode
--json-output, --jsonbooleanfalseJSON output
--pipebooleanfalsePlain text for CI
--path, -pdirectory.Project root path

codex metrics

Compute quality metrics, save snapshots, track trends.

bash
codex metrics
codex metrics --snapshot --json
codex metrics --history 10
codex metrics --trend
FlagTypeDefaultDescription
--snapshotbooleanfalseSave a quality snapshot
--historyinteger0Show last N snapshots
--trendbooleanfalseShow trend analysis
--json-output, --jsonbooleanfalseJSON output
--pipebooleanfalsePlain text for CI

codex gate

Enforce quality gates for CI.

bash
codex gate --strict
codex gate --min-maintainability 60 --max-complexity 15
FlagTypeDefaultDescription
--min-maintainabilityfloat40.0Min MI score
--max-complexityinteger25Max complexity
--max-issuesinteger20Max total issues
--strictbooleanfalseExit code 1 on failure

codex hotspots

Identify high-risk code hotspots.

bash
codex hotspots
codex hotspots --top-n 10 --json
codex hotspots --no-git --pipe
FlagTypeDefaultDescription
--top-n, -ninteger20Number of hotspots
--include-git / --no-gitbooleantrueInclude git churn

codex impact

Analyze blast radius of a change.

bash
codex impact parse_file
codex impact src/parser.py --json
codex impact MyClass --max-depth 3 --pipe
FlagTypeDefaultDescription
--max-depth, -dinteger5BFS depth limit

codex trace

Trace execution relationships for a symbol.

bash
codex trace parse_file
codex trace MyClass.process --json
FlagTypeDefaultDescription
--max-depth, -dinteger5Traversal depth

codex pr-summary

Generate a Pull Request intelligence report.

bash
codex pr-summary
codex pr-summary --json
codex pr-summary -f src/main.py -f src/utils.py

Servers & Integration

codex serve

Start the HTTP bridge server for AI agents.

bash
codex serve --port 24842
FlagTypeDefaultDescription
--host, -htext127.0.0.1Host to bind
--port, -pinteger24842Port to bind
--pathdirectory.Project root

codex web

Start the web interface and REST API.

bash
codex web
codex web --port 9000 --host 0.0.0.0
FlagTypeDefaultDescription
--host, -htext127.0.0.1Host to bind
--port, -pinteger8080Port to bind
--pathdirectory.Project root

codex mcp

Start the MCP server for Claude/Cursor.

bash
codex mcp --path /your/project

codex lsp

Start the Language Server Protocol server (stdio).

bash
codex lsp --path /your/project

codex tui

Interactive terminal search interface.

bash
codex tui
codex tui --mode hybrid -k 20
FlagTypeDefaultDescription
--mode, -mchoicehybridDefault search mode
--top-k, -kinteger10Results per query

Code Generation & Automation

codex evolve

Run the self-improving development loop.

bash
codex evolve
codex evolve --iterations 5 --budget 50000
codex evolve --timeout 300
FlagTypeDefaultDescription
--iterations, -ninteger3Max improvement iterations
--budget, -binteger20000Max total tokens
--timeout, -tinteger600Max wall-clock seconds

codex ci-gen

Generate CI/CD workflow templates.

bash
codex ci-gen analysis       # Full analysis workflow
codex ci-gen safety         # Lightweight safety-only
codex ci-gen precommit      # Pre-commit hook config

codex docs

Generate documentation for CodexA components.

bash
codex docs
codex docs --section plugins -o reference/

codex viz

Generate Mermaid diagrams from codebase analysis.

bash
codex viz callgraph
codex viz deps --target src/main.py
codex viz symbols --target auth.py
codex viz workspace
FlagTypeDefaultDescription
--target, -ttextSymbol or file to visualize
--output, -ofileWrite to file instead of stdout

codex watch

Watch for changes and re-index automatically.

bash
codex watch
codex watch --interval 5

Model Management

codex models list

List available embedding models.

codex models info <name>

Show detailed model information.

codex models download <name>

Pre-download a model for offline use.

codex models switch <name>

Switch active embedding model (requires re-index).

Plugin Management

codex plugin list

List discovered plugins.

codex plugin info <name>

Show plugin details.

codex plugin new <name>

Scaffold a new plugin from template.

bash
codex plugin new my-formatter
codex plugin new lint-checker --hooks CUSTOM_VALIDATION,POST_AI
codex plugin new metrics -o ./plugins/ -a "Your Name"

Workspace Management

codex workspace init

Initialize a new workspace.

codex workspace add <name> <path>

Register a repository in the workspace.

codex workspace list

List all registered repositories.

codex workspace remove <name>

Unregister a repository.

codex workspace index

Index workspace repositories.

codex workspace search <query>

Search across all workspace repos.

bash
codex workspace search "authentication" --top-k 10 --json
codex workspace search "auth" --repo backend --repo frontend

Released under the MIT License.