How to Build and Schedule Codex-Based Agents
Complete guide to autonomous multi-hour Ralph loops, skill automation, and scheduled agent deployment with OpenAI Codex
OpenAI Codex agents represent a new frontier in autonomous software development. Unlike traditional AI assistants that pause for confirmation at every step, Codex agents can run autonomously for hours, making decisions, writing code, and executing tasks without human intervention.
This guide walks through the complete setup: enabling the hidden `/goal` command for autonomous runs, building reusable skills that scale, configuring schedule-based automations, and deploying agent outputs directly to production via GitHub and Vercel.
Codex agents are not chat interfaces - they are autonomous workers. Set them up correctly, and they become force multipliers: daily bug triage, automated code reviews, scheduled data pipelines, and continuous deployment workflows that run while you sleep.
1Enable the Hidden /goal Command
The /goal command allows Codex to run autonomously for hours without requiring human confirmation for every step. However, it must be manually enabled in your configuration files.
Configuration Steps
- Navigate to your Codex app data directory:
- Mac: ~/.config/codex/config.toml
- Windows: %APPDATA%/codex/config.toml
- Linux: ~/.config/codex/config.toml
- Open the file and locate the flag for the Ralph loop / goal command feature
- Change the flag to enable the feature
- Save the file and restart the Codex app
If you do not see the /goal command option after restarting, check that your Codex version is up to date. Run codex --version and update if necessary.
2Create the agents.md File
The agents.md file acts as the onboarding document and continuous memory for your agent. If the run restarts or spawns sub-sessions, this file provides crucial context to keep the agent on track.
Creating Your agents.md
- Open a new chat in your project root directory
- Ask Codex: "Please generate an agents.md file that documents our project goals, architecture, and constraints"
- Ensure the file includes:
- Project goal: What is the agent trying to accomplish?
- Architectural decisions: Tech stack, libraries, design patterns
- Environment notes: Dependencies, required services, configurations
- Known failure modes: What has gone wrong before? How to recover?
3Grant Full Access Permissions
By default, Codex pauses to ask for your permission before executing shell commands, writing files, or making network requests. For a scheduled or multi-hour run, this will cause the agent to stall indefinitely.
Enabling Full Access Mode
- Open Codex and go to Settings - General
- Locate the Auto Review section
- Switch the permission level to Full Access
- Confirm the warning and save
Start with Prompt Mode on (Step 6) to validate the agent's planned actions before granting Full Access. Once you trust the agent's decision-making, enable Full Access. This staged approach prevents costly mistakes.
4Select the Correct Model and Intelligence Level
Codex defaults to GPT-5.2, which can cause complex multi-hour runs to stall or take twice as long as necessary. Model selection is critical for performance.
Optimal Configuration
- Model: Use GPT-5.5 (not GPT-5.2)
- GPT-5.5 handles multi-step reasoning and long-running tasks significantly better
- Only fallback to GPT-5.2 for simple tasks or token budget constraints
- Intelligence Level:
- Medium: Standard planning and execution (default for most tasks)
- High: Large builds, complex debugging, or multi-phase workflows
- Avoid "Extra High": Burns through session budget rapidly without proportional benefit
Run the same task with Medium and High intelligence levels to profile execution time and cost. Plot the curve and find your sweet spot - often Medium is sufficient for 80% of tasks.
5Define Standardized Skills
Skills are reusable markdown recipes that tell Codex exactly how to complete a specific task consistently. Skills are the foundation of scalable agent automation.
Creating a Skill
- Complete the task once manually alongside Codex in a standard chat session
- Let Codex observe and participate as you work through the task
- Discuss edge cases and error handling as they occur
- Once complete, type: "Turn what you just did into a skill"
- Codex generates a structured markdown file with:
- Task description and objective
- Prerequisites and setup steps
- Step-by-step implementation
- Error handling and rollback procedures
- Save the skill to ~/.codex/skills/ (global) or ./project_skills/ (local project folder)
Codex automatically references saved skills in future autonomous runs. Skills compound in value: the more you build, the more capable your agent becomes.
6Scope the Task Using Plan Mode
Before initiating a massive autonomous run, use Plan Mode to align on strategy without executing any code. This costs minimal tokens and prevents expensive mistakes.
Using Plan Mode
- Toggle Plan mode ON in the Codex UI (Settings or top toolbar)
- Describe your goal: "Build a daily bug triage agent that reads issues from GitHub and assigns priority labels"
- Allow Codex to ask clarifying questions:
- What criteria define high/medium/low priority?
- Should old issues be automatically closed?
- Which GitHub repositories should be scanned?
- Iterate on the plan until you are satisfied with the proposed architecture and steps
- Turn Plan mode OFF and execute
Plan Mode is free to iterate - use it extensively. Spend 10 minutes aligning on the plan to save 2 hours of wasted execution time. The planning phase is where precision pays dividends.
7Check Rate Limits and Environment
Codex operates on a 5-hour rolling window budget. Before starting a major autonomous run, verify your quota and clean up your environment to prevent stalls.
Pre-Execution Checklist
- Rate limits: Go to Settings - Rate Limits Remaining and verify sufficient budget
- Close target files: If you have a file open in another application (Excel, VS Code, etc.) while Codex tries to write to it, you will get a file lock error and the run will stall indefinitely
- Close Excel spreadsheets before running file-write operations
- Ensure no IDE or editor has your target files open
- Verify environment: Check that all required services are running (database, API servers, etc.)
- Backup critical files: Before a destructive operation, create a backup branch in Git
8Start an On-Demand Autonomous Run
To run your agent immediately (not scheduled):
Triggering /goal
- Type /goal [YOUR OBJECTIVE HERE] in the chat
- Example: /goal Refactor the payment module to use the new async API
- Codex begins planning and execution automatically
- Monitor the context window bar at the bottom of the screen
- If it fills up, Codex auto-compacts the conversation history
- Auto-compaction can cause nuance loss - periodically ask: "Summarize your progress and ensure you haven't lost context"
- The agent runs until completion or it hits the 5-hour budget limit
Watch the first 5-10 minutes of execution. If the agent makes unexpected decisions early on, pause and restart with better instructions. Early course correction is infinitely cheaper than running the full task incorrectly.
9Schedule the Agent (Automations)
Turn your /goal run into a recurring background task. Examples: daily bug triage, weekly codebase cleanup, automated security reviews.
Setting Up Automations
- Open the Automations tab in the Codex app
- Click "Create new automation" and write the task prompt
- Example: "Daily at 2 AM: Triage all open GitHub issues, label by priority, and post a summary to Slack"
- Set your schedule using cron-style syntax
- Every Sunday at 5 PM
- Daily at 2:00 AM
- 0 0 * * * (midnight daily)
- CRITICAL: The Automations UI defaults to GPT-5.2
- You MUST manually change the model to GPT-5.5
- Set reasoning/intelligence to High
- Save and verify the settings are applied
- Ensure your machine is on and the Codex app is running at the scheduled time (automations run locally)
Deployment Integration (Optional but Recommended)
For seamless deployment of agent-generated outputs:
- Connect your Codex workspace to a GitHub repository
- Link the repository to Vercel for automatic deployment
- Every time your automated agent commits code, Vercel automatically deploys it live
- This enables fully autonomous CI/CD pipelines
Key Takeaways
Enable /goal command, create agents.md memory file, grant Full Access permissions, use GPT-5.5 with High intelligence.
Build reusable skill recipes by completing tasks with Codex, then asking it to formalize them. Skills compound in value.
Use Plan Mode to align on strategy before execution. Spend 10 minutes planning to save 2 hours of wasted execution.
Close target files, verify rate limits, monitor context window, trigger /goal and let the agent run autonomously for hours.
Create scheduled automations in 5 minutes. CRITICAL: Manually set model to GPT-5.5 and intelligence to High before saving.
Connect to GitHub and Vercel. Agent commits automatically trigger live deployments - true autonomous CI/CD.
Codex agents are not science fiction - they are operational infrastructure today. The engineers who master agent setup in 2026 will have 10x force multipliers: while competitors write code, they run autonomous agents that write better code, fix bugs, and deploy continuously. The gap is not in capability (both have the same tools) but in configuration discipline. Set up your agents ruthlessly: clear agents.md, validated skills, explicit constraints, proper rate limits. This is the new frontier of software development.
This guide was produced by FazDane Analytics based on OpenAI Codex documentation and best practices. Specific features, UI elements, pricing, and API availability may change. For current information, refer to the official OpenAI Codex documentation. Always test agent behavior in Plan Mode before enabling Full Access. Local automations require the Codex app to be running on your machine at the scheduled time.