למה עדיין קשה לקבל Code Review מסוכני קוד
יש לי פרומפט קבוע ל Code Review שנראה ככה:
---
description: Review attached code
---
Review the provided code change.
Explain:
- What the code does
- Is the implementation complete
- What other alternatives can solve the same problem? Why was the current alternative chosen?
Then Code Review, focus on:
- Correctness - Bugs and logic errors
- Performance - are there newly introduced regressions? how will the feature work with production data?
- Scale
- Code architecture
- Coding best practices
- Security issues
- Error handling gaps
- Handled and unhandled edge cases
Test Coverage
- Examine existing tests
- Search for untested paths or incomplete tests, specifically tests that only verify the happy path
- Find if the untested code could break in ways we didn't consider
Multi Threaded or Concurrency
- We're writing a web application whose code runs from both user facing web frontend and background workers
- Evaluate code for multi threaded and concurrency anti patterns or possible hidden bugs, deadlocks, duplicate execution, starvation
- Evaluate the need for transactions only where absolutely needed due to the performance penalty of locking.
Security
- We're writing a web application performing in possible hostile environment
- Verify authorization is checked on every route
- Verify user input is sanitized before used
Finally look for AI anti patterns:
- Dead code
- Duplicated code or logic
** DO NOT RUN ANY CODE NOR DO NOT INTERACT WITH THE SYSTEM IN ANY WAY **
This is a static analysis code review running on an isolated machine.
כן זה ארוך אבל מעניין. תנו אותו למודל חכם (אופוס או דיפסיק פרו) ותמיד הוא ימצא על מה להתלונן. תקנו דבר אחד ותפעילו שוב ואתם תראו שתקבלו רשימה קצת שונה של בעיות. ככל שממשיכים לתקן רשימת הבעיות משתנה. הפעלה עם מודל אחר מחזירה רשימת בעיות קצת אחרת.
אפשר גם לשנות את הפרומפט ולייצר כמה סוכנים, אחד עבור ביצועים, עוד אחד לאבטחת מידע ושלישי לאיכות הקוד. אבל זה לא משנה את הבעיה המהותית:
אי אפשר לקבל רשימה מקיפה של כל הבעיות - כל הפעלה וכל תיקון חושפים בעיות נוספות.
בעיות מסוימות מדורגות "חשובות" אבל למעשה הן לא חשובות בכלל. לפעמים המודל נטפל לדברים שאנחנו יודעים שהם בסדר אבל בגלל שהם שם הוא לא מצליח לראות בעיות אמיתיות. "תיקון" אותם דברים שהם לגמרי בסדר פתאום גורם למודל להציף בעיות אחרות כן חשובות.
הבעיות שהסוכן מוצא עשויות לתת תחושה שקרית של בטחון - "וואו הוא מצא דברים כל כך מתוחכמים בטוח הוא היה רואה את הדברים הבסיסיים והפשוטים ששבורים בקוד" זו לא תמיד מסקנה נכונה כשמדובר בסוכני קידוד.
סך הכל קחו את הפרומפט תהנו ממנו ואני מקווה שהוא יעזור גם לכם לשפר את הקוד לפני שממזגים PR. אבל שימו לב שאנחנו עדיין רחוקים מתהליך Code Review אמין.