DEV Community

CodeKing
CodeKing

Posted on

"I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home"

Last Tuesday I was on the train home when a Slack message came in: "prod build is broken, can you look?"

I didn't have my laptop open. I didn't want to SSH from my phone. But I had something else — a Telegram bot connected to my localhost machine at home.

I typed: "launch claude code in ~/projects/api-server, fix the failing build"

By the time I walked through my front door, the fix was committed.

That's not how localhost is supposed to work. But here we are.

The Idea That Sounded Crazy

For months, CliGate was "just" a proxy — it sat between your AI coding tools and their APIs, handling routing, account pooling, and key management.

But every time I used the built-in chat to test credentials, the same thought kept nagging me:

Why am I testing models in this chat window, then switching to a terminal to actually use Claude Code or Codex?

What if the chat window could just... launch them?

And then the scarier thought:

What if I didn't even need to be at my computer?

What Changed: Two New Layers

Layer 1: Agent Runtime — Your Chat Window Becomes a Control Room

CliGate's chat can now spawn Claude Code or Codex as real background processes.

Not simulated. Not a wrapper around an API call. The actual CLI tools, running headless, streaming structured events back into your browser.

Here's how it works under the hood:

For Codex:

codex exec --experimental-json --model gpt-5 "fix the failing test"
Enter fullscreen mode Exit fullscreen mode

CliGate spawns this as a child process, reads the JSONL event stream, and maps every event — agent_message, command_execution, file_change, todo_list, reasoning — into the chat UI in real time.

For Claude Code:

claude --print --output-format stream-json --input-format stream-json
Enter fullscreen mode Exit fullscreen mode

Same idea. Claude Code's headless mode exposes a structured stdin/stdout protocol. CliGate reads it, bridges it, and surfaces everything in the chat.

What You Actually See

When you tell CliGate's chat "use codex to refactor the auth module":

  1. A session starts — you see session abc123 started with codex
  2. Codex thinks — reasoning events stream in
  3. Codex runs commands — you see the actual shell commands and their output
  4. Codex changes files — you see diffs
  5. Codex finishes — you get a summary

The killer feature: permission bridging.

When Claude Code asks "Can I edit server.js?" — that question doesn't disappear into a terminal you're not watching. It pops up in the chat. You click Approve or Deny. Claude Code continues.

Session status flow:

starting → running → waiting_approval → running → completed
                          ↑
                    You approve here
Enter fullscreen mode Exit fullscreen mode

This means you don't need a terminal window open at all. The chat window IS your terminal now — but one that actually understands what the agent is doing.

Layer 2: Channel Gateway — Your Phone Becomes the Remote Control

This is where it gets wild.

CliGate now has a Channel Gateway that connects external messaging platforms to the Agent Runtime. Currently supported:

  • Telegram (polling mode)
  • Feishu / Lark (webhook mode)

The architecture:

Your Phone (Telegram / Feishu)
        ↓
  Channel Gateway
        ↓
  Agent Runtime (Orchestrator)
        ↓
  Codex / Claude Code (child process)
        ↓
  CliGate Proxy Core
        ↓
  Upstream AI Models
Enter fullscreen mode Exit fullscreen mode

You text your Telegram bot. The Channel Gateway receives the message, routes it to the orchestrator, which decides whether to start a new Codex/Claude Code session or continue an existing one. Results stream back to your phone.

Pairing for security:

You don't want random people controlling your localhost. So there's a pairing flow — the first time you message the bot, it gives you a code. Enter that code in the CliGate dashboard. Now your Telegram account is paired and authorized.

Approval buttons:

When Claude Code needs permission, you get an inline button in Telegram:

🔒 Claude Code wants to edit server.js

[Approve]  [Deny]
Enter fullscreen mode Exit fullscreen mode

Tap Approve. Done. Claude Code continues — on your desktop machine — while you're standing in line at a coffee shop.

Real Talk: What This Actually Solves

Problem 1: Long-running tasks

You tell Claude Code to analyze a large codebase. It takes 20 minutes. Without this feature, you're staring at a terminal for 20 minutes. With it, you get a notification on your phone when it's done.

Problem 2: Permission fatigue

Claude Code asks for permission constantly. If you're not watching the terminal, it just... sits there. Now permission requests reach you wherever you are — browser, Telegram, Feishu.

Problem 3: Context switching

You're in a meeting. A build breaks. You text your bot: "launch codex in ~/projects/backend, fix the test in auth.test.js". You go back to your meeting. Codex handles it.

What I Didn't Build (On Purpose)

This is NOT a full web clone of Claude Code's TUI. It's NOT a complete Codex terminal emulator.

CliGate doesn't try to replicate every feature of these tools. It does exactly four things:

  1. Start a session
  2. Monitor progress in real time
  3. Bridge permission requests and questions
  4. Resume or continue a conversation

The actual coding work is still done by Codex and Claude Code. CliGate is the orchestration layer — the thing that lets you interact with them without sitting in front of a terminal.

The Setup

If you already have CliGate running:

Agent Runtime works out of the box — just use the chat window and mention codex or claude code in your message.

For Telegram:

  1. Create a bot via @botfather
  2. Add your bot token in CliGate's Channel settings
  3. Message your bot — it'll ask you to pair
  4. Enter the pairing code in the dashboard
  5. Start sending tasks

For Feishu:

  1. Create a custom app in Feishu's developer console
  2. Add App ID, App Secret, and Verification Token in Channel settings
  3. Set the webhook URL to your CliGate instance
  4. Same pairing flow

The Honest "Is This Production Ready?" Answer

No. It's early.

The Agent Runtime is solid for single-session workflows. The Channel Gateway handles Telegram well. Feishu needs more testing.

What's missing:

  • Multi-turn conversations across long time windows need more state management
  • File attachments from channels aren't supported yet
  • Error recovery from crashed sessions could be more graceful

But for the "text your computer to fix a bug" workflow? It works. I use it daily.

What's Your Remote Development Setup?

I'm curious about how others handle this problem:

  • Do you SSH from your phone?
  • Do you use VS Code's remote features?
  • Have you tried controlling AI coding agents remotely?

The idea of "your desktop is a server, your phone is the client" feels like it's going to be a bigger pattern. I'd love to hear how others approach it.


GitHub: github.com/codeking-ai/cligate

CliGate is open-source under AGPL-3.0. Not affiliated with Anthropic, OpenAI, or Google.

Top comments (1)

Collapse
 
codekingai profile image
CodeKing

This is still early but I'm using it daily. How do you handle remote access to your dev
machine? Would love to hear other approaches.