Capabilities
PageSpeed Insights Loop
What It Does
Section titled “What It Does”Runs a Google PageSpeed Insights audit on any URL, then treats the output as a to-do list rather than a report. Claude picks the top opportunity, applies a code fix, waits for the deploy, re-runs the audit, confirms the score moved, and loops. The loop only stops when the score hits the target (typically 90+ on mobile, 95+ on desktop) or no further fixable issues remain.
The point: most people run PageSpeed, see a 62, and move on. Running PSI as a loop is the difference between “I know my site is slow” and “my site is fast now.”
When To Use
Section titled “When To Use”- After any website migration or major deploy. Themes change, JS bundles change, scores drop.
- When a site feels sluggish. Start with a mobile audit on the homepage.
- As a monthly health check on the properties that matter most (TMS, MyTechSupport, All Things Handy).
- When you say: “run PageSpeed on X”, “audit X for speed”, “fix the performance on X”, “loop PSI until green on X”.
How To Invoke
Section titled “How To Invoke”Not a standalone slash command yet (see Known Gaps). Invoke conversationally:
Run a PageSpeed loop on https://themarketingshow.com until mobile is 90+Claude will:
- Run
python3 ~/apps/google-search-console/psi.py <url> --mobile - Pick the top actionable opportunity from the output
- Propose a code fix (image format, lazy loading, unused CSS removal, font preload, etc.)
- Apply the fix with user approval
- Commit, push, wait for Cloudflare or Vercel deploy to go live
- Re-run the audit
- Compare the new score
- Loop until target is met or all easy wins are exhausted
Prerequisites
Section titled “Prerequisites”| Requirement | Where |
|---|---|
| PageSpeed Insights API access | GOOGLE_PSI_API_KEY in shared-secrets.env (optional — works at lower rate limits without) |
| Source code access | James must own the code for the target site (headless WordPress, GHL-hosted sites fall back to “suggest” mode only) |
| Deploy verification | ~/apps/cc/verify-deploy.sh polls the live site until build.txt matches |
Where It Lives
Section titled “Where It Lives”- Script:
~/apps/google-search-console/psi.py - Usage:
python3 psi.py <url>for mobile + desktop, or--mobile/--desktopfor one strategy - Output modes: human-readable terminal output (default), or
--jsonfor programmatic handoff
Example Session
Section titled “Example Session”James: Run a PageSpeed loop on https://mytechsupport.com until mobile is 90+.
Claude: Baseline mobile score: 62. Top opportunities: 1. Serve images as WebP (est +15) 2. Eliminate render-blocking CSS (est +8) 3. Defer off-screen images (est +4)
Starting with #1. Proposed edit: add <picture> elements with WebP sources for /public/images/hero.png plus 7 others. Apply?James: yesClaude: [edits, commits, pushes, waits for Vercel deploy] Deploy confirmed. Re-running audit... New mobile score: 78. +16.
Next opportunity: Eliminate render-blocking CSS. Proposed edit: move critical CSS inline, defer the rest. Apply?James: yesClaude: [repeats] New mobile score: 91. Target reached.The Teaching Moment
Section titled “The Teaching Moment”This is the iteration loop at its purest. The student watches one number go up across three commits. It is the difference between Claude as a search engine (“here is your score”) and Claude as a collaborator (“here is your score, here is what I am doing about it, let me know when to stop”).
Good material for the Mastery School curriculum — not the crash course. Students need to understand CLAUDE.md, GitHub, and deploy verification before a loop this compound is meaningful.
Known Gaps / TODOs
Section titled “Known Gaps / TODOs”- No
/pagespeedslash command yet. Invoked conversationally only. A skill file in~/.claude/commands/would make the trigger phrases deterministic. - No historical benchmarks. Unlike GSC audits, PSI runs are one-shot. A benchmark DB (like
gsc-benchmarks.db) would show score trends over time. - No portfolio mode. You have to point it at one site at a time. A “loop across all my sites” pass would catch regressions.
- No fallback for GHL-hosted pages. If the code is not in a repo you control, the loop drops to suggest-only mode. Worth documenting which sites that applies to.
Related
Section titled “Related”- GSC Audit — the complementary SEO health pass; often catches the same slow pages via different signals.
- Three Scales of Editing — this loop is a concrete example of scale two (global-site edits driven by a single trigger).