{"record":{"id":"6cf7e7ca2b265080","repo":"chenhg5/cc-connect","slug":"claudecode-read-claude-code-usage-output-w","errorCode":null,"errorMessage":"claudecode: read Claude Code /usage output: %w","messagePattern":"claudecode: read Claude Code /usage output: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/claudecode/claude_usage.go","lineNumber":163,"sourceCode":"\t\tstate       claudeUsageProbeState\n\t\tlastScreen  string\n\t\tlastChange  = time.Now()\n\t\tusageScreen string\n\t)\n\n\tfor {\n\t\tselect {\n\t\tcase <-probeCtx.Done():\n\t\t\tif usageScreen != \"\" {\n\t\t\t\treturn usageScreen, nil\n\t\t\t}\n\t\t\tif screenErr := detectClaudeUsageOutputError(lastScreen, stderr.String()); screenErr != nil {\n\t\t\t\treturn \"\", screenErr\n\t\t\t}\n\t\t\treturn \"\", fmt.Errorf(\"claudecode: timed out waiting for Claude Code /usage panel: %w\", probeCtx.Err())\n\t\tcase err := <-readDone:\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", fmt.Errorf(\"claudecode: read Claude Code /usage output: %w\", err)\n\t\t\t}\n\t\tcase <-processDone:\n\t\t\tif usageScreen != \"\" {\n\t\t\t\treturn usageScreen, nil\n\t\t\t}\n\t\t\tif screenErr := detectClaudeUsageOutputError(lastScreen, stderr.String()); screenErr != nil {\n\t\t\t\treturn \"\", screenErr\n\t\t\t}\n\t\t\tif waitErr != nil {\n\t\t\t\treturn \"\", fmt.Errorf(\"claudecode: Claude Code exited before /usage rendered: %w\", waitErr)\n\t\t\t}\n\t\t\treturn \"\", fmt.Errorf(\"claudecode: Claude Code exited before /usage rendered\")\n\t\tcase <-ticker.C:\n\t\t\tscreen := normalizeClaudeUsageText(terminal.String())\n\t\t\tif screen != lastScreen {\n\t\t\t\tlastScreen = screen\n\t\t\t\tlastChange = time.Now()\n\t\t\t}","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/claudecode/claude_usage.go#L145-L181","documentation":"Raised by the /usage probe when reading the Claude Code process's merged output stream fails. It fires when the pty/pipe backing the probe breaks — usually because the underlying process died or the descriptor was closed unexpectedly.","triggerScenarios":"Thrown at agent/claudecode/claude_usage.go:163 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry /usage after confirming the claude binary runs normally","Check for claude processes crashing on startup (auth, network)","Look at accompanying stderr in logs for the process's own error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}