Chat kitchenTry it → read → next · ~10 min

Tutorials · Chapter B (2/4) · ~10 min

AI for coding

Try it → see it → read → next

Use AI to explain, debug, and test — never to merge unreviewed code.

On paths: Builder · Student

Try tools: Code & developers

Try yourself

Playground

AI coding assistant patterns

Same snippet — three safe workflows: explain, debug, test.

function total(items) {
  let sum = 0
  for (let i = 0; i <= items.length; i++) {
    sum += items[i]
  }
  return sum
}
PromptExplain this function line-by-line for a beginner. No rewrites yet.

Recap

What you just did

You ran three playbooks on the same snippet: explain, find bug, write tests — the safe daily rhythm.

Teach

How it works

1) Explain before you change

Explain this code line-by-line. Assume I know basic JavaScript.
Do not rewrite yet.
[paste]

2) Debug with a narrow ask

Find the bug causing wrong totals. Show a minimal diff only.
[paste + error message]

3) Tests before refactor

Write 3 unit tests for edge cases. Then suggest one refactor if tests pass.
[paste]

Always run tests locally. Never paste secrets, API keys, or customer data.

Use it

When you'd use this

  • Learning unfamiliar codebases
  • Stuck on an error message
  • Drafting tests or docstrings

Watch out

Watch out

  • AI invents APIs — verify against docs
  • “Fix everything” diffs can break behavior
  • Don't commit code you didn't read

Try next

Try this next

Use the How to use AI for code review recipe on the reference shelf.