New to Claude Skills? Learn how to install them →

google on GitHub

Spanner Basics

Free

Streamline your Google Cloud Spanner workflows.

by google17.6k stars on google/skills
1 views
Updated Aug 10, 2026
Get this skill

Free · Opens the source repo

What Spanner Basics does

Spanner Basics is designed for developers and database administrators working with Google Cloud Spanner, a fully managed database service. This skill provides essential workflows and guidance for provisioning instances, designing schemas, and executing SQL queries. With a focus on performance and best practices, it helps users avoid common pitfalls, such as inefficient primary key designs that can lead to hotspots in data access.

The skill emphasizes the importance of schema design, recommending interleaved tables for closely related data that is often accessed together. By following the provided guidelines, users can ensure that their database is optimized for performance from the outset. Additionally, the skill includes critical safety instructions, ensuring that users confirm any destructive operations before execution, which is vital for maintaining data integrity.

Users will find a variety of reference materials bundled within the skill, including detailed explanations of core concepts, command-line operations, and best practices for using client libraries and Terraform for infrastructure management. This comprehensive approach makes it easier for users to get up to speed with Spanner and effectively manage their database environments.

Whether you're designing a new database schema, diagnosing performance issues, or simply looking to improve your Spanner usage, this skill provides the necessary tools and guidance to enhance your workflow and ensure efficient data management.

When to use it

Use this skill when provisioning databases, designing schemas, or troubleshooting performance issues in Google Cloud Spanner.

When not to use it

This skill may not be suitable for users unfamiliar with SQL or those looking for a general-purpose database management tool.

What you can build with it

Provisioning a New Database

Use the skill to efficiently provision a new Spanner database instance, following best practices for schema design.

Optimizing Query Performance

Diagnose slow queries using the provided workflows and adjust your schema or queries based on performance insights.

Implementing Schema Changes

Apply schema updates safely with user confirmation, ensuring that changes are made without risking data integrity.

How to install Spanner Basics

View source

1. Install with the skills CLI

npx skills add google/skills/spanner-basics --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by google

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.

Frequently asked questions about Spanner Basics

Similar skills