Builds and optimizes serverless container services on GCP Cloud Run, covering deployment configuration, concurrency/cold-start tuning, and integration with Pub/Sub, Cloud SQL, and Secret Manager.
Ships in 10-platform. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
适用于在 GCP 上构建生产级无服务器应用,并需要在以下两类计算之间做选型与调优时:
同时覆盖冷启动优化、并发配置、Pub/Sub 事件架构、Cloud SQL 连接、Secret Manager 密钥管理。
不该用边界:
核心原则:容器跑 Cloud Run、简单事件处理用 Functions;容器要启动快且无状态;用 cpu-boost + min-instances 优化冷启动;并发按负载设定;/tmp 占用内存须计入;优雅处理 SIGTERM;仅在必要时用 VPC Connector(会增加延迟)。
PORT(默认 8080),以非 root 用户运行,监听 SIGTERM 优雅关停。gcloud run deploy ... --source . 直接部署,或经 cloudbuild.yaml 构建-推送-部署三步流水线。--cpu-boost、设 --min-instances、用 distroless 镜像、对重依赖懒加载。关键参数与命令:
# 直接部署服务
gcloud run deploy my-service \
--source . --region us-central1 --allow-unauthenticated \
--memory 512Mi --cpu 1 \
--min-instances 1 --max-instances 100 \
--concurrency 80 --cpu-boost
# Functions(gen2)三种触发器
gcloud functions deploy hello-http --gen2 --runtime nodejs20 \
--trigger-http --allow-unauthenticated --region us-central1
gcloud functions deploy process-messages --gen2 --runtime nodejs20 \
--trigger-topic my-topic --region us-central1
gcloud functions deploy process-uploads --gen2 --runtime nodejs20 \
--trigger-event-filters="type=google.cloud.storage.object.v1.finalized" \
--trigger-event-filters="bucket=my-bucket" --region us-central1
并发取值参考:=1 仅用于 CPU 密集或线程不安全代码;8~20 内存密集型;80 默认、I/O 密集型友好;250 上限、用于极轻量处理器。粗算:并发 ≈ 内存上限 / 单请求内存(如 512MB、单请求 20MB → 安全并发约 25)。
容器(多阶段、非 root、监听 PORT、优雅关停):
FROM node:20-slim AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
FROM node:20-slim
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY src ./src
COPY package.json ./
ENV PORT=8080
EXPOSE 8080
USER node
CMD ["node", "src/index.js"]
const express = require('express');
const app = express();
app.use(express.json());
app.get('/health', (req, res) => res.status(200).send('OK'));
process.on('SIGTERM', () => {
console.log('SIGTERM received, shutting down gracefully');
server.close(() => process.exit(0));
});
const PORT = process.env.PORT || 8080;
const server = app.listen(PORT, () => console.log(`listening on ${PORT}`));
Pub/Sub 推送订阅 → Cloud Run(200 确认,500 触发重试,并配死信队列):
gcloud pubsub topics create orders
gcloud pubsub subscriptions create orders-push \
--topic orders --push-endpoint https://my-service-xxx.run.app/pubsub --ack-deadline 600
# 死信队列
gcloud pubsub topics create orders-dlq
gcloud pubsub subscriptions update orders-push \
--dead-letter-topic orders-dlq --max-delivery-attempts 5
app.post('/pubsub', async (req, res) => {
if (!req.body.message) return res.status(400).send('Invalid Pub/Sub message');
try {
const m = req.body.message;
const data = m.data ? JSON.parse(Buffer.from(m.data, 'base64').toString()) : {};
await processOrder(data);
res.status(200).send('OK'); // 确认
} catch (e) {
res.status(500).send('failed'); // 触发重试
}
});
Cloud SQL(Unix socket + 连接池,池大小 5~10):
const { Pool } = require('pg');
const pool = new Pool({
user: process.env.DB_USER, password: process.env.DB_PASS, database: process.env.DB_NAME,
host: `/cloudsql/${process.env.INSTANCE_CONNECTION_NAME}`,
max: 5, idleTimeoutMillis: 30000, connectionTimeoutMillis: 10000,
});
// 部署时附加:--add-cloudsql-instances PROJECT:REGION:INSTANCE
Secret Manager(环境变量或文件挂载):
echo -n "my-secret-value" | gcloud secrets create my-secret --data-file=-
gcloud run deploy my-service --update-secrets=API_KEY=my-secret:latest # 环境变量
gcloud run deploy my-service --update-secrets=/secrets/api-key=my-secret:latest # 文件挂载
--memory。--cpu-throttling=false --min-instances=1,或把重活移交 Cloud Tasks / Pub/Sub worker。--cpu-boost、懒加载重模型、先起服务后台异步初始化、迁移用 Cloud Run Jobs 单独跑。pool_recycle≈300、pool_pre_ping、TCP keep-alive,或用 Cloud SQL Connector 自动重连。--timeout 调高,或改为 webhook 回调 / Cloud Tasks / 流式响应。--execution-environment=gen2 显式指定,并自行处理 HTTPS 跳转。USER),端口走 PORT 环境变量,勿硬编码。采编自 sickn33/antigravity-awesome-skills(MIT)。
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/10-platform:gcp-cloud-runfrom 10-platform
npx claudepluginhub findscripter/everything-skills --plugin 10-platform66 skills in this plugin
/agentmail-email-infra当 AI 智能体需要真实邮箱完成注册/验证码/事务通信时使用;通过 AgentMail REST API 开通账号、收发邮件、注册 Webhook、查询 karma 余额并产出可执行调用;不适用于自建/企业 SMTP/IMAP 或个人邮箱代收。触发词:AgentMail、智能体邮箱、theagentmail.net/agentphone-voice-sms-agents当需要给 AI 代理配备电话号码、发起/接听语音通话、收发短信、查看通话转写或配置 Webhook 时使用;调用 AgentPhone REST API(base=https://api.agentphone.to/v1)完成代理/号码/通话/短信/Webhook/用量的全生命周期管理,产出可直接执行的 curl 与 Webhook 处理代码;不适用于自建 Twilio/SIP/STUN 等底层电信栈或非 AgentPhone 平台。触发词:电话代理、语音通话、短信、号码、Webhook、转写。/ai-native-cli-design当设计/改造供 AI 智能体调用的命令行工具时使用;按 core/recommended/ecosystem 三层产出 JSON 优先、可校验的 CLI 契约(默认 JSON、结构化错误、退出码、护栏、agent/ 目录与自描述);不适用于纯人类交互 CLI、GUI 或库 API 设计;触发词:agent CLI、AI 友好命令行、CLI JSON 输出、退出码规范、agent/ 目录Other plugins' skills for the same job