如何用 Hermes Agent 建立安全的定期 PageSpeed SEO 稽核 Skill

為 Hermes Agent 建立唯讀 PageSpeed 稽核,保留原始證據,並在人工審核後才啟用定期執行。

如何用 Hermes Agent 建立安全的定期 PageSpeed SEO 稽核 Skill

Hermes Agent 適合重複執行界線清楚的測量,而不適合自行修復正式網站。本教學建立唯讀 PageSpeed Skill:它檢查公開頁面、保存原始 JSON、產生有日期的報告;先驗證一次手動基線,之後才可以由人決定是否排程。

PageSpeed 分數是某個 URL、某個時間點的 Lighthouse 實驗室結果。Chrome UX Report(CrUX)只有在 Google 回傳時才是實際使用者欄位資料。兩者都不是代理修改 CMS、程式碼庫或部署的授權。

將本文交給 Hermes 安裝 Skill

Read [THIS ARTICLE URL] and install the Hermes skill described there.

First inspect my local Hermes configuration and project guidance. Explain the
destination before writing. Create only:
~/.hermes/skills/pagespeed-seo-baseline/SKILL.md
~/.hermes/skills/pagespeed-seo-baseline/scripts/pagespeed_baseline.py

Copy the complete code blocks from the article. Verify Python syntax and report
the two paths. Explain how to configure PAGESPEED_API_KEY locally, but never
ask for or display its value. Do not run PageSpeed, schedule work, use CMS,
hosting or repository credentials, edit another skill, or change a live site.
Stop after installation and verification.

若 Hermes 無法讀取公開頁面,請把本文的SKILL.md和 runner 區塊貼到同一段對話。目錄應位於~/.hermes/skills/,而不是網站專案內:這是獨立監測工具。

完成條件:基線在前,排程在後

項目

本流程提供的結果

對象

在本機或隔離環境使用 Hermes 的 SEO、開發與技術行銷人員

成果

/pagespeed-seo-baseline Skill、raw JSON、Markdown 報告與經檢閱才可啟用的排程

輸入

公開 URL、精選 URL 清單、或具樣本上限的 sitemap

前置條件

Hermes Agent、Python 3.9+、PageSpeed Insights API 金鑰與報告目錄

完成定義

URL、策略、原始結果、欄位資料範圍均被記錄,且沒有網站變更

發布檢查應使用精選 URL。Sitemap 樣本只能比較不同範本的模式,不能宣稱已測試全站;程式應每個第一層路徑取一個 URL,再依 sitemap 順序補到上限,也不驗證孤立頁、canonical 或可索引性。

只在安全環境設定金鑰

在 Google Cloud 啟用 PageSpeed Insights API 並建立受限制金鑰。值只存在本機祕密機制或啟動 Hermes 的環境,絕不放進 Skill、報告、聊天訊息或 Git。

export PAGESPEED_API_KEY="replace-with-your-key"

初次稽核建議使用專用受限制金鑰的本機執行。Docker、遠端終端或沙箱需要金鑰時,應明確評估其中的程式能讀取該金鑰;先確認目前 API 額度,再決定頻率。

SKILL.md 的安全契約

建立以下結構:

~/.hermes/skills/pagespeed-seo-baseline/
SKILL.md
scripts/
pagespeed_baseline.py

---
name: pagespeed-seo-baseline
description: Create a read-only PageSpeed Insights baseline for public URLs or a controlled sitemap sample. Save raw JSON and a dated report. Never edit a site, repository, CMS, hosting configuration, or deployment.
required_environment_variables:
- PAGESPEED_API_KEY
---

# PageSpeed SEO Baseline

## Boundaries

- Read `PAGESPEED_API_KEY` from the runtime environment only. Never print, message, save, or commit it.
- Do not use browser logins, SSH, CMS, hosting, Git write, deployment, or website-editing tools.
- Run both `mobile` and `desktop`; save every successful response under `raw/` before summarizing it.
- Treat Lighthouse as lab data. Treat `loadingExperience` as page-level CrUX and `originLoadingExperience` as origin-level CrUX only when returned.
- For `--sitemap`, state the sampling rule and excluded URLs. Prefer `--urls-file` for important templates.
- Never create or change a schedule before a human reviews one successful manual report and explicitly approves scope, cadence, report path, and delivery destination.

Runner 應只用標準函式庫,支援--url、每行一個 URL 的--urls-file及 XML sitemap;請求performanceaccessibilitybest-practicesseo,並為 mobile 和 desktop 保存回應。429 和 5xx 可有限重試,但不得隱藏失敗。

mkdir -p "$HOME/hermes-pagespeed-reports"
cd ~/.hermes/skills/pagespeed-seo-baseline
python3 scripts/pagespeed_baseline.py \
--url "https://www.example.com/" \
--out "$HOME/hermes-pagespeed-reports/homepage-baseline"

預期會產生report.mdsummary.jsonraw/001-mobile.jsonraw/001-desktop.json。檢查要求 URL、最終 URL、策略、時間戳記與非空 JSON。403 時確認 API 啟用和金鑰限制;sitemap 失敗時可以用小型--urls-file排查,但不可默默改變稽核範圍。

正確解讀 PageSpeed 資料

資料

代表意義

不應宣稱

Lighthouse 分數、LCP、INP、CLS、TBT

指定頁面與策略的一次實驗室測量

所有使用者都有這種體驗

loadingExperience

回傳時的頁面或 URL 模式 CrUX

整個網域的結果

originLoadingExperience

回傳時的網域 CrUX

每個範本都相同

沒有 CrUX

此回應沒有合格欄位資料

沒人造訪此頁

區分單次 Lighthouse 實驗室測量、頁面層級 CrUX 與網域層級 CrUX 的圖。

重複出現的大型圖片機會可作為調查圖片管線的理由,但不能自行指示 Hermes 壓縮資產、延後腳本或修改快取標頭。

只有可信的報告後才排程

未驗證的代理工作排程化,只會更頻繁地產生錯誤證據。和網站負責人檢閱第一份報告後,定義精確 URL 範圍或 sitemap 上限、頻率、保存期限與交付位置。

手動基線、人為核准與每週報告的 Hermes 安全排程流程。

Hermes 必須先顯示排程、命令、環境假設、報告位置和失敗通知;使用已核准的手動範圍,將輸出寫到$HOME/hermes-pagespeed-reports/weekly/YYYY-MM-DD/,保存 90 天,只向已核准擁有者交付report.mdsummary.json,等待明確啟用確認。

將報告交給獨立修復簡報

修復要求只應產生簡報:列出受影響 URL、實驗室或欄位證據、可能機制、開發負責人、預期效益、風險、測試方法、回滾訊號與假設。不能編輯程式碼、內容、設定或部署。

驗證清單

  • [ ] Skill 在~/.hermes/skills/pagespeed-seo-baseline/,名稱和目錄一致。
  • [ ] PAGESPEED_API_KEY已宣告但不存在檔案、聊天或報告。
  • [ ] 手動報告有 mobile/desktop、raw JSON、最終 URL 與清楚範圍。
  • [ ] 只有回傳時才將 CrUX 標為頁面或網域層級。
  • [ ] 排程均經人檢閱,且只能寫入已核准的報告位置。
  • [ ] 稽核 Skill 沒有 CMS、程式碼庫、主機或部署權限。

常見問題

Hermes 可以檢查 sitemap 的每個頁面嗎?

可以處理更多 URL,但不必然有用或安全。PageSpeed 會消耗額度,sitemap 常混合範本、封存頁與低優先內容。先從每個範本一頁或受控分層樣本開始,只有在結果需要時才擴大。

Author: Julian Mercer,Auspia Technical SEO Practitioner。Julian 撰寫保留清楚證據軌跡的技術工作流程,協助團隊在正式變更前檢閱自動化 SEO 發現。

探索此主題

繼續閱讀相同的成長脈絡