Skip to content
Skillpedia
Databases22k · #10351

spanner-basics

What it does

This skill helps you use Cloud Spanner, Google's globally consistent database. It is for teams who need a database that scales across regions with strong consistency.

When to use it

  • ✓When you want to provision a Cloud Spanner instance or database.
  • ✓When you need to design a primary key or schema that avoids hotspots.
  • ✓When Spanner queries or client code are slow and you need to diagnose them.

Skill link

https://github.com/google/skills/blob/main/skills/cloud/spanner-basics/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/google/skills/blob/main/skills/cloud/spanner-basics/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Design a Cloud Spanner schema for my orders app and warn me about any primary key that could create hotspots.”

5 new skills a week. 1 minute to read.

How it works

It explains how to set up instances and databases, and it warns about primary keys that increase in order, which can create hotspots. It asks for approval before any non-emulator database change.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

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

  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.
  • 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.

FAQ

Will it change my live database without asking?

No. It needs explicit confirmation before any DML or DDL change or any destructive operation.

What is a hotspot in Spanner?

A pattern where many writes hit the same part of the key range, often caused by sequential primary keys.

Does it support parent-child table layouts?

Yes. It suggests interleaved tables for strongly related data that is often read together.

Details

Original description by the author

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

repo: google/skills

Popularity

GitHub stars
22k
Ranking position
#10351
License
Apache-2.0
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills