-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Open
Labels
enhancementNew feature or requestNew feature or request
Description
What feature would you like to see?
Summary
Enable codex-cli to run terminal sessions in the background, similar to how Claude Code supports background terminals. This would allow long-running processes to continue without needing to keep the CLI window open, with the option to reattach later.
Problem
- Developers often run commands that take hours (servers, builds, migrations, log tails).
- Currently, they must keep codex-cli in the foreground or rely on external tools like
tmux
,screen
, ornohup
. - This is inconvenient, error-prone, and inconsistent across platforms.
Goals
- Start commands as background sessions that survive terminal closure.
- Detach and reattach to a session with full TTY support.
- Provide log streaming and export without requiring reattachment.
- Ensure sessions are listed, inspectable, and manageable directly from codex-cli.
- Cross-platform support (macOS, Linux, WSL).
Non-Goals
- Full tmux replacement.
- Orchestrating sessions across multiple hosts.
Proposed UX
Examples
- Start a background process:
codex run --bg --name api-dev "pnpm dev"
diff
Copy code
- List sessions:
codex sessions list
diff
Copy code
- Tail logs without attaching:
codex sessions logs api-dev --follow
arduino
Copy code
- Attach/detach:
codex sessions attach api-dev
bash
Copy code
- Stop/clean up:
codex sessions stop api-dev
codex sessions rm api-dev
markdown
Copy code
Config Options
- Storage directory for session metadata and logs
- Maximum session count
- Log rotation and retention settings
- Idle timeout or TTL for auto-expiration
Benefits
- Improves developer productivity by reducing reliance on external tools.
- Provides a unified workflow for running and managing long-running processes.
- Makes codex-cli more competitive with similar tools that already provide background terminal support.
Alternatives Considered
- Continue relying on tmux/screen. Works but adds complexity and reduces portability.
- Use
nohup
or&
in shell. Limited functionality, no reattachment or lifecycle management.
Acceptance Criteria
- Background sessions survive CLI and terminal restarts.
- Users can list, inspect, attach, detach, and stop sessions.
- Logs are captured and exportable.
- Works across macOS, Linux, and WSL with minimal setup.
Are you interested in implementing this feature?
Yes
Additional information
No response
PabloLION, noctis-linden, bearyung, IvanLi-CN, smaccoun and 1 more
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request