עבודה נכונה עם עוזר AI לקודWorking well with an AI coding assistant
מפגש 32: מתי לסמוך, איך לבדוק, איך לבקש, ואיך לא לאבד את ההבנה.Session 32: When to trust it, how to verify, how to ask, and how not to lose understanding.
מתי לסמוך, איך לבדוק, איך לבקש, ואיך לא לאבד את ההבנה. בסוף המפגש מוסיפים צעד לפרויקט המלווה.When to trust it, how to verify, how to ask, and how not to lose understanding. At the end we add a step to the companion project.
מה נעשה היוםToday's plan
תפקידRole
בקשהPrompting
סקירהReview
בדיקותTests
המצאותHallucinations
אבטחהSecurity
עוברים על סדר היום ומזכירים את הפרויקט המלווה.Walk through the plan and mention the companion project.
חלש: אחריות, הקשר שלא נתתם, עובדות עדכניותWeak at: responsibility, context you didn't give, current facts
אתם עדיין המתכנתיםYou're still the programmer
עוזרי AI לקוד כמו Claude משנים את העבודה של מתכנתים: הם כותבים טיוטה במהירות, מסבירים שגיאות ומציעים גישות. אבל הם לא מכירים את הפרויקט שלכם אלא אם תספרו להם, והם יכולים לטעות בביטחון מלא. הכלל: האחריות על הקוד שלכם. מה שלא מבינים, לא מכניסים. הקוד הבא "נכתב על ידי עוזר" לבקשה "ממוצע דירוגים". יש בו שתי בעיות:AI coding assistants like Claude change how programmers work: they draft quickly, explain errors and suggest approaches. But they don't know your project unless you tell them, and they can be confidently wrong. The rule: the code is your responsibility. What you don't understand doesn't go in. The next code was "written by an assistant" for the request "average rating". It has two problems:
אנלוגיהAnalogy
עוזר AI הוא כמו מתמחה מוכשר מאוד ביום הראשון: עובד מהר ויודע המון, אבל לא מכיר את המשרד, ואתם חותמים על מה שיוצא.An AI assistant is like a very talented intern on day one: works fast and knows a lot, but doesn't know the office, and you sign off on what goes out.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
נושאTopic 2
בקשהPrompting
לבקש טובAsking well
הקשר: מה הפרויקט, איזו גרסהContext: what the project is, which version
דוגמת קלט ופלטAn input and output example
אילוצים: בלי ספריות, טיפוסים, מקרי קצהConstraints: no libraries, types, edge cases
בקשה טובה דומה לבקשה מעמית: מה אתם בונים, מה כבר יש, מה בדיוק צריך, ודוגמה. במקום "תכתוב ממוצע", כותבים בקשה שמגדירה מקרי קצה. אפשר אפילו לבנות את הבקשה בקוד, כמו תבנית:A good prompt is like asking a colleague: what you're building, what exists, exactly what's needed, and an example. Instead of "write an average", write a request that spells out the edge cases. You can even build the prompt in code, like a template:
אנלוגיהAnalogy
בקשה מעורפלת לעוזר היא כמו לבקש מנהג מונית "לנסוע למרכז": הוא ייסע, אבל כנראה לא למקום שרציתם.A vague request to an assistant is like telling a taxi driver "drive to the centre": they'll drive, just probably not where you meant.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
נושאTopic 3
סקירהReview
לקרוא לפני שמקבליםRead before you accept
סקירה: האם אני מבין כל שורה?Review: do I understand every line?
מריצים על מקרי קצהRun it on edge cases
מבקשים הסבר על מה שלא ברורAsk for an explanation of what's unclear
לפני שמכניסים קוד שנוצר, עושים סקירת קוד כמו לקוד של אדם: קוראים שורה אחרי שורה, ושואלים מה קורה ברשימה ריקה, בערך חסר, בקלט מוזר. הנה הגרסה המתוקנת של הפונקציה, והרצה על כל המקרים מהבקשה:Before adding generated code, do a code review like you would for a person's code: read line by line, and ask what happens with an empty list, a missing value, odd input. Here's the fixed version of the function, run on every case from the request:
אנלוגיהAnalogy
סקירת קוד היא כמו לקרוא חוזה לפני שחותמים: גם אם עורך דין מעולה ניסח אותו, השם שלכם עליו.Code review is like reading a contract before signing: even if a great lawyer drafted it, it's your name on it.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
נותנים לעוזר את הבדיקותGive the assistant the tests
הבדיקות מחליטות, לא תחושת בטןTests decide, not gut feeling
השיטה הכי אמינה לעבוד עם AI היא TDD (מפגש 19): אתם כותבים את הבדיקות, שהן מפרט שאפשר להריץ, והעוזר כותב קוד שמעביר אותן. אחר כך הבדיקות, לא ההרגשה, אומרות אם הקוד נכון. הנה בדיקות לפונקציה שעדיין לא קיימת, ושתי "הצעות" שונות:The most reliable way to work with AI is TDD (session 19): you write the tests, a spec you can run, and the assistant writes code that passes them. Then the tests, not a feeling, say whether the code is right. Here are tests for a function that doesn't exist yet, and two different "suggestions":
אנלוגיהAnalogy
בדיקות הן כמו שבלונה למכונית חדשה: לא משנה מי ייצר את החלק, אם הוא לא נכנס בשבלונה, הוא לא נכנס לרכב.Tests are like a template on an assembly line: whoever made the part, if it doesn't fit the template, it doesn't go in the car.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
מודלים לפעמים ממציאים: מתודה שנשמעת הגיונית אבל לא קיימת, פרמטר שלא קיים, או חבילה ב-pip עם שם דומה לאמיתית (ויש תוקפים שרושמים חבילות כאלה בכוונה!). פייתון עצמה עוזרת לבדוק: hasattr, dir ו-help מראים מה באמת קיים.Models sometimes hallucinate: a method that sounds plausible but doesn't exist, a parameter that isn't there, or a pip package with a name close to a real one (and attackers register such packages on purpose!). Python itself helps check: hasattr, dir and help show what really exists.
אנלוגיהAnalogy
המצאה של מודל היא כמו נווט שבטוח שיש פנייה ימינה: לפעמים הוא צודק, אבל כדאי להסתכל על השלט לפני שמסובבים את ההגה.A model's hallucination is like a navigator certain there's a right turn: sometimes right, but look at the sign before turning the wheel.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
טעות נפוצהCommon mistake
check_claims.py
shelf = ["Dune", "Emma"]
shelf.remove_all("Dune")
מה Python עונהWhat Python says
AttributeError: 'list' object has no attribute 'remove_all'
AttributeError: 'list' object has no attribute 'remove_all': אין כזו. לרשימה יש remove (מופע ראשון). dir(list) מראה את כל מה שקיים.AttributeError: 'list' object has no attribute 'remove_all': there's no such thing. Lists have remove (first occurrence). dir(list) shows everything that exists.
מריצים קוד עם מתודה שהעוזר המציא.Running code with a method the assistant invented.
נושאTopic 6
אבטחהSecurity
פרטיות ואבטחהPrivacy and security
לא מדביקים סיסמאות, מפתחות ומידע אישיDon't paste passwords, keys or personal data
לא מריצים פקודות שלא מביניםDon't run commands you don't understand
קוד שנוצר יכול להכיל פרצותGenerated code can contain holes
שלושה כללים. אחד: לא מדביקים לצ'אט מפתחות API, סיסמאות או מידע אישי של אחרים. שניים: פקודה שעוזר מציע (rm -rf, pip install של חבילה לא מוכרת) מריצים רק אם מבינים מה היא עושה. שלושה: קוד שנוצר יכול להכיל פרצות קלאסיות, כמו SQL injection (מפגש 23). אפשר לבנות בדיקה קטנה שמחפשת סודות לפני ששולחים טקסט:Three rules. One: don't paste API keys, passwords or other people's personal data into a chat. Two: run a command an assistant suggests (rm -rf, pip install of an unknown package) only if you understand what it does. Three: generated code can contain classic holes, like SQL injection (session 23). You can build a small check that looks for secrets before sending text:
אנלוגיהAnalogy
להדביק מפתח API לצ'אט זה כמו לצעוק את הקוד של הכספת באמצע רחוב: גם אם אף אחד לא שמע, עדיף להחליף אותו.Pasting an API key into a chat is like shouting the safe's code in the street: even if nobody heard, better change it.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.