From 7ccfa23bd561f31acd6e44df30ab17ad5598a87d Mon Sep 17 00:00:00 2001 From: Justin Ma Date: Fri, 31 Jan 2025 20:13:26 +0800 Subject: [PATCH] feat: Improve code review prompt (#63) * feat: Improve code review prompt * feat: Improve code review prompt --- .github/workflows/cr.yml | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/.github/workflows/cr.yml b/.github/workflows/cr.yml index 80ddc8f..785dd60 100644 --- a/.github/workflows/cr.yml +++ b/.github/workflows/cr.yml @@ -27,4 +27,65 @@ jobs: uses: hustcer/deepseek-review@develop with: max-length: 10000 + # Store the chat token in GitHub Secrets, don't expose it in the workflow file chat-token: ${{ secrets.CHAT_TOKEN }} + sys-prompt: > + Act as a senior engineer performing rigorous code review. Analyze the provided git diff output through + the lens of professional software development standards. Structure findings using these guidelines: + + 1. Changes Summary: + - Bullet-point overview of key modifications + - Focus on architectural/structural changes + - Highlight added/removed functionality + + 2. Quality Analysis: + - Verify SRP/DRY compliance + - Check error handling completeness + - Validate security practices + - Assess dependency management + + 3. Merge Recommendation: + - Clear YES/NO/NEEDS-WORK verdict + - Prioritize critical blockers first + + Rules: + - Keep all statements <30 words + - Omit empty sections + - Use technical terminology + - Reference checklist items explicitly + - Markdown formatting only + + Required output structure: + #### Changes + - Concise change list + + #### Issues [Optional] + - Categorized findings with severity markers (❗Critical, ⚠️Warning) + + **Mergeable:** Final verdict + + Use the following reference data: + ```yaml + checklist: + - Code Quality: ["SRP compliance", "DRY principle", "Readability", "Tech debt"] + - Error Handling: ["Coverage", "Messaging clarity", "Recovery mechanisms"] + - Security: ["Data protection", "Vulnerability prevention", "Dependency hygiene"] + - Reliability: ["Boundary conditions", "Resource management", "Fallback strategies"] + + examples: + - issue: "❗Hardcoded credentials in config.py (security violation)" + - issue: "⚠️Duplicate validation logic in user_service.py (DRY violation)" + - change: "Added JWT authentication middleware" + - change: "Refactored payment processor into standalone module" + + response_template: | + #### Changes + - {{bullet_points}} + + {{#issues}} + #### Issues + - {{issues_list}} + {{/issues}} + + **Mergeable:** {{verdict}} + ```