google-accounts
Use when setting up, managing, or switching between Google CLI account contexts — scaffolds google-cli.json, adds client contexts, validates auth, and switches active context across gogcli, goplaces, gaql-cli, and gcloud.
| Model | Source |
|---|---|
| sonnet | pack: google-cli |
Full Reference
Google Accounts
Section titled “Google Accounts”Unified multi-account context management for the google-cli pack. Manages google-cli.json at the project root — named contexts that map to per-tool account settings. The GOOGLE_CLI_CONTEXT env var overrides the active context at runtime. Four modes: setup (first-time scaffold), add (new client context), check (validate all auth), switch (change active context).
Mandatory Announcement — FIRST OUTPUT before anything else:
┏━ ⚡ google-accounts ━━━━━━━━━━━━━━━━━━━━━━━━━━━┓┃ [one-line description of what mode/action] ┃┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛No exceptions. Box frame first, then work.
Quick Reference
Section titled “Quick Reference”| Item | Value |
|---|---|
| Config file | google-cli.json (project root) |
| Env override | GOOGLE_CLI_CONTEXT |
| Tools covered | gogcli, goplaces, gaql-cli/mcc-gaql, gcloud |
| Credentials | Always env:VAR_NAME, never raw values |
Reference Index
Section titled “Reference Index”| I want to… | File |
|---|---|
| Understand google-cli.json schema, field reference | reference/schema.md |
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Phase 1: SETUP
Section titled “Phase 1: SETUP”Triggered by: first-time use, “set up google accounts”, no google-cli.json exists.
-
Detect installed tools:
Terminal window which gog # gogcliwhich goplaces # goplaceswhich gaql # gaql-cliwhich gcloud # gcloud SDK -
For each installed tool, detect current auth state:
- gogcli:
gog auth list --check→ extract active email - goplaces:
echo $GOOGLE_PLACES_API_KEY→ non-empty = ready, useenv:GOOGLE_PLACES_API_KEY - gaql-cli: check
~/.config/gaql/config.tomlor$GOOGLE_ADS_CONFIGURATION_FILE_PATHfor customer_id - gcloud:
gcloud config get-value account+gcloud config configurations list→ extract active config name
- gogcli:
-
Build default context from detected state — skip tools that are not installed.
-
Write
google-cli.jsonto project root:{"default": "main","contexts": {"main": {"goplaces": "env:GOOGLE_PLACES_API_KEY","gcloud": "detected-config-name","ads": {"customer_id": "detected-or-null","login_customer_id": null}}}} -
Show the generated file, explain how to add more contexts with
google-accounts add.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Phase 2: ADD
Section titled “Phase 2: ADD”Triggered by: “add client context acme”, “add google account”, “new context”.
-
Ask context name if not provided.
-
For each installed tool, ask for account/key/config:
- gogcli: “Which Google account email for this context?”
- goplaces: “Which env var holds the Places API key for this context? (e.g.
ACME_PLACES_KEY)” - gcloud: “Which gcloud configuration name? Run
gcloud config configurations listto see options.” - ads: “Google Ads customer ID? (xxx-xxx-xxxx format)” + “MCC login_customer_id? (null if direct account)”
-
Validate auth works for each entry before writing:
- gogcli:
gog auth list --checkand verify email is listed - goplaces: env var non-empty (
[ -n "$VAR_NAME" ]) - gcloud:
gcloud config configurations describe <name>exits 0 - ads: customer_id matches
^\d{3}-\d{3}-\d{4}$format
- gogcli:
-
Append new context to
google-cli.json. If file does not exist, run SETUP first.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Phase 3: CHECK
Section titled “Phase 3: CHECK”Triggered by: “check google accounts”, “validate auth”, “account status”.
-
Read
google-cli.json. If missing, prompt to run SETUP. -
For each context, for each tool entry, validate:
Tool Validation Command Pass Condition gogcli gog auth list --checkContext email is listed goplaces [ -n "${RESOLVED_VAR}" ]Env var is set and non-empty gcloud gcloud config configurations describe <name>Exits 0 ads Format check customer_id matches xxx-xxx-xxxx -
Report table: context × tool with ✓/✗ status:
Context gogcli goplaces gcloud adsmain ✓ [email protected] ✓ key set ✓ default ✓ 123-456-7890acme ✓ [email protected] ✗ key missing ✓ acme-prod ✓ 987-654-3210 -
For each ✗, explain the fix:
- gogcli missing:
gog auth add <email> - goplaces missing: set the env var in
.env/.envrc - gcloud missing:
gcloud config configurations create <name> - ads format error: re-enter in
xxx-xxx-xxxxformat
- gogcli missing:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Phase 4: SWITCH
Section titled “Phase 4: SWITCH”Triggered by: “switch to acme”, “use acme context”, “set active context”.
-
Validate target context exists in
google-cli.json. If not found, list available contexts. -
Update
defaultfield ingoogle-cli.json:{ "default": "acme", "contexts": { ... } } -
Output
.envrcsnippet for the new context:Terminal window export GOOGLE_CLI_CONTEXT="acme"export GOOGLE_PLACES_API_KEY="${ACME_PLACES_KEY}"export CLOUDSDK_ACTIVE_CONFIG_NAME="acme-prod"Tell the user to paste into
.envrcand rundirenv allow— or source manually. -
Activate gcloud config for immediate effect:
Terminal window gcloud config configurations activate acme-prodSkip if no gcloud entry in the context.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
What This Skill Does NOT Do
Section titled “What This Skill Does NOT Do”- Modify upstream tools’ config files (gogcli keyring, gaql config.toml, gcloud configs)
- Create gcloud configurations — outputs the creation command, user runs it
- Store secrets — always
env:VAR_NAMEreferences, never raw values - Block on missing tools — skips tools not installed, reports what was skipped
Integration
Section titled “Integration”| Need | Skill / Rule |
|---|---|
| Routed by | google-pimp → routing table |
| Enforced by | google-cli-context rule (passive — reads active context before CLI commands) |
| Pairs with | google-workspace-workflow (multi-account pipelines) |
| Pairs with | google-ads-workflow (MCC ops with context injection) |