Lesson 2 of 4 · about 6 min

Your first AI wins: 5 everyday tasks

When you finish, you can get useful help from AI on explaining, testing, debugging, reviewing and documenting code.

Stuck? Ask the AI tutor

Win one: explain code you did not write

Inheriting a file with no comments is a daily experience. A weak prompt is “What does this do?” followed by a paste. A stronger one is: “Explain this Python function to a developer new to this project. Describe inputs, outputs and side effects, then list anything that looks fragile. Do not change the code.”

Check the answer against the code itself. Trace one real input by hand. If the explanation says the function returns a list but you see a generator, the explanation is wrong, and now you know how much to trust the rest. Use AI for orientation, not as the final word.

Win two: write tests you would not have time for

Weak: “Write tests for this function.” Strong: “Write pytest tests for this function. Cover an empty list, one item, duplicates, negative numbers and a very large list. Name each test so a failure explains itself. Tell me which cases you are unsure about.”

Then read every assertion. AI often writes tests that pass because they copy the code's own logic, which proves nothing. Ask yourself: if I broke the function on purpose, would this test fail? Try it. A test you have seen fail is a test you can trust.

Win three: debug with evidence

Weak: “It crashes, fix it.” Strong: “This endpoint returns a 500 after I added the caching layer. Here is the stack trace and the function. List the three most likely causes with one check for each. Do not propose a fix yet.” Asking for checks keeps you in charge of the investigation.

Run the checks, then report back what you found. This back-and-forth is where the tool shines. Be wary of a confident fix that appears on the first reply. Apply one change at a time, and use version control so you can undo any attempt quickly.

Win four: review your own change first

Before you ask a teammate, ask the assistant for a first pass: “Review this diff for off-by-one errors, unhandled nulls, security issues such as injection, and unclear names. Sort findings into must-fix and nitpick.” It will catch small slips and save your colleague's time for the questions that need a human.

Verify each finding. Assistants sometimes flag problems that are not real, or praise code that has a real flaw. Treat the review as a checklist generator, not an approval. Your teammate's review and your tests are still the gate.

Win five: documentation and commit notes

Many developers dislike writing documentation, which makes it a good place to start. Paste a function and ask for a short reference: purpose, parameters, return value, errors, and one example. Ask for a commit message that explains why the change was made, not only what changed.

Edit the result so it sounds like your team. Check that examples actually run. An example that does not run is worse than none, because readers trust it. A good rule: anything you publish under your name, you have read and run.

Practice now

  1. Take a small function from your own project (nothing secret). Ask an AI tool to explain it, then write three tests for it. Break the function on purpose and confirm at least one test fails.
  2. Take your last diff and ask for a review using a prompt that sorts findings into must-fix and nitpick. Mark which findings were real.

Use any AI assistant you have. Do not paste private, client or patient information into it.

Check yourself

1. Why should you ask for debugging checks before a fix?

2. What is a common weakness of AI-written tests?

3. How should you treat an AI code review?

Ask the AI tutor

Ask anything about this lesson, in any language. The tutor is an AI: it can be wrong, and it never needs your personal details.

AI-drafted. Checked by an automated validator and a separate AI reviewer; a person has not read every lesson. Translations and tutor answers are AI-made. Found a mistake? Tell us. AI can be wrong. General information only, not professional advice. Not affiliated with any AI company named. Current University is not accredited.