paperclipai/paperclip · error

Could not parse Claude CLI usage output.

Error message

Could not parse Claude CLI usage output.

What it means

Error "Could not parse Claude CLI usage output." thrown in paperclipai/paperclip.

Solutions

  1. Upgrade the Claude CLI; the usage output format may have changed.
  2. Run `claude /usage` manually to check output.

When it happens

Trigger: Thrown at packages/adapters/claude-local/src/server/quota.ts:422 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@3f1d897a7c (2026-08-18). Data as JSON: /api/errors/28c99a3becae40f2. Report an issue: GitHub.

Appendix: source

Thrown at packages/adapters/claude-local/src/server/quota.ts:484

      continue;
    }
    if (current) current.lines.push(line);
  }
  if (current) sections.push(current);

  const windows = sections.map<QuotaWindow>((section) => {
    const usedPercent = section.lines.map(percentFromLine).find((value) => value != null) ?? null;
    return {
      label: section.label,
      usedPercent,
      resetsAt: null,
      valueLabel: null,
      detail: formatClaudeCliDetail(section.label, section.lines),
    };
  });

  if (!windows.some((window) => normalizeForLabelSearch(window.label) === "currentsession")) {
    throw new Error("Could not parse Claude CLI usage output.");
  }
  return windows;
}

function quoteForShell(value: string): string {
  return `'${value.replace(/'/g, `'\\''`)}'`;
}

function buildClaudeCliShellProbeCommand(): string {
  const feed = "(sleep 2; printf '/usage\\r'; sleep 6; printf '\\033'; sleep 1; printf '\\003')";
  const claudeCommand = "claude --tools \"\"";
  if (process.platform === "darwin") {
    return `${feed} | script -q /dev/null ${claudeCommand}`;
  }
  return `${feed} | script -q -e -f -c ${quoteForShell(claudeCommand)} /dev/null`;
}

export async function captureClaudeCliUsageText(timeoutMs = 12_000): Promise<string> {

View on GitHub (pinned to 3f1d897a7c)