agentleFS
CloudflareKnown publishercloudflare/speedtest/AGENTS.md

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
  1. Very specific:

    Test files are written in TypeScript (.test.ts).

    line 35
  2. Distinctive:

    All changes must go through a pull request.

    line 98
  3. Distinctive:

    Before editing that workflow:

    line 105
  4. Very specific:

    Use gpt-5.6-terra, not gpt-5.6-sol: sol returns 400 for function tools whenever reasoning_effort is set.

    line 109

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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 mode

Tests

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 by tsconfig.json: lib is ["ES2022", "DOM", "DOM.Iterable"] and @types/node is deliberately absent, so fs, Buffer, process and require() do not typecheck. There is no browser-target (browserslist) check.
  • Zero runtime dependencies — do not add npm dependencies.
  • ESM-only ("type": "module") — use import/export, never require().
  • 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")
  • printWidth is 80 — set explicitly, since oxfmt defaults to 100
  • Private class fields use #field syntax 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. Exports LoggingMeasurementEngine (default), which wraps MeasurementEngine and logs results to speed.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 via PerformanceResourceTiming
    • PacketLossEngine/ — WebRTC TURN relay for UDP packet loss
    • LoadNetworkEngine/ — parallel fetch load generator
    • ReachabilityEngine/ — simple fetch with timeout
  • src/Results/ — aggregation, stats (percentile, jitter), and AIM scoring.
  • src/utils/ — small helpers: math (sum, avg, percentile, scaleThreshold) and authorization (attaches the authorizationToken as an Authorization header to the requests that carry it, gated on authorizationEnabled and withheld from non-HTTPS endpoints unless allowInsecureAuthorizationToken is set). The whole authorization feature is experimental/unstable — options are marked 🧪 in the README and @experimental in their JSDoc.
  • example/turn-worker/ — separate Cloudflare Worker sub-project with its own package.json and 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:
    1. Go to Actions > "Create Release PR" > pick patch/minor/major > Run.
    2. The workflow creates a releases/v* PR with the version bump.
    3. A team member reviews and merges the release PR.
    4. On merge, the publish workflow auto-creates a git tag and publishes to npm.
  • 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/* returns authentication_error for any model id. OpenAI and Workers AI both work.
  • Use gpt-5.6-terra, not gpt-5.6-sol: sol returns 400 for function tools whenever reasoning_effort is set.
  • Comment-triggered runs execute main's copy of the workflow, since issue_comment is a repository-level event. Only pull_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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.