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 syncAvailable commands
| Command | Description |
|---|---|
init | Interactive setup wizard — configures environment variables and tests connections |
sync | Sync GSC data, match URLs, detect decay, and generate tasks |
list-sites | List all GSC properties accessible to the service account |
diagnose | View diagnostics for unmatched URLs or live-test a single URL against Sanity |
doctor | Validate environment, credentials, database, and Sanity connectivity |
Global options
pagebridge --help # Show help for all commands
pagebridge --version # Show package versionAll 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:
- Loads environment variables and initializes GSC, database, and Sanity clients
- Finds or creates the gscSite document in Sanity
- Fetches search analytics from GSC (90 days to 3 days ago by default)
- Matches GSC URLs to Sanity documents by slug
- Stores unmatched URL diagnostics
- Optionally checks Google index status (
--check-index) - Detects decay patterns and creates refresh tasks (unless
--skip-tasks) - Writes performance snapshots to Sanity for the Studio UI