构建TUI现在很简单。
Building a TUI is easy now

原始链接: https://hatchet.run/blog/tuis-are-easy-now

## 使用 Claude Code 构建 TUI:令人惊讶的流畅体验 受启发于终端代码代理被快速采用的预期,作者决定为 Hatchet(一个任务和工作流编排工具)构建一个文本用户界面 (TUI)。 之前对代理驱动的开发持怀疑态度,经历了一次前端重构失败后,他发现使用 Claude Code 构建 TUI 效率惊人——仅用两天就完成了。 成功的关键是利用 “Charm” 栈(Bubble Tea、Lip Gloss 和 Huh)进行 TUI 开发,以及 Hatchet 现有前端的参考实现和定义良好的 OpenAPI 规范。 重要的是,Claude Code 在 *测试* TUI 方面表现出色,驱动基于终端的应用程序并快速识别问题。 现有的 ASCII 图形渲染器也被用于可视化工作流。 由此产生的 TUI 在用户中出乎意料地受欢迎,因其性能和易用性而受到赞扬,与 Web UI 相比更胜一筹。 作者强调了 TUI 的优势——文本优先的设计、信息密度以及与开发者工作流程的无缝集成——并鼓励其他人探索 TUI 开发,特别是借助 Claude Code 等工具。 [在线演示链接](原文链接)

构建TUI现在很容易了 (hatchet.run) 11点 由 abelanger 1小时前 | 隐藏 | 过去 | 收藏 | 2条评论 emilfihlman 10分钟前 [–] TUI的问题在于,使用移动设备的虚拟键盘,让它们在浏览器中表现正常似乎是不可能的!我认为唯一合理的选择似乎是自己重新实现一个,这简直是太愚蠢了。回复 NetOpWibby 2分钟前 | 父评论 [–] 移动设备不适合TUI 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请YC | 联系 搜索:
相关文章

原文

When I first booted up Claude Code in May 2025, I thought: huh, this is cute. A terminal-based coding agent...they must be pandering to developers.

Within the first 30 minutes, I was convinced: this was going to be huge. So huge that we at Hatchet discussed whether we should build a new product line around terminal-based coding agents.

Ultimately, we decided against it, but that first experience with Claude Code stuck with me. It seems so simple and obvious in hindsight that a terminal-based agent would have a incredibly fast adoption curve among developers.

Perhaps you have a similar feeling that the tool you're working on should have a TUI. Perhaps you've always wanted to build a TUI yourself. Or perhaps you just like saying too-ee.

I say: go for it. It's much easier than I was expecting, using a few neat tricks with Claude Code. This is coming from a skeptic. We had previously attempted an aggressive, agent-first refactor of our frontend which was built in a week, bug-bashed for five, then abandoned.

In comparison, this TUI was mostly driven by Claude Code, but was built and shipped in a few days. You can check it out a live demo here:

For all you budding TUI developers, I wanted to write out some of the decisions that made this significantly easier than similar projects of mine: a “happy path” to building a successful TUI application.

Why build a TUI?

I've always wanted a TUI for Hatchet. Something like k9s, but for tasks and workflow runs. I wasn't sure anyone else would find it useful, and we didn't even really announce it to our community, but within a few days we got some very positive, unsolicited feedback from our users. For example:

Guys great work on the Hatchet CLI (especially the TUI!) It feels so [much more] performant than the UI.

I love this comment, because it gets at the heart of why I love TUIs - they just feel easier to use, even though it uses the exact same API as the UI. They're also the opposite of how web applications have been trending the past few years: TUIs are text-first, information-dense, and most importantly, they live inline to your code, preventing constant tab switching. And since our users are primarily developing Hatchet tasks and durable workflows in their IDE, we wanted to provide an experience where workflows could be visualized and run from a terminal, instead of constantly switching between your code and your browser.

The stack

Let's get into the details. Every frontend application starts with a stack: A typical one these days might be React, react-query, Tailwind, ShadCN, and some additional Tanstack libraries.

There's an equivalent of these libraries for TUI development — and they're all maintained by the same company! I'm referring to the Charm stack: if you're unfamiliar, the team at Charm has been building out a set of TUI libraries which are incredibly delightful to use. I primarily used Bubble Tea, Lip Gloss, and Huh. Don't let the cutesy nature of these libraries fool you — they're incredibly well-documented and have tons of examples.

And while I found it slightly more difficult to build anything custom outside of Bubble Tea and Bubbles, it's certainly easier than building a React-based rendering engine like the one that Claude Code uses internally.

One of my favorite bits was the ease at which I could apply a style to any TUI element in a way that felt cohesive using Lip Gloss and Huh themes. I then reused this style throughout the Hatchet CLI, instead of just with the TUI. For example, most commands in the Hatchet CLI are interactive by default, with forms that use the Lip Gloss theme:

联系我们 contact @ memedata.com