Scheduled Task Automation with Codex
It is Monday morning. Over the weekend, three dependency vulnerabilities were published, someone merged a commit with a console.log statement, and the test coverage on the payments module dropped from 85% to 72%. You find out about these during standup. But if you had set up Codex automations on Friday, you would have arrived to a prioritized inbox with each issue already identified, analyzed, and — in some cases — fixed.
What You’ll Walk Away With
Section titled “What You’ll Walk Away With”- Ready-to-use automation prompts for the most common recurring development tasks
- A workflow for testing automations safely before scheduling them
- Techniques for combining automations with skills for complex multi-step workflows
- Security and sandbox configuration for unattended background tasks
The Workflow
Section titled “The Workflow”How Automations Work
Section titled “How Automations Work”Local scheduled tasks run in ChatGPT desktop on a schedule you define. Each run:
- Runs in the local project or a dedicated worktree, depending on the option you chose
- Executes the prompt with your default sandbox settings
- Reports findings to Scheduled in the ChatGPT desktop sidebar
- Archives the run automatically if there is nothing to report
You need ChatGPT desktop running and the project available on disk for local runs. ChatGPT web also manages scheduled tasks, but web runs cannot access a folder on your computer.
Step 1: Test Before Scheduling
Section titled “Step 1: Test Before Scheduling”Never schedule an automation blindly. Test the prompt manually in a regular thread first.
- Open ChatGPT desktop in Codex mode and create a new task in the same project.
- Choose Worktree if the scheduled task should stay isolated from the main checkout.
- Paste your automation prompt and run it.
- Review the results: Did it find the right things? Did it make appropriate changes? Did it stay within scope?
Iterate on the prompt until you are satisfied, then create the automation with the tested prompt.
Step 2: Set Up Core Automations
Section titled “Step 2: Set Up Core Automations”Here are the automations most teams should run from day one:
Daily: Code Quality Check
Section titled “Daily: Code Quality Check”Weekly: Dependency Health
Section titled “Weekly: Dependency Health”Nightly: Bug Hunter
Section titled “Nightly: Bug Hunter”This is similar to the $recent-code-bugfix skill pattern from the official Codex docs. You can also create a skill and invoke it from the automation:
Check my commits from the last 24h and submit a $recent-code-bugfix.Weekly: Architecture Drift Detection
Section titled “Weekly: Architecture Drift Detection”Weekly architecture check:
1. Pull the latest from origin/main2. Compare the current codebase structure against docs/ARCHITECTURE.md3. Check for: - New directories or modules not documented - Documented modules that no longer exist - New cross-module dependencies that violate documented boundaries - New external service integrations not mentioned in the architecture doc4. If drift is detected, update docs/ARCHITECTURE.md to match reality
Report what changed and whether it represents intentional evolution or accidental drift.Daily: Team Activity Briefing
Section titled “Daily: Team Activity Briefing”Step 3: Combine Automations with Skills
Section titled “Step 3: Combine Automations with Skills”Skills let you encapsulate complex workflows that automations can invoke. Create a skill, save it to your personal or repo skills directory, and reference it with $skill-name in the automation prompt.
Example: Create a $test-coverage-report skill that knows how to run coverage, compare to baselines, and format the output. Then the automation becomes:
Run $test-coverage-report on the latest main branch. If coverage dropped on any module, investigate and propose tests to restore it.Skills make automations more maintainable: update the skill once, and every automation that uses it gets the improvement.
Step 4: Configure Security for Background Tasks
Section titled “Step 4: Configure Security for Background Tasks”Automations run with your default sandbox settings. Since they run unattended, security configuration matters.
Recommended sandbox settings for automations:
- workspace-write (default recommendation) — lets Codex read and modify files in the project. Tool calls that need network or access outside the workspace fail unless explicitly allowed.
- Use a rules file to selectively allow specific commands to run outside the sandbox (for example, allow
npm audit, which needs network access). Rules live in a.rulesfile under~/.codex/rules/and are written in Starlark, usingprefix_rule()to allowlist a command prefix.
# Allow `npm audit` (needs network) to run outside the sandbox in automations.prefix_rule( pattern = ["npm", "audit"], decision = "allow", justification = "npm audit needs network access for vulnerability checks",)Test the rule before relying on it, then restart Codex so it reloads the file:
codex execpolicy check --pretty \ --rules ~/.codex/rules/default.rules \ -- npm auditApproval policy:
Scheduled tasks run unattended with the default sandbox settings chosen for the local client. Use the narrowest access that works and review managed requirements; an operation outside the available boundary fails rather than waiting indefinitely for a person.
Step 5: Manage Your Automation Inbox
Section titled “Step 5: Manage Your Automation Inbox”The Automations pane in the Codex-mode sidebar in the ChatGPT desktop app is your inbox. It has a Triage section where automation runs with findings appear. You can:
- Filter to show All runs or only Unread ones
- Click into a run to see the full conversation and any diffs
- Archive runs you have addressed
- Pin runs you want to keep (this also prevents the worktree from being cleaned up)
Build a routine: every morning, check your automation inbox before standup. Address findings, sync fixes to local, and archive completed items.
When This Breaks
Section titled “When This Breaks”Automation runs while you are not looking and makes unintended changes. If sandbox is set to danger-full-access and the prompt is vague, Codex might modify files in unexpected ways. Use workspace-write mode and review the first few runs of any new automation before trusting it. The worktree isolation protects your main checkout, but the worktree changes can still be synced or turned into PRs.
Worktree buildup from frequent automations. Tasks configured for worktree isolation create background worktrees. ChatGPT desktop keeps the 15 most recent Codex-managed worktrees by default; change the retention limit in Worktree settings or clean up completed runs you no longer need.
Automation reports the same findings every day. If a linting error has been in the codebase for weeks and nobody fixes it, the daily automation keeps reporting it. Add an ignore mechanism: “Skip issues listed in .automation-ignore.json. Only report new findings since the last run.”
ChatGPT desktop must be running for local tasks. If the app closes or the machine sleeps, a local-folder run cannot execute. Enable “Prevent sleep while running,” use a web scheduled task when local files are unnecessary, or use the Codex SDK/GitHub Action for a server-side coding workflow.