Spanner Basics
GoogleOfficialPublished by Google
- Skill
- Tool integration
- Cloud and DevOps
- Apache-2.0
- Low risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
Spanner Basics provides guidance and workflows for interacting with Google Cloud Spanner. It covers administrative tasks like provisioning instances and databases, as well as development tasks such as designing schemas, writing SQL queries, and utilizing client libraries. The skill includes specific instructions for performance-oriented schema design, such as primary key selection and table interleaving, and provides reference material for IAM security, Terraform, and PostgreSQL dialect usage.
What it does
- Provides commands for provisioning and managing Spanner instances and databases.
- Offers guidance on designing performant database schemas.
- Assists in writing SQL queries and client library code for Spanner.
- Helps diagnose performance issues using system tables.
- Includes reference documentation for IAM, Terraform, and PostgreSQL compatibility.
- Requires explicit user confirmation for all DDL and DML operations.
When to use it
- When setting up or managing Cloud Spanner instances and databases via CLI.
- When designing database schemas, including primary keys and interleaved tables.
- When writing or debugging SQL queries and application code for Spanner.
- When investigating performance metrics using system tables.
- When implementing infrastructure as code using Terraform for Spanner resources.
Advantages
- Centralizes access to Spanner-specific CLI commands and best practices.
- Ensures safe execution by requiring user approval for destructive operations.
- Provides structured guidance on complex topics like schema evolution.
- Includes standardized attribution for command execution.
Usage examples
- “Create a new Spanner instance named my-app-db with 1 node in us-central1.”
- The agent will generate the appropriate gcloud spanner instances create command with the specified configuration.
- “How should I design my primary key to avoid hotspots?”
- The agent will provide guidance on avoiding monotonically increasing or decreasing values as the first part of a primary key.
- “Show me how to list all databases in my instance.”
- The agent will provide the gcloud spanner databases list command for the specified instance.
- “Help me find the most resource-intensive queries in my database.”
- The agent will suggest querying SPANNER_SYS.QUERY_STATS_TOP_HOUR to identify high CPU usage queries.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/google/spanner-basics/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip spanner-basics.zip -d .agents/skills
Documentation by Google
Spanner Basics
This skill provides core workflows and guidance for administering and developing with Cloud Spanner on Google Cloud, a fully managed, mission-critical database service offering global transactional consistency and automatic, synchronous replication for high availability.
Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command, you
MUST read Usage Attribution. For commands executed
directly in the terminal (never in generated scripts, Terraform, or user code),
prefix gcloud with
CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:spanner-basics)"
and append agent-skills/1.0 (skill:spanner-basics) to User-Agent headers.
Core Principles
Performance First: Spanner scales horizontally. Efficiency is tied to Primary Key design. Always warn against using monotonically increasing/decreasing values (like sequential timestamps) as the first part of a primary key to avoid hotspots.
Schema Design: Prefer interleaved tables for strongly related parent-child data that is frequently accessed together.
Safety
[!CAUTION] CRITICAL INSTRUCTION: You MUST obtain explicit user confirmation before making any non-emulator database changes (DML or DDL) or destructive operations (such as dropping tables, indexes, or any other Spanner resources). Do not execute them automatically; instead, output the command (e.g.,
gcloud spanner databases ddl update) and ask for explicit user approval. When database access is unavailable or authentication fails, do not block on trying to verify the existence of the instance, database, or table. Assume the provided resources exist and directly generate the DDL commands.
Common Workflows
Schema Evolution & DDL
Use
gcloud spanner databases ddl updateto apply schema updates (such as CREATE, ALTER, or DROP tables and indexes).Reference schema-design.md for guidelines on primary key selection and interleaved tables.
Diagnosing Performance Issues
Use
SPANNER_SYStables to identify slow or resource-intensive queries.For example, query
SPANNER_SYS.QUERY_STATS_TOP_HOURto find queries with the highest CPU usage.
Reference Directory
Core Concepts: Explanation of Spanner internals, architecture, and design.
CLI Usage: Essential
gcloud spannercommand-line operations for managing instances and databases.IAM Security: Roles, permissions, and data governance best practices for Spanner.
Client Library Usage: Using Google Cloud client libraries for Spanner (Java, Go, Python, Node.js).
Terraform Usage: Infrastructure as Code examples for provisioning Spanner instances and databases.
MCP Usage: Using the Spanner remote MCP server.
PostgreSQL Dialect: Best practices and examples for using the PostgreSQL interface in Spanner.
Queues Usage: Cloud Spanner Queues: mental model, design constraints, and links related to transactional message queues.
Schema Design: Guidelines on primary key selection and interleaved tables for performance.
If you need product information that's not found in these references, use the
search_documents tool of the Developer Knowledge MCP server.
Files
- ATTRIBUTION.mdAdded by AutoGineer846 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md3.8 KiB
- references/attribution.md1.8 KiB
- references/cli-usage.md1.3 KiB
- references/client-library-usage.md3.5 KiB
- references/core-concepts.md1.1 KiB
- references/iam-security.md1.2 KiB
- references/mcp-usage.md1.5 KiB
- references/postgresql-dialect.md951 B
- references/queues-usage.md10.8 KiB
- references/schema-design.md3.4 KiB
- references/terraform-usage.md928 B
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an MCP server
Security
What our scanner noticed· Low risk
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Publisher
- Google (Official)
- Source
- google/skills · skills/cloud/spanner-basics · commit 2194d3b
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Google.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download spanner-basics.zip