The Code Quality and Performance Standard
Good code is cheap to change. Code that copies itself, keeps what it replaced and grows one file at a time gets more expensive with every fix, and so does the page it sends to a phone. This standard is how we keep both small, with people and AI writing to the same bar.
Version 1.0. Updated November 23, 2026. By Kisora Thomas, Apotome Labs.
Summary
Every codebase we ship is built from small parts with one job each, keeps one home for every helper, token and component, shares code between projects through versioned modules instead of copies, and holds nothing that nothing uses. Every page stays inside a budget for JavaScript, images, fonts and motion, and meets WCAG 2.2 level AA. A script checks these rules on every build.
Each rule carries one of three levels:
- Must. The build fails without it.
- Should. Reported by the build, and fixed when the file is next touched.
- Could. Good practice a reviewer may ask for.
The standard is reviewed every quarter, and sooner when a tool it relies on changes.
Why it matters
The cost of untidy code is rarely the untidiness. It is the fix that lands in one copy and misses the others, and the visitor who waits for script the page never uses.
- Copies drift, and drift causes bugs. A study of code clones in production systems found that inconsistent changes to clones are very frequent, and that a significant number of them are faults.1
- AI makes copying easier. An analysis of 211 million changed lines found that copy-pasted lines rose from 8.3% to 12.3% of changes between 2021 and 2024, while moved, reused code fell from 25% to under 10%.2
- Most of the web sends more than it needs. The median mobile page ships 558 KB of JavaScript, and about 44% of it goes unused while the page loads.6
We use AI in our work, and hold it to the same bar as everything else. This standard is that bar.
Principles
Ten ideas produce every rule below. When a case is not covered, we decide it from these.
- Small parts, one job each. A page composes sections, a section owns its state, a card shows one thing.
- One home for everything. One token per value, one formatter per format, one component per control. A second copy is a bug that has not happened yet.
- Share by module, never by paste. Code two projects use is a versioned module, copied in by a script and checked for drift.
- Nothing ships that nothing uses. Replaced code is deleted in the same change.
- Names say what; comments say why. A comment explains a constraint or an incident, never the code beneath it.
- Errors that matter are seen. A failed load or save reaches the person using the product.
- Few dependencies. A package must do something the platform cannot.
- Light on the visitor's device. A page sends the script, images and motion it needs, and no more.
- The machine checks it. A rule the build cannot check is a suggestion.
- AI writes to the same bar. Generated code meets every rule, with no allowance for volume.
Behind all ten is one idea from Google's engineering practice: optimize "for the reader of the code rather than the author".8
Small parts
Must: no source file over 600 lines. Content files and design tokens are exempt. Components aim for under 300 lines, pages that only compose for under 150. A file that needs divider comments to find your way around is several files, and each divider is usually a component.
Must: one folder map in every project, two levels deep at most: pages, components grouped by feature, shared primitives, composables, content, the API layer, styles and helpers. Anyone who has opened one of our projects can find their way around the next.
<template>
<HeroPanel />
<ServicesPanel />
<ProjectsPanel />
<ReviewsPanel />
<ContactPanel />
</template>Should: a name says what a file is before it is opened. Pages end in Page, sections in Panel, repeated items in Card. Component names are multi-word, as the Vue style guide requires.4
Components and styles
Must: one shape for every component. Script, then template, then scoped styles. Props and events are typed, and every list item has a key, both among the Vue style guide's essential rules.4 Actions are buttons and navigation is links, never a clickable box.
Must: styles are SCSS on design tokens. Colours, theme and anything a site owner can recolour are CSS custom properties with role names, such as surface, ink and accent, never a hue. Components hold no raw colour values. Spacing, type, radius and motion come from fixed scales. Stylesheets load with @use, because Sass deprecated @import in October 2024 and plans to remove it.3
:root {
--surface: #f7f5f0;
--ink: #141414;
--ink-rgb: 20, 20, 20;
--hair: rgba(var(--ink-rgb), 0.14);
--accent: #2f4bd8;
--space-4: 1.5rem;
}
.review-card {
padding: var(--space-4);
border: 1px solid var(--hair);
&.is-active { border-color: var(--accent); }
}Should: one primitive per control. One field component for every input type, one button, one dialog and one toast that any screen can call. A form becomes a stack of the same piece, and a fix to the field fixes every form.
One home for everything
Must: formatting has one source. Dates, money, phone numbers, escaping and URL slugs come from one shared module in every project. Before anyone writes a helper, they search for the one that exists.
Must: money is whole cents in every variable, field and API response. Dollars exist only in the formatted text a person reads.
Must: a calendar day is never treated as a moment. This is the bug that drifting copies spread most often:
A due date stored as 2026-11-23 is passed to new Date(), read as midnight UTC, and shown as Nov 22 to anyone west of London.
The shared formatter reads 2026-11-23 as a local day and shows Nov 23 everywhere. Every screen uses it, so the fix lands once.
Must: copy lives in content files, not inside components, and the API layer is one client plus one file per area, each call typed where it is made.
Shared modules
Must: code used by two projects is a versioned module. Every module lives in one private catalog, each in a folder with its own version, changelog and tests. A script copies it into a project, stamps the version, and records a fingerprint of every file. The project commits the copy, so its build needs no registry and no credentials. When a copy no longer matches its fingerprint, the build fails, and the fix goes to the module instead of drifting in one project.
| Module | What it holds |
|---|---|
| Search | Prerendering, sitemaps, robots rules, structured data |
| Editor kit | On-page editing, forms, newsletters, events, galleries, the customer portal |
| Format | Dates, money, phone numbers, escaping, slugs |
| Interface | Fields, buttons, dialogs, toasts, loaders, status and chart pieces, tokens |
| Motion | Scroll reveals, smooth scrolling, transitions, 3D fields, reduced-motion handling |
| App | The API client, sign-in and route guards, view state kept in the URL |
| Native | The shell for iOS and Android builds |
| Services | Authentication, email and server setup for our back ends |
| Quality | The checker described in section 13 |
Must: a module does nothing until it is configured. With its settings unset it sends and fetches nothing, so it is safe to add before a project goes live.
What stays bespoke. Headers, footers, heroes and pages carry each client's identity, and are written for that client. Their behaviour, such as a mobile menu or a scroll lock, comes from the modules. Their look never does.
Clean repositories
Must: nothing unused. No unused files, exports, dependencies, local variables or parameters. The build checks with Knip, which finds unused dependencies, exports and files,9 and with TypeScript's own unused-code checks.10
Must: nothing left behind. No backup or scratch files, no starter-template files, no saved web pages or data dumps, no build output, no plan documents from past work, and no commented-out code. A project's README describes that project. One-off scripts are deleted once they have run.
Must: comments say why. A comment that restates the code or narrates its history is removed.
// Helper function to make authenticated requests/**
* A value pasted into a multi-line field often arrives with a trailing
* newline. The sign-in provider answers a one-character difference with
* "client not found", which reads like a deleted client, not a typo.
*/Should: errors that matter are seen. A failed load shows an error, never an empty list that reads as "nothing here", and a failed save is never silent. Best-effort work, such as analytics or a prefetch, may fail quietly.
Line shape
Must: if it fits on one line, it is on one line. A statement, import, object, call or element that fits in 120 characters stays on one line. Past 120, it splits at the outermost bracket, one item per line. Code reads top to bottom faster when its shape follows its meaning, not a formatter's habits.
const filter = useViewState(
'status',
'all',
{ valid: ['all', 'sent'] },
)
const filter = useViewState('status', 'all', { valid: ['all', 'sent'] })The rules are our own, checked by our own script. No semicolons, single quotes in scripts, two-space indent.
Performance budgets
A performance budget is "a set of limits imposed on metrics that affect site performance".5 Ours are checked on every build. The Core Web Vitals targets that these budgets serve are set in our SEO and AEO Standard.12
| Budget | Should | Must |
|---|---|---|
| JavaScript on a first visit to a public page (compressed) | 100 KB | 170 KB |
| JavaScript on a first visit to an app or portal (compressed) | 250 KB | 350 KB |
| Any image served | 300 KB | 500 KB |
| The largest image above the fold | 250 KB | |
| Web fonts on a first visit | 2 families, 4 files | |
| 3D canvases on one page | 1 |
- Must: heavy features load when needed. 3D, maps, charts and editors are never in a public page's first download, and a visitor never downloads the admin.
- Must: images reserve their space with a width and height, ship as AVIF or WebP at the sizes the page shows, and load lazily below the fold.
- Must: motion respects the visitor. Every animation honours the reduced-motion setting,11 and a 3D scene pauses when it is off screen and shows a still image when motion is reduced.
- Should: one animation loop per page, not a scroll listener for every element.
Accessibility
Our target is WCAG 2.2 at level AA, the W3C Recommendation published on 12 December 2024.7 The engineering rules that get us there are part of this standard, so our Accessibility Statement only promises what the build and our launch checks verify.
- Must: a language on every page, one main heading, headings in order, and landmarks for header, navigation, main content and footer.
- Must: a visible label on every field, alternative text on every image, and a word beside every colour that carries meaning.
- Must: everything works from a keyboard, with a visible focus ring. Dialogs keep focus inside, close on Escape, and return focus where it was.
- Must: text contrast of at least 4.5 to 1. Our colour tokens are chosen to pass, so components built on them pass too.
- Should: touch targets of at least 24 by 24 pixels, and a pause control on anything that moves on its own for more than five seconds.
AI-assisted work
We use AI in our work, and every rule above applies to it. These habits are the ones that separate careful work from filler, and they are written into every project's instructions so each session starts with them.
- Read first. The surrounding code, its neighbours and the shared modules, before writing anything.
- Search before writing. For an existing helper, component or token. Most duplication starts as a new copy of something that already existed.
- Stay in scope. A fix to a button does not restructure the page. A real defect in the same feature is fixed in the same pass.
- No filler. No narrating comments, no options nothing uses, no compatibility layers without callers, no fallback chains for values that cannot be missing, no summary documents.
- Delete what you replace, in the same change.
- Say what was verified. A passing local build is not proof that a deploy works.
How we check
One script runs at the end of every build, on the same servers that publish the site, and writes a report beside the search report. A Must failure fails the build. Existing projects start in report mode while they are brought up to standard, then switch to enforce mode for good; new projects enforce from their first commit.
| Check | Passes when |
|---|---|
| File size | No source file over 600 lines |
| Unused code | No unused files, exports, dependencies, locals or parameters |
| Duplicated helpers | No formatting or escaping helper defined outside the shared module |
| Shared modules | Every copied file matches its recorded fingerprint |
| Styles | No raw colour values outside the design tokens |
| Leftovers | No backup, scratch, starter-template or build-output files |
| JavaScript | The first visit to every public page is within budget |
| Images | No image over 500 KB |
The report also tracks file sizes and page weight over time, and prints any number that moved by more than 10% since the last build, so drift shows up before it crosses a line. Before launch we add a keyboard pass, a contrast check on the colour tokens, and the launch checks in our SEO and AEO Standard.
References
- 1Do Code Clones Matter?Juergens, Deissenboeck, Hummel and Wagner, ICSE 2009
- 2AI Copilot Code Quality: 2025 Look Back at 12 Months of DataGitClear
- 3@import is DeprecatedSass
- 4Style Guide: Priority A, EssentialVue.js
- 5Performance budgets 101web.dev
- 6Web Almanac 2024: JavaScriptHTTP Archive
- 7Web Content Accessibility Guidelines (WCAG) 2.2W3C
- 8Software Engineering at Google: Style Guides and RulesAbseil
- 9Knip: declutter your JavaScript and TypeScript projectsKnip
- 10TSConfig reference: noUnusedLocals and noUnusedParametersTypeScript
- 11prefers-reduced-motionMDN
- 12Web Vitalsweb.dev