chenhg5/cc-connect · error
claudecode: write Claude Code /usage probe input: %w
Error message
claudecode: write Claude Code /usage probe input: %w
What it means
Raised by the /usage probe when writing a keystroke to the Claude Code process's stdin fails (e.g. sending the '/usage' command or a key action from the probe state machine). It fires when the process has already exited and its stdin pipe is closed.
Source
Thrown at agent/claudecode/claude_usage.go:195
screen := normalizeClaudeUsageText(terminal.String())
if screen != lastScreen {
lastScreen = screen
lastChange = time.Now()
}
if usageReady(lastScreen) {
if usageScreen == "" {
usageScreen = lastScreen
}
}
if screenErr := detectClaudeUsageOutputError(lastScreen, stderr.String()); screenErr != nil {
return "", screenErr
}
if usageScreen != "" && time.Since(lastChange) >= claudeUsageStableFor {
return usageScreen, nil
}
if action := nextClaudeUsageProbeAction(lastScreen, &state, time.Now()); action != "" {
if _, err := io.WriteString(ptmx, action); err != nil {
return "", fmt.Errorf("claudecode: write Claude Code /usage probe input: %w", err)
}
}
}
}
}
func (a *Agent) usageProbeEnv() []string {
a.mu.Lock()
defer a.mu.Unlock()
return a.runtimeEnvLocked()
}
func nextClaudeUsageProbeAction(screen string, state *claudeUsageProbeState, now time.Time) string {
if now.Sub(state.lastActionAt) < claudeUsageActionGap {
return ""
}
if action := promptActionForScreen(screen); action != "" && state.promptResponses < 6 {View on GitHub (pinned to 4000b2338a)
Solutions
- Retry the /usage request
- Check why Claude Code terminated early (see preceding log lines)
- Upgrade Claude Code if it crashes on startup
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at agent/claudecode/claude_usage.go:195 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/a9ae04e1ba0b7aa0.
Report an issue: GitHub.