GCP Serverless Application Development Guide
This skill supports application development on GCP serverless services, based on the
bundled infrastructure selection documents (references/docs/).
Knowledge Base
The details of the infrastructure selection are collected in the documents below.
Read them whenever an implementation decision is unclear — GCP service specifications
and limits are easy to get wrong from general knowledge alone, so it matters to confirm
them against the bundled documents.
| Doc |
File |
Content |
| Index |
references/docs/infrastructure.md |
Overall structure, service list, environment strategy |
| Compute |
references/docs/infrastructure-1-compute.md |
Cloud Run, Cloud Functions, Docker build |
| Data |
references/docs/infrastructure-2-data.md |
Firestore, Spanner, Neo4j, Qdrant, ES, Storage |
| Async |
references/docs/infrastructure-3-async.md |
Cloud Tasks, Pub/Sub, Eventarc, Scheduler |
| CI/CD |
references/docs/infrastructure-4-cicd.md |
GitHub Actions, Cloud Build, Artifact Registry |
| Auth |
references/docs/infrastructure-5-auth.md |
Firebase Auth, WIF, Secret Manager |
| Observability |
references/docs/infrastructure-6-observability.md |
Sentry, structlog, Cloud Monitoring |
| Ops |
references/docs/infrastructure-7-ops.md |
Local dev, emulators, deploy, scaling |
| Incident |
references/docs/infrastructure-8-incident.md |
Rollback, maintenance, backup, recovery |
| Network |
references/docs/infrastructure-9-network.md |
Ingress, TLS, CORS, DDoS, VPC |
| App Constraints |
references/docs/infrastructure-10-app-constraints.md |
Backend/Frontend/Mobile development constraints |
| Alternatives |
references/docs/infrastructure-11-gcp-alternatives.md |
Comparison between GCP services and selection rationale |
Core Principles
- Region: all services fixed to
asia-northeast1 (Tokyo)
- Tier: separate Core (required for the initial release) from Extension (optional)
- Idempotency: delivery is at-least-once, so implement every async handler idempotently
- Stateless: Cloud Run is stateless — design without in-memory state
- Serverless first: prefer Cloud Run over GKE
- Managed first: prefer managed services over self-hosted ones
Phase Guide
Phase 1: Project Scaffold
When starting a new project, read references/scaffold.md to check the project
structure and the setup procedure.
Main scaffold targets:
- monorepo structure:
backend/ + frontend/ + emulator/
- Backend: Python (FastAPI + uvicorn), dependencies managed with uv, multi-stage Dockerfile
- Frontend: Next.js (standalone), multi-stage Dockerfile
- Emulator: Firebase Emulator Suite started via docker-compose.yaml
- Task runner: tasks defined in a justfile
- CI/CD: GitHub Actions workflow
- Firestore: security rules + indexes
- Environment: encrypted management with dotenvx
Phase 2: Feature Development
When implementing a feature, decide in this order:
Data model design: which data store to use?
- Read
references/decision-tree.md to check the selection flow
- Firestore (Core) / Spanner, Neo4j, Qdrant, ES (Extension)
Sync vs async: should this processing return synchronously or be pushed to an async path?
- An immediate response is required -> synchronous processing in a Cloud Run Service
- 1:1 processing that must reliably complete -> Cloud Tasks
- 1:N fan-out -> Pub/Sub
- GCP service event -> Eventarc
Direct from client vs through the server: does the client access Firestore directly?
- Read-heavy + real-time -> Firestore onSnapshot (Client SDK)
- Write + business logic -> through the Backend API
Implementation pattern: read references/patterns.md to check the pseudocode
Phase 3: Deploy & Operations
Procedure for deployment and operations:
- Container build: multi-stage Docker build -> push to Artifact Registry
- Cloud Run deploy:
gcloud run deploy with revision-based rollback
- Firestore deploy:
firebase deploy for security rules + indexes
- Monitoring setup: Sentry + Cloud Logging + Cloud Monitoring SLI/SLO
- Incident response: the flow of rollback -> investigate -> fix -> verify
Phase 4: Architecture Decisions
When a technology choice is unclear:
- Read
references/docs/infrastructure-11-gcp-alternatives.md to check the comparison structure
- Cloud Run vs GKE -> almost always Cloud Run. Consider GKE only for stateful workloads
- Firestore vs Cloud SQL -> Firestore if the Client SDK or real-time is required
- Cloud Tasks vs Pub/Sub -> Tasks for explicit 1:1, Pub/Sub for 1:N fan-out
- Services vs Jobs vs Worker Pools -> Services for an HTTP endpoint, Jobs for batch, Worker Pools for a pull consumer
How to Use References
Read the reference files as needed. There is no need to read all of them at once.
| Situation |
Read this |
| Creating a new project |
references/scaffold.md |
| Technology choice / architecture decision |
references/decision-tree.md |
| Concrete implementation method |
references/patterns.md |
| Checking detailed constraints / specifications |
the matching references/docs/infrastructure-*.md |
Using the google-dev-knowledge MCP
GCP services are updated frequently, so the information in the bundled documents may be
out of date. If the google-dev-knowledge MCP server is available, it can supplement
them with the latest information from the official documentation. The division of roles
is that the bundled documents provide the policy and the structure, while the MCP
provides the latest specifications and numbers.
Flow when the MCP is available:
- Read the bundled documents to check the policy and patterns
- For the main services included in the answer, search the latest official documentation with
mcp__google-dev-knowledge__search_documents (at least once)
- Fetch the relevant documents from the search results with
mcp__google-dev-knowledge__get_documents and check the details
- If the bundled documents and the official documentation differ, the official documentation wins
Situations where searching with the MCP is especially effective:
- When mentioning a service quota / limit / pricing
- When stating API parameters or default values
- When explaining a new feature (Worker Pools, Firestore Pipeline, etc.)
- When comparing concrete specs in a cross-cloud comparison
When the MCP is not available:
Work from the bundled documents only. However, present the setup guidance in
references/mcp-setup.md at the end of the answer, so that the user can also consult
the latest official documentation from then on.
Cross-Cloud Comparison
When asked for a comparison with other clouds:
| GCP Service |
AWS Equivalent |
Azure Equivalent |
| Cloud Run |
ECS Fargate / App Runner |
Container Apps |
| Firestore |
DynamoDB |
Cosmos DB |
| Cloud Tasks |
SQS (FIFO) |
Queue Storage |
| Pub/Sub |
SNS + SQS |
Service Bus |
| Cloud Functions |
Lambda |
Functions |
| Firebase Auth |
Cognito |
Azure AD B2C |
| Cloud Spanner |
Aurora (global) |
Cosmos DB (relational) |
| Eventarc |
EventBridge |
Event Grid |
| Cloud Scheduler |
EventBridge Scheduler |
Logic Apps |
| Secret Manager |
Secrets Manager |
Key Vault |
| Artifact Registry |
ECR |
Container Registry |
When comparing, explain "why this GCP service was chosen" based on
references/docs/infrastructure-11-gcp-alternatives.md.
1---2name: gcp-serverless-appdev3description: GCP serverless application development guide covering Cloud Run, Firestore, Cloud Tasks, Pub/Sub, Firebase Auth, Cloud Functions, Eventarc, and Cloud Scheduler: service selection, implementation patterns, and gcloud-based deployment. Use when the user is designing or writing the application side — mentions "GCPで開発", "Cloud Runで", "Firestoreに", "新しいGCPプロジェクト", scaffolding a GCP app, choosing between Cloud Tasks and Pub/Sub, Firestore data modeling, Firebase Auth integration, deploying a service with gcloud, or comparing GCP services with AWS/Azure equivalents, including cross-cloud migration discussions. Not for Terraform/OpenTofu — any .tf, `tofu`, "tfファイル", or "インフラをコード化" request is gcp-serverless-tf.4license: MIT5---67# GCP Serverless Application Development Guide89This skill supports application development on GCP serverless services, based on the10bundled infrastructure selection documents (`references/docs/`).1112## Knowledge Base1314The details of the infrastructure selection are collected in the documents below.15Read them whenever an implementation decision is unclear — GCP service specifications16and limits are easy to get wrong from general knowledge alone, so it matters to confirm17them against the bundled documents.1819| Doc | File | Content |20|-----|------|---------|21| Index | `references/docs/infrastructure.md` | Overall structure, service list, environment strategy |22| Compute | `references/docs/infrastructure-1-compute.md` | Cloud Run, Cloud Functions, Docker build |23| Data | `references/docs/infrastructure-2-data.md` | Firestore, Spanner, Neo4j, Qdrant, ES, Storage |24| Async | `references/docs/infrastructure-3-async.md` | Cloud Tasks, Pub/Sub, Eventarc, Scheduler |25| CI/CD | `references/docs/infrastructure-4-cicd.md` | GitHub Actions, Cloud Build, Artifact Registry |26| Auth | `references/docs/infrastructure-5-auth.md` | Firebase Auth, WIF, Secret Manager |27| Observability | `references/docs/infrastructure-6-observability.md` | Sentry, structlog, Cloud Monitoring |28| Ops | `references/docs/infrastructure-7-ops.md` | Local dev, emulators, deploy, scaling |29| Incident | `references/docs/infrastructure-8-incident.md` | Rollback, maintenance, backup, recovery |30| Network | `references/docs/infrastructure-9-network.md` | Ingress, TLS, CORS, DDoS, VPC |31| App Constraints | `references/docs/infrastructure-10-app-constraints.md` | Backend/Frontend/Mobile development constraints |32| Alternatives | `references/docs/infrastructure-11-gcp-alternatives.md` | Comparison between GCP services and selection rationale |3334## Core Principles35361. **Region**: all services fixed to `asia-northeast1` (Tokyo)372. **Tier**: separate Core (required for the initial release) from Extension (optional)383. **Idempotency**: delivery is at-least-once, so implement every async handler idempotently394. **Stateless**: Cloud Run is stateless — design without in-memory state405. **Serverless first**: prefer Cloud Run over GKE416. **Managed first**: prefer managed services over self-hosted ones4243## Phase Guide4445### Phase 1: Project Scaffold4647When starting a new project, read `references/scaffold.md` to check the project48structure and the setup procedure.4950Main scaffold targets:51- **monorepo structure**: `backend/` + `frontend/` + `emulator/`52- **Backend**: Python (FastAPI + uvicorn), dependencies managed with uv, multi-stage Dockerfile53- **Frontend**: Next.js (standalone), multi-stage Dockerfile54- **Emulator**: Firebase Emulator Suite started via docker-compose.yaml55- **Task runner**: tasks defined in a justfile56- **CI/CD**: GitHub Actions workflow57- **Firestore**: security rules + indexes58- **Environment**: encrypted management with dotenvx5960### Phase 2: Feature Development6162When implementing a feature, decide in this order:63641. **Data model design**: which data store to use?65 - Read `references/decision-tree.md` to check the selection flow66 - Firestore (Core) / Spanner, Neo4j, Qdrant, ES (Extension)67682. **Sync vs async**: should this processing return synchronously or be pushed to an async path?69 - An immediate response is required -> synchronous processing in a Cloud Run Service70 - 1:1 processing that must reliably complete -> Cloud Tasks71 - 1:N fan-out -> Pub/Sub72 - GCP service event -> Eventarc73743. **Direct from client vs through the server**: does the client access Firestore directly?75 - Read-heavy + real-time -> Firestore onSnapshot (Client SDK)76 - Write + business logic -> through the Backend API77784. **Implementation pattern**: read `references/patterns.md` to check the pseudocode7980### Phase 3: Deploy & Operations8182Procedure for deployment and operations:83841. **Container build**: multi-stage Docker build -> push to Artifact Registry852. **Cloud Run deploy**: `gcloud run deploy` with revision-based rollback863. **Firestore deploy**: `firebase deploy` for security rules + indexes874. **Monitoring setup**: Sentry + Cloud Logging + Cloud Monitoring SLI/SLO885. **Incident response**: the flow of rollback -> investigate -> fix -> verify8990### Phase 4: Architecture Decisions9192When a technology choice is unclear:93- Read `references/docs/infrastructure-11-gcp-alternatives.md` to check the comparison structure94- Cloud Run vs GKE -> almost always Cloud Run. Consider GKE only for stateful workloads95- Firestore vs Cloud SQL -> Firestore if the Client SDK or real-time is required96- Cloud Tasks vs Pub/Sub -> Tasks for explicit 1:1, Pub/Sub for 1:N fan-out97- Services vs Jobs vs Worker Pools -> Services for an HTTP endpoint, Jobs for batch, Worker Pools for a pull consumer9899## How to Use References100101Read the reference files as needed. There is no need to read all of them at once.102103| Situation | Read this |104|-----------|-----------|105| Creating a new project | `references/scaffold.md` |106| Technology choice / architecture decision | `references/decision-tree.md` |107| Concrete implementation method | `references/patterns.md` |108| Checking detailed constraints / specifications | the matching `references/docs/infrastructure-*.md` |109110## Using the google-dev-knowledge MCP111112GCP services are updated frequently, so the information in the bundled documents may be113out of date. If the `google-dev-knowledge` MCP server is available, it can supplement114them with the latest information from the official documentation. The division of roles115is that the bundled documents provide the policy and the structure, while the MCP116provides the latest specifications and numbers.117118**Flow when the MCP is available:**1191. Read the bundled documents to check the policy and patterns1202. For the main services included in the answer, search the latest official documentation with `mcp__google-dev-knowledge__search_documents` (at least once)1213. Fetch the relevant documents from the search results with `mcp__google-dev-knowledge__get_documents` and check the details1224. If the bundled documents and the official documentation differ, the official documentation wins123124Situations where searching with the MCP is especially effective:125- When mentioning a service quota / limit / pricing126- When stating API parameters or default values127- When explaining a new feature (Worker Pools, Firestore Pipeline, etc.)128- When comparing concrete specs in a cross-cloud comparison129130**When the MCP is not available:**131Work from the bundled documents only. However, present the setup guidance in132`references/mcp-setup.md` at the end of the answer, so that the user can also consult133the latest official documentation from then on.134135## Cross-Cloud Comparison136137When asked for a comparison with other clouds:138139| GCP Service | AWS Equivalent | Azure Equivalent |140|-------------|---------------|-----------------|141| Cloud Run | ECS Fargate / App Runner | Container Apps |142| Firestore | DynamoDB | Cosmos DB |143| Cloud Tasks | SQS (FIFO) | Queue Storage |144| Pub/Sub | SNS + SQS | Service Bus |145| Cloud Functions | Lambda | Functions |146| Firebase Auth | Cognito | Azure AD B2C |147| Cloud Spanner | Aurora (global) | Cosmos DB (relational) |148| Eventarc | EventBridge | Event Grid |149| Cloud Scheduler | EventBridge Scheduler | Logic Apps |150| Secret Manager | Secrets Manager | Key Vault |151| Artifact Registry | ECR | Container Registry |152153When comparing, explain "why this GCP service was chosen" based on154`references/docs/infrastructure-11-gcp-alternatives.md`.