CLI Reference

The @pagebridge/cli package provides the pagebridge command for syncing GSC data, listing sites, and diagnosing URL matching issues.

Installation

# As a dev dependency
pnpm add -D @pagebridge/cli

# Or use from the monorepo
pnpm sync
bash

Available commands

CommandDescription
initInteractive setup wizard — configures environment variables and tests connections
syncSync GSC data, match URLs, detect decay, and generate tasks
list-sitesList all GSC properties accessible to the service account
diagnoseView diagnostics for unmatched URLs or live-test a single URL against Sanity
doctorValidate environment, credentials, database, and Sanity connectivity

Global options

pagebridge --help     # Show help for all commands
pagebridge --version  # Show package version
bash

All commands include usage examples in their --help output.

Environment

The CLI loads environment variables from a .env file in the current directory. Environment loading is deferred until a command actually runs — commands like --help and --version do not read .env files. All required environment variables must be set before running commands that interact with external services.

Sync workflow

The sync command runs the full PageBridge pipeline:

  1. Loads environment variables and initializes GSC, database, and Sanity clients
  2. Finds or creates the gscSite document in Sanity
  3. Fetches search analytics from GSC (90 days to 3 days ago by default)
  4. Matches GSC URLs to Sanity documents by slug
  5. Stores unmatched URL diagnostics
  6. Optionally checks Google index status (--check-index)
  7. Detects decay patterns and creates refresh tasks (unless --skip-tasks)
  8. Writes performance snapshots to Sanity for the Studio UI