Catalog
google/spanner-basics

google

spanner-basics

Assists in provisioning instances and databases, designing performant schemas, and querying data in Spanner. Use when designing primary keys, writing SQL queries or client library code, or diagnosing performance issues.

v1.0LATEST
NewUpdated Jul 30, 2026

Spanner Basics

This skill provides core workflows and guidance for administering and developing with Google Cloud Spanner, a fully managed, mission-critical database service offering global transactional consistency and automatic, synchronous replication for high availability.

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

  1. Use gcloud spanner databases ddl update to apply schema updates (such as CREATE, ALTER, or DROP tables and indexes).
  2. Reference schema-design.md for guidelines on primary key selection and interleaved tables.

Diagnosing Performance Issues

  1. Use SPANNER_SYS tables to identify slow or resource-intensive queries.
  2. For example, query SPANNER_SYS.QUERY_STATS_TOP_HOUR to find queries with the highest CPU usage.

Reference Directory

  • Core Concepts: Explanation of Spanner internals, architecture, and design.
  • CLI Usage: Essential gcloud spanner command-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.
  • 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.

Files9
9 files · 25.0 KB

Select a file to preview

Overall Score

82/100

Grade

B

Good

Grades are signals, not a certification. Always review a skill yourself before use.

Safety

85

Quality

82

Clarity

83

Completeness

78

Summary

A comprehensive knowledge base for Google Cloud Spanner administration and development. This skill provides structured guidance on provisioning instances, designing performant schemas, querying data, and diagnosing performance issues. It includes detailed reference materials on CLI operations, client libraries, IAM security, schema design patterns, and infrastructure-as-code approaches.

Detected Capabilities

Structured knowledge retrievalDatabase schema design guidanceCLI command examplesClient library code examples for multiple languagesTerraform infrastructure templatesPerformance diagnostic queriesIAM role and permission documentation

Trigger Keywords

Phrases that agents use to match this skill to user intent.

spanner schema designspanner primary keyspanner hotspot preventionspanner performance diagnosisspanner instance setupspanner client libraryspanner terraformspanner query optimizationspanner iam rolesspanner postgresql dialect

Risk Signals

INFO

MCP integration with Spanner remote server

SKILL.md, references/mcp-usage.md
INFO

CLI commands for database operations (create, alter, drop)

SKILL.md, references/cli-usage.md
INFO

Schema modification via gcloud spanner databases ddl update

SKILL.md Core Principles section

Referenced Domains

External domains referenced in skill content, detected by static analysis.

cloud.google.comdocs.cloud.google.comregistry.terraform.iowww.apache.org

Use Cases

  • Design primary keys to avoid hotspots in Spanner databases
  • Set up and manage Spanner instances and databases using gcloud CLI
  • Write queries and client application code for Spanner using Python, Java, Go, or Node.js
  • Diagnose performance issues by querying SPANNER_SYS tables
  • Define schemas with interleaved tables for parent-child relationships
  • Provision Spanner infrastructure as code using Terraform
  • Implement PostgreSQL dialect support in Spanner applications

Quality Notes

  • Excellent separation of concerns: main SKILL.md provides high-level guidance with references to detailed topic-specific docs
  • Strong safety guardrail: explicitly requires user confirmation before executing non-emulator DML/DDL operations
  • Comprehensive coverage of multiple interfaces: CLI, client libraries (Python/Java/Go/Node.js), Terraform, MCP, and PostgreSQL dialect
  • Well-organized reference structure with clear topic hierarchies (Core Concepts, CLI Usage, IAM Security, Schema Design, etc.)
  • Performance-first philosophy clearly articulated in Core Principles section with specific anti-patterns (monotonic PKs)
  • Includes pragmatic fallback guidance: when DB access unavailable, assume resources exist and generate DDL commands
  • Good examples across all major programming languages and infrastructure-as-code tools
  • Clear emphasis on principle of least privilege in IAM Security reference
  • Schema design checklist provides concrete verification points for agents reviewing/generating schemas
Model: claude-haiku-4-5-20251001Analyzed: Jul 30, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Use google/spanner-basics in your dev environment

Command Palette

Search for a command to run...