agentleFS
bokuwalilybokuwalily/claude-code-skills/skills/gsc-cli-automation/SKILL.md

gsc-cli-automation

Skill0 starsChanged 5 months agoMITView on GitHub

Google Search Consoleをコマンドで操作したい時(サイトマップ送信・検索パフォーマンス取得・URLインデックス状態の検査)。サービスアカウントが弾かれる時のADC(ユーザー認証)フォールバック手順込み。

  • Installs packages

The file

Files
SKILL.md

GSC をCLIで操作(googleapis + ADC)

ツール実体: ~/gsc-automation/gsc.mjs()。新規セットアップ時の手順。

Procedure

  1. 前提: gcloud(brew install --cask google-cloud-sdk)、node、googleapis。
  2. GCPプロジェクト作成+Search Console API有効化:
    gcloud auth login                              # ブラウザ同意(ユーザー)
    PID="gsc-auto-$RANDOM$RANDOM"
    gcloud projects create "$PID" --name="GSC Automation"
    gcloud config set project "$PID"
    gcloud services enable searchconsole.googleapis.com
  3. 認証はADC(ユーザー)が確実(本人が全プロパティ所有なら):
    gcloud auth application-default login \
      --scopes=openid,https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/webmasters
    gcloud auth application-default set-quota-project "$PID"
    googleapis 側は new google.auth.GoogleAuth({ scopes:['.../webmasters'] })(keyFile無し)でADCを自動使用。
  4. 動作確認: node gsc.mjs sites で所有プロパティが出れば成功。
  5. node gsc.mjs sync(config.jsonの全sitemap送信)/ report / inspect を利用。

Pitfalls

  • サービスアカウント方式はGSCの「ユーザー追加」がSAメールを弾く事がある("メールアドレスが見つかりませんでした")。作りたて伝播遅延もあるが、本人所有ならADCユーザー認証の方が確実で各プロパティへのSA追加作業も不要。
  • ADCは quota project 未設定だとAPIが quota エラー→set-quota-project 必須。
  • gcloud iam service-accounts keys create はSA作成直後だとNOT_FOUND(伝播待ち8秒で再試行)。
  • Indexing APIで一般ページのインデックス強制は禁止(求人/動画限定・スパム判定)。やれるのはsitemap送信+クロール待ち+URL検査(読み取り)。
  • siteUrl はURLプレフィックス型なら末尾スラッシュ必須。
  • GSC未登録プロパティはAPI操作不可("sufficient permission"エラー)→先にプロパティ追加+所有権確認(HTMLファイル方式が楽)。
  • 秘密: SAキー/ADC credentialは絶対コミットしない。~/.config/ 配下・chmod 600。

Verification

node gsc.mjs sites で siteOwner 表示。inspect <site> <page> で coverage=Submitted and indexed ならインデックス済確認。

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.