From zero to advanced with OpenAI’s coding agent.
Content extracted from the INEMA.Codex channel · Updated in May 2026
O Codex is OpenAI's coding agent — a direct rival to Claude Code. Its main differentiator: it runs agents in the cloud, letting you delegate coding tasks remotely (even from your phone) and receive ready-to-use pull requests without keeping the terminal open.
Codex has a context of 274K tokens (larger than Claude Code), native worktree support for parallel execution, and direct integration with GitHub Actions. For those who already use Claude Code, it’s a natural complement for long-running tasks in the cloud.
| Version | Best for | Detail |
|---|---|---|
| CLI (terminal) | Speed + local control | macOS, Windows, Linux. Direct integration with commands, tests, and repositories |
| App (Windows) | Complete visual interface | Skills, plugins, built-in browser, previews, multiple parallel threads, automations |
| Web (ChatGPT) | Delegate to the cloud | Connects GitHub repositories, runs agents without your PC turned on, accessible through the ChatGPT app |
The Codex CLI is installed via npm. Prerequisite: Node.js (which includes npm). After installing, sign-in uses device auth — you open a link in the browser and paste a code.
Installation is simple but has pitfalls: an outdated Node.js version causes errors. Device auth login is more secure than an API key — it works even in Docker containers.
winget install --id Git.Git -e --source winget # depois instale Node.js em nodejs.org
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - sudo apt-get install -y nodejs
npm -v # Deve retornar algo como: 10.x.x
npm install -g @openai/codex
codex login --device-auth # Saída esperada: # 1. Abra o link no browser: https://auth.openai.com/codex/device # 2. Digite o código: OJER-V4KD (expira em 15 min) # Device codes são alvo de phishing. NUNCA compartilhe. # Successfully logged in ✓
⚠️ The code expires in 15 minutes. Open the link immediately after running the command.
docker run --rm -it \ -v paperclip-codex-home:/codex-home \ -v "$PWD:/app" -w /app \ seu-container bash # Dentro do container: codex login --device-auth
After installing, you run codex in the terminal to open interactive mode. Inside it, / accesses internal commands and @ references project files.
The file agents.md is equivalent to CLAUDE.md — it defines permanent context, project goals, and instructions Codex remembers between sessions. Without it, Codex starts from scratch in every chat.
codex # abre modo interativo codex "crie uma API" # prompt direto codex chat # modo conversa codex --full-auto "..." # executa sem pedir confirmação
/plan mode— activates planning mode/model— switch models (low/high)/reasoning— adjust reasoning/browser use— activate browser/skill creator— create a skill/personality— adjust personalityCreate with codex init or manually. It works as permanent onboarding for the agent.
# agents.md ## Sobre o projeto - App de gestão de portfólio de ações - Stack: Next.js + Convex + Alpha Vantage API ## Decisões já tomadas - Usar shadcn/ui para componentes - Banco de dados: Convex (não Supabase) ## Instruções para o Codex - Sempre rodar testes antes de commit - Não fazer deploy sem minha aprovação
Codex asks for confirmation for every action by default. The approval policies control when and whether it asks for approval — from always asking to never asking anything.
If you're in a secure environment (container, isolated VM), disabling confirmations removes friction and greatly speeds up the cycle. For production or critical systems, keep confirmations enabled.
| Flag | Behavior | Risk |
|---|---|---|
| -a on-request | Codex decides when to ask | Low |
| -a never | Never asks for approval | Medium |
| --full-auto | Shortcut: on-request + sandbox write | Medium |
| --dangerously-bypass-approvals-and-sandbox | Zero confirmations, zero sandbox | High ⚠️ |
# ~/.codex/config.toml # Configuração equilibrada (recomendada em containers) approval_policy = "never" sandbox_mode = "workspace-write" # Configuração mais agressiva (só em ambientes isolados) # approval_policy = "never" # sandbox_mode = "danger-full-access"
Skills are reusable instructions for recurring tasks. You create it once, and Codex invokes it automatically when the task matches its description, or you call it explicitly with $nome-da-skill.
Skills eliminate repetition. A “PR review” skill can run 3 subagents in parallel (security, tests, architecture) without you rewriting the prompt every time.
meu-projeto/
.agents/
skills/
pr-review-agent/
SKILL.md ← obrigatório
scripts/ ← opcional
references/ ← opcional
--- name: pr-review-agent description: Use esta skill quando o usuário pedir revisão de pull request, branch, diff ou código alterado. Revise segurança, testes, arquitetura e riscos. --- Ao revisar um PR: 1. Leia o diff completo 2. Identifique arquivos alterados 3. Procure riscos de segurança 4. Verifique cobertura de testes 5. Avalie arquitetura e manutenção 6. Classifique achados por severidade 7. Sugira ações concretas 8. Finalize com checklist
# Invocação explícita $pr-review-agent # Invocação natural (Codex detecta automaticamente) "Revise o PR #42 e encontre problemas de segurança" # Combinando com subagentes "Use a skill $pr-review-agent com 3 subagentes em paralelo: segurança, testes, arquitetura"
Codex has several “names” for agents, but in practice you create them in 3 ways: a regular thread/task, configured subagents, and scheduled automations.
Understanding the hierarchy avoids confusion about the terminology. Start with threads + skills + automations. Subagents and workers come later.
| Name | What is | How to use |
|---|---|---|
| Main agent | Codex coordinating the task | Regular chat/thread |
| Agent thread | Separate conversation/task | New thread in the project |
| Worker agent | Worker for part of the work | "Split this into workers…" |
| Task agent | Agent with a specific task | "Create a task agent for…" |
| Subagent | Parallel specialized agent | "Use subagents…" |
| Background agent | Background agent | Background thread/task |
| Parallel agent | Multiple simultaneous tasks | Threads, subagents, or worktrees |
| Automation | Scheduled task | Automations tab |
| Skill | Reusable recipe | $skill-name or natural language |
| AGENTS.md | Permanent instructions | File in the project |
Specialized subagents are launched in parallel. Codex doesn't create them automatically — you need to explicitly ask in the prompt with "use subagents in parallel".
Complex tasks such as codebase audits, feature planning, and refactoring can be split up and run in parallel—dramatically reducing the total time.
Use subagentes em paralelo para [objetivo]. Divida o trabalho assim: 1. Subagente A: [papel específico] 2. Subagente B: [papel específico] 3. Subagente C: [papel específico] Regras: - Cada subagente trabalha de forma independente - Não edite arquivos ainda, apenas analise e planeje - Espere todos terminarem - Consolide os resultados - Remova duplicações - Priorize por impacto Formato final: 1. Resumo 2. Achados por agente 3. Plano consolidado 4. Riscos 5. Próximas ações
Use the $pr-review-agent skill with subagents running in parallel. Create: - 1 subagent focused on security - 1 subagent focused on tests - 1 subagent focused on architecture - 1 subagent focused on performance Each one applies the skill's process to its focus. Then consolidate the results without duplication.
Worktrees let multiple agents work in parallel without mixing changes in the same branch or directory. OpenAI highlights worktrees as a core part of Codex's multi-agent workflow.
Without worktrees, two agents editing the same file create conflicts. With worktrees, each agent works in its own directory + branch, and you merge afterward.
Parallel agents, no conflicts, each on its own branch
Codex creates a branch, commits, pushes, and opens a PR with a summary of the changes
Codex can run as CI, apply patches, and post reviews
Codex in the cloud lets you delegate tasks and receive PRs through the ChatGPT app
Automations let you configure routines that Codex runs on a set schedule or frequency, without you being present. Available in the Automations from the Codex App (Windows).
Automations turn Codex into a team member that works while you sleep—reviewing code, running tests, generating reports, and creating commits.
Every Monday at 9 a.m.: 1. Update dependencies if it's safe 2. Run tests 3. Run the build 4. Review recent errors 5. Generate a report at reports/weekly-review.md 6. If there are changes, create a commit with a clear message Use a new thread for each run. Use medium reasoning. Don't deploy without my approval.
Real example documented in the community: building a stock portfolio app complete using Codex 5.5 — with an interface, database, real market data, and marketing materials — with no prior programming experience.
Pushes Codex to its limits: real multitasking with 3 simultaneous agents (dev + video + research), image generation to choose an interface, automated tests, and reverse prompting.
Design with image generation — Codex generates visual interface options, and you choose the layout
Frontend + database — Creates a UI in Next.js and connects Convex to persist the portfolio
Real data — Adds price charts via the free Alpha Vantage API
Multitasking — 3 simultaneous agents: a dev building the app, a second creating a launch video (Remotion), and a third researching AI stocks in the browser (computer use)
Reverse prompting — Ask Codex "what do you think should be done next?" to find out the next steps