QuestionQ130

Prompt Engineering & Structured Output

You are incorporating Claude Code into your Continuous Integration/Continuous Deployment (CI/CD) pipeline. The system performs automated code reviews, creates test cases, and gives feedback on pull requests. You must design prompts that deliver actionable feedback while minimizing false positives.

Your automated review invokes the Claude API for each PR, using tool_use with a report_findings tool that returns a JSON array of finding objects (each containing file_path, line_number, severity, category, and description). During testing of a large PR that changes 30+ files, the response reaches the max_tokens limit and is truncated in the middle of the JSON, causing the pipeline parser to fail.

What is the most effective way to address this?

Explanation

Partitioning a large pull request into smaller file subsets bounds each structured report_findings response, avoiding incomplete JSON while retaining findings across the entire PR. The resulting arrays can be merged after each valid tool response. A max_tokens stop can truncate an incomplete tool-use block, so a single oversized structured response is not a reliable design.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!