克劳德 Chill:修复克劳德代码在终端中的闪烁问题
Claude Chill: Fix Claude Code's flickering in terminal

原始链接: https://github.com/davidbeesley/claude-chill

## Claude-Chill:驯服 Claude Code 的终端输出 Claude-Chill 是一个 PTY 代理,旨在改善与 Claude Code 的用户体验。Claude Code 经常发送大量、全屏的终端更新,即使只有微小的变化。这会导致延迟、闪烁和无法使用的滚动回溯。 Claude-Chill 拦截这些更新,利用 VT100 模拟器跟踪屏幕状态并仅渲染差异。它在缓冲区中保留输出历史记录,允许用户暂停 Claude(使用可配置的按键,默认 Ctrl+6)并通过终端滚动回溯查看完整历史记录。 主要功能包括可配置的历史记录大小、回溯按键以及在一段时间不活动后转储历史记录的自动回溯功能。可以通过命令行参数或 `claude-chill.toml` 文件进行配置。 本质上,Claude-Chill 通过优化终端渲染并启用有效历史记录查看,使与 Claude Code 输出的交互更加流畅和实用。目前在 Linux 和 macOS 上进行了测试,并以“按原样”提供供个人使用。

## Claude Code 闪烁问题修复与讨论总结 最近的 Hacker News 论坛讨论了 Claude Code 终端渲染中长期存在的闪烁问题。Claude Code 的创建者 Anthropic 发布了一个差异渲染器,旨在减少闪烁,目前影响大约 1/3 的会话——这是一项显著的改进。他们还为 VSCode 和 tmux 贡献了同步输出的补丁,可以完全消除闪烁,并推荐使用 Ghostty 以获得无闪烁的体验。 讨论强调了用户对 Anthropic 关于该问题的沟通感到沮丧,尽管提交了频繁的错误报告,但用户感觉被蒙在鼓里。 事实证明,问题源于渲染系统的复杂性,该系统使用 React,需要优化来管理垃圾回收和屏幕缓冲区更新。 一些人认为选择 React 是核心问题。 用户正在分享解决方法,并对 Claude Code 的性能和资源使用情况表示担忧,与 Codex(用 Rust 编写)等替代方案相比。 虽然承认团队的努力,但许多人认为 Anthropic 应该优先修复这个核心问题,因为它是一个商业产品,并且拥有大量资金。
相关文章

原文

CI License: MIT Linux macOS Windows Rust

A PTY proxy that tames Claude Code's massive terminal updates using VT-based rendering.

Claude Code uses synchronized output to update the terminal atomically. It wraps output in sync markers (\x1b[?2026h ... \x1b[?2026l) so the terminal renders everything at once without flicker.

The problem: Claude Code sends entire screen redraws in these sync blocks - often thousands of lines. Your terminal receives a 5000-line atomic update when only 20 lines are visible. This causes lag, flicker, and makes scrollback useless since each update clears history.

claude-chill sits between your terminal and Claude Code:

  1. Intercepts sync blocks - Catches those massive atomic updates
  2. VT-based rendering - Uses a VT100 emulator to track screen state and renders only the differences
  3. Preserves history - Accumulates content in a buffer for lookback
  4. Enables lookback - Press a key to pause Claude and view the full history buffer
cargo install --path crates/claude-chill
claude-chill claude
claude-chill -- claude --verbose   # Use -- for command flags
$ claude-chill --help
A PTY proxy that tames Claude Code's massive terminal updates

Usage: claude-chill [OPTIONS] <COMMAND> [ARGS]...

Arguments:
  <COMMAND>  Command to run (e.g., "claude")
  [ARGS]...  Arguments to pass to the command

Options:
  -H, --history <HISTORY_LINES>
          Max lines stored for lookback (default: 100000)
  -k, --lookback-key <LOOKBACK_KEY>
          Key to toggle lookback mode, quote to prevent glob expansion (default: "[ctrl][6]")
  -a, --auto-lookback-timeout <AUTO_LOOKBACK_TIMEOUT>
          Auto-lookback timeout in ms, 0 to disable (default: 5000)
  -h, --help
          Print help
  -V, --version
          Print version
# Basic usage
claude-chill claude

# Pass arguments to claude
claude-chill -- claude --verbose

# Custom history size
claude-chill -H 50000 claude

# Custom lookback key
claude-chill -k "[f12]" claude

# Disable auto-lookback (see below)
claude-chill -a 0 claude

# Combine options with claude arguments
claude-chill -H 50000 -a 0 -- claude --verbose

Press Ctrl+6 (or your configured key) to enter lookback mode:

  1. Claude pauses - Output from Claude is cached, input is blocked
  2. History dumps - The full history buffer is written to your terminal
  3. Scroll freely - Use your terminal's scrollback to review everything
  4. Exit - Press the lookback key again or Ctrl+C to resume

When you exit lookback mode, any cached output is processed and the current state is displayed.

After 5 seconds of idle (no new renders), the full history is automatically dumped to your terminal so you can scroll back without pressing any keys. This is useful for reviewing Claude's output after it finishes working.

Note: The auto-lookback causes a brief screen flicker during the transition as it clears the screen and writes the history buffer. Disable with -a 0 or adjust the timeout with -a 10000 (10 seconds).

Create ~/.config/claude-chill.toml:

history_lines = 100000          # Max lines stored for lookback
lookback_key = "[ctrl][6]"      # Key to toggle lookback mode
refresh_rate = 20               # Rendering FPS
auto_lookback_timeout_ms = 5000 # Auto-lookback after 5s idle (0 to disable)

Note: History is cleared on full screen redraws, so lookback shows output since Claude's last full render.

[modifier][key] - Examples: [f12], [ctrl][g], [ctrl][shift][j]

Modifiers: [ctrl], [shift], [alt]

Keys: [a]-[z], [f1]-[f12], [pageup], [pagedown], [home], [end], [enter], [tab], [space], [esc]

Note: Quote the key value on the command line to prevent shell glob expansion: -k "[ctrl][7]"

Ctrl+6 sends 0x1E, a control character not frequently used by terminals, signals, or shells. Avoid Ctrl+letter hotkeys - terminals can't distinguish Ctrl+J from Ctrl+Shift+J.

claude-chill creates a pseudo-terminal (PTY) and spawns Claude Code as a child process. It then acts as a transparent proxy between your terminal and Claude:

┌──────────────┐     ┌──────────────┐     ┌──────────────┐
│   Terminal   │◄───►│ claude-chill │◄───►│  Claude Code │
│   (stdin/    │     │   (proxy)    │     │   (child)    │
│    stdout)   │     │              │     │              │
└──────────────┘     └──────────────┘     └──────────────┘
  1. Input handling: Keystrokes pass through to Claude, except for the lookback key which toggles lookback mode
  2. Output processing: Scans output for sync block markers. Non-sync output passes through directly
  3. VT emulation: Feeds output through a VT100 emulator to track the virtual screen state
  4. Differential rendering: Compares current screen to previous and emits only the changes
  5. History tracking: Maintains a buffer of output for lookback mode since the last full redraw
  6. Signal forwarding: Window resize (SIGWINCH), interrupt (SIGINT), and terminate (SIGTERM) signals are forwarded to Claude

This tool was developed for personal convenience. It works for me on Linux and macOS, but it hasn't been extensively tested across different terminals or edge cases. Don't use it to send anyone to space, perform surgery, or run critical infrastructure. If it breaks, you get to keep both pieces.

See CONTRIBUTING.md.

MIT

联系我们 contact @ memedata.com