Getting Started

Background Service & Environment Variables

Keep the server alive with t3 service install, bind custom ports with t3 serve, and configure T3CODE_* vars.

If you only run the desktop app on one laptop, you rarely need to touch daemon commands or environment variables. They become essential in two cases:

  1. Keeping the backend running after closing windows or logging out of SSH, so remote clients and phones can reconnect anytime;
  2. Avoiding port 3773 collisions or relocating the ~/.t3 data directory.

1. Managing the Persistent Service (t3 service)

On macOS and Linux, the t3 CLI manages native user-level background services:

  • macOS: Registers a launchd (LaunchAgents) service that starts on login;
  • Linux: Registers a systemd user service and attempts to enable lingering (loginctl enable-linger) so it keeps running even after you disconnect from SSH;
  • Windows note: Native background OS service commands via t3 service are not directly supported on Windows.

Core subcommands:

bash
# Install and start the background service
t3 service install

# Check running state, startup status, and log file location
t3 service status

# Restart the background service (handy after authenticating a new CLI)
t3 service restart

# Update the background service launcher to the latest release
t3 service update

# Stop and remove startup registration (keeps projects, threads, and settings)
t3 service uninstall

2. Manual Headless Launch (t3 serve)

For servers, custom systemd units, or scripts where you do not want a browser window opened:

bash
# Headless server on default port 3773
t3 serve --port 3773 --no-browser

# Bind strictly to your Tailscale IP
t3 serve --host 100.x.y.z --port 3773 --no-browser

# Relocate the root workspace/data directory
t3 serve --base-dir /data/t3code

Warning: On public VPS machines, avoid exposing an unprotected server directly on --host 0.0.0.0. Prefer Tailscale, an SSH tunnel, or T3 Connect.


3. Inside ~/.t3 (Local Data Layout)

By default, T3 Code keeps persistent data under ~/.t3/:

  • ~/.t3/userdata/state.sqlite: SQLite store holding thread history, environment state, and pairing grants (development builds typically use ~/.t3/dev);
  • ~/.t3/userdata/keybindings.json: Custom keyboard shortcuts managed via Settings → Keybindings;
  • Managed worktrees and runtime logs organized under the base directory.

4. T3CODE_* Environment Variables

When running in containers, custom services, or pinned setups, these environment variables override defaults:

VariablePurpose
T3CODE_PORTPin the backend listening port (default 3773)
T3CODE_HOSTOverride the bound network interface address
T3CODE_BASE_DIROverride the default ~/.t3 base directory
T3CODE_STATE_DIRRelocate the SQLite state directory (~/.t3/userdata by default)
T3CODE_HOMERoot home path context used by the background service runner
T3CODE_AUTH_TOKENToken authenticating communication between clients and the server
T3CODE_MODE / T3CODE_CHANNEL / T3CODE_VERSIONRuntime mode, release channel, and version overrides
T3CODE_TELEMETRY_ENABLEDToggle telemetry behavior

5. Customizing Keybindings

If you prefer mod+Enter to send prompts and Enter for newlines, adjust it in Settings → Keybindings, or inspect and edit ~/.t3/userdata/keybindings.json directly.