QuotaCheap Playbook

Codex CLI nâng cao: resume, exec, slash commands và terminal workflow cho coding agent

Hướng dẫn Codex CLI nâng cao cho developer: resume sessions, codex exec, slash commands, /plan, /review, /status, /permissions, cloud exec, config.toml và…

Codex CLI không chỉ là lệnh `codex`. Khi biết dùng resume, exec, /review, /plan, /status, permissions, cloud exec và config, terminal trở thành cockpit để điều phối coding agent.

Playbook tiếng Việt về Codex CLI nâng cao theo tài liệu OpenAI: TUI workflow, resume sessions, codex exec, slash commands, /review, /plan, /status, /permissions, /compact, /fork, file mention, image input, cloud exec, config.toml, web search, sandbox, và cost control.

Nhiều developer dùng Codex CLI như một chat box trong terminal: gõ codex, hỏi một câu, xem nó sửa file, rồi thoát.

Dùng vậy vẫn có giá trị.

Nhưng đó mới là tầng thấp nhất.

Codex CLI thật ra là một cockpit để điều phối coding agent: có interactive TUI, resume sessions, non interactive codex exec, slash commands, /review, /plan, /status, permissions, file mention, image input, web search, cloud task, config layers và transcript.

Khi biết phối hợp các phần này, CLI không chỉ giúp sửa một file; nó giúp bạn quản lý cả một workflow coding có kiểm soát.

Tài liệu OpenAI mô tả CLI như một surface cho conversational workflow nơi bạn review Codex actions in real time.

Nó cũng có resume để mở lại thread cũ, exec để chạy non interactive automation, cloud exec để launch cloud tasks, và slash commands để steer session mà không rời terminal.

Bài này đi vào Codex CLI nâng cao: dùng khi nào, dùng lệnh nào, tránh bẫy nào, và làm sao để terminal workflow vừa nhanh vừa không mất kiểm soát.

Tư duy đúng: CLI là cockpit, không phải hộp chat Một cockpit tốt cho bạn thấy ba thứ: agent đang ở đâu; agent được phép làm gì; agent đã làm gì và còn rủi ro gì.

Codex CLI có đủ ba lớp đó.

Bạn có thể mở session: Hoặc start bằng prompt: Trong TUI, docs nói bạn có thể gửi prompts, code snippets, screenshots, xem Codex explain plan trước khi change, approve/reject steps, đọc markdown/diffs, copy output, queue follow up bằng Tab, search prompt history, và exit bằng /exit hoặc Ctrl+C.

Nhưng điểm nâng cao nằm ở cách bạn giữ thread sạch, resume đúng context, review diff, điều chỉnh permissions, và chuyển task sang cloud/exec khi phù hợp.

Start đúng directory trước khi start đúng prompt Một lỗi rất thường gặp: prompt hay nhưng Codex đang ở sai root.

Docs nói có thể launch từ any directory bằng codex cd để set working root: Nếu cần phối hợp nhiều project hoặc package, dùng add dir để expose writable roots: Đây không chỉ là tiện ích.

Nó ảnh hưởng sandbox, file discovery, AGENTS.md loading, git diff, tests, và command execution.

Trước task quan trọng, chạy /status trong TUI.

Docs nói /status hiển thị active model, approval policy, writable roots, token usage, remote address nếu có, server version.

Đây là sanity check rẻ.

Nếu /status cho thấy wrong root/writable roots, dừng lại.

Đừng để agent sửa đúng code ở sai chỗ.

Resume: đừng bắt Codex mất trí nhớ mỗi ngày Codex stores transcripts locally để bạn pick up where you left off.

resume là một trong các lệnh đáng dùng nhất.

Các mode trong docs: codex resume mở picker recent interactive sessions.

codex resume all xem sessions beyond current working directory.