59API

← Volver a las guías

Claude Code + tmux on Remote Servers

Claude Code · EN · 2026-07-22

Why this setup is worth it

If you are shipping code all day, the fastest way to make Claude Code useful is to run it where your project already lives: on a remote server, inside tmux. That gives you a persistent coding session that survives dropped SSH connections, laptop sleep, and quick context switches. You can leave Claude Code thinking, come back later, and pick up exactly where you left off.

This guide shows a practical setup for busy developers: connect to a server, start a tmux session, launch Claude Code, and keep the workflow cheap by routing requests through 59API. 59API is an AI API relay with pay-as-you-go access to Claude Opus, Sonnet, Haiku, and Fable, plus GPT models, all at some of the lowest relay prices and with native official-quality models.

What you need before you start

59API matters here because remote coding sessions can generate a lot of tokens. A relay with low per-use cost makes it realistic to leave the agent running for refactors, test fixes, and long planning passes without worrying about a big bill. The referral rebate is a nice bonus if your team ends up adopting the same workflow.

Step 1: SSH into the server and create a tmux session

Log in to your remote server as usual, then start a named tmux session so you can reconnect later:

tmux new -s code

Using a name like code, repo, or the project name makes it easier to manage multiple sessions. If you disconnect, tmux keeps your shell, editor, and Claude Code process alive.

Useful tmux basics:

Step 2: Point Claude Code at 59API

Configure Claude Code to use 59API as its API endpoint. In practice, that means setting your API key from 59API and using the base URL https://api.59api.com wherever your Claude Code setup expects a compatible provider URL or proxy endpoint.

If you already use OpenAI SDKs or other compatible tooling, the same relay can be reused across your stack. That is the big advantage: one cheap, compatible endpoint for agent workflows, scripts, and app integration.

Once configured, verify that Claude Code can authenticate and make a simple request. If your environment supports a test command or health check, run it before starting real work so you do not discover a credential problem halfway through a long session.

Step 3: Start Claude Code inside tmux

From inside the tmux session, cd into your repository and launch Claude Code as you normally would. The main idea is simple: keep the agent, shell, and tools in one persistent terminal context on the server. That way, Claude Code can inspect files, run tests, patch code, and retry without depending on your laptop staying connected.

A good first use case is a narrow task:

Busy developers get the most value by keeping the task scoped. Give Claude Code one repo, one branch, and one clear target. tmux handles session persistence; Claude Code handles the code changes.

Step 4: Use panes for a faster loop

tmux becomes powerful when you split the screen. Keep Claude Code in one pane and use another for tests, git status, or logs. A common pattern is:

This setup reduces context switching. You can ask Claude Code to make a change, run tests immediately in the next pane, and keep iterating without leaving the remote machine.

Step 5: Make it reliable for long sessions

For remote AI coding, reliability matters more than speed. A few habits help:

Because 59API charges pay-as-you-go and is built for compatibility with Claude Code, you can keep this loop running without overpaying for idle time. That is especially useful when you are using stronger models like Sonnet or Opus for tricky debugging, while saving money with lighter models for routine work.

When to choose this workflow

Use Claude Code with tmux and a remote server when the work is too large for a quick local edit but too small to justify a full engineering marathon. It is ideal for overnight fixes, CI-driven refactors, and production-adjacent work where server-side dependencies already exist. If you want to try it with minimal overhead, sign up for 59API, point your Claude Code setup at https://api.59api.com, and start a tmux session on your next SSH login.

Precios · Docs

¿Listo para empezar?

Conecta Claude y GPT en minutos a los precios más bajos, sin recortes. Regístrate para obtener tu clave API.

Registro gratis