Back to Resources
    Guide
    Recommended Platform
    Updated April 2026

    Codex Project Setup Guide

    How to structure your project for OpenAI Codex (CLI + VS Code) using AGENTS.md and Skills under .agents/skills/. Powered by the GPT-5 family.

    Prerequisites

    • A ChatGPT Plus, Pro, Business, or Enterprise plan with Codex access
    • Codex CLI (npm i -g @openai/codex) or Codex extension for VS Code installed
    • Familiarity with Learner Brain concepts (rules, skills, workflows, meta layer)

    Step 1: Plan Your File Layout

    Codex looks for AGENTS.md at your project root, then walks down toward your current working directory, merging instructions as it goes. Skills live under .agents/skills/ and are auto-discovered.

    Recommended Structure

    your-project/
    ├── AGENTS.md                 # Main instructions (auto-loaded by Codex)
    ├── .agents/
    │   └── skills/
    │       ├── run-tests/
    │       │   └── SKILL.md      # Reusable procedure
    │       └── deploy/
    │           └── SKILL.md      # Reusable procedure
    ├── services/
    │   └── payments/
    │       └── AGENTS.md         # Nested override for this subdir
    └── ~/.codex/
        └── AGENTS.md             # Global instructions (across all projects)

    The 32 KiB Cap

    Codex caps combined AGENTS.md content at ~32 KiB by default (project_doc_max_bytes). Keep each AGENTS.md focused. When it grows beyond ~200 lines, split it into a nested AGENTS.md (e.g. services/payments/AGENTS.md) or extract the workflow into a Skill.

    Step 2: Write Your Root AGENTS.md

    Start with the meta-learning protocol, project context, and working agreements. Resist the urge to dump every detail here — push procedures into Skills.

    AGENTS.md (project root)

    # AGENTS.md — Project Instructions
    
    Codex reads this file before any work. Keep it small and durable —
    push deep workflows into Skills under `.agents/skills/`.
    
    ## Discovery (how Codex layers context)
    1. **Global:** `~/.codex/AGENTS.override.md` (if present), else `~/.codex/AGENTS.md`
    2. **Project:** root → CWD, walking down. Each directory: `AGENTS.override.md` → `AGENTS.md`
    3. **Merge:** files closer to your CWD override earlier guidance
    
    ## Meta-Learning Protocol
    You operate under The Learner Brain methodology. Improve the *system*, not just the output.
    
    ### Triggers
    1. **Repetition** — same correction twice
    2. **Friction** — a workaround the user shouldn't repeat
    3. **Manual labor** — multi-step task that should become a Skill
    4. **Preference** — codify expressed style or approach
    
    ### Upgrade Format
    ```
    🧠 BRAIN UPGRADE PROPOSAL
    Trigger: [what caused this]
    Surface: [AGENTS.md | Skill | Hook]
    Location: [path]
    Proposed change: [exact addition]
    Rationale: [why it prevents future friction]
    ```
    
    ## Project Context
    - Language: [Your language]
    - Framework: [Your framework]
    - Test command: [pnpm test | bun test | etc.]
    
    ## Working Agreements
    - Run lint + tests before claiming a task is done
    - Never commit `.env*` or anything under `secrets/`
    - Propose ONE upgrade at a time and wait for approval

    Step 3: Add Your First Skill

    Skills are progressively-disclosed procedures. Codex reads each Skill's description field at the start of a session and only loads the full SKILL.md content when the task matches.

    .agents/skills/run-tests/SKILL.md

    ---
    name: run-tests
    description: Run the project's full test suite, summarize failures, and propose a fix plan. Use when the user asks for tests, verification, or coverage.
    ---
    
    # Run Tests Skill
    
    ## When to use
    - Before completing a task
    - When the user says "run tests" / "verify" / "check"
    
    ## Steps
    1. Detect package manager (pnpm > bun > npm)
    2. Run the test command
    3. If failures: group by file, summarize root cause, propose smallest fix
    4. If passing: report counts and exit
    
    ## Outputs
    - A short summary (✅ N passed | ❌ M failed)
    - Proposed next action

    Description-driven discovery

    Write the description as if it's the only thing Codex will read — because at the start of a session, it usually is. State when to use and what it does, not how it works internally.

    Where Skills live

    • REPO: .agents/skills/ at CWD, parents, and repo root (team-shared, version-controlled)
    • USER: ~/.agents/skills/ (personal, all repos)
    • ADMIN: /etc/codex/skills/ (machine-wide)
    • SYSTEM: bundled with Codex (e.g. $skill-creator)

    Two ways to invoke

    • Explicit: type $skill-name in your prompt or run /skills to browse
    • Implicit: Codex picks a Skill when your task matches its description
    • Author with $skill-creator; install curated Skills via $skill-installer <name>
    • Disable without deleting via [[skills.config]] in ~/.codex/config.toml

    Step 4: Pick the Right Model + Reasoning Effort

    Codex runs on the GPT-5 family. As of April 2026, gpt-5.5 is the recommended flagship for most coding work; fall back to gpt-5.4 if it isn't available in your account yet. Match the model and reasoning effort to the task to keep cost, latency, and quality in balance.

    Default coding (recommended)

    Complex coding, agentic workflows, knowledge work.

    model: gpt-5.5 · effort: medium

    Flagship fallback

    Use when gpt-5.5 isn't yet available — strong reasoning + tool use.

    model: gpt-5.4 · effort: medium

    Coding-specialist

    Industry-leading coding model — also powers gpt-5.4 internally.

    model: gpt-5.3-codex

    Fast / lower-cost

    Lighter coding tasks and subagents.

    model: gpt-5.4-mini · effort: low

    Real-time iteration

    Near-instant coding (research preview, ChatGPT Pro only).

    model: gpt-5.3-codex-spark

    Hard debugging (alternative)

    Previous flagship — deeper deliberation on hard problems.

    model: gpt-5.2 · effort: high

    Set it once

    Set your default in ~/.codex/config.toml with model = "gpt-5.5", then override per-session with codex -m gpt-5.4-mini or /model inside the TUI.

    Step 5: Choose an Approval Mode

    Codex runs in a sandbox. Approval mode controls how much Codex can do before pausing for review.

    Suggest — read-only by default; Codex proposes diffs you apply manually. Best when learning a new codebase.

    Auto-Edit — Codex writes files but asks before running shell commands. The default for everyday work.

    Full Auto — sandboxed full autonomy (no network by default). Use only for trusted, well-scoped tasks with good tests.

    Step 6: Verify the Setup

    Run codex in your project root and ask "what AGENTS.md files are loaded?" Codex should list every file it merged.

    Ask Codex to do a task that should trigger a Skill. Confirm it references the SKILL.md by name in its plan.

    Trigger a repetition (correct the same thing twice). Confirm Codex proposes a Brain Upgrade in the format you defined.

    Constraints to Know

    Combined AGENTS.md content is capped at ~32 KiB by default.

    Codex memory is session-only by default. Your AGENTS.md and Skills files are the persistent memory — see the memory types guide.

    Skills require a description in frontmatter or they won't be discovered.

    References

    This template was last reviewed in April 2026 against the official OpenAI Codex docs. Spot something out of date? Let us know.