From dbad4cf822101833dae710f2b415d53aabb107ea Mon Sep 17 00:00:00 2001 From: pacnpal <183241239+pacnpal@users.noreply.github.com> Date: Tue, 10 Dec 2024 15:27:35 -0500 Subject: [PATCH] Update claude-review.yml --- .github/workflows/claude-review.yml | 53 +++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/.github/workflows/claude-review.yml b/.github/workflows/claude-review.yml index 4011177..010f474 100644 --- a/.github/workflows/claude-review.yml +++ b/.github/workflows/claude-review.yml @@ -91,22 +91,44 @@ jobs: echo "Found $DIFF_SIZE bytes of relevant changes" echo "diff_size=$DIFF_SIZE" >> $GITHUB_OUTPUT - # Prepare the diff content for the API request - DIFF_CONTENT=$(cat diff_filtered.txt) + # Prepare prompt and diff content + PROMPT="You are performing a code review. Please analyze this code diff and provide a thorough review that covers: + + 1. Potential conflicts with existing codebase + 2. Code correctness and potential bugs + 3. Security vulnerabilities or risks + 4. Performance implications + 5. Maintainability and readability issues + 6. Adherence to best practices and coding standards + 7. Suggestions for improvements + + For each issue found: + - Explain the problem clearly + - Rate the severity (Critical/High/Medium/Low) + - Provide specific recommendations for fixes + - Include code examples where helpful + + If no issues are found in a particular area, explicitly state that. + + Here is the code diff to review: + + \`\`\` + $(cat diff_filtered.txt) + \`\`\`" - # Create the API request using a heredoc - REQUEST=$(cat << EOF - { - "model": "claude-3-sonnet-20240229", - "max_tokens": 4096, - "temperature": 0.7, - "messages": [{ - "role": "user", - "content": "You are performing a code review. Please analyze this code diff and provide a thorough review that covers:\n\n1. Potential conflicts with existing codebase\n2. Code correctness and potential bugs\n3. Security vulnerabilities or risks\n4. Performance implications\n5. Maintainability and readability issues\n6. Adherence to best practices and coding standards\n7. Suggestions for improvements\n\nFor each issue found:\n- Explain the problem clearly\n- Rate the severity (Critical/High/Medium/Low)\n- Provide specific recommendations for fixes\n- Include code examples where helpful\n\nIf no issues are found in a particular area, explicitly state that.\n\nHere is the code diff to review:\n\n\`\`\`\n$DIFF_CONTENT\n\`\`\`" - }] - } - EOF - ) + # Create the API request using jq to properly escape the content + echo "Creating API request..." + REQUEST=$(jq -n \ + --arg prompt "$PROMPT" \ + '{ + "model": "claude-3-sonnet-20240229", + "max_tokens": 4096, + "temperature": 0.7, + "messages": [{ + "role": "user", + "content": $prompt + }] + }') # Make the API request echo "Sending request to Claude API..." @@ -124,6 +146,7 @@ jobs: echo 'EOF' >> $GITHUB_OUTPUT else echo "Error in Claude API response: $RESPONSE" + echo "Request was: $REQUEST" exit 1 fi