본문으로 건너뛰기
cccskills
무료GitHub에 공개

postgresql-best-practices-cloudbase

CloudBase PostgreSQL access-pattern and slow-query quality guidance. Use when designing how tables are read and written, eliminating per-row database calls, adding indexes for filters or joins, reviewing high-traffic data access, or explaining a slow SQL query. Not for first-time PG SDK setup, login UI, or NoSQL collections.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구PostgreSQL
설치 방법 보기

포함된 파일(6)

  • SKILL.md5.1 KB
  • LICENSE.md1.0 KB
  • references/access-patterns.md3.6 KB
  • references/capacity-and-connections.md3.1 KB
  • references/indexes-and-explain.md2.6 KB
  • references/schema-and-rls.md3.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

CloudBase PostgreSQL Best Practices

This skill turns a working CloudBase PG implementation into a reviewable access design. It makes query paths, indexes, row authorization, and launch capacity explicit before code is considered complete.

Sibling skills (local only)

Sibling CloudBase skills ship beside this skill. Use local relative paths such as ../postgresql-development-cloudbase/SKILL.md.

If a referenced sibling skill file is missing from this environment, ask the user to install the full CloudBase plugin (or the missing skill). Do not HTTP-fetch remote skill or protocol markdown into the agent context.

When to use

  • A feature needs a new or changed access pattern.
  • Application code performs repeated, serial, or high-frequency PG queries.
  • A SQL query, RPC, endpoint, or polling path is slow.
  • A high-traffic launch needs a database readiness review.

Do NOT use for

  • PG environment setup, app.rdb() syntax, migrations, GRANTs, or base RLS correctness: use ../postgresql-development-cloudbase/SKILL.md.
  • Login provider or UI implementation: use the matching auth skill.
  • Confirmed NoSQL collection work: use the document database skill.
  • Platform alarm diagnosis or slow-log collection: use ../ops-inspector/SKILL.md.

Workflow

1. Inventory access paths

List every changed endpoint, job, RPC, or UI flow and its reads and writes. Record filters, joins, sort keys, expected cardinality, and request frequency.

Complete when: every changed path has a concrete query inventory; unknown volume or peak concurrency is marked as an assumption for the user.

2. Design schema, indexes, and row authorization together

Derive columns and indexes from the query inventory. Every frequent filter, join, and stable ordering path must have a deliberate index decision. For user-owned rows, use the role as the policy gate and identity as the row predicate:

CREATE POLICY orders_select_own ON public.orders
  FOR SELECT TO authenticated
  USING ((SELECT auth.uid()) = owner_id);

Apply schema DDL through the versioned applyMigration workflow defined by ../postgresql-development-cloudbase/SKILL.md. This keeps Git, development, and production reproducible; the tradeoff is that experiments require a new migration version instead of ad hoc schema mutation.

Complete when: every query predicate has an index decision, every user-owned path has an ownership predicate, and all DDL is represented in one reviewable migration for the change.

3. Implement bounded database access

Batch related keys, combine repeated reads, and execute independent queries concurrently. Keep each result bounded by a filter plus .limit() / .range(), or by an RPC that implements keyset pagination.

const userIds = [...new Set(rows.map((row) => row.user_id))];
const { data: profiles, error } = await db
  .from("profiles")
  .select("id, display_name")
  .in("id", userIds);

if (error) throw error;

Send request logs, traces, and high-volume analytics to the platform logging service or purpose-built analytics storage. Keep PG for transactional data that participates in business queries and constraints.

Complete when: the changed code has no database call inside an item loop, no repeated read of the same row in one request, and no unbounded hot-path query.

4. Check launch capacity when traffic is material

For campaigns, rankings, polling endpoints, or other bursty paths, inspect the target environment with queryEnv(action="info", envId=...). Report the observed PG allocation, expected peak load, and unresolved capacity risk. CloudBase currently requires an explicit capacity plan; do not represent autoscaling as guaranteed.

Complete when: the current allocation is recorded and either judged against an explicit traffic assumption or raised to the user as an unresolved launch blocker.

Routing

Current branchRead
Repeated calls, serial queries, polling, pagination, or logging tablesreferences/access-patterns.md
Missing indexes, slow SQL/RPC, or query-plan reviewreferences/indexes-and-explain.md
New schema, tenant isolation, or RLS performancereferences/schema-and-rls.md
Campaign launch or database sizingreferences/capacity-and-connections.md

Load only the references required by the current branch.

Minimum self-check

  • Every changed access path is accounted for.
  • Every frequent filter, join, and stable sort has an index decision.
  • Database round trips are bounded independently of result cardinality.
  • RLS separates role gating (TO) from row authorization (auth.uid()).
  • Schema changes use the canonical migration workflow.
  • Capacity claims are based on observed allocation and stated traffic assumptions.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use this skill for Node.js backend AI via @cloudbase/node-sdk (>=3.16.0) — cloud functions, CloudRun, Express/Koa/NestJS, serverless APIs, scheduled jobs, LLM proxies, agent orchestration. The only SDK supporting image generation (ai.createImageModel + generateImage). Text via ai.createModel with groups cloudbase, hunyuan-exp, or custom-*; model ids (e.g. deepseek-v4-flash, glm-5, kimi-k2.6) go in the `model` field of generateText/streamText. MUST run two-step preflight before code — see body. NOT for browser/Web (use ai-model-web) or Mini Program (use ai-model-wechat).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TencentCloudBase/CloudBase-AI-Toolkit1.1천2026년 10월 19일 업데이트

Use this skill when a browser/Web app (React, Vue, Next, Nuxt, static sites, SPAs, dashboards, AI chat UI, 页面, 前端, 网页) needs AI models via @cloudbase/js-sdk. Default routing for Web/frontend AI — call directly from the browser, do NOT propose a Node.js proxy. Covers generateText and streamText; models via ai.createModel with groups cloudbase, hunyuan-exp, or custom-*, model id in the `model` field. MUST run two-step preflight before code — see body. NOT for Node.js backend (use ai-model-nodejs), Mini Program (use ai-model-wechat), or image generation (Node SDK only).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TencentCloudBase/CloudBase-AI-Toolkit1.1천2026년 10월 19일 업데이트

Use this skill for WeChat Mini Program AI via wx.cloud.extend.AI (小程序, wx.cloud apps). Covers generateText and streamText with callbacks (onText, onEvent, onFinish); streamText needs a data wrapper, generateText returns the raw response. Models via wx.cloud.extend.AI.createModel with groups hunyuan-exp (小程序成长计划), cloudbase (main managed), or custom-*; model id goes in the data wrapper `model` field. MUST run two-step preflight before code — see body. NOT for browser/Web (use ai-model-web), Node.js backend (use ai-model-nodejs), or image generation (use ai-model-nodejs).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TencentCloudBase/CloudBase-AI-Toolkit1.1천2026년 10월 19일 업데이트

Use when auditing CloudBase cloud API wrappers, MCP tools, generated action metadata, or related docs for outdated or incorrect action names, parameters, casing, request shapes, or missing contract tests, especially during periodic quality review or before preparing corrective PRs.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TencentCloudBase/CloudBase-AI-Toolkit1.1천2026년 10월 19일 업데이트

CloudBase Node SDK auth guide for server-side identity, user lookup, and custom login tickets. This skill should be used when Node.js code must read caller identity, inspect end users, or bridge an existing user system into CloudBase; not when configuring providers or building client login UI.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TencentCloudBase/CloudBase-AI-Toolkit1.1천2026년 10월 19일 업데이트

CloudBase auth provider configuration and login-readiness guide. This skill should be used when users need to inspect, enable, disable, or configure auth providers, publishable-key prerequisites, login methods, SMS/email sender setup, or other provider-side readiness before implementing a client or backend auth flow.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TencentCloudBase/CloudBase-AI-Toolkit1.1천2026년 10월 19일 업데이트

TencentCloudBase의 스킬 모두 보기

이 스킬의 문제 신고