speedtest
AGENTS.md749 starsChanged 3 months agoMITView on GitHub
Browser-side TypeScript library (@cloudflare/speedtest) that measures connection quality against Cloudflare's edge. Powers speed.cloudflare.com. Uses Vitest with two test projects: - Unit tests (tests/unit/**/*.test.ts) — pure function tests for utils, config, and Results. Run in Node, no browser needed. Fast. - E2E tests (tests/e2e/*.test.ts) — runs a realistic speed test in a real Chromium browser via Vitest Browser Mode + Playwright. Tests the full library integration (fetch, PerformanceResourceTiming, module loading) with multiple measurement phases (latency, download, upload), loaded latency, AIM scoring,…
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
We split this AGENTS.md into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 35
Test files are written in TypeScript (.test.ts).
- Distinctive: line 98
All changes must go through a pull request.
- Distinctive: line 105
Before editing that workflow:
- Very specific: line 109
Use gpt-5.6-terra, not gpt-5.6-sol: sol returns 400 for function tools whenever reasoning_effort is set.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Browser-side TypeScript library (@cloudflare/speedtest) that measures
connection quality against Cloudflare's edge. Powers speed.cloudflare.com.
Commands
pnpm install # install deps
pnpm build # tsdown → dist/speedtest.js (ESM) + auto-generated .d.ts
pnpm dev # tsdown watch mode
pnpm lint # oxlint + oxfmt --check + tsc
pnpm lint:oxlint # oxlint only
pnpm lint:oxfmt # oxfmt --check (format gate, no writes)
pnpm lint:tsc # tsc type check
pnpm format # oxlint --fix && oxfmt (writes in place)
pnpm test # run all tests (unit + e2e)
pnpm test:unit # run unit tests only (fast, no browser)
pnpm test:e2e # run e2e tests only (Playwright, needs Chromium)
pnpm test:watch # run tests in watch modeTests
Uses Vitest with two test projects:
- Unit tests (
tests/unit/**/*.test.ts) — pure function tests for utils, config, and Results. Run in Node, no browser needed. Fast. - E2E tests (
tests/e2e/*.test.ts) — runs a realistic speed test in a real Chromium browser via Vitest Browser Mode + Playwright. Tests the full library integration (fetch, PerformanceResourceTiming, module loading) with multiple measurement phases (latency, download, upload), loaded latency, AIM scoring, and raw data point validation. Packet loss is skipped (CORS limitation).
Test files are written in TypeScript (.test.ts). Source is also TypeScript.
To run e2e tests locally, install Chromium first: npx playwright install chromium
Key constraints
- Browser-only — code uses
fetch,PerformanceResourceTiming,RTCPeerConnection,performance.now(). Never introduce Node.js-only APIs. Enforced bytsconfig.json:libis["ES2022", "DOM", "DOM.Iterable"]and@types/nodeis deliberately absent, sofs,Buffer,processandrequire()do not typecheck. There is no browser-target (browserslist) check. - Zero runtime dependencies — do not add npm dependencies.
- ESM-only (
"type": "module") — useimport/export, neverrequire(). - TypeScript — source is TypeScript with
strict: true. Declarations (.d.ts) are auto-generated by tsdown from the source.
Style
oxlint + oxfmt (.oxlintrc.json, .oxfmtrc.json) run on commit via
lint-staged (Husky pre-commit hook), and in CI via pnpm lint.
- No trailing commas (
trailingComma: "none") - Single quotes, no parens on single-param arrows (
arrowParens: "avoid") printWidthis 80 — set explicitly, since oxfmt defaults to 100- Private class fields use
#fieldsyntax throughout
Markdown and YAML are excluded from oxfmt (ignorePatterns): Prettier never
covered them, and formatting them now would rewrite the README config table and
re-indent every workflow.
Architecture
src/index.ts— entrypoint. ExportsLoggingMeasurementEngine(default), which wrapsMeasurementEngineand logs results tospeed.cloudflare.com/__results.src/config/— default config and AIM scoring thresholds.src/engines/— sub-engines for each measurement type:BandwidthEngine/— HTTP fetch-based download/upload viaPerformanceResourceTimingPacketLossEngine/— WebRTC TURN relay for UDP packet lossLoadNetworkEngine/— parallel fetch load generatorReachabilityEngine/— simple fetch with timeout
src/Results/— aggregation, stats (percentile, jitter), and AIM scoring.src/utils/— small helpers: math (sum,avg,percentile,scaleThreshold) andauthorization(attaches theauthorizationTokenas anAuthorizationheader to the requests that carry it, gated onauthorizationEnabledand withheld from non-HTTPS endpoints unlessallowInsecureAuthorizationTokenis set). The whole authorization feature is experimental/unstable — options are marked 🧪 in the README and@experimentalin their JSDoc.example/turn-worker/— separate Cloudflare Worker sub-project with its ownpackage.jsonand Prettier config; not part of the library build, and excluded from oxlint and oxfmt.
PRs and releases
- PRs target
main. Branch protection requires 1 approval and CI to pass. - CI runs install, build, then oxlint / format check / typecheck as separate steps, on Node 22.x and 24.x.
- CI also runs unit tests (
pnpm test:unit) and e2e tests (pnpm test:e2e). - Releases are manual, not automatic per PR:
- Go to Actions > "Create Release PR" > pick
patch/minor/major> Run. - The workflow creates a
releases/v*PR with the version bump. - A team member reviews and merges the release PR.
- On merge, the publish workflow auto-creates a git tag and publishes to npm.
- Go to Actions > "Create Release PR" > pick
- Do NOT push directly to
main— the branch ruleset blocks direct pushes. All changes must go through a pull request.
AI review (Bonk)
.github/workflows/bonk.yml reviews PRs automatically on open, and on demand
when someone with write access comments /bonk.
Before editing that workflow:
- The gateway's Anthropic key is invalid —
anthropic/*returnsauthentication_errorfor any model id. OpenAI and Workers AI both work. - Use
gpt-5.6-terra, notgpt-5.6-sol: sol returns 400 for function tools wheneverreasoning_effortis set. - Comment-triggered runs execute
main's copy of the workflow, sinceissue_commentis a repository-level event. Onlypull_request: [opened]uses the branch copy, and it does not fire on pushes to an open PR — so verifying a change to this file means opening a fresh PR.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

