What is Claude Code? I Run It Headless at 3AM, Not in an IDE

Claude Code processed twelve tasks on my home server last night while I was asleep. Total cost: about a dollar twenty. If you keep hearing it's a "developer tool," you've been sold the wrong frame — most tutorials show the demo, not the deployment.
The reframe: it's a process, not an assistant
The surface definition is fine: Claude Code is a terminal-native agent from Anthropic. It reads your files, runs shell commands, edits code, calls APIs, reports back. You give it a task in plain English, it does the work.
What almost nobody shows you is that Claude Code does not need a human watching it. It doesn't need an IDE. It doesn't need a screen. It's a Linux process. And anything that's a process on Linux, you can schedule, you can background, you can run in parallel.
That single reframe is what changes the economics for a small business owner. You stop thinking "AI pair programmer" and start thinking "junior ops hire who works the night shift for thirty bucks a month."
Headless mode is the unlock. One flag, no TTY, no interactive prompt — just stdin to stdout, like every other Unix tool that's ever existed:
claude -p "$(cat /home/lazar/prompts/invoice_retry.md)" \
--output-format json \
--max-turns 25 \
>> /var/log/claude/invoice_retry.log 2>&1
That's it. That's the entire interface between cron and a working agent.
My actual setup: one mini-PC, four tmux sessions
I run a small mini-PC at home on WSL Ubuntu. Draws about as much power as a desk lamp. On that machine right now I have four Claude Code instances running in four tmux sessions. Tmux just keeps terminal sessions alive after I disconnect — nothing exotic.
- Session 1: invoicing ops for a client running hundreds of recurring invoices a month
- Session 2: email triage — sorts inbound, drafts replies, flags the rest
- Session 3: lead scoring — reads form submissions, ranks them, pushes to CRM
- Session 4: log monitor that watches the other three and pings me on Telegram if anything breaks
Four agents. One small machine. Zero humans in front of it.
Spinning up a long-running session is boring on purpose:
tmux new-session -d -s invoicing
tmux send-keys -t invoicing "cd ~/agents/invoicing && ./run_loop.sh" C-m
tmux new-session -d -s email_triage
tmux send-keys -t email_triage "cd ~/agents/email && ./run_loop.sh" C-m
tmux new-session -d -s monitor
tmux send-keys -t monitor "cd ~/agents/monitor && ./watch.sh" C-m
Disconnect, close the laptop, go to sleep. The sessions keep running.
One concrete job: the 2 AM invoice retry loop
Abstraction is useless here, so let me walk through one job end-to-end.
At 2 AM, a cron job fires. Cron is the Linux scheduler — it's been around since the 70s, it's boring, it's bulletproof.
0 2 * * * /home/lazar/agents/invoicing/run_retry.sh
The script launches Claude Code in headless mode with a prompt file. The prompt is written like instructions for a new hire on their first day — specific tables, specific rules, specific escalation path:
# Job: Failed Invoice Retry
You have access to the Postgres database `billing_prod` and the Stripe API.
1. Query `failed_invoices` where `retry_attempts < 3` AND `failed_at > NOW() - INTERVAL '24 hours'`.
2. For each row:
- If `failure_code` is in [`network_timeout`, `rate_limited`, `stripe_5xx`], retry via Stripe API.
- If `failure_code` is in [`invalid_card`, `bad_address`, `customer_not_found`], skip and tag `manual_review`.
3. Write outcome to `retry_log` with timestamp, invoice_id, result, reason.
4. POST a summary to the Telegram channel `ops-alerts` in this format:
"Invoice retry run: X attempted, Y succeeded, Z flagged. Failures: [list]."
5. Exit.
Claude Code reads the prompt, opens the database, runs the queries, makes the decisions, hits the billing API, writes the log, posts the summary, and exits.
I wake up at 7 AM. I check Telegram. Twelve invoices retried, ten succeeded, two flagged for manual review with reasons attached. That's the whole loop.
Real numbers: what a night actually costs
I'm tired of "AI is cheap" with no numbers, so here's the bill.
- One night, twelve scheduled tasks: ~$1.20 in API cost
- Full month, four agents, ~12 tasks/night: $30–$40
- Hardware: mini-PC pulling ~15W, electricity rounds to noise
- Human time replaced: 5–7 hours/week of someone clicking through dashboards
For a small business, the monthly bill lands under one streaming subscription. The thing that used to be a part-time admin task is now a cron entry.
The cost stays low for a specific reason: each job is bounded. The prompt tells the agent exactly what tables to query, what rules to apply, when to stop. You don't let an agent "explore." You give it a job with edges. Open-ended agents burn tokens. Bounded agents finish in under 60 seconds and cost pennies.
Guardrails: because yes, it makes mistakes
People always ask this last, so I'll put it up front: yes, it makes mistakes. That is exactly why the fourth tmux session — the log monitor — exists.
The architecture is just four primitives:
- Prompt file — instructions a new hire could read
- Cron — when the job runs
- Tmux — keeps long sessions alive
- Telegram bot — where the agent reports in
Every agent posts a summary at the end of every run. The monitor agent reads the logs from the other three and screams on Telegram if:
- An agent didn't post a summary within its expected window
- The summary contains the word
errororexception - The retry count on any job exceeds a threshold
# monitor agent's check_health.py (simplified)
import subprocess, time, requests
EXPECTED = {
"invoicing": 60 * 60 * 6, # runs every 6h
"email": 60 * 30, # runs every 30m
"leadscore": 60 * 60, # runs every 1h
}
for agent, max_silence in EXPECTED.items():
last = int(subprocess.check_output(
["stat", "-c", "%Y", f"/var/log/claude/{agent}.log"]
))
if time.time() - last > max_silence:
requests.post(TELEGRAM_URL, json={
"chat_id": CHAT_ID,
"text": f"⚠️ {agent} silent for {(time.time()-last)//60:.0f}min"
})
That's the whole pattern. You build the guardrails once, and the system runs. Two invoices flagged for manual review last night instead of being silently dropped — that's the guardrail working, not failing.
Why most tutorials miss this entirely
Most Claude Code content shows it inside a fancy editor, fixing a bug, with a developer narrating. That demo sells the tool to developers. It does not sell the tool to the person who actually needs it: the operator drowning in repetitive admin.
If you're a solopreneur or you run a small team, you're not hiring Claude Code as a coder. You're hiring it as ops staff. It happens to be able to write code, sure, but the job you're giving it is closer to a junior operations assistant who never sleeps, never asks for a raise, and costs less than your phone bill.
The mental model to leave with:
- Claude Code is a worker, not an assistant
- Workers get jobs, jobs get schedules, schedules get logs, logs get monitored
- The whole stack is: terminal + prompt file + cron + tmux + Telegram
- The only real skill is writing the prompt file like instructions for a new hire's first day
Nothing fancy. Nothing that requires a cloud subscription. A small machine in the corner of your office can do this.
Why bizflowai.io helps with this
Most of what I deploy for clients at bizflowai.io is exactly this pattern — headless agents on small infrastructure, scheduled with cron, monitored over Telegram, scoped to one boring job each. Invoice retries, lead scoring, email triage, inbound form routing, overnight reconciliation. The setup is unglamorous on purpose: prompt files, log files, one bot channel for alerts. Clients don't care about the architecture, they care that 5–7 hours a week of dashboard-clicking disappeared and the monthly bill looks like a streaming subscription.
Frequently asked questions
What is Claude Code and how can it run without a human watching?
Claude Code is a terminal-native agent from Anthropic that reads files, runs shell commands, edits code, and calls APIs based on plain-English instructions. Because it runs as a Linux process, it can be scheduled with cron, kept alive in tmux sessions, and run in parallel in headless mode. That means it can execute tasks overnight on a small machine with no IDE, no screen, and no human present.
How do I run Claude Code as an automated worker for small business tasks?
Run Claude Code in headless mode on a Linux machine (even a small mini-PC with WSL Ubuntu works). Write a prompt file describing the task in plain English, including exact tables, rules, and escalation paths. Schedule it with cron, keep sessions alive using tmux, and have the agent post summaries to a channel like Telegram. Add a log-monitoring agent to alert you when something breaks.
How much does it cost to run Claude Code agents for small business automation?
Running four Claude Code agents across roughly a dozen scheduled tasks per night costs about thirty to forty dollars per month in API fees, according to one operator's setup. A single overnight job, such as retrying failed invoices, runs under two dollars. The hardware can be a small mini-PC that draws roughly as much power as a lamp, with no cloud subscription required.
Why should small business owners use Claude Code as ops staff instead of a coding assistant?
Most tutorials show Claude Code fixing bugs inside an IDE, which appeals to developers. But solopreneurs and small teams benefit more by treating it as a junior operations assistant that handles invoicing, email triage, lead scoring, and monitoring. Framed this way, Claude Code can replace five to seven hours per week of dashboard clicking for less than the cost of a phone bill.
When should I add a log monitor to my Claude Code automation setup?
Always add a log monitor when running unattended Claude Code agents, because the agents will make mistakes. A dedicated monitoring agent watches the other agents' outputs and pings you on a channel like Telegram if anything breaks. Combined with per-agent summary posts and flagging ambiguous cases for manual review, this catches errors before they cause damage in production workflows.
Want more like this?
I publish practical AI automation, GenAI engineering, and faceless content workflows on YouTube every week.
Subscribe to bizflowai.io on YouTube — never miss a new tutorial.
Planning an AI automation project or need a second opinion on your architecture?
Connect with me on LinkedIn — Lazar Milicevic, GenAI Engineer & bizflowai.io Founder.
Visit bizflowai.io for our services, case studies, and AI consulting.
Frequently asked questions
What is Claude Code and how can it run without a human watching?
Claude Code is a terminal-native agent from Anthropic that reads files, runs shell commands, edits code, and calls APIs based on plain-English instructions. Because it runs as a Linux process, it can be scheduled with cron, kept alive in tmux sessions, and run in parallel in headless mode. That means it can execute tasks overnight on a small machine with no IDE, no screen, and no human present.
How do I run Claude Code as an automated worker for small business tasks?
Run Claude Code in headless mode on a Linux machine (even a small mini-PC with WSL Ubuntu works). Write a prompt file describing the task in plain English, including exact tables, rules, and escalation paths. Schedule it with cron, keep sessions alive using tmux, and have the agent post summaries to a channel like Telegram. Add a log-monitoring agent to alert you when something breaks.
How much does it cost to run Claude Code agents for small business automation?
Running four Claude Code agents across roughly a dozen scheduled tasks per night costs about thirty to forty dollars per month in API fees, according to one operator's setup. A single overnight job, such as retrying failed invoices, runs under two dollars. The hardware can be a small mini-PC that draws roughly as much power as a lamp, with no cloud subscription required.
Why should small business owners use Claude Code as ops staff instead of a coding assistant?
Most tutorials show Claude Code fixing bugs inside an IDE, which appeals to developers. But solopreneurs and small teams benefit more by treating it as a junior operations assistant that handles invoicing, email triage, lead scoring, and monitoring. Framed this way, Claude Code can replace five to seven hours per week of dashboard clicking for less than the cost of a phone bill.
When should I add a log monitor to my Claude Code automation setup?
Always add a log monitor when running unattended Claude Code agents, because the agents will make mistakes. A dedicated monitoring agent watches the other agents' outputs and pings you on a channel like Telegram if anything breaks. Combined with per-agent summary posts and flagging ambiguous cases for manual review, this catches errors before they cause damage in production workflows.