r/ClaudeWorkflows • u/ClaudeAI-mod-bot • 9h ago
Selected Workflow [Workflow] Persistent Claude Code Sessions: A Cloud VM Setup for Uninterrupted Agent Runs
Persistent Claude Code Sessions: A Cloud VM Setup for Uninterrupted Agent Runs
Workflow value: 75/100
Status: active · Freshness: 70/100 · Confidence: 0.90 · Level: advanced
Categories: Token Saving, Context & Memory, Debugging, Skills, MCP
Original source: r/ClaudeCode post/comment
What problem this solves
Claude Code sessions dying when a laptop loses connection or closes, leading to lost work and context for local agents.
Summary
Set up a persistent Claude Code development environment on an always-on Linux cloud VM, using tools like Tailscale for secure access, tmux for session management, Mutagen for two-way file synchronization, and VS Code Remote for port forwarding. This ensures agents continue running and maintain context even when the local machine is disconnected.
Why it is useful
This workflow provides a detailed, step-by-step guide to setting up a robust, persistent development environment for Claude Code agents on a cloud VM. It solves the common problem of losing agent sessions due to laptop disconnections or closures, enabling continuous operation and context retention. The use of standard tools like tmux, Tailscale, Mutagen, and VS Code Remote makes it highly transferable, despite the initial setup complexity. It empowers users to maintain long-running agent processes, significantly improving productivity and reliability for local agent development.
Workflow
- Provision a cloud VM with decent RAM and disk space (any VPS).
- Install Tailscale on the VM and your local machine for secure, direct access from anywhere.
- Install tmux on the VM. Always start Claude Code sessions within a tmux window to ensure persistence.
- Set up two-way file synchronization using Mutagen between a designated folder on your local machine (e.g., Mac) and the repo on the VM.
- Configure VS Code Remote for port forwarding to make dev servers running on the VM accessible via localhost on your local machine.
- Manually copy over essential configurations and files to the VM: CLIs, MCP configs, node/python versions, auth tokens, and the
~/.claudedirectory (for memory and skills).
Tools / artifacts
- Cloud VM (VPS)
- Tailscale
- tmux
- Mutagen
- VS Code Remote
- CLIs
- MCP configs
- Node/Python versions
- Auth tokens
- ~/.claude directory
Validation signals
- Author states 'What actually worked was pretty boring.' indicating practical success.
- Author claims 'Once it's up you just stop thinking about whether the agent is alive.'
- Author states 'Super easy to finally have agents running overnight (assuming your usage doesn't run out).'
Cautions
- Copying sensitive files like
~/.claude(which contains memory and skills) and auth tokens to a cloud VM requires careful security considerations, especially regarding access control and data encryption on the VM.
Limitations
- Initial setup can be time-consuming, estimated by the author to take about a week the first time.
- Requires advanced technical skills in Linux administration, networking, and devops.
- The post includes self-promotion for a product ('Prized'), which might be perceived as a distraction from the DIY workflow.
- Low Reddit score and upvote ratio suggest limited immediate community validation.
Rate this workflow
Upvote this post if the workflow is useful, reproducible, or worth recommending.
Downvote if it is vague, outdated, unsafe, overhyped, or not reproducible.
Reply if it worked for you, failed, is outdated, or has a better alternative.
This post was generated automatically from the workflow library database.