Practicing engineering judgment with AI

By

Tagged: AI

Practice engineering judgment with AI through a worked export failure: gather evidence, compare designs, test risks, review changes, and learn from decisions.

A coding agent can hand you a working patch before you’ve even decided if it’s the right change to make.

So pause before asking for code. Write down what you’re seeing in plain, observable terms, and decide upfront what kind of evidence will tell you the fix worked.

That small habit is one of the best ways to sharpen your engineering judgment while working with AI. You make a call, let the agent investigate or build it, and then check how the result lines up with what you expected.

You don’t need a massive distributed system to practice this. Everyday work like a slow page, a broken import, or a clunky form gives you plenty of trade-offs to think through.

Let’s walk through a concrete example: a support app whose CSV export times out for large accounts. It’s a made-up scenario with sample numbers, just to keep the focus on the decisions you’d make in a real codebase.

Separate what happened from your explanation

Saying “the export needs a background queue” already locks you into a solution. Saying “the export request returns an error for this account” gives you something real to investigate.

Start by writing down the account’s rough size, the active filters, and the exact action that failed. Leave customer data out of your notes, because you can mirror the size and shape of the account without copying private records.

Next, write down what a real fix looks like for the person using the feature. Maybe they need every matching ticket, including old ones, in a CSV their spreadsheet can open cleanly. A quick download that quietly drops older records misses the point.

Here’s what that short starting note looks like:

QuestionWhat we know
What failed?Downloading all matching tickets for a large account
What still works?The same export with a narrow date filter
What is unknown?Which stage eats the time or memory
What must stay true?Right records, existing permissions, valid CSV
What counts as fixed?The full export finishes with those rules intact

Separating what happened from why you think it happened sounds simple, right up until you open a bug report that states a guess as a fact.

Coding agents fall for that trap fast, and they’ll argue for it with total confidence. If you prompt an agent to “fix the queue problem,” it’ll go hunting for a queue problem. Hand it the symptom instead, and ask it to trace where the request fails before touching the architecture.

Ask for evidence that can change your mind

Before touching any code, list the main ways this export could fail.

Maybe the database query itself is slow, or the app is firing extra queries for every single ticket. Maybe it’s holding the entire CSV in memory at once, or a proxy or platform timeout is killing the request before the code finishes.

Each guess points to a specific thing to measure, and a clear signal that rules it out:

Possible causeWhat to measureWhat weakens it
Slow database queryTime spent fetching the rowsRows come back fast
Per-ticket lookupsQuery count grows with ticket countQuery count stays small and fixed
Whole-file bufferingMemory climbs as the file growsMemory stays flat while it fails
Request deadlineFailure timing and which layer cuts it offFailure happens earlier inside export code

Treat that list as a starting map, and check what you find against the timeout before jumping to a fix. Seeing a big memory spike is a useful clue, so verify it’s what kills the request before building around it.

From there, give the agent a tight, bounded assignment:

Reproduce the CSV export failure without changing its behavior. Identify where the request spends its time. Record the input size and the evidence supporting the likely cause. If the failure is outside the exporter, follow the request far enough to show that.

Give the task a clear stopping point. You only need enough proof to pick the right fix, not a full performance audit of the whole app.

If the agent can’t reproduce the error, stop and figure out why. Compare the local setup, data volume, and filters against the failing account, instead of treating “couldn’t reproduce” as “problem solved.”

Compare designs by the work they create

Say the investigation shows that fetching the rows is fast enough, and the real bottleneck is building the entire CSV in memory at once.

That puts streaming on the table. Instead of building the whole file upfront, the server sends chunks as it goes. Just watch the whole pipeline, because loading every row into an array before streaming puts you right back where you started.

A background job is another route. You build the full file outside the HTTP request, then let the customer download it when it’s ready. That solves the timeout cleanly, while adding file storage, job state, and a retrieval flow you’ll have to run and support.

You could also cap the date range if customers rarely need years of history at once. Because that changes what the product does, make it an explicit product call rather than sneaking it into a performance fix.

ApproachWhen it fitsNew questions it creates
Improve the queryDatabase work is the bottleneckDoes it still hold up on large accounts?
Stream rows and CSV outputWhole-file buffering is the main issueHow do partial downloads and cancellations behave?
Generate the file in a background jobThe work needs to outlive the requestWho handles retries, stored files, expiry, and failed jobs?
Limit export scopeSmaller exports cover the real needWhat do customers do when they need full history?

A queue can be the right call. You just want all the extra moving parts on the table before you accept the patch, not as surprises a week later.

The illustration below walks through the streaming option using sample figures to show the trade-off.

Fig 1 · 1/3Reason through the export repair
Reproduce and measure

Keep an eye on the request time limit before you commit to streaming. Flat memory won’t save the download if building the file still runs past the request deadline. Here’s how that looks in practice:

1/3Query work
Query workWhen measured database work dominates the export, investigate the query and retest the original case.Reproduce thefailureMeasure databaseworkQuery dominatesInvestigate thequeryRetest originalinput
2/3Buffering
BufferingWhen memory grows while constructing the whole CSV, investigate bounded reads and streaming, then retest the original case.Reproduce thefailureMeasure CSVconstructionMemory grows withoutputInvestigatestreamingRetest originalinput
3/3Request lifetime
Request lifetimeWhen export work exceeds the available request lifetime, investigate background generation and retest the original case.Reproduce thefailureMeasure completiontimeRequest deadlineexceededInvestigate a jobRetest originalinput

Make a prediction before reading the patch

Once a patch is sitting in front of you, it’s surprisingly easy to talk yourself into thinking it looks fine.

Write down what worries you before you read a single line of diff. With a streaming CSV export, a few failure modes jump out right away: rows coming back in a new order, a pagination boundary skipping a ticket, the server burning CPU after the user hits cancel, or a mid-stream crash leaving behind a half-written file that looks complete.

Permission checks matter just as much. A faster export that drops an account filter is a security bug, no matter how quick the download feels.

Turn those worries directly into the prompt you give the agent:

Keep the existing export filters, columns, and permission rules. Address the observed buffering problem. Avoid unrelated changes. Show how the implementation handles a failure after output begins, and report any behavior the current download interface cannot communicate clearly.

You won’t predict every bug ahead of time, and that’s fine. Writing your concerns down first gives you your own baseline to compare against once the code comes back.

It also surfaces blind spots early. If you don’t know how your app tells a user their download was cut short, go check that before deciding streaming is the right path.

Choose tests that could reject the implementation

A test that mirrors the code’s own assumptions won’t catch much.

Say the exporter pulls tickets through a helper function. The agent mocks that helper, feeds it five tidy rows, and asserts that five lines come out. That checks basic formatting while skipping the real database query and account filtering completely.

Start with a small dataset where you can work out the exact expected output by hand. Mix in tickets from another account and tickets outside the chosen date range, so a broken filter fails loud and fast.

For the CSV itself, throw in fields containing a comma, a double quote, and a line break, then parse the output with a real CSV parser. Counting newlines breaks the moment a ticket description spans two lines.

Then run the big input that triggered the timeout in the first place and watch memory as it goes. The small fixture checks your data logic, while the large run shows if memory stays under control.

CheckWhat it verifiesWhat stays untested
Known small datasetSelected rows and expected valuesBehavior at large sizes
Two accounts in the fixtureAccount isolation on this pathOther authorization paths
Quoted and multiline fieldsCSV escaping for those inputsEvery spreadsheet client
Original failing input shapeThe size-related failure itselfOther workloads and concurrency
Failure partway throughCleanup and partial-output handlingFailures at other stages
User cancels a downloadWhether work stops after cancelEvery kind of network drop

Ask for a verification report that lists what ran and what it produced. Hearing “all tests passed” hides everything if you don’t know what those tests touched, which is the same gap I wrote about in choosing fast tests for coding agents.

Narrowing down a bug works the same way whether you’re typing the code or steering an agent, and I cover that habit in more detail in my guide to debugging.

Read the patch as a future maintainer

Every patch you merge becomes code you’ll have to maintain six months from now.

Trace the request from start to finish first. Find where the app identifies the current user, where the filters come in, and where the query applies them, then follow the rows all the way to the HTTP response.

Check resource cleanup next. When the exporter opens a database cursor or a temporary file, see what closes it when everything goes right, and what closes it when the query errors out or the user cancels mid-download.

If the diff adds retries, trace what happens when the same operation runs twice. Retrying a read query is usually harmless, while retrying a job that writes a file and fires off an email can duplicate side effects fast.

When a patch pulls in a new dependency, check why the tools you already have couldn’t handle it. Sometimes a library is worth adding, as long as you’re happy owning its updates and API over time.

Don’t skip the tests and config files in the diff. A green test run could mean the exporter got faster, or it could mean someone bumped a timeout or shrank the large test fixture.

Finish by asking the agent to walk through one ugly edge case in plain English. Try something like: “The database drops out after the first chunk reaches the browser. What does the customer get, and where is the error logged?”

Use that answer as a map and open the lines of code yourself to confirm it matches.

Use disagreement to uncover assumptions

You don’t have to take the agent’s first plan just to keep things moving. Pushing back a little usually saves you from building the wrong fix.

When the agent suggests adding a queue, ask what evidence points to needing one. If it pitches streaming instead, ask which part of the pipeline stays bounded in memory and which part still grows. Giving it a concrete question like that forces a real check instead of a confident guess.

Another good prompt is asking for the strongest reason to turn down its own proposal. That often brings up an assumption neither of you stated out loud, like whether the export needs a consistent snapshot while records are still changing underneath it.

Watch out for asking a second agent to rubber-stamp a patch without giving it the full story. If it only sees a clean diff, it’ll miss the same requirement the first agent missed. Hand the reviewer the failure you saw and the behaviors that have to keep working, then have it trace those through the diff. You can find the built-in review commands in AI code review.

Product tradeoffs stay on your plate too. An agent can spell out what happens when a download occasionally cuts off with partial data, and then it’s up to you to decide whether your customers can live with that or if you need a safer design.

Decide how to ship and how to recover

A fix can pass every local test and still act weird under real traffic.

Before you deploy an export change, pick the numbers you want to watch once it’s live. Completed exports, failure counts, and how long large exports take will tell you a lot right away. Just keep ticket contents out of your diagnostic logs.

If your app already has a way to turn a change on for a handful of accounts, use that. You don’t need to build a fancy rollout system just to ship one small patch.

Write down your stop condition ahead of time too. Telling yourself to “watch it carefully” doesn’t help much when things get noisy. Something concrete like “stop expanding access if exports drop rows or mix data across accounts” gives you a clear line to act on.

Think through how you’ll undo the change before you need to. Rolling back a pure code change is usually easy, while a change that adds stored jobs, new database state, or a schema migration takes more care. Make sure the previous version can still read whatever the new code writes before you assume rollback is a one-click escape hatch.

The diagram below maps out the release flow with that recovery path built in:

Verify and release the exportCheck known data, the original failure, and interruptions before release. Observe behavior, continue when criteria hold, and stop and recover when they fail.YesNoKnown data matchesOriginal casecompletesInterruptionscheckedRelease to chosenscopeCriteria met?ContinueStop rolloutInvestigateRecover

Local tests only cover the inputs and environments you thought to check. Watching production catches the conditions they missed, which is why the diagram keeps a recovery path right after release.

Keep a short decision journal

Once the work is done, compare how it played out against your original plan.

Maybe writing the fix was quick, while figuring out that the request never even reached the export code took most of your time. Or maybe you accepted a big refactor from the agent and then had to pick it apart just to test one behavior.

Notes like that point straight to what you should change next time: check the request path first, or ask for the smallest possible fix before talking about a redesign.

A good entry only needs a few sentences. For an export bug like this one, it might look like this:

I expected whole-file buffering to explain the failure. Measurements backed that up for memory, yet the download still hit the request deadline. Streaming fixed one limit and left the other alone. Next time an export breaks, measure total completion time against the deployed request path before choosing a design.

Notice what makes that useful: it records what changed your mind and what you’ll check earlier next time. Writing “be more careful next time” gives you nothing to act on when the next bug shows up.

Write down the times your hunch was right, too. If you suspected a missing account filter and your test fixture caught it, that confirms a review habit worth keeping, which isn’t something you’ll ever learn from counting generated lines or comparing minutes spent typing. When a choice matters to future maintainers, save it as a decision record in the project so the reasoning stays next to the code.

Practice on changes small enough to understand

You don’t need a big project to sharpen this habit. Pick your next bug and jot down what you think is causing it before you ask the agent to touch the code, along with one piece of evidence that would prove your guess wrong.

Once the investigation comes back, stack the findings up against your guess. If they don’t match, work out why before you ask for a patch so you stay in charge of the design.

Whenever an agent proposes a new dependency or service, list what you’re signing up to maintain. Who keeps it updated? What breaks when it goes down? Which user-facing feature relies on it? Put that list next to a version built with tools your project already has, and the tradeoff gets clear fast.

You can also practice reviewing on a patch before you merge it. Pick a single external input, like an account ID or an imported field, and trace where you validate it and every operation it touches. Have the agent trace the same value on its own, then compare the two paths to see what one of you missed.

Even on a busy day, a few minutes is enough. Predict how one function could fail, then open its error path and check how close you were. You can run small checks like that on real tickets without turning your workday into homework.

Next time you hand a fix to an agent, keep one decision for yourself: write down what would convince you the change is safe to ship. When the patch comes back, check it against your note before you read the agent’s summary. That’s the same job I talk about in Proton’s AI manifesto and what it means to lead coding agents.

Want me to talk about your product? You can sponsor this site.

Related posts about ai: