Architecting Persistent Agentic Workflows: Deploying Anthropic’s Claude Code on KVM-based VPS via tmux
The paradigm of software development is shifting from interactive, human-led coding to asynchronous, agent-led orchestration. While tools like Anthropic's Claude Code—a terminal-based AI coding agent capable of multi-step reasoning, file manipulation, and automated test execution—offer unprecedented productivity, they are fundamentally limited by the lifecycle of the host machine. If you run Claude Code on a local workstation, the agent’s progress is tethered to your laptop's power state and network connectivity.
To unlock true "always-on" capabilities, developers must move the agentic workload from local environments to a persistent Virtual Private Server (VPS). This allows for long-running refactoring tasks—such as migrating an entire backend framework—to execute 24/7, independent of the developer's physical presence or device status.
The Infrastructure: KVM Virtualization and Resource Allocation
To host an agent capable of indexing repositories, running heavy test suites (e.g., Jest or Vitest), and installing complex dependencies, a standard shared hosting environment is insufficient due to idle-sleep policies. A KVM (Kernel-based Virtual Machine) architecture is required.
For a production-grade agentic workflow, the recommended specification includes:
- vCPU: At least 2 cores to handle concurrent processes (the agent, the test runner, and the web server).
- RAM: 8GB minimum to prevent OOM (Out of Memory) errors during heavy dependency installation or large-scale codebase indexing.
- Storage: NVMe SSDs for high I/O throughput, essential when the agent is performing massive file reads/writes across a deep directory tree.
By utilizing a VPS, you also gain a stable network backbone. This ensures that npm install operations and Git clones are not bottlenecked by domestic Wi-Fi latency or packet loss, providing a deterministic environment for the agent to operate within.
Achieving Session Persistence with tmux
The most critical technical hurdle in deploying Claude Code on a remote server is session termination. When an SSH connection is severed—whether due to network instability or the developer closing their terminal—the child processes initiated by that shell are typically sent a SIGHUP signal, terminating the agent mid-task.
To circumvent this, we implement tmux (Terminal Multiplexer). By wrapping the Claude Code execution within a tmux session, we create a persistent environment that survives SSH disconnection.
The deployment workflow follows this sequence:
- Initialize a named session:
tmux new -s agent - Launch the agent: Execute the
claudeCLI. - Detach/Reattach: The developer can detach from the session (
Ctrl+B, thend) and later reattach (tmux attach -t agent) to monitor progress via any terminal, regardless of their physical location.
Remote Orchestration: The Research Preview Interface
Anthropic’s Remote Control feature (currently in research preview) acts as the bridge between the persistent VPS and the developer's mobile or browser-based interface. By invoking the /remote control command within a Claude Code session, the agent generates an authenticated link or QR code.
This allows for a decoupled architecture:
- The Execution Layer (VPS): Runs the heavy lifting, maintains the filesystem state, and executes the logic.
- The Interface Layer (Mobile/Browser): Acts as a lightweight window into the running process, allowing developers to send prompts, approve file edits, or trigger test suites via the Claude mobile app.
Context Engineering: The claude.md Configuration File
An AI agent is only as effective as the context it is provided. To prevent "hallucinations" and ensure adherence to project-specific standards, developers should implement a claude.md file in the root of their repository. This serves as a high-leverage configuration layer for the agent.
A robust claude.md should define:
- Project Overview: The core architecture (e.g., "This is an Express.js backend").
- Operational Constraints: Instructions to keep commits small and use specific branching strategies.
- Automated Workflows: Explicit instructions to run the test suite after every modification and to open a Pull Request (PR) only when all tests pass.
- Coding Standards: Rules regarding linting, middleware implementation, or directory structures.
By engineering this file, you transform Claude Code from a general-purpose assistant into a specialized, project-aware engineer that understands your specific CI/CD requirements and architectural patterns.
Use Case: Large-Scale Framework Migration
The true value of an always-on agent is demonstrated during high-latency, high-complexity tasks like migrating a backend from Express.js to Fastify. Such a task involves refactoring every route, updating middleware logic, and ensuring compatibility with the existing test suite—a process that can take hours of continuous computation.
By issuing the command via the mobile interface:
"Migrate the entire backend from Express to Fastify. Update all routes and middleware. Run the full test suite. Open a pull request once everything passes."
The developer can walk away. The agent, running inside tmux on the KVM VPS, iterates through the codebase, handles the breaking changes, validates the logic against the test runner, and ultimately presents a completed PR for human review. This shifts the developer's role from "coder" to "reviewer," significantly increasing engineering velocity.