Automations
ตั้งเวลางาน Codex ซ้ำๆ อัตโนมัติ
ภาพรวม
ทำให้งานประจำทำงานในเบื้องหลังได้โดยอัตโนมัติ Codex จะเพิ่มผลการค้นพบไปยัง inbox หรือ archive งานโดยอัตโนมัติหากไม่มีอะไรต้องรายงาน คุณสามารถรวม automations กับ skills สำหรับงานที่ซับซ้อนมากขึ้นได้
สำหรับ project-scoped automations เครื่องที่รัน local Codex app ต้องเปิดอยู่, Codex ต้องรันอยู่ และโปรเจกต์ที่เลือกต้องยังมีอยู่บน disk เมื่อถึงเวลาที่กำหนด
ใน Git repositories คุณสามารถเลือกว่า automation จะรันใน local project หรือบน worktree ใหม่ ทั้งสองตัวเลือกรันในเบื้องหลัง Worktrees แยก automation changes ออกจากงานที่ยังทำอยู่ ส่วนการรันใน local project อาจแก้ไขไฟล์ที่คุณกำลังทำงานอยู่ ในโปรเจกต์ที่ไม่ได้ใช้ version control automations รันโดยตรงใน project directory
คุณสามารถปล่อยให้ model และ reasoning effort ใช้ค่า default หรือเลือกเองหากต้องการควบคุมมากขึ้น
การจัดการงาน
ดู automations ทั้งหมดและการรันได้ใน automations pane ใน Codex app sidebar
ส่วน "Triage" ทำหน้าที่เป็น inbox automation runs ที่มีผลการค้นพบจะแสดงที่นั่น และคุณสามารถกรอง inbox เพื่อแสดง automation runs ทั้งหมดหรือเฉพาะที่ยังไม่ได้อ่าน
Standalone automations เริ่ม fresh runs ตามกำหนดและรายงานผลใน Triage ใช้เมื่อแต่ละ run ควรเป็นอิสระหรือเมื่อ automation ควรรันข้ามหลายโปรเจกต์ หากต้องการกำหนดเองให้เลือก custom schedule และป้อน cron syntax
สำหรับ Git repositories แต่ละ automation สามารถรันใน local project หรือบน dedicated background worktree ใช้ worktrees เมื่อต้องการแยก automation changes ออกจากงานที่ยังทำอยู่ ใช้ local mode เมื่อต้องการให้ automation ทำงานโดยตรงใน main checkout
Automations ใช้ sandbox settings เริ่มต้นของคุณ ในโหมด read-only tool calls จะล้มเหลวหากต้องแก้ไขไฟล์ เข้าถึง network หรือทำงานกับแอปในเครื่อง เมื่อเปิด full access background automations จะมีความเสี่ยงสูงขึ้น ปรับ sandbox settings ได้ใน Settings และ allowlist คำสั่งด้วย rules ตามต้องการ
Automations สามารถใช้ plugins และ skills เดียวกับที่ Codex มี เพื่อให้ automations บำรุงรักษาง่ายและแชร์ข้ามทีม ให้ใช้ skills เพื่อกำหนด action และให้ tools และ context คุณสามารถ trigger skill ใน automation โดยตรงด้วย $skill-name
ขอให้ Codex สร้างหรืออัปเดต Automations
คุณสร้างและอัปเดต automations จาก Codex thread ปกติได้ บอกถึงงาน, กำหนดเวลา และว่า automation ควรอยู่กับ thread ปัจจุบันหรือเริ่ม fresh runs Codex สามารถร่าง automation prompt เลือกประเภท automation ที่เหมาะสม และอัปเดตเมื่อ scope หรือกำหนดเปลี่ยน
ตัวอย่างเช่น ขอให้ Codex แจ้งเตือนใน thread นี้ขณะที่ deployment เสร็จสิ้น หรือขอให้สร้าง standalone automation ที่ตรวจสอบโปรเจกต์ตามกำหนด
Skills ยังสร้างหรืออัปเดต automations ได้ด้วย ตัวอย่างเช่น skill สำหรับดูแล pull request สามารถตั้ง recurring automation ที่ตรวจสถานะ PR กับ GitHub plugin และแก้ review feedback ใหม่
Thread Automations
Thread automations คือ heartbeat-style recurring wake-up calls ที่ผูกกับ thread ปัจจุบัน ใช้เมื่อต้องการให้ Codex กลับมา conversation เดิมตามกำหนด
ใช้ thread automation เมื่องานตามกำหนดควรเก็บ context ของ thread แทนที่จะเริ่มจาก prompt ใหม่ทุกครั้ง
Thread automations ใช้ minute-based intervals สำหรับ follow-up loops ที่ active หรือกำหนด daily/weekly เมื่อต้องการ check-in ในเวลาเฉพาะ
Thread automations เหมาะสำหรับ:
- ตรวจสอบคำสั่งที่รันนานจนกว่าจะเสร็จ
- Poll Slack, GitHub หรือ source อื่นๆ เมื่อผลลัพธ์ควรอยู่ใน thread เดิม
- เตือน Codex ให้ดำเนินการ review loop ต่อตามกำหนด
- รัน skill-driven workflows ที่ใช้ plugins เช่น ตรวจสถานะ PR และแก้ feedback ใหม่
- รักษา chat ให้มุ่งเน้นงาน research หรือ triage ที่กำลังดำเนินอยู่
ใช้ standalone หรือ project automation เมื่อแต่ละ run ควรเป็นอิสระ เมื่อควรรันข้ามหลายโปรเจกต์ หรือเมื่อผลการค้นพบควรปรากฏเป็น automation runs แยกใน Triage
เมื่อสร้าง thread automation ให้ทำ prompt ให้ทนทาน ควรบอกว่า Codex ควรทำอะไรทุกครั้งที่ thread ตื่น วิธีตัดสินว่ามีอะไรสำคัญต้องรายงานหรือไม่ และเมื่อใดควรหยุดหรือขอข้อมูลเพิ่มเติม
ทดสอบ Automations
ก่อนกำหนด automation ให้ทดสอบ prompt ด้วยตนเองใน thread ปกติก่อน ซึ่งช่วยยืนยัน:
- Prompt ชัดเจนและกำหนด scope ถูกต้อง
- Model, reasoning effort และ tools ที่เลือกหรือค่าเริ่มต้นทำงานตามที่คาดหวัง
- Diff ที่ได้สามารถตรวจสอบได้
เมื่อเริ่มกำหนด runs ให้ตรวจ outputs แรกสองสามอันและปรับ prompt หรือกำหนดตามต้องการ
การทำความสะอาด Worktrees สำหรับ Automations
หากเลือก worktrees สำหรับ Git repositories กำหนดที่บ่อยอาจสร้าง worktrees จำนวนมากตามเวลา Archive automation runs ที่ไม่ต้องการแล้ว และหลีกเลี่ยงการ pin runs เว้นแต่ตั้งใจจะเก็บ worktrees ไว้
สิทธิ์และโมเดลความปลอดภัย
Automations รันแบบ unattended และใช้ sandbox settings เริ่มต้นของคุณ
- หาก sandbox mode เป็น read-only tool calls จะล้มเหลวหากต้องแก้ไขไฟล์ เข้าถึง network หรือทำงานกับแอปในเครื่อง พิจารณาอัปเดต sandbox settings เป็น workspace write
- หาก sandbox mode เป็น workspace-write tool calls จะล้มเหลวหากต้องแก้ไขไฟล์นอก workspace เข้าถึง network หรือทำงานกับแอปในเครื่อง คุณสามารถ allowlist คำสั่งเพื่อรันนอก sandbox ด้วย rules
- หาก sandbox mode เป็น full access background automations จะมีความเสี่ยงสูงขึ้น เนื่องจาก Codex อาจแก้ไขไฟล์ รันคำสั่ง และเข้าถึง network โดยไม่ถาม พิจารณาอัปเดตเป็น workspace write และใช้ rules เพื่อกำหนดคำสั่งที่รันด้วย full access ได้
Automations ใช้ approval_policy = "never" เมื่อนโยบาย organization อนุญาต หาก admin requirements ไม่อนุญาต automations จะ fallback ไปยัง approval behavior ของโหมดที่เลือก
ตัวอย่าง
สร้าง Skills ใหม่อัตโนมัติ
สแกนไฟล์ ~/.codex/sessions ทั้งหมดจากวันที่ผ่านมา และหากมีปัญหาในการใช้ skills ใด ให้อัปเดต skills เพื่อให้เป็นประโยชน์มากขึ้น (personal skills เท่านั้น)
ติดตามความเปลี่ยนแปลงโปรเจกต์
ดู commits ล่าสุดจาก remote origin/master หรือ origin/main แล้วสร้าง exec briefing สำหรับ 24 ชั่วโมงที่ผ่านมา จัดกลุ่มตาม workstream พร้อม narrative ภาษาธรรมดา
รวม Automations กับ Skills เพื่อแก้ Bugs ตัวเอง
สร้าง skill ใหม่สำหรับหาและแก้ bugs ที่คุณแนะนำเองจาก commits ล่าสุด:
---
name: recent-code-bugfix
description: Find and fix a bug introduced by the current author within the last week in the current working directory.
---
# Recent Code Bugfix
## Overview
Find a bug introduced by the current author in the last week, implement a fix, and verify it when possible.
## Workflow
### 1) Establish the Recent-Change Scope
- Determine the author from `git config user.name`/`user.email`
- Use `git log --since=1.week --author=<author>` to list recent commits
### 2) Find a Concrete Failure
- Look for recent failures in tests, lint, or runtime errors
- Confirm the root cause is directly connected to the author's changes
### 3) Implement the Fix
- Update only the files needed to resolve the issue
- Keep changes consistent with local style and tests
### 4) Verify
- Prefer the smallest validation step available
### 5) Report
Summarize the root cause, fix, and verification performed.
จากนั้นสร้าง automation ใหม่:
Check my commits from the last 24h and submit a $recent-code-bugfix.