AgentShell lets several terminal windows use different AI-service logins while they all work in the same real project directory. It changes each tool's state directory; it does not copy the project, change the Unix user, or create a container.
This guide uses three example profiles:
personallabcompany
Profile names are labels chosen locally. They may contain letters, numbers, dots, underscores, and hyphens.
AgentShell's --account selects an authentication/state profile:
codex --account personalCodex's native --profile/-p option selects a configuration profile. It does not select a different ChatGPT login. The two concepts are independent.
The AgentShell option must be the first option. Everything after it is passed to the native tool:
# Correct
codex --account lab -m gpt-5.6-sol "Review this repository"
# Incorrect: native Codex receives an unknown --account option
codex -m gpt-5.6-sol --account labPlain commands remain unchanged:
codex
codexr
codexmvRun these in any terminal and from any current directory:
source ~/.bashrc
agentshell personal
codexrThat is the normal workflow. Replace personal with lab or company when needed. Once inside the named shell, plain codex, codexr, and codexmv all use that account.
For the first login only:
source ~/.bashrc
codex --account personal login
agent-profile history personal sharedAfter login, return to the three-command workflow. Run exit when you want to leave the named AgentShell terminal.
One-shot commands remain available when a dedicated shell is not wanted:
codex --account personal
codexr --account personal
codexr --account personal --allOn a new computer:
cd "$HOME/ProjectsLFS"
git clone https://github.com/lachlanchen/AgentShell.git
cd AgentShell
./install.sh
. "$HOME/.bashrc"No sudo, Docker, or additional Unix user is required.
The installer creates:
~/.local/lib/agentshell/agentshell installed runtime
~/.local/bin/agent-* command links
~/scripts/sourced_agent_shell.sh Bash integration
~/.local/share/agentshell/profiles/ account state
Confirm the integration:
type codex
type agentshell
agentshell --helptype codex should report a Bash function after .bashrc is loaded. The function only intercepts a leading --account or --project; otherwise it preserves the normal workstation wrapper.
Create as many profiles as needed:
agent-profile create personal
agent-profile create lab
agent-profile create companyCreation is idempotent: running the same command again reuses the profile.
List profiles:
agent-profile listExample output:
ACCOUNT CODEX LOGIN HISTORY STATE
company not logged in shared .../profiles/company
lab not logged in shared .../profiles/lab
personal saved shared .../profiles/personal
Run one login at a time:
codex --account personal login
codex --account lab login
codex --account company loginCodex opens its login flow. In the browser, authenticate with the account intended for that profile. The resulting credential is saved only in that profile's private CODEX_HOME.
This equivalent command is useful when managing profiles:
agent-profile login personal codexIf the callback browser cannot reach the terminal machine, use:
codex --account personal login --device-authFollow the displayed URL and code from any convenient browser.
codex --account personal login status
agent-profile status personal codex
agent-profile listInside a running Codex TUI, /status is the best check for the exact authenticated identity and current session details.
codex --account lab logout
codex --account lab loginThis affects only lab; it does not log out personal, company, or ordinary ~/.codex.
Authentication and the SQLite session index are separate choices.
| Mode | Authentication | Resume index | Best for |
|---|---|---|---|
private |
Profile-local | Profile-local | Confidential separation |
shared |
Profile-local | Shared ~/.codex index |
Resuming the same workstation sessions with several accounts |
New profiles default to private history. Change a profile to shared history with:
agent-profile history personal shared
agent-profile history lab shared
agent-profile history company sharedReturn one profile to private history:
agent-profile history company privateShow the current choice:
agent-profile history company
agentshell status companyIn shared mode:
- credentials remain under
~/.local/share/agentshell/profiles/ACCOUNT/codex-home/; - the resume catalog is
~/.codex/state_5.sqlite; codexr --account ACCOUNTcan discover established workstation sessions;- session titles, previews, and paths in that index are visible to every shared profile.
Changing modes does not delete either history. It changes which SQLite location future commands use.
cd /path/to/project
codex --account personalNative arguments and prompts continue to work:
codex --account lab -m gpt-5.6-sol
codex --account company --search "Review the current repository"
codex --account personal -C /path/to/projectAgentShell prints a short launch banner in an interactive terminal so the selected label is visible before Codex starts.
This is the clearest workflow for long-running work:
cd /path/to/project
agentshell personalThe prompt begins with [agent:personal]. Inside that shell, use normal commands:
agentshell -v
codex
codexr
codexmvThe working directory remains unchanged. Exit the dedicated shell with:
exitOpen another terminal and run agentshell lab to use the lab login in the same repository.
Creating lab also creates:
agent-lab-codex
agent-lab-codexr
agent-lab-codexmv
agent-lab-claude
agent-lab-gemini
agent-lab-copilot
These forms are equivalent:
codex --account lab --version
agent-codex --account lab --version
agent-lab-codex --version
agent-run --account lab codex --version--project is an alias for --account:
codex --project labThe workstation codexr wrapper defaults to sessions whose recorded working directory exactly matches the current directory:
cd /path/to/project
codexr --account personalUse the arrow keys to select, Enter to resume, and q or Ctrl+C to cancel.
Show sessions from every directory:
codexr --account personal --allSearch by a partial directory name:
codexr --account personal --non-strict EchoMindInclude non-interactive runs:
codexr --account personal --all --include-non-interactiveUse Codex's native picker instead of the fast workstation picker:
codexr --account personal --nativeResume the newest native session directly:
codex --account personal resume --lastResume by UUID or a name assigned with /rename:
codex --account personal resume SESSION_ID_OR_NAME--non-strict belongs to codexr, not plain codex:
# Correct
codexr --account personal --non-strict incoder
# Incorrect
codex non-strict incoderIf a project directory was renamed or moved, update the indexed session paths with:
codexmv --account personal /old/project/path /new/project/pathThis changes Codex session metadata; it does not move project files. The workstation wrapper writes a rollback journal before updating the SQLite rows.
Useful forms:
# Update metadata and resume the newest migrated session
codexmv --account personal --latest /old/path /new/path
# Update metadata without opening Codex
codexmv --account personal --no-resume /old/path /new/path
# Use the native picker after migration
codexmv --account personal --native /old/path /new/pathInside a dedicated AgentShell terminal:
agentshell -vExample:
AgentShell 0.2.0
Current account: personal
Codex login: saved
History mode: shared
Codex home: .../profiles/personal/codex-home
SQLite home: /home/lachlan/.codex
Working dir: /path/to/project
From an ordinary terminal, inspect a named profile explicitly:
agentshell status personal
agent-profile status personal codexagentshell -v in an ordinary shell correctly reports none (ordinary shell). A one-shot child command such as codex --account personal cannot change the parent shell's environment. Its launch banner identifies the selected profile, and /status identifies the authenticated account inside Codex.
Terminal 1, personal work:
source ~/.bashrc
agentshell personal
codexrTerminal 2, lab work:
source ~/.bashrc
agentshell lab
codexTerminal 3, company work:
source ~/.bashrc
agentshell company
codexEvery terminal sees the same filesystem and Git worktrees. Only provider state and authentication are selected by the profile.
AgentShell also prepares separate state roots for Claude Code, Gemini CLI, and GitHub Copilot CLI:
claude --account lab
gemini --account personal
copilot --account companyOr enter agentshell lab and run the commands without --account. Each provider still requires its own normal login flow. Codex is the most deeply integrated provider on this workstation.
cd "$HOME/ProjectsLFS/AgentShell"
git pull --rebase
./install.sh
. "$HOME/.bashrc"Validate after updating:
agentshell -v
agent-profile list
codex --version
codex --account personal login statusThe current shell has not loaded AgentShell's Bash integration, or --account was not first.
. "$HOME/.bashrc"
type codex
codex --account personal login statusNew Bash terminals load the integration automatically.
Inspect the profile's history route:
agentshell status personalTo use the established workstation index:
agent-profile history personal sharedA new private profile may have no SQLite database until Codex creates state there. The workstation wrapper falls back to the native picker rather than treating that as corruption.
codexr --account personal --all
codexr --account personal --non-strict PART_OF_OLD_PATHIf a folder was renamed, use codexmv after confirming the old and new paths.
codex --account personal logout
codex --account personal loginThen open Codex and run /status.
codex --account personal login --device-authYou are in an ordinary parent shell. Either inspect a profile explicitly:
agentshell status personalor enter it:
agentshell personal
agentshell -vThis means the picker was cancelled. It does not indicate session-database damage. Run codexr again or use q to leave the picker.
. "$HOME/.bashrc"
printf '%s\n' "$PATH"
ls -l "$HOME/.local/bin/agentshell"If required, rerun ./install.sh; it is designed to be idempotent and refuses to overwrite unrelated commands.
Profile state lives under:
~/.local/share/agentshell/profiles/ACCOUNT/
Important rules:
- Do not upload
auth.json, profile state, cookies, or tokens. - Shared history exposes indexed titles, previews, and paths to every profile using that index.
- AgentShell profiles are not an OS security boundary; all processes still run as the same Unix user.
- Use separate Unix users or separately controlled machines for mutually untrusted people.
- Prefer browser login. If an account-specific API variable is necessary, place it in that profile's mode-0600
env.sh, not a public repository or shared.bashrc.
AgentShell deliberately shares authored Codex configuration, skills, plugins, and rules where safe, while keeping provider credentials profile-local.
# Reload integration
. "$HOME/.bashrc"
# Create and inspect profiles
agent-profile create personal
agent-profile list
agentshell status personal
# Login/status/logout
codex --account personal login
codex --account personal login --device-auth
codex --account personal login status
codex --account personal logout
# History mode
agent-profile history personal shared
agent-profile history personal private
# One-shot use
codex --account personal
codexr --account personal
codexr --account personal --all
# Dedicated terminal
agentshell personal
agentshell -v
exit
# Moved project sessions
codexmv --account personal /old/path /new/path
# Update
cd "$HOME/ProjectsLFS/AgentShell"
git pull --rebase
./install.sh
. "$HOME/.bashrc"Codex documents CODEX_HOME as the root for config, authentication, logs, sessions, and skills. It separately documents CODEX_SQLITE_HOME for SQLite-backed state. AgentShell uses that supported separation to keep each login private while optionally sharing the resume index: