One command to set up Claude Code and Codex CLI on Replit with full persistence and automatic token refresh.
When Replit containers restart, everything outside /home/runner/workspace/ is wiped - including installed CLIs, conversations, auth tokens, and command history. DATA Tools fixes all of that.
npx -y replit-tools(The -y skips the "Ok to proceed?" prompt)
That's it. The installer will:
- Install Claude Code (if not already installed)
- Install OpenAI Codex CLI (if not already installed)
- Detect existing config and preserve your data
- Set up persistence so everything survives restarts
- Auto-refresh OAuth tokens before they expire
- Launch the session picker so you can start working immediately
| Tool | Source | Purpose |
|---|---|---|
| Claude Code | curl https://claude.ai/install.sh |
Anthropic's CLI for Claude |
| Codex CLI | npm i -g @openai/codex |
OpenAI's coding assistant |
Both are installed only if not already present. Existing installations are preserved.
Everything is stored in a single .replit-tools/ directory:
| Data | Location | Survives Restart? |
|---|---|---|
| Claude conversations | .replit-tools/.claude-persistent/ |
Yes |
| Claude credentials | .replit-tools/.claude-persistent/ |
Yes |
| Claude binary | .replit-tools/.claude-versions/ |
Yes |
| Codex data | .replit-tools/.codex-persistent/ |
Yes |
| Bash history | .replit-tools/.persistent-home/ |
Yes |
| Per-terminal sessions | .replit-tools/.claude-sessions/ |
Yes |
| Auth logs | .replit-tools/.logs/ |
Yes |
| Scripts | .replit-tools/scripts/ |
Yes |
Claude OAuth tokens expire every 8-12 hours. DATA Tools automatically refreshes them:
- On every shell start: Checks token expiry and refreshes if < 2 hours remaining
- When expired: Attempts automatic refresh using the stored refresh token
- Transparent: You'll see
๐ Token expires in 1h, refreshing...thenโ Token refreshed (11h remaining)
This means you can leave overnight and come back to a working session - no more claude login every morning.
# Check token status
/home/runner/workspace/.replit-tools/scripts/claude-auth-refresh.sh --status
# Force refresh now
/home/runner/workspace/.replit-tools/scripts/claude-auth-refresh.sh --force
# Or use a permanent API token (never expires)
claude setup-tokenAfter installation (and on every new shell), you'll see:
โ
Claude authentication: valid (11h remaining)
โ
Claude Code ready: 2.0.71 (Claude Code)
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Claude Session Manager โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
(2 Claude instance(s) running in other terminals)
[c] Continue last session for this terminal
โโ b3dcb95c...
[r] Resume a specific session (pick from list)
[n] Start new session
[s] Skip - just give me a shell
Choice [c/r/n/s]: _
Press r to see full session metadata:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
[1]
ID: b3dcb95c-cebb-4082-b671-988c8d36578e
Messages: 237 | Size: 912.1KB
Active: 2m ago
Started: 2026-01-18 18:22:12 UTC
First: "Can you help me fix this bug..."
Latest: "Thanks, that worked!"
Each session shows:
- Full UUID
- Message count and file size
- Time since last activity
- Start and last activity timestamps
- First and latest prompts (truncated)
Each terminal tracks its own session independently:
Terminal pts/0 โ Session abc123... (your migration work)
Terminal pts/1 โ Session def456... (your docs work)
Terminal pts/2 โ Session ghi789... (your debugging)
Press c to continue YOUR terminal's last session. Other terminals are unaffected.
The installer creates symlinks from ephemeral locations to persistent .replit-tools/ storage:
~/.claude โ .replit-tools/.claude-persistent/
~/.codex โ .replit-tools/.codex-persistent/
~/.local/share/claude/versions/ โ .replit-tools/.claude-versions/
~/.local/bin/claude โ .replit-tools/.claude-versions/X.X.X
Three layers ensure setup runs on every restart:
.replitonBoot hook (runs at container boot).config/bashrc(runs on every shell start)- Scripts in
.replit-tools/scripts/(called by above)
The installer checks for:
CLAUDE_CONFIG_DIR- Respects custom Claude config directory if set in Replit SecretsCODEX_HOME- Respects custom Codex config directory- Existing persistent config - Uses your existing config if present (won't migrate if custom dir set)
- Replit Secrets - Detects
ANTHROPIC_API_KEYandOPENAI_API_KEY - Existing installations - Won't reinstall Claude or Codex if already present
- Existing data in ~/.claude - Moves it to persistent storage instead of overwriting
Claude Code:
| Variable | Purpose |
|---|---|
CLAUDE_CONFIG_DIR |
Custom directory for Claude config/data |
CLAUDE_WORKSPACE_DIR |
Alternative name (both are valid) |
CLAUDE_DATA_DIR |
Alternative name |
CLAUDE_HOME |
Alternative name |
ANTHROPIC_API_KEY |
Claude API authentication |
OpenAI Codex CLI:
| Variable | Purpose |
|---|---|
CODEX_HOME |
Custom directory for Codex config/data (official) |
CODEX_CONFIG_DIR |
Alternative name |
CODEX_DATA_DIR |
Alternative name |
OPENAI_API_KEY |
Codex API authentication |
If you set these in your Replit Secrets to paths inside /home/runner/workspace/, DATA Tools will use those directories for persistence instead of the defaults. Your custom directories will NOT be migrated - we respect your configuration.
npx -y replit-toolscurl -fsSL https://raw.githubusercontent.com/stevemoraco/DATAtools/main/install.sh | bashnpm install -g replit-tools
replit-toolsAfter installation, these aliases are available:
| Command | Description |
|---|---|
cr |
Continue last Claude session |
claude-resume |
Same as cr |
claude-new |
Start a new Claude session |
claude-pick |
Claude's built-in session picker |
cm |
Show the session manager menu |
claude-menu |
Same as cm |
l |
Login to Claude (authenticate) |
claude-login |
Same as l |
These aliases work from any shell, even without the session manager loop running.
export CLAUDE_NO_PROMPT=trueAdd to .config/bashrc to make permanent.
claude setup-tokenCreates a long-lived API token that never expires (recommended for unattended use).
workspace/
โโโ .replit-tools/ # All DATA Tools data (gitignored)
โ โโโ .claude-persistent/ # Claude conversations & credentials
โ โโโ .codex-persistent/ # Codex CLI data
โ โโโ .claude-sessions/ # Per-terminal session tracking
โ โโโ .claude-versions/ # Claude binary versions
โ โโโ .persistent-home/ # Bash history
โ โโโ .logs/ # Auth refresh logs
โ โโโ scripts/ # Setup & management scripts
โ โโโ setup-claude-code.sh
โ โโโ claude-session-manager.sh
โ โโโ claude-auth-refresh.sh
โโโ .config/bashrc # Shell startup config (sources scripts)
โโโ .gitignore # Updated to ignore .replit-tools/
If you used DATA Tools v1.x (before the .replit-tools/ consolidation), your data will be automatically migrated:
Old Location โ New Location
.claude-persistent/ โ .replit-tools/.claude-persistent/
.codex-persistent/ โ .replit-tools/.codex-persistent/
.claude-sessions/ โ .replit-tools/.claude-sessions/
.persistent-home/ โ .replit-tools/.persistent-home/
.local/share/claude/versions/ โ .replit-tools/.claude-versions/
Migration only happens if:
- Old location exists AND new location doesn't
- You don't have custom
CLAUDE_CONFIG_DIRorCODEX_HOMEset
Your original data is copied (not moved), so nothing is lost.
source /home/runner/workspace/.replit-tools/scripts/setup-claude-code.shsource /home/runner/workspace/.config/bashrcThe auto-refresh should handle this, but if it fails:
# Check why refresh failed
cat /home/runner/workspace/.replit-tools/.logs/auth-refresh.log
# Manual refresh
/home/runner/workspace/.replit-tools/scripts/claude-auth-refresh.sh --force
# Or use permanent token (recommended)
claude setup-tokennpx -y replit-toolsRunning the installer again is safe - it preserves existing data.
The installer adds .replit-tools/ to .gitignore, which protects:
| Path | Contains | Why Protected |
|---|---|---|
.replit-tools/.claude-persistent/ |
OAuth tokens, refresh tokens, conversations | Critical - full account access |
.replit-tools/.codex-persistent/ |
API keys in auth.json, conversations |
Critical - full account access |
.replit-tools/.claude-sessions/ |
Session UUIDs, terminal mappings | Session metadata |
.replit-tools/.persistent-home/ |
Bash history | May contain typed secrets |
.replit-tools/.logs/ |
Token refresh timestamps | Auth timing info |
Your API keys, OAuth tokens, and conversation history won't be committed to git.
Developer Assistant Tool Automation - everything you need to run AI coding assistants on Replit, persisted and ready to go.
GitHub: stevemoraco/DATAtools
MIT