
Spanner Basics
FreeStreamline your Google Cloud Spanner workflows.
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 source1. Install with the skills CLI
npx skills add google/skills/spanner-basics --agent claude-code2. 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 googleSpanner 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
- 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.
- 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
ClickHouse Logs Queries
Efficiently manage Supabase logs with ClickHouse SQL.
EF Core D2 Database Diagram Generator
Visualize your EF Core models as D2 diagrams effortlessly.
Safe SQL Execution
Ensure secure SQL execution in Supabase applications.
Oracle to PostgreSQL Migration
Identify migration risks between Oracle and PostgreSQL.
SSMA Console
Streamline Oracle to SQL Server migrations with ease.
SQL Performance Optimization
Enhance SQL query efficiency across all databases.
