Skip to content
AI Engineer Guide.

concept · coding · intermediate · concept 15 of 30

Compiler/linter feedback

0 of 30 complete

Why it matters

A model can produce code that reads correctly and still fails to compile, and every later check depends on the build. Compiler and linter output gives the agent a deterministic signal with a file, a line and a rule, which is far cheaper than asking a model to review its own work. The difficulty is volume: correlated diagnostics can bury the one error that matters and send the agent editing symptoms.

Mental model

It is spell-check while writing: immediate, local and mechanical. The metaphor breaks because a type error is not a typo, and fixing the reported line can be wrong when the cause sits upstream, so the agent must re-run and compare counts instead of editing every line.

How it works

Fix one root cause, re-run, compare the countInteractive
transitionfailurerepeat✕ refused

Event · step 1 of 8

Edit · three files

Entry: the agent has staged a change across three files. Exit is a check run, not a review, because the harness owns the command and the working directory.

In state

  • Edit

Next: Check · 41 diagnostics

Diagnostics
—
Check runs
0
Suppressions
0
Step 1/8 · Edit · three files

Figure. Seven states. The checker's exit code selects the edge, and a repair only counts as progress when the next run reports fewer diagnostics. Suppression is drawn as a refused move: silencing a diagnostic never reaches Green.

What to notice. The loop is harness work, not model work: the checker runs outside the model and its count is compared between runs. Triage orders correlated errors so one root cause is repaired per pass. Counts, file names, the two-warning result, the five-warning budget and the three-run repeat window are illustrative; the trace covers one checker and one linter, and timeout, toolchain-version and monorepo-config failures are omitted.

Text version

A state machine with seven states. Edit is the start and goes to Check on run. Check goes to Triage when diagnostics are greater than zero, to Green on exit zero, to Suppressed on a new ignore directive, and to Stalled when the same diagnostic fingerprint appears a third time. Triage goes to Repair on first root per file, and Repair loops back to Check on re-run. Suppressed has a dotted edge with no arrowhead to Green labelled silence, refused. The trace walks Edit, Check with 41 diagnostics, Triage, Repair, Check with 7, Green, then Suppressed, then a second task that stalls. Counters show diagnostics falling from 41 to 7 to 0, four check runs and one suppression in the first task, then 41 diagnostics and three check runs in the second.

  1. Run the type checker before the tests, since a type error makes test results meaningless.
  2. Parse diagnostics into file, line, code and message, then sort by file and position.
  3. Fix the first error in each file and re-run instead of editing every reported line at once.
  4. Treat any new suppression comment as a change that needs a stated justification.
  5. Separate errors from warnings and give warnings a bounded budget per task.
  6. Compare the diagnostic count after each edit batch, not only the exit code.

Trade-offs

ChoiceGood forCostFails when
Type check every editCatches structural mistakes earlySlow on large projectsFeedback must return in seconds
Full lint every turnConsistent styleNoise dominates the signalCodebase carries legacy warnings
Fix all diagnostics at onceFewer round tripsCascading edits, new errorsDiagnostics are correlated
Errors only, warnings laterFocusedStyle drift accumulatesTeam enforces lint in CI
Trade-off mapInteractive

Good for

Catches structural mistakes early

Cost

Slow on large projects

Fails when

Feedback must return in seconds

  1. Feedback must return in seconds
  2. Codebase carries legacy warnings
  3. Diagnostics are correlated
  4. Team enforces lint in CI

Figure. Each choice with what it buys, what it costs, and the case where it loses.

What to notice. The fourth column is the decision: if the losing case describes your situation, the choice is wrong.

Text version

Four trade-offs: Type check every edit is good for Catches structural mistakes early, costs Slow on large projects, and fails when Feedback must return in seconds. Full lint every turn is good for Consistent style, costs Noise dominates the signal, and fails when Codebase carries legacy warnings. Fix all diagnostics at once is good for Fewer round trips, costs Cascading edits, new errors, and fails when Diagnostics are correlated. Errors only, warnings later is good for Focused, costs Style drift accumulates, and fails when Team enforces lint in CI

Failure modes

  • Diagnostic cascade. The agent fixes the symptom of the first error and creates ten more. Debug: compare diagnostic counts before and after each edit batch.
  • Suppression instead of fix. New ignore comments silence the error and hide the bug. Debug: grep the diff for added suppression directives and require a reason.
  • Wrong toolchain. The agent runs a different compiler version than CI and gets different results. Debug: print the tool version and config path in the feedback log.

In production

Record diagnostic count per iteration and time to green. Alert when a task adds suppressions or edits build configuration, since both hide problems from later checks.

Common misconceptions

People think: A clean compile means the change is correct.

Actually: It means the code is well-typed; behaviour is still untested.

People think: More diagnostics always help.

Actually: Correlated errors mislead, so ordering and deduplication matter more than volume.

Interview angle

Order the checks by dependency and explain how diagnostics are parsed. A strong answer deduplicates cascades, treats new suppressions as suspicious and compares counts between runs. Running the compiler once at the end and reading its output as prose is the weak version, because it cannot tell a fix from a new error.

Sources