{"record":{"id":"0fb98077782cb2af","repo":"abhigyanpatwari/GitNexus","slug":"claude-cli-returned-empty-output","errorCode":null,"errorMessage":"claude CLI returned empty output","messagePattern":"claude CLI returned empty output","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/wiki/local-cli-client.ts","lineNumber":114,"sourceCode":"  prompt: string,\n  config: LocalCLIConfig,\n  systemPrompt?: string,\n  options?: CallLLMOptions,\n): Promise<LLMResponse> {\n  const commandInfo = getDetectedCommand('claude');\n  if (!commandInfo) {\n    throw new Error('Claude CLI not found. Install Claude Code and ensure `claude` is on PATH.');\n  }\n\n  const args = ['-p', '--output-format', 'text', '--no-session-persistence'];\n  if (config.model) {\n    args.push('--model', config.model);\n  }\n  const fullPrompt = systemPrompt ? `${systemPrompt}\\n\\n---\\n\\n${prompt}` : prompt;\n\n  const response = await runLocalCLI('claude', commandInfo, args, config, fullPrompt, options);\n  if (!response.content) {\n    throw new Error('claude CLI returned empty output');\n  }\n  return response;\n}\n\nexport async function callCodexLLM(\n  prompt: string,\n  config: LocalCLIConfig,\n  systemPrompt?: string,\n  options?: CallLLMOptions,\n): Promise<LLMResponse> {\n  const commandInfo = getDetectedCommand('codex');\n  if (!commandInfo) {\n    throw new Error('Codex CLI not found. Install Codex CLI and ensure `codex` is on PATH.');\n  }\n\n  const outputDir = await fs.mkdtemp(path.join(os.tmpdir(), 'gitnexus-wiki-codex-'));\n  const outputPath = path.join(outputDir, 'last-message.txt');\n  const workingDirectory = config.workingDirectory || process.cwd();","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/wiki/local-cli-client.ts#L96-L132","documentation":"The claude CLI was found and executed (`claude -p --output-format text --no-session-persistence`) and returned without error, but the captured stdout content was empty. The subprocess succeeded at the transport level, yet produced no answer text for the prompt (system prompt prepended, separated by '---').","triggerScenarios":"The model refuses or returns an empty turn (safety refusal with empty text output, empty response bug); session/auth state causing the CLI to print nothing; prompt too large or truncated by CLI limits; stdout swallowed when --output-format/flags change in a Claude Code update.","commonSituations":"Unauthenticated Claude Code printing an empty/interactive message in print mode; version upgrades changing default output behavior; refusal cases on security-heavy repo content; very large module prompts hitting CLI input limits.","solutions":["Verify the CLI works manually: `claude -p 'say hi' --output-format text` — if empty, fix auth/install first","Re-run `claude` interactively to complete login/consent, then retry wiki generation","Update Claude Code if a version regression changed -p output behavior","Retry with `-v/--verbose` to see the raw command and response; if it recurs on one module, split/shrink that prompt"],"exampleFix":"# before\ngitnexus wiki --provider claude   # empty output\n\n# after\nclaude -p 'say hi'   # verify non-empty\ngitnexus wiki --provider claude -v","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await callClaudeLLM(prompt, config);\n} catch (err) {\n  if (err instanceof Error && err.message === 'claude CLI returned empty output') {\n    return callClaudeLLM(prompt, config); // one retry — transient empty turns happen\n  }\n  throw err;\n}","preventionTips":["Verify `claude -p 'ping' --output-format text` returns text before starting a wiki run","Keep Claude Code updated; pin a version in CI to avoid output-format regressions","Retry empty-output calls once before failing the whole wiki run"],"tags":["llm","claude-code","empty-response","gitnexus"],"backgroundTag":"empty-cli-output","analyzedSha":"aac7515d2a8c50a1f8f923c6fb77218b333560d6","analyzedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}