Series
Claude Code in Your Own Web App
Build a web app that runs Claude Code in tmux, gives it work and brings every question, permission prompt and plan it has into your page: on your own machine, on your own subscription or a local model.
Sixteen parts, from typing into a terminal nobody watches to a small web app you can use from your phone. You build Sitesmith: you describe a website, Claude Code builds it in a folder, and the page shows the site as it grows. Claude Code runs as the real program, in tmux, with all its tools and your own settings, on your Claude subscription. The page starts it, types your requests into it, reads its screen where it has to, and listens to its hooks for everything else: what it does, when it is done, and what it wants to know. Its questions, permission prompts and plans come up as dialogs in the page, and whatever the page cannot answer goes back to the terminal, which is one click away. Later parts add several sites at once, notifications, files and pictures for Claude Code, a local model through Ollama, and a login for your phone. Every part ends with working code, and the finished project is a download.
Quest line
- Claude Code in a Terminal Nobody WatchesMeet Sitesmith, the web app this series builds around the real Claude Code, and try its foundation by hand: Claude Code running in a tmux session in the background, keys typed into it, and its screen read back.25 min
- A Server and a PageSet up the Sitesmith project: a small Node server that runs TypeScript directly, keeps every site in a folder and pushes changes to the page, a preview server on a port of its own, and a plain TypeScript page built with Vite.50 min
- A tmux Session for Every SiteGive every site a Claude Code session of its own: a tmux server configured to be driven, sessions started in the site's folder through your login shell, and a header that shows whether Claude Code runs, works or has exited.35 min
- The Terminal in the PageBring each site's tmux session into the page: node-pty attaches to it on the server, a WebSocket carries the bytes, and xterm.js draws them in a Terminal tab next to the preview.35 min
- Typing a RequestLet the page send requests: the text goes into a file in the site's folder, and Sitesmith types one short line into Claude Code, but only once the screen shows an empty input box.40 min
- Hooks Report BackGive every session a settings file with hooks: a small script posts each event to the server, which follows the tools Claude Code uses, reads what it says from its transcript, and learns the exact end of every turn.40 min
- The End of a TurnShow what Claude Code says when it is done, rendered from Markdown without letting the model's text bring its own HTML, reply to it from the page, and tell exactly when a turn is over, also when it ends without a Stop hook.25 min
- Claude Code's Questions in the PageThe core of Sitesmith: a PreToolUse hook holds Claude Code when it asks a question, the server hands the question to the page, and your answer goes back as the hook's output, so Claude Code goes on as if you had answered in the terminal.40 min
- Permission Prompts in the PageHold Claude Code's permission prompts with a PermissionRequest hook and answer them in the page: allow once, allow from now on, or deny. And know why the terminal shows its own dialog at the same time.25 min
- When the Page Can't AnswerNo page open, the tab closed, the server restarting, a dialog the page has never seen: every way a question can miss the page, and how each ends in the page or the terminal, never in a wait for nobody. Plus the trust dialog, read from the screen and answered with keys.35 min
- Approving a PlanA "Plan first" box for the request: Claude Code works in plan mode, the server switches the mode with Shift+Tab and reads it off the status line, and the plan comes up in the page to approve or to send back with a note.25 min
- Several Sites at OnceLet several sites work side by side: the server has kept everything per site from the start, so this part is about the page. The sidebar shows what each site's Claude Code is doing, and the tab's title counts the sites that wait for you.15 min
- Tell Me When It Needs MeA switch in the sidebar turns on browser notifications and a short chime: for a question in a site you are not looking at, and for the end of a run while the tab is in the background. Clicking a notification opens the site.20 min
- Files and Pictures for Claude CodeHand Claude Code a logo, photos or a PDF along with a request: chosen with a button or dropped anywhere on the page, streamed into the site's assets/ folder under a clean name and a size limit, and named in the request so Claude Code looks at them first.25 min
- A Local Model as the BrainLet a site's Claude Code think with a model on your own machine: Ollama answers Anthropic's API, a few environment variables point the session at it, and the rest of Sitesmith stays as it is. With an honest look at what a small model on a CPU can do.35 min
- Sitesmith on Your PhoneOpen Sitesmith from your phone on your home network: the server listens on the LAN, prints a login link with a QR code, and keeps everyone else out with a token, a cookie and the Host and Origin checks. Then a look back at the whole series.35 min