Cross-platform Codex workspace switcher with a preserved macOS shell workflow.
Project description
codex-workspaces
codex-workspaces switches between multiple Codex workspace directories under ~/.codex-workspaces/workspaces/ and points the active ~/.codex path at the selected workspace.
The project now has two entry points:
- A cross-platform Python 3 CLI for Linux, macOS, and Windows.
- The original macOS Bash script, still kept at
macos/codex-workspaces, for users who installed the shell workflow directly.
On macOS, the Python CLI preserves the original app workflow: stop Codex App, switch the workspace link, and start Codex App again. On Linux and Windows, app control is skipped and the CLI only switches the workspace link.
Features
- Manage workspace directories such as
~/.codex-workspaces/workspaces/work. - Manage account snapshots under
~/.codex-workspaces/accounts/. - Switch the active
~/.codexsymlink or directory link. - Initialize workspace directories with metadata.
- Temporarily switch the current workspace account with
accounts use, then restore the workspace default account. - Migrate older
~/.codex-<name>workspaces and import legacy~/.codex-accountsauth snapshots. - Keep macOS Codex App stop/start/restart support.
- Show local token usage stats from Codex
state_*.sqlitein read-only mode. - Block unsafe operations from a detected Codex built-in terminal when they cannot be delegated safely.
- Support English and Chinese output through
CODEX_WORKSPACES_LANG. - Package as a Python project with tests, CI, and PyPI publishing workflow.
Requirements
- Python 3.9 or newer for the Python CLI.
- macOS is required only for Codex App control commands:
start,stop, andrestart. - Linux and macOS use directory symlinks.
- Windows uses directory symlinks when available and falls back to directory junctions.
Install
Install the Python CLI from PyPI:
python3 -m pip install codex-workspaces
For isolated CLI installs, pipx is recommended:
pipx install codex-workspaces
Install from a local checkout for development:
python3 -m pip install -e ".[dev]"
The legacy macOS shell installer is still available from the macos/ directory:
tmp="$(mktemp -t codex-workspaces.XXXXXX)" && curl -fsSL https://raw.githubusercontent.com/blockchain-project-lives/codex-workspaces/main/macos/codex-workspaces -o "$tmp" && bash "$tmp" install && rm -f "$tmp"
Workspace Layout
Default layout:
~/.codex -> active workspace link
~/.codex-workspaces/
config.json
state.json
lock
workspaces/
work/
auth.json
.codex-workspace.json
personal/
auth.json
.codex-workspace.json
accounts/
acct_work/
auth.json
meta.json
Customize paths with CODEX_WORKSPACES_LINK and CODEX_WORKSPACES_ROOT.
Usage
Initialize workspaces:
codex-workspaces init personal
codex-workspaces init work
Migrate older ~/.codex-<name> directories without deleting the originals:
codex-workspaces migrate --dry-run
codex-workspaces migrate
If your current ~/.codex is a real directory instead of a link, migrate it into a named workspace explicitly:
codex-workspaces init personal --migrate-current
Set up account snapshots after Codex has created an auth.json in the active workspace:
codex-workspaces use work --no-stop --no-start
codex-workspaces accounts save work
codex-workspaces accounts set-default work acct_work --activate
codex-workspaces accounts list
Standalone accounts can be initialized and later populated from the current workspace auth.json:
codex-workspaces accounts init research
codex-workspaces accounts save research
Import legacy codex-accounts AUTH-mode snapshots:
codex-workspaces accounts import-legacy ~/.codex-accounts
Switch workspaces:
codex-workspaces work
codex-workspaces use personal
codex-workspaces switch work
On macOS, switching stops and restarts Codex App by default. Skip those steps when needed:
codex-workspaces work --no-stop --no-start
Inspect workspaces:
codex-workspaces list
codex-workspaces current
codex-workspaces doctor
codex-workspaces stats
codex-workspaces stats work --days 14
Switch accounts within the current workspace:
codex-workspaces accounts use acct_personal
codex-workspaces accounts restore-default
accounts use only changes the current workspace active_account_id; it does not change default_account_id. Entering a workspace with codex-workspaces use <workspace> restores that workspace's default account when one is configured.
auth.json contains credentials. Do not commit workspace directories, account snapshots, SQLite state, sessions, or shell snapshots to git; the project .gitignore excludes these patterns for local checkouts.
Manage workspace metadata and lifecycle:
codex-workspaces note work "main paid workspace"
codex-workspaces rename work main
codex-workspaces delete old-workspace --force
Control Codex App on macOS:
codex-workspaces stop
codex-workspaces start
codex-workspaces restart
stats only reads local SQLite files such as state_*.sqlite or sqlite/state_*.sqlite. It does not call quota or refresh private APIs.
Environment Variables
| Variable | Default | Description |
|---|---|---|
CODEX_APP_NAME |
Codex |
macOS app name to control. |
CODEX_QUIT_TIMEOUT |
20 |
Seconds to wait for app exit. |
CODEX_WORKSPACES_LINK |
$HOME/.codex |
Active workspace link path. |
CODEX_WORKSPACES_ROOT |
$HOME/.codex-workspaces |
Managed root for workspaces, accounts, backups, and lock file. |
CODEX_WORKSPACES_LANG |
auto | Force output language with en or zh. |
Only the CODEX_WORKSPACES_* variables are used for workspace-specific configuration.
Development
python3 -m pip install -e ".[dev]"
python3 -m pytest
python3 -m build
python3 -m twine check dist/*
Design, test, and release notes live in docs/.
Publishing
CI runs tests on Linux, macOS, and Windows across Python 3.9, 3.11, and 3.13. The Publish to TestPyPI workflow runs for v* tags, and the Publish to PyPI workflow publishes from release/v* branches or manual runs.
Configure TestPyPI and PyPI Trusted Publishing for this repository before using the release workflows. See docs/RELEASE.zh-CN.md.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codex_workspaces-0.2.1.tar.gz.
File metadata
- Download URL: codex_workspaces-0.2.1.tar.gz
- Upload date:
- Size: 42.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
443aed457e805f84f9012fe4e32b3411c1430be26937ec0329ef997bac86984d
|
|
| MD5 |
1cb13a4cdf7357db5b91398b406b1f0b
|
|
| BLAKE2b-256 |
af606a3aa47b20ec56f6ed1a2cfd5811cb9f3b4f1289fa82a1990f5e85bc4fba
|
Provenance
The following attestation bundles were made for codex_workspaces-0.2.1.tar.gz:
Publisher:
publish.yml on blockchain-project-lives/codex-workspaces
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_workspaces-0.2.1.tar.gz -
Subject digest:
443aed457e805f84f9012fe4e32b3411c1430be26937ec0329ef997bac86984d - Sigstore transparency entry: 2070731229
- Sigstore integration time:
-
Permalink:
blockchain-project-lives/codex-workspaces@91bc51c6983881f4b4e18a016e17696c0a14d64d -
Branch / Tag:
refs/heads/release/v0.2.1 - Owner: https://github.com/blockchain-project-lives
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@91bc51c6983881f4b4e18a016e17696c0a14d64d -
Trigger Event:
push
-
Statement type:
File details
Details for the file codex_workspaces-0.2.1-py3-none-any.whl.
File metadata
- Download URL: codex_workspaces-0.2.1-py3-none-any.whl
- Upload date:
- Size: 30.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
464938a9ddef4b5134f3a1f01cc0b99df368d49c5aceb39265adcc4b2614e33f
|
|
| MD5 |
5e4a2a4a4d52e970ac5ca7adc00cbf62
|
|
| BLAKE2b-256 |
57f1639a93c9f6de431b24cf026410af78b152d2a953d49cb5f1d404ec992309
|
Provenance
The following attestation bundles were made for codex_workspaces-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on blockchain-project-lives/codex-workspaces
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_workspaces-0.2.1-py3-none-any.whl -
Subject digest:
464938a9ddef4b5134f3a1f01cc0b99df368d49c5aceb39265adcc4b2614e33f - Sigstore transparency entry: 2070731266
- Sigstore integration time:
-
Permalink:
blockchain-project-lives/codex-workspaces@91bc51c6983881f4b4e18a016e17696c0a14d64d -
Branch / Tag:
refs/heads/release/v0.2.1 - Owner: https://github.com/blockchain-project-lives
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@91bc51c6983881f4b4e18a016e17696c0a14d64d -
Trigger Event:
push
-
Statement type: