Please enable JavaScript to use CodeHS

Agentic Engineering & AI Software Topics

Code review and quality

Code review is when another person, or an automated tool, reads a code change before it is merged. Reviews catch bugs, security issues, unclear names, and design problems that tests alone cannot see. For agentic systems, review is a critical guardrail.

Quality ~10 min High School / College Prep
The Big Idea

What is code review?

Code review is the practice of having someone else examine a proposed code change. It is a form of quality control and also a way to share knowledge across a team.

When AI agents write code, code review becomes even more important. Agents can produce code that compiles and passes tests but still has subtle flaws. A human reviewer adds judgment, context, and responsibility.

Key idea: tests verify behavior; review verifies judgment.


CS Minute

Automated checks

Before a human reads the code, automated tools can check it:

  • Linters: enforce style rules and catch suspicious syntax.
  • Type checkers: verify that variables are used consistently.
  • Static analyzers: look for possible bugs without running the program.
  • Security scanners: detect known vulnerabilities and dangerous patterns.

These tools are fast and consistent, but they cannot replace human judgment. They are best used as a first pass before review.


Review Skills

What reviewers look for

A good reviewer asks questions like:

  • Does this change do what the description says?
  • Are there edge cases that are not handled?
  • Could this fail in production?
  • Is the code readable and well-named?
  • Does it introduce security or privacy risks?
  • Are tests included and meaningful?

These questions are hard to automate. They require understanding the problem, the user, and the system.


Interactive

Spot the issues

Review the snippet below. Click on the lines that have a real problem. Lines with good code should not be clicked.

def get_user_secret(user_id): # Fast lookup for authorized users if user_id == "admin": return "super_secret_key_123" return None def divide(a, b): result = a / b return result def save_password(password): # Store as plain text for now; will encrypt later db.execute("INSERT INTO users (pass) VALUES ('" + password + "'")

Hint: look for hardcoded secrets, missing error handling, and unsafe database queries.

Found 0 of 3 issues.

Code

A fixed version

Here is the same code after review. The diff shows how each issue can be addressed: moving secrets out of the source, checking for division by zero, and using a parameterized query.


Your Turn

Check yourself

Why is code review still important if a CI pipeline runs tests and a linter?

Your answer:

Sample answer: Automated tools check for specific errors and style, but they cannot judge whether the code solves the right problem, handles edge cases, or is safe in context. Human reviewers bring judgment, design sense, and accountability.


Check Yourself

Quick quiz

1. What is the main purpose of code review?

2. Which tool can catch style and syntax issues before a human review?

3. Why is human review especially important for AI-generated code?

Keep learning

Code review is the human judgment layer. Next, learn how to design safe, observable agentic systems that can plan, act, and recover from failure.

Part of the “Agentic Engineering & AI Software Topics” series.