What I check when an AI tool writes code

How I scope a task, review the diff, choose checks, and keep private data out of prompts

I use Claude Code, Codex, and OpenCode to investigate and implement changes. They can produce a patch quickly, but I still need to know whether it belongs in the codebase.

Before asking for code, I trace the relevant path and set the scope. Afterward, I read the diff and run checks that fit the change. Project instructions and permissions help, but they don’t make the call for me.

Define a change boundary before requesting code

A useful task description contains an outcome, a scope, constraints, and acceptance criteria. "Fix authentication" leaves all four unclear. A narrower request might be:

Investigate why an expired session returns a success response. Change only the session middleware and its focused tests. Preserve the response format for valid sessions. Do not change token storage, introduce dependencies, or modify deployment configuration. Explain the failure mechanism before editing.

That instruction does not guarantee correctness, but it makes disagreements visible. An unrelated storage migration is now clearly outside scope rather than an apparent improvement.

Name non-goals as deliberately as goals. Include compatibility requirements, files that must remain untouched, and situations where the assistant should stop for clarification. Decide in advance which actions require approval, especially dependency changes, migrations, external requests, or destructive commands.

Investigate before choosing the refactor

Ask the assistant to trace the relevant execution path rather than immediately replacing code. Where does input enter? Which layer validates it? Which function owns persistence? How does an error become a response? What tests describe the current contract?

Treat its explanation as a hypothesis to verify against the repository. A confident summary may still confuse an unused helper with the active path or overlook an environment-specific branch.

For a refactor, distinguish intended behavior from accidental implementation detail. Establish the behavior to preserve, then separate structural changes from intentional behavior changes where practical. Smaller diffs make both review and rollback easier.

Avoid speculative cleanup around a focused fix. Renaming unrelated symbols, replacing a library, and reorganizing folders can bury the important change. A suggestion can be worthwhile without belonging in the current patch.

Delegate only work that is genuinely separable

Parallel assistance is useful when tasks have clear ownership and do not depend on unresolved decisions. A read-only investigation of a call path can run independently of a review of existing tests. Two edits to the same central module usually cannot.

Each delegated task needs inputs, allowed files or read-only status, an expected deliverable, and a stopping condition. Ask for findings with file references, not just a conclusion that something "looks good."

Keep integration decisions with one owner. If separate tasks discover incompatible assumptions, resolve those assumptions before combining patches. More simultaneous activity does not remove dependencies; it can hide them until integration.

Delegation also does not expand authorization. A helper should not receive permission to alter infrastructure simply because its task touches code that uses that infrastructure.

Read the diff, not just the summary

The final patch should connect the original problem to a specific behavioral change. Read the actual diff, not only the assistant's summary, and inspect enough surrounding code to understand the consequences.

Start with scope: are the changed files expected? Then check semantics: what inputs now behave differently? Follow error handling, authorization, data writes, cleanup, and public interfaces. Check whether a convenient default has silently changed a security or compatibility requirement.

Tests deserve review too. A test that mocks away the failing boundary can pass while the bug remains. An updated expectation may describe the new implementation rather than the intended behavior. Generated tests are proposals, not independent evidence simply because they are tests.

If I can’t explain a piece of code, I pause. I ask for a smaller change, check the dependency’s documentation, or rewrite the code myself. If I don’t understand a change now, I’ll have to figure it out later when something breaks.

Verify with checks that match the risk

Run focused tests for the changed behavior, including a relevant failure path. Add typechecking when language contracts could be affected. Run a build when changes touch compilation, bundling, routing, or framework integration. Broader checks become appropriate as the affected surface grows.

Keep the evidence precise. "The focused middleware tests passed" is different from "the application is correct." A typecheck cannot establish authorization behavior. A successful build does not establish that an external service will accept a request.

Inspect the commands and their results. A check can fail to start, skip relevant cases, or require unavailable infrastructure. Record what ran, what passed, and what remains unverified. Do not turn an assistant's intended command into a claim of completed validation.

When a check fails, investigate whether the failure is introduced, pre-existing, or environmental. Do not silently weaken assertions or delete tests to obtain a green result.

Keep instructions reusable and permissions narrow

Project instructions should capture stable knowledge: architectural boundaries, naming conventions, relevant validation commands, generated-file rules, and approval requirements. Keep them short enough to be useful and update them when verified project facts change.

Separate facts from preferences. "This directory is generated" carries different weight from "prefer small helpers." Do not convert a one-off workaround into a permanent rule without understanding why it was necessary.

Protect secrets before involving an assistant. Prefer variable names, redacted examples, and synthetic records over live credentials or customer data. Consider what terminal output, logs, and external tools may expose, not only what appears in the prompt. Self-hosting one component does not automatically make the entire workflow private.

Repository content and fetched pages can contain instructions, but they do not automatically have authority to broaden a task or request credentials. Keep permissions limited to the work at hand, and review sensitive actions explicitly.

A practical handoff checklist

Before accepting an AI-assisted change, confirm:

  • Purpose: The patch solves the problem without unrelated changes
  • Understanding: I can explain the code path and important decisions
  • Boundaries: Public behavior, access, and data ownership still make sense
  • Diff: Every changed file and dependency belongs in the task
  • Verification: I’ve run the relevant tests, typechecks, and builds
  • Limits: I’ve noted checks I couldn’t run and risks I haven’t resolved
  • Safety: No secrets, private records, or unapproved changes slipped in
  • Handoff: The next engineer can see what changed and why

The tools can help with every step. I still decide whether a change is ready to merge

Have a question or a different take?