chenhg5/cc-connect · error

claudecode: missing %s block in Claude Code /usage output

Error message

claudecode: missing %s block in Claude Code /usage output

What it means

A parse guard in parseClaudeUsageWindow: the expected section header (e.g. 'Usage' or a window header) was not found anywhere in the captured /usage lines. It fires when Claude Code's /usage output format changed or the wrong screen region was captured, so the window block cannot be located.

Source

Thrown at agent/claudecode/claude_usage.go:344

		Name:    "Usage",
		Allowed: true,
		Windows: []core.UsageWindow{session, week},
	}}
	return report, nil
}

func parseClaudeUsageWindow(lines []string, header string, windowSeconds int, now time.Time) (core.UsageWindow, error) {
	start := -1
	headerLower := strings.ToLower(header)
	for i, line := range lines {
		lower := strings.ToLower(strings.TrimSpace(line))
		if strings.HasPrefix(lower, headerLower) {
			start = i
			break
		}
	}
	if start < 0 {
		return core.UsageWindow{}, fmt.Errorf("claudecode: missing %s block in Claude Code /usage output", header)
	}

	var (
		usedPercent *int
		resetRaw    string
	)
	for i := start + 1; i < len(lines); i++ {
		line := strings.TrimSpace(lines[i])
		if line == "" {
			continue
		}
		lower := strings.ToLower(line)
		if i > start+1 && (strings.HasPrefix(lower, "current ") || strings.HasPrefix(lower, "extra usage")) {
			break
		}
		if usedPercent == nil {
			if m := claudeUsagePercentRe.FindStringSubmatch(line); len(m) == 2 {
				v, _ := strconv.Atoi(m[1])

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Upgrade Claude Code to a version whose /usage output cc-connect knows
  2. Report the format change so the parser can be extended
  3. Capture and inspect the raw /usage screen to confirm what was rendered
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at agent/claudecode/claude_usage.go:344 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/b895960dd4497898. Report an issue: GitHub.