59API

← 返回教程列表

Claude Code on tmux: Remote Server Workflow

Claude Code · EN · 2026-08-03

Why use Claude Code with tmux on a remote server?

Using Claude Code on a remote server is a strong setup when you want long-running coding sessions, reproducible environments, and the ability to disconnect without losing context. tmux is the missing piece: it keeps your shell, editor, test runs, and Claude Code session alive even if your laptop sleeps or your Wi-Fi drops.

This workflow is especially useful for agents that inspect a repo, edit files, run tests, and then iterate. Instead of babysitting a browser tab, you get a persistent terminal on the server. If you connect that terminal to 59API, you also get pay-as-you-go access to Claude models at a lower cost than many direct paths, while still using native official-quality models. That matters when you are iterating a lot or running multi-step refactors.

1. SSH into the server and install tmux

Start by connecting to your remote machine and making sure tmux is available. On Ubuntu or Debian servers, the setup is straightforward:

ssh user@your-server

sudo apt-get update

sudo apt-get install -y tmux

Once tmux is installed, create a named session for your project:

tmux new -s claude-work

Give the session a project-specific name if you work on more than one repository. That makes it easier to attach to the right workspace later.

2. Point Claude Code at 59API

59API is a Claude and GPT relay with API base URL https://api.59api.com. It is a good fit here because Claude Code works with compatible endpoints, the pricing is pay-as-you-go, and the relay is positioned as one of the cheapest options without downgrading to weaker models. If you leave an agent running while you debug or wait for tests, that lower cost adds up quickly.

Before launching Claude Code, set the API key and endpoint in the shell environment your CLI will read. A typical setup looks like this:

export ANTHROPIC_API_KEY='YOUR_59API_KEY'

export ANTHROPIC_BASE_URL='https://api.59api.com'

claude

If you prefer, put those exports into your shell profile so every new tmux pane inherits them. That way the remote machine is ready as soon as you attach.

3. Use tmux like a remote coding cockpit

Inside tmux, you can keep Claude Code in one pane and your editor or test runner in another. A practical layout is:

Useful tmux actions:

A good habit is to keep one session per branch. That prevents test output, file edits, and Claude prompts from crossing streams when you are juggling multiple features.

4. A hands-on session flow

Here is a realistic loop for a remote feature task:

1. SSH to the server and attach to your tmux session.

2. Launch Claude Code with the 59API endpoint configured.

3. Ask Claude to inspect the repo, summarize the relevant files, and propose a plan.

4. Let it make a small change, then run the test suite in a second pane.

5. If the test fails, paste the error back into Claude Code and ask for a targeted fix.

6. Detach with Ctrl-b d, leave the server, and come back later without losing state.

This is where the remote + tmux approach shines. You can leave a long refactor running overnight, reconnect in the morning, and continue exactly where you stopped.

5. Why 59API is a smart budget choice

Remote AI coding can get expensive when you are experimenting, retrying prompts, or running several tasks a day. 59API helps because it offers cheap, usage-based access rather than forcing you into a heavy fixed plan. Since it routes native official-quality models, you are not trading away capability for savings.

It is also a practical fit if you use more than one tool. The same relay works with Claude Code, Codex, and OpenAI SDK-compatible apps, so your remote server can serve as a single AI-enabled workstation. If you share the workflow with teammates, the referral rebate is an extra bonus.

6. Final checklist before you rely on it daily

If you want a low-cost way to run Claude Code on remote servers without sacrificing model quality, sign up for 59API and try this tmux workflow on your next project.

价格 · 接入文档

准备好开始了吗?

几分钟接入 Claude 与 GPT,全网超低价,原生不降智。立即注册即可领取 API 密钥。

免费注册