Skip to main content

Cross-platform Codex workspace switcher with a preserved macOS shell workflow.

Project description

codex-workspaces

English | 简体中文 | Changelog

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 ~/.codex symlink 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-accounts auth snapshots.
  • Keep macOS Codex App stop/start/restart support.
  • Show local token usage stats from Codex state_*.sqlite in 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, and restart.
  • 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 account metadata and snapshots:

codex-workspaces accounts note acct_research "lab account"
codex-workspaces accounts rename acct_research acct_lab
codex-workspaces accounts delete acct_lab --force

Account deletion always requires --force and refuses to delete an account that is still configured as any workspace's default account.

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

codex_workspaces-0.3.0.tar.gz (44.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codex_workspaces-0.3.0-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

Details for the file codex_workspaces-0.3.0.tar.gz.

File metadata

  • Download URL: codex_workspaces-0.3.0.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for codex_workspaces-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7dfffc1cc1a519bd85e30ddb088d6822d7e3a3aefd119e90ad0a7b71d82fc571
MD5 dc6d321dc925afb0905284eef6e719f6
BLAKE2b-256 dea9b9dafa92a3baca896681b5d0a4f9939d10df77308a0beeaf3bf026c69891

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_workspaces-0.3.0.tar.gz:

Publisher: publish.yml on blockchain-project-lives/codex-workspaces

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_workspaces-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for codex_workspaces-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf246ef0d43af34471763a614fd2b1cb3b9d33cc6b281e4c8ba427e2eb2a61ba
MD5 02073c0b7405b7cae2fbd4e576ea53e4
BLAKE2b-256 17fb44712fd89942d47be53cc0a7a2b45e7198f93d4be4d8f21959df6383e1e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_workspaces-0.3.0-py3-none-any.whl:

Publisher: publish.yml on blockchain-project-lives/codex-workspaces

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page