Skip to content

heymegabyte/agent-skills / 08-deploy-and-runtime-verification

deploy-and-runtime-verification

Unverified

MANDATORY deploy after every code change. Typecheck → deploy → purge CDN → E2E on production → visual verify → fix-forward loop. Workers Builds native CI/CD, D1 Time Travel PIT recovery, D1→R2 long-term backups, wrangler rollback, wrangler secrets management, structured observability, cross-browser smoke tests, rollback procedures, and GitHub auto-configuration.

FileKindSize
SKILL.mdskill md5.6 KB
backup-and-disaster-recovery.mdmarkdown2.7 KB
changelog-and-releases.mdmarkdown5.3 KB
ci-cd-pipeline.mdmarkdown7.1 KB
critical-css.mdmarkdown4.7 KB
font-subsetting.mdmarkdown4.5 KB
gh-fix-ci.mdmarkdown3.5 KB
launch-day-sequence.mdmarkdown5.2 KB
pipeline-health-check.mdmarkdown4.5 KB
r2-lifecycle.mdmarkdown5.6 KB
service-worker.mdmarkdown9.7 KB
uptime-and-health.mdmarkdown6.5 KB

font-subsetting.md

View on GitHub
---
name: "Font Subsetting"
version: "1.1.0"
updated: "2026-04-23"
description: "glyphhanger → WOFF2 → R2 self-host. Sora, Space Grotesk, JetBrains Mono subset to Latin+common. Preload critical, font-display:swap. Budget ≤100KB."
---

# Font Subsetting

## glyphhanger Subset Command

```bash
# Install
npm install -g glyphhanger
pip install fonttools brotli zopfli

# Subset to Latin + common symbols (covers 99%+ of English content)
glyphhanger --whitelist=US_ASCII --formats=woff2 --subset=Sora-Regular.ttf
glyphhanger --whitelist=US_ASCII --formats=woff2 --subset=Sora-Medium.ttf
glyphhanger --whitelist=US_ASCII --formats=woff2 --subset=SpaceGrotesk-SemiBold.ttf
glyphhanger --whitelist=US_ASCII --formats=woff2 --subset=SpaceGrotesk-Bold.ttf
glyphhanger --whitelist=US_ASCII --formats=woff2 --subset=JetBrainsMono-Regular.ttf

# Output: *-subset.woff2 files (typically 60-80% smaller)

# For sites with specific character needs, crawl first:
glyphhanger https://example.com --formats=woff2 --subset=*.ttf
```

## @font-face Declarations

```css
/* src/styles/fonts.css — self-hosted from R2 */
@font-face {
  font-family: 'Sora';
  src: url('/fonts/Sora-Regular-subset.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-007F, U+00A0-00FF, U+2000-206F, U+2190-21FF, U+2200-22FF;
}

@font-face {
  font-family: 'Sora';
  src: url('/fonts/Sora-Medium-subset.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-007F, U+00A0-00FF, U+2000-206F;
}

@font-face {
  font-family: 'Space Grotesk';
  src: url('/fonts/SpaceGrotesk-SemiBold-subset.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-007F, U+00A0-00FF;
}

@font-face {
  font-family: 'Space Grotesk';
  src: url('/fonts/SpaceGrotesk-Bold-subset.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-007F, U+00A0-00FF;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Regular-subset.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-007F, U+00A0-00FF;
}
```

## Preload Critical Fonts (HTML head)

```html
<!-- Preload only above-fold fonts (body + heading) — max 2-3 -->
<link rel="preload" href="/fonts/Sora-Regular-subset.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/fonts/SpaceGrotesk-Bold-subset.woff2" as="font" type="font/woff2" crossorigin>
```

`crossorigin` attribute required even for same-origin fonts (CORS fetch mode). Only preload fonts used above the fold — preloading all fonts wastes bandwidth and delays LCP.

## @fontsource Alternative (pre-subset, tree-shakeable)

```bash
pnpm add @fontsource-variable/sora @fontsource-variable/space-grotesk @fontsource/jetbrains-mono
```

```typescript
// In Angular styles.css or main.ts
import '@fontsource-variable/sora/wght.css';           // Variable font, all weights
import '@fontsource-variable/space-grotesk/wght.css';
import '@fontsource/jetbrains-mono/400.css';            // Single weight
```

@fontsource ships WOFF2-only, pre-subset to Latin by default. Faster setup than manual glyphhanger. Trade-off: less control over exact subset, slightly larger than custom subset.

## R2 Upload + Cache Headers

```bash
# Upload subset fonts to R2 with immutable caching
for f in fonts/*-subset.woff2; do
  wrangler r2 object put "assets/fonts/$(basename $f)" --file "$f" \
    --content-type "font/woff2" \
    --cache-control "public, max-age=31536000, immutable"
done
```

## Worker Font Serving (if not using R2 public bucket)

```typescript
app.get('/fonts/:filename', async (c) => {
  const object = await c.env.R2.get(`fonts/${c.req.param('filename')}`);
  if (!object) return c.notFound();
  return new Response(object.body, {
    headers: {
      'Content-Type': 'font/woff2',
      'Cache-Control': 'public, max-age=31536000, immutable',
      'Access-Control-Allow-Origin': '*',
    },
  });
});
```

## Size Budget

- **Target per font file** — 15-25KB (subset WOFF2)
- **Total all fonts** — ≤100KB

### Typical breakdown

- Sora 400 (~18KB)
- Sora 500 (~18KB)
- Space Grotesk 600 (~16KB)
- Space Grotesk 700 (~16KB)
- JetBrains Mono 400 (~20KB)
- **Total: ~88KB**

If over budget: drop least-used weight, use `font-synthesis: weight` for minor weight differences.

Never use Google Fonts CDN (privacy, extra DNS lookup, no HTTP/3 multiplexing with your origin). Self-host always.
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall