OpenClaw를 Claude Code로 대체하는 방법
how i replaced my openclaw with claude code
핵심 요약
systemd와 tmux를 활용해 Claude Code를 24시간 무중단으로 구동하고 텔레그램으로 제어하는 설정법을 공유함.
- 무중단 구동 — systemd와 tmux를 조합해 Claude Code가 죽지 않고 계속 실행되도록 설정함.
- 텔레그램 연동 — 공식 MCP 플러그인을 활용해 외부에서 폰으로 Claude와 대화할 수 있게 함.
- 자동화 훅 — 데드락 방지 및 사용자 개입 없이 도구 호출을 처리하는 3가지 훅을 구현함.
- 보안 경계 — 에이전트가 도구를 자동으로 실행하므로 반드시 격리된 VM 환경에서 구동해야 함.
it's a systemd unit. here's how.
keep claude alive: systemd + tmux
# /etc/systemd/system/claude.service
[Unit]
After=network.target
[Service]
Type=forking
User=you
WorkingDirectory=/home/you/project
ExecStart=/usr/bin/tmux new-session -d -s claude -c /home/you/project \
"bash -lc 'while true; do /home/you/.local/bin/claude --dangerously-skip-permissions --channels plugin:telegram@claude-plugins-official; sleep 2; done'"
ExecStop=/usr/bin/tmux kill-session -t claude
Restart=on-failure
RestartSec=3
[Install]
WantedBy=multi-user.target
four non-obvious bits:
- the inner
while true; do claude…; sleep 2; donerestarts claude when it crashes, notRestart=. systemd only sees the tmux session; a crash inside the pane is invisible to it. Type=forking, notsimple. tmux daemonizes its server, so the launching command exits immediately.--dangerously-skip-permissions: nobody at the keyboard to approve tool calls, so claude greenlights its own. use an isolated VM.--channels plugin:telegram@claude-plugins-officialwires claude to telegram. install anthropic's official telegram plugin (the MCP) and pair your bot first.
systemctl enable --now claude, then talk to it from your phone. tmux attach -t claude drops you into the live session; ctrl-b d detaches without killing it.
make it survive unattended: 3 hooks
anthropic's official telegram plugin has three known deadlocks. add a hook to fix each:
- pickers no one can see:
AskUserQuestion/ExitPlanModerender in the local tmux pane only. PreToolUse hook denies them, instructs claude to ask in chat instead. - the reply-tool slip: claude sometimes writes the answer to the transcript instead of sending it. Stop hook catches loose text, curls it to your chat, blocks the stop if there's nothing to send.

