惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
About on SuperTechFans
量子位
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 聂微东
V
Visual Studio Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 司徒正美
V
V2EX
The GitHub Blog
The GitHub Blog
博客园_首页
月光博客
月光博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MyScale Blog
MyScale Blog
博客园 - 叶小钗
F
Fortinet All Blogs
T
Tailwind CSS Blog
GbyAI
GbyAI
酷 壳 – CoolShell
酷 壳 – CoolShell
IT之家
IT之家
WordPress大学
WordPress大学
B
Blog
H
Help Net Security

Hacker News: Show HN

PurrrrrFocus: Pomodoro Timer App - App Store Workflow Engine — Multi-Step Orchestration for Bun RapidPhoto: Pro Photo Editor App - App Store GitHub - DheerG/swarms: Achieve extraordinary results with claude code across a variety of tasks SPICE simulation → oscilloscope → verification with Claude Code — Lucas Gerads Show HN: VCoding – A 5 MB native Windows IDE with no dynamic dependencies Show HN: LLMs don't hallucinate because they're bad at math, it's the format GitHub - Agent-FM/agentfm-core: AgentFM is a peer-to-peer network that turns everyday computers into a decentralized AI supercomputer. AgentFM lets you run massive AI workloads directly across a global mesh of idle CPUs and GPUs. Show HN: Tracking Top US Science Olympiad Alumni over Last 25 Years GitHub - Potarix/agent-hub: One place to talk to all your agents Show HN: Runtime security for AI agents(injection,tool abuse, data exfiltration) GitHub - dubeyKartikay/lazyspotify: Terminal Spotify client for macOS and Linux GitHub - the-banana-tool/king-louie: Easy to use GUI Personal AI Assistant. Win/Linux/Mac. Show HN I made my vacation rental bookable by AI agents–no Airbnb, 0% commission GitHub - basteez/jsf-autoreload: maven plugin to enable hot reload on jsf projects uvm32/hosts/host-gdbstub at main · ringtailsoftware/uvm32 GitHub - labsai/EDDI: Config-driven engine that turns JSON into production-grade AI agents. Multi-agent orchestration, 12+ LLM providers, MCP/A2A protocols, RAG, persistent memory, and enterprise compliance (EU AI Act, GDPR, HIPAA). Built on Quarkus. GitHub - glitchnsec/fortyone-oss: AI Executive Assistant Platform Quickstart | Alien GitHub - muxshed/shed: One stream in, or many. Every destination, simultaneously. No cloud middleman, no per-channel fees, no limits. GitHub - ocrbase-hq/ocrbase: 📄 PDF/IMG ->.MD/JSON Document OCR API for PaddleOCR and GLMOCR. Self-hostable. GitHub - impactjo/home-memory: MCP server that lets your AI assistant remember everything about your home. GitHub - Sets88/dbcls: DbCls is a powerful terminal database client that supports various databases GitHub - neptun2000/heor-agent-mcp GitHub - SeanFDZ/macmind: Single-layer transformer in HyperTalk for the classic Macintosh RollQuation: Math Puzzles - Apps on Google Play GitHub - dropbox/witchcraft Show HN: Agent-cache – Multi-tier LLM/tool/session caching for Valkey and Redis GitHub - opentalon/opentalon: OpenTalon is an open-source platform built from the ground up in Go as a robust alternative to OpenClaw LinkedIn™ 职位抓取工具 - Chrome 应用商店
GitHub - sbhattap/claude-pee: Use Claude Code programmati...
subarnab · 2026-05-14 · via Hacker News: Show HN

A drop-in front-end for the claude CLI that:

  • spawns claude in a PTY,
  • assigns a fresh --session-id <UUIDv4>,
  • forwards every other flag verbatim,
  • optionally injects a one-shot prompt via -p,
  • tails the matching session transcript jsonl, and
  • prints just the assistant's reply to stdout (text by default, or json/stream-json).

Termination is driven by claude's own Stop hook — no flaky screen-idle heuristics. When claude finishes a turn, the hook touches a sentinel file; claude-pee sees it, sends /exit, and exits with the child's status code.

Install

cargo build --release
cp target/release/claude-pee ~/.local/bin/      # or anywhere on PATH

Requires Rust 1.85+ (edition 2024).

Quick start

claude-pee -p "what is 2 + 2"
# → 4

Drop-in for claude

The simplest way to make claude go through claude-pee everywhere you already type it:

# ~/.zshrc / ~/.bashrc
alias claude='claude-pee'

This is safe because shell aliases are resolved only in interactive shells. When claude-pee internally does spawn("claude"), it goes through $PATH and finds the real binary — no recursion.

If you need the replacement visible to scripts too, put a claude shim earlier in $PATH and point CLAUDE_PEE_EXEC at the real claude:

ln -s "$(which claude-pee)" ~/bin/claude
export CLAUDE_PEE_EXEC=/usr/local/bin/claude   # absolute path to the real one

Flags

Owned by claude-pee (consumed, never forwarded):

Flag Purpose
-p PROMPT / -p=PROMPT One-shot prompt to inject. Triggers auto-/exit after claude responds.
--output-format text|json|stream-json What to print on stdout. Default text.

Everything else is passed through to claude after --session-id <UUID> --settings <hook-json>. So claude-pee --permission-mode plan -p hi becomes:

claude --session-id <UUID> --settings '<json>' --permission-mode plan

Output formats

Format What goes to stdout
text (default) The assistant's plain text reply. Thinking-only and tool-use-only turns are skipped.
json The assistant message transcript line, verbatim JSON (one per turn). Result lines too.
stream-json Every transcript line as it lands, verbatim.

Diagnostic logs go to stderr via log + env_logger. Default level info (silent). Set RUST_LOG=debug for the per-line tailer trace; RUST_LOG=trace also surfaces "tailing <path>" and "injecting /exit".

Environment variables

Variable Default Effect
CLAUDE_PEE_EXEC claude Binary to spawn. Empty value behaves like unset.
CLAUDE_PEE_QUIESCE_MS 500 Milliseconds the TUI must be idle before the prompt is injected. Heuristic — needed because the Stop hook can't fire before the first turn. Set higher if your machine is slow. Must be > 0.
CLAUDE_PEE_INJECT_CHAR_DELAY_MS 0 Per-character typing delay (simulates human typing or works around input rate-limiters).
RUST_LOG info Standard env_logger filter.

How termination works

  1. At startup claude-pee computes a sentinel path ${TMPDIR}/claude-pee-<UUID>.done and builds a --settings JSON containing:

    {
      "hooks": {
        "Stop": [
          { "hooks": [ { "type": "command", "command": "touch '<sentinel>'" } ] }
        ]
      }
    }

    That gets passed to claude --settings … so claude registers the hook for this session only — no permanent config changes.

  2. claude-pee waits for the PTY screen to go quiescent (so the TUI is ready to receive input), then types the prompt + \r.

  3. When claude finishes its turn, it runs the registered Stop hook, which touches the sentinel.

  4. claude-pee sees the sentinel appear, sends /exit\r\n, and waits for the child to exit.

  5. The sentinel is removed on exit via an RAII guard (even on error/panic paths).

Examples

# Text answer only
claude-pee -p "tell me a joke"

# Full assistant message as JSON (one line)
claude-pee -p "tell me a joke" --output-format json | jq

# Stream every transcript event live
claude-pee -p "do a long task" --output-format stream-json | jq -c .

# Override the executable (e.g. point at a build)
CLAUDE_PEE_EXEC=~/code/claude/dist/claude claude-pee -p hi

# Slow down injection (simulate typing)
CLAUDE_PEE_INJECT_CHAR_DELAY_MS=50 claude-pee -p hello

# Bigger pre-prompt grace window on a slow machine
CLAUDE_PEE_QUIESCE_MS=2000 claude-pee -p hi

# Diagnose what the tailer is doing
RUST_LOG=debug claude-pee -p hi

Caveats

  • Without -p it's a passthrough — no auto-/exit, so you'll need to exit claude yourself (interactive use). Useful if you just want the session-id assignment and the transcript path printed (set RUST_LOG=trace).
  • The pre-prompt quiescence wait is heuristic — the Stop hook can't help here because no turn has happened yet. If you see the prompt being typed before claude is ready, raise CLAUDE_PEE_QUIESCE_MS.
  • Depends on claude honouring --session-id, --settings, and /exit. Tested against current claude code; if the schema changes upstream, this could break.
  • Stdout is for the parsed output only. There is no "echo the raw PTY to my stdout" mode (it would interleave with the parsed output).

Source layout

src/main.rs        entry + run() orchestration
src/args.rs        CLI parsing
src/config.rs      Config: args + env → resolved runtime config
src/child.rs       PTY spawn, drain, vt100 screen hashing
src/hook.rs        Stop-hook sentinel + --settings JSON + RAII cleanup
src/inject.rs      auto-inject: TUI wait → prompt → sentinel → /exit
src/transcript.rs  jsonl discovery + tail + per-format output

Lints are strict (clippy::all/pedantic/nursery/cargo denied, unsafe_code forbidden, no unwrap/expect/panic outside tests). pre-commit runs cargo fmt, check, clippy, test, and doc on every commit.