Check every package and function it suggests

Módulo 1: Code with AI, and check every line

Conteúdo do curso

Esta aula ainda não está no seu idioma, então aqui está em inglês.

Encontre os erros

Guess first, no penalty. You asked an AI to add a row to a pandas table and retry an upload. Your project pins pandas 2.2. Tap the two lines to check before you use them.

The AI's suggestion

0 de 2 encontrados

A package is code someone else published for you to install from a registry, the official index of packages, such as npm for JavaScript or PyPI for Python. AI tools sometimes invent package names that sound right. Attackers know this, so they can register those names and fill them with harmful code.

AI tools also learned from old code, so they suggest functions that were removed years ago. Your lockfile (the file that pins the exact versions your project uses, such as package-lock.json or poetry.lock) tells you which version's docs apply.

Before you install or trust anything new:

  • Find it on the registry. Check the maintainer, the source repository and how widely it's used.
  • Check the version. Read the docs for the version in your lockfile, not the latest one.
  • Prefer what you have. If the standard library or an existing dependency does the job, use that.

A worked example

The notes one developer wrote before using the suggestion above:

upload-retry-helper: not something we use. Not installing. A loop with
  a timeout covers the retry in five lines.
df.append: lockfile says pandas 2.2. The 2.0 release notes say append
  was removed, use concat. Changed to:
  df = pd.concat([df, pd.DataFrame([new_row])], ignore_index=True)

Preencha as lacunas

Fill the gaps.

Checklist

Before I install a package an AI suggested, I find it on the and check its . I read the docs for the version in my .

Try it

Seus passos, cerca de 1 minutos

0 de 1
  1. 1.Check every package and function an AI suggested in your last task against the registry and your lockfile. Add the checklist above to your kit.1 min

Your AI code review kit is now complete. Keep it next to your editor:

1. Ask for tests: normal, empty, bad and boundary cases, exact values.
2. Ask for code: task, context, rules, then code + edge cases + tests.
3. Diff review: scope, errors, edge cases, your codebase, security.
4. Logic check: trace one small, mixed example by hand. Keep it as a test.
5. Package check: registry, maintainer, lockfile version, use what you have.

Exercícios

Pergunta 1 de 2

An AI tells you to run 'npm install' for a package you've never seen. What is the safest first step?

Tutor de IA

Tire dúvidas sobre esta aula e tenha ajuda na tarefa do “Experimente”. O tutor faz parte do Learn Pro.

Ver o Learn Pro