PTENES
10 Modules · Beginner to Advanced

Codex Basic

From zero to advanced with OpenAI’s coding agent.

Content extracted from the INEMA.Codex channel · Updated in May 2026

⚡ CODEX CLI Central orchestrator 📦 Installation npm + login ⚙️ Config flags + .toml 🎯 Skills SKILL.md + invoke 🤖 Subagents parallel 🌿 Worktrees parallel git 🔄 Automations CI/CD + schedule Beginner → Intermediate → Advanced
Level 1 — Beginner
3 modules

🟢 What It Is

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.

💡 Why learn

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.

🔑 Key Concepts: The 3 Versions

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
✅ Strengths
  • • 274K context (more than Claude Code)
  • • Cloud execution (no PC needs to be on)
  • • Native parallel threads
  • • GitHub Actions integrated
  • • Reusable project skills
ℹ️ Context
  • • Requires an OpenAI account (Plus/Pro recommended)
  • • Free accounts have limitations
  • • Equivalent to Claude's agents.md
  • • Uses GPT-5 models (low and high)

🟢 What It Is

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.

💡 Why learn

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.

🔑 Step by Step

Step 1 — Install Node.js
🟩 Windows
winget install --id Git.Git -e --source winget
# depois instale Node.js em nodejs.org
🟦 Linux (Ubuntu/Debian)
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
Step 2 — Verify npm
npm -v
# Deve retornar algo como: 10.x.x
Step 3 — Install Codex
npm install -g @openai/codex
Step 4 — Log in (device auth)
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.

💡 Using Docker
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

🟢 What It Is

After installing, you run codex in the terminal to open interactive mode. Inside it, / accesses internal commands and @ references project files.

💡 Why learn

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.

🔑 Key Concepts

codex                    # abre modo interativo
codex "crie uma API"     # prompt direto
codex chat               # modo conversa
codex --full-auto "..."  # executa sem pedir confirmação
Commands / internal
/plan mode— activates planning mode
/model— switch models (low/high)
/reasoning— adjust reasoning
/browser use— activate browser
/skill creator— create a skill
/personality— adjust personality
📄 agents.md — the context file

Create 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
Level 2 — Intermediate
3 modules

🟢 What It Is

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.

💡 Why learn

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.

🔑 Approval Flags

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 ⚠️
config.toml — persist preferences
# ~/.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"

🟢 What It Is

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.

💡 Why learn

Skills eliminate repetition. A “PR review” skill can run 3 subagents in parallel (security, tests, architecture) without you rewriting the prompt every time.

🔑 Skill Structure

Where to save
meu-projeto/
  .agents/
    skills/
      pr-review-agent/
        SKILL.md          ← obrigatório
        scripts/          ← opcional
        references/       ← opcional
Minimal SKILL.md
---
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
How to invoke
# 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"

🟢 What It Is

Codex has several “names” for agents, but in practice you create them in 3 ways: a regular thread/task, configured subagents, and scheduled automations.

💡 Why learn

Understanding the hierarchy avoids confusion about the terminology. Start with threads + skills + automations. Subagents and workers come later.

🔑 Table of 10 Types

Name What is How to use
Main agentCodex coordinating the taskRegular chat/thread
Agent threadSeparate conversation/taskNew thread in the project
Worker agentWorker for part of the work"Split this into workers…"
Task agentAgent with a specific task"Create a task agent for…"
SubagentParallel specialized agent"Use subagents…"
Background agentBackground agentBackground thread/task
Parallel agentMultiple simultaneous tasksThreads, subagents, or worktrees
AutomationScheduled taskAutomations tab
SkillReusable recipe$skill-name or natural language
AGENTS.mdPermanent instructionsFile in the project
Level 3 — Advanced
4 modules

🟢 What It Is

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".

💡 Why learn

Complex tasks such as codebase audits, feature planning, and refactoring can be split up and run in parallel—dramatically reducing the total time.

🔑 Prompt Formula for Subagents

Prompt template (copy and adapt)
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
Real example: combining subagents + skill
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.

🟢 What It Is

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.

💡 Why learn

Without worktrees, two agents editing the same file create conflicts. With worktrees, each agent works in its own directory + branch, and you merge afterward.

🔑 Codex Git/GitHub Capabilities

🌿 Worktrees

Parallel agents, no conflicts, each on its own branch

📋 Automatic PRs

Codex creates a branch, commits, pushes, and opens a PR with a summary of the changes

⚡ GitHub Actions

Codex can run as CI, apply patches, and post reviews

📱 Mobile Phone

Codex in the cloud lets you delegate tasks and receive PRs through the ChatGPT app

🟢 What It Is

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).

💡 Why learn

Automations turn Codex into a team member that works while you sleep—reviewing code, running tests, generating reports, and creating commits.

🔑 Example: Automated Weekly Review

Automation prompt (every Monday at 9 a.m.)
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.

🟢 What It Is

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.

💡 Why learn

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.

🔑 Project Workflow

1

Design with image generation — Codex generates visual interface options, and you choose the layout

2

Frontend + database — Creates a UI in Next.js and connects Convex to persist the portfolio

3

Real data — Adds price charts via the free Alpha Vantage API

4

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)

5

Reverse prompting — Ask Codex "what do you think should be done next?" to find out the next steps

Final result
  • ✅ Save actions and record the number of shares
  • ✅ Calculate portfolio value with live pricing
  • ✅ Persistent data in the database (Convex)
  • ✅ Launch video ready
  • ✅ Marketing materials generated