How to Run Claude Code as a Background Daemon
You start a Claude Code task. It's going to take a while — refactoring a module, running through test failures, generating boilerplate for a new feature.
You wait. And wait. And then you need to leave.
Close your laptop? Task dead. Terminal session gone. The 15 minutes Claude spent understanding your codebase? Wasted. You're starting from scratch when you get back.
This is the default Claude Code experience. And it's broken for anyone who doesn't sit at their desk for 8 hours straight.
The Problem: Claude Code Is a Foreground Process
Claude Code is designed as an interactive terminal application. It runs in your shell. It expects you to be there, watching, approving tool calls, typing follow-ups.
This works great when you're actively coding. It doesn't work when:
- You want to kick off a long task and walk away
- Your laptop needs to sleep (battery, meetings, commute)
- You want to check on progress from another device
- You're on your phone and want to start something quick
Every other critical developer tool — your database, your dev server, your Docker containers — runs as a background process. Claude Code doesn't. Until you make it.
Option 1: nohup / tmux / screen (The DIY Way)
The first thing most developers try:
# Using tmux
tmux new-session -d -s claude "claude"
# Or nohup
nohup claude &
This keeps Claude Code alive when you close your terminal. But it solves exactly one problem and introduces three new ones:
You can't interact with it remotely. Claude is running in a detached session on your machine. To talk to it, you need to SSH back in and reattach. On a phone? Good luck typing tmux attach -t claude on a touch keyboard.
No per-project isolation. You get one session. Switch projects? You're context-switching Claude too. No clean separation.
No notification when it's done. Claude finishes a task at 3 PM while you're in a meeting. You don't find out until you sit back down at 5 PM. Two hours of idle time on a tool you're paying for.
tmux keeps the process alive. It doesn't make it useful while you're away.
Option 2: Claude Code as a launchd/systemd Service
You can write a service definition that starts Claude Code on boot:
# macOS launchd plist (simplified)
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.claude.code</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/claude</string>
</array>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
Now it starts automatically and restarts if it crashes. But you still have the same interaction problem — it's running, but you can't talk to it from your phone. And Claude Code's interactive nature means it's sitting there waiting for input that never comes.
A service without a remote interface is a process that runs but doesn't work.
Option 3: The Actual Solution — A Daemon with a Remote Interface
Here's what you actually need:
- A background process that runs Claude Code
- A way to send it messages from anywhere (your phone, another computer)
- Per-project sessions so you can manage multiple codebases
- Notifications when tasks complete
This is what Clautel does. It's a background daemon that bridges Claude Code to Telegram.
npm install -g clautel
clautel setup
clautel start
That's it. Three commands. Claude Code is now running as a daemon.
What "Background Daemon" Actually Means
When you run clautel start, here's what happens:
The daemon starts and stays alive. It's not a terminal session. It's a proper background process. Close your terminal, close your laptop lid (with sleep disabled), log out — it keeps running. On macOS, you can install it as a launchd service with clautel install-service so it starts on boot.
Each project gets its own Telegram bot. You use the manager bot to run /add with a project path. Clautel creates a dedicated worker bot for that project. You now have a Telegram chat that's permanently connected to Claude Code in that directory.
Messages go in, results come out. Type "fix the failing test in auth.test.ts" in Telegram. Claude Code reads your files, runs the test, identifies the issue, makes the fix. You see the diff in the chat. Approve or reject.
Sessions persist. Started something in your terminal this morning? Type /resume in Telegram. You'll see your recent sessions with timestamps and context previews. Tap one to pick up exactly where you left off — full conversation history, full context.
The Workflow That Changes
Before (foreground-only):
- Start Claude Code task at desk
- Wait for it to finish
- Close laptop → task dies
- Reopen → start from scratch
- All work happens at your desk
After (background daemon):
- Start task from Telegram on your commute
- Claude works while you're in a meeting
- Check progress from your phone whenever
/resumefrom your terminal when you're back at your desk- Work happens wherever you are
The daemon doesn't give you more hours in the day. It removes the constraint that your most powerful development tool only works when you're physically sitting in front of it.
Quick Setup (5 Minutes)
Step 1: Install
npm install -g clautel
Step 2: Setup — Creates your manager bot via BotFather, sets your Telegram ID, activates your license.
clautel setup
Step 3: Start the daemon
clautel start
Step 4: Add a project — Open your manager bot in Telegram:
/add <bot_token> /path/to/your/project
Step 5 (optional): Install as a system service — Auto-starts on boot, restarts on crash.
clautel install-service
Now open your project's worker bot in Telegram and type anything. Claude Code is running in the background, connected to your project, waiting for instructions.
The Commands You'll Use Most
| Command | What It Does |
|---|---|
| Any message | Talks to Claude Code in that project |
/resume | Pick up a recent CLI session in Telegram |
/session | Get session ID to continue in your terminal |
/preview <url> | Screenshot any URL (including localhost) |
/model | Switch between Claude models |
/new | Start a fresh session |
/cost | Check token usage |
SSH vs Daemon: Why This Is Different
"Can't I just SSH into my machine and use Claude Code remotely?"
You can. But SSH on a phone is painful — tiny terminal, touch keyboard, no copy-paste that works well, no rich formatting. You're fighting the interface instead of coding.
A Telegram bot is a chat interface. It's designed for mobile-first interaction. You type in natural language, you get formatted responses with code blocks, you tap buttons to approve actions. The interface disappears and you're just having a conversation with Claude Code.
SSH gives you remote access. A daemon with Telegram gives you remote usability.
Clautel runs Claude Code as a background daemon and bridges it to Telegram. Works with Claude Pro and Max. 7-day free trial at $4/mo. npm install -g clautel