AI AgentTypeScriptCI/CDCode Quality

How to validate AI-generated code: five layers in this site’s build

···5 min read

Revised September 16, 2026: the earlier article did not supply records for its tenfold claims, specific PR file and test counts, or claimed failure frequency. Those claims have been removed. It also described proposed compiler settings as universally enabled here. This version distinguishes the checked-in configuration from recommendations.

This site renders articles twice: React for visitors, and generated HTML for readers that do not execute JavaScript. Seeing new text in a browser does not establish that it appears in the initial response. That concrete failure boundary explains why the build needs output checks.

Layer one: what the compiler actually checks

The current tsconfig.app.json enables strict, noUnusedLocals, noUnusedParameters, erasableSyntaxOnly, noFallthroughCasesInSwitch, and noUncheckedSideEffectImports. It does not enable noUncheckedIndexedAccess or exactOptionalPropertyTypes. Those additional options should not be reported as existing controls.

json
{
  "strict": true,
  "noUnusedLocals": true,
  "noUnusedParameters": true,
  "erasableSyntaxOnly": true,
  "noFallthroughCasesInSwitch": true,
  "noUncheckedSideEffectImports": true
}

The latter options may be useful when reviewing dynamic indexing and optional properties, but adoption has a migration cost in an existing project. Type assertions can bypass some checks, and external JSON still needs runtime validation. Successful compilation is not evidence that the data is correct.

Layer two: configuration is not execution

The ESLint configuration extends recommended JavaScript, TypeScript, React Hooks, and React Refresh settings. There is an npm run lint command, but npm run build does not invoke it. Having a configuration file does not establish that every deployment passed its checks.

A mandatory rule needs an execution path, a decision about warnings, and a process for exceptions. A claim that all any types are prohibited is incomplete without checking the actual rule, scope, and existing failures.

Layer three: inspect the delivered HTML

The build generates and validates article data, runs TypeScript and Vite, creates localized and prerendered entrypoints. It then checks content, publisher scope, and the OKF knowledge directory. check-prerendered-html.mjs reads the resulting files to detect missing routes, empty main content, and incorrect H1 counts. It examines the output rather than only the source component.

bash
npm run articles:generate
npm run build
# The three final output checks
node scripts/check-prerendered-html.mjs
node scripts/check-publisher-scope.mjs
node scripts/check-okf.mjs

The content-length check catches empty shells. It is neither an editorial quality score nor an AdSense word-count requirement. Human review is still needed to decide whether a page answers its reader’s question.

Layer four: make cross-page rules fail visibly

check-publisher-scope.mjs compares the sitemap, canonicals, noindex policy, and advertising scripts. Article pages expect one AdSense script; other pages should not load it. This is this site’s chosen scope, not a universal Google requirement.

Test the guard with a counterexample: add an advertising script to the homepage in a disposable build copy, then rerun the check. It should report advertising outside an article page. The download includes the checker source and reproduction steps. Do not inject faults into production.

Example: what npm run build actually runs

Part of the checks above sits on two lines of this site's package.json. Line 13, prebuild, runs generate-article-artifacts.mjs first. npm runs a script with a pre prefix before the script of the same name. Line 14, build, then chains six commands with &&.

Diagram: the seven steps of npm run build chained from left to right, each with the error it blocks and its file and line; lint and test listed apart as not in the build
The actual build order on this site. Based on package.json:13-17 and the check scripts (read 2026-11-04). Diagram drawn by KeepOnFirst.

The npm documentation says that a script exiting with a code other than 0 aborts the process. && also runs the next command only after the previous one succeeds. If any check throws, the later steps do not run and the build fails.

StepFailure condition (excerpt)Source
Article data (prebuild)Duplicate slug, missing English translation, invalid date, source URL not http or httpsscripts/lib/collect-article-data.mjs:108-110, 142, 158, 186, 200
tsc -bType errors under strict and the other tsconfig optionstsconfig.app.json:21-26
check-prerendered-htmlFewer than 120 visible characters, or not exactly one H1scripts/check-prerendered-html.mjs:82-83
check-publisher-scopeAdSense outside an article page, or a wrong script count on an articlescripts/check-publisher-scope.mjs:84, 92
check-okfknowledge/ or the public /okf/ breaks the OKF rulesscripts/check-okf.mjs:49-52, 54-72, 106-108
What each step blocks (this site's repo, 2026-11-04)

Two scripts are not in the chain: lint on line 16 and test on line 17. npm test runs the files under tests/, but build does not call it. A passing build proves the five steps above passed. It does not prove that lint or the tests passed.

Adding them to the build is a separate decision. Each addition is one more gate that can block a deployment and one more rule to maintain. Without it, someone must remember to run them before a push. Write that tradeoff down. Do not let an AI change settle it in passing.

This list also goes out of date. check-okf.mjs joined the build on 2026-10-17 (commit 2d4df10). The September version of this article named only two final checks. This revision corrects that.

The three rules an OKF directory must meet: “How to write an OKF bundle”.

Layer five: review the tests as well

Tests should encode requirements or existing contracts, not merely restate the current implementation. For example, the expected behavior for division by zero must be decided before rewriting a test to accept whatever the implementation returns. This is an illustrative example, not a recovered incident log.

Human review still needs to examine failure paths, compatibility with old data, duplicated logic, and changes to acceptance criteria. An HTML checker can catch advertising in the wrong place; it cannot decide whether a review has enough evidence.

Which decisions stay with a person: “Why I stopped asking AI to build the whole app”.Download the site verification materials and reproduction steps

Sources