mcpField
S
spanner-basics

spanner-basics

github.com/googleData & databases21.6k4.8k installsUpdated today
Repository

About spanner-basics

spanner-basics guides developers and administrators working with Cloud Spanner on Google Cloud. It covers schema design, performance diagnosis, and database operations, with explicit safeguards for changes.

Key features

  1. 01Cloud Spanner administration and development guidance
  2. 02DDL schema evolution workflows
  3. 03SPANNER_SYS performance diagnosis
  4. 04Primary key and interleaved table design advice
  5. 05Database change safety requirements

Use cases

  1. 01Plan table and primary key schemas
  2. 02Apply database DDL updates
  3. 03Investigate high-CPU queries
  4. 04Manage instances with gcloud

MCP support

The skill describes using the Spanner remote MCP server and requires reading usage attribution before running MCP commands.

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/google/skills --skill spanner-basics

After installing, type/spanner-basicsin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
attribution.md
cli-usage.md
client-library-usage.md
core-concepts.md
iam-security.md
mcp-usage.md
postgresql-dialect.md
queues-usage.md
schema-design.md
terraform-usage.md

Details

From the project README

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.

Comments

Markdown supported