Install
$ agentstack add skill-tencentcloudbase-cloudbase-skills-postgresql-development Open-source listing, not yet scanned by AgentStack. Follow the source repository for install instructions.
Security review
⚠ Flagged1 finding(s); flagged for manual review. · v0.1.0 How review works →
- • Prompt-injection patterns
- • Secret / credential exfiltration
- • Dangerous shell & filesystem operations
- • Untrusted network calls
- • Known-malicious package signatures
- high Destructive filesystem operation.
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ● Environment & secrets Used
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Standalone Install Note
If this environment only installed the current skill, start from the CloudBase main entry and use the published cloudbase/references/... paths for sibling skills.
- CloudBase main entry:
https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/SKILL.md - Current skill raw source:
https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/postgresql-development/SKILL.md
CloudBase PostgreSQL Development
Activation Contract
Use this first when
- The task says CloudBase PG, PostgreSQL, Postgres, PG mode, RLS, JS SDK v3 PostgreSQL,
app.rdb(),queryPgDatabase, ormanagePgDatabase. - A Web app or CMS must persist business data in CloudBase PostgreSQL instead of NoSQL or MySQL.
Then also read
- Web auth provider readiness ->
../auth-tool/SKILL.md(standalone fallback:https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/auth-tool/SKILL.md) - Web login implementation ->
../auth-web/SKILL.md(standalone fallback:https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/auth-web/SKILL.md) - General Web implementation and verification ->
../web-development/SKILL.md(standalone fallback:https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/web-development/SKILL.md) - Browser storage upload ->
../cloud-storage-web/SKILL.md(standalone fallback:https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/cloud-storage-web/SKILL.md) - Raw HTTP API details only when SDK coverage is blocked ->
../http-api/SKILL.md(standalone fallback:https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/http-api/SKILL.md) - PG reference index ->
references/index.md - PG mode overview ->
references/pg-mode-overview.md - Auth / GRANT / RLS details ->
references/auth-and-rls.md - End-to-end PG app closure ->
references/app-workflow.md - PG storage details ->
references/storage-pg.md - HTTP API fallback ->
references/http-api.md - Troubleshooting ->
references/troubleshooting.md
Do NOT use first
relational-database-tool/queryMysqlDatabase/manageMysqlDatabase: those are MySQL-oriented.no-sql-web-sdk/ collection APIs for business data that must live in CloudBase PG.
Required Flow
🚨 CRITICAL: PG mode API is NOT the same as NoSQL
CloudBase PG (app.rdb(), app.storage.from('bucket')) uses different API method names than CloudBase NoSQL (app.database(), app.uploadFile()). Low-capability models often paste legacy NoSQL/auth snippets from training; reject that path immediately. If this task is PG-backed, do not write app.database(), db.collection(...), app.uploadFile(), getLoginState(), or route guards based on auth.getUser(). Use app.rdb(), PG storage v3, and auth.getSession() instead. If you are used to writing .where(), .orderBy(), .count() from other ORMs or NoSQL — stop and read the table below.
| ❌ Do NOT use these (NoSQL / ORM habits) | ✅ Use these in PG mode | |------------------------------------------|------------------------| | .where({ field: value }) | .match({ field: value }) or .eq("field", value) | | .where("field", "ilike", "%v%") | .ilike("field", "%v%") | | .orderBy("field", { ascending: false }) | .order("field", { ascending: false }) | | .count() | .select("*", { count: "exact" }) — count is in response | | .offset(n) | .range(from, to) | | app.uploadFile() (legacy NoSQL upload) | app.storage.from('bucket').upload(key, file) | | app.getTempFileURL() (legacy NoSQL URL) | app.storage.from('bucket').createSignedUrl(key, expiresIn) | | app.storage.from() (no bucket name) | app.storage.from('bucket') — must pass bucket name |
If you find yourself typing .where() or .orderBy() or .count() — stop and use the correct method from the right column.
- First, confirm this environment actually has PostgreSQL provisioned. Call
envQuery(action="info", envId=...)and read the derivedEnvInfo.RuntimeBackendsblock ({ postgresql, nosql, mysql }) along withEnvInfo.RuntimeMode. It is only safe to apply this skill's PG-specific guidance whenRuntimeBackends.postgresql === true(equivalently,EnvInfo.PostgreSQLis non-empty AND/OREnvInfo.Metacontainspostgresql=enable).
- PG mode is a new-environment mode selected when creating a CloudBase environment with PostgreSQL. Do not try to "upgrade" a legacy environment in place; create/select a PG-mode environment instead.
- If
RuntimeBackends.postgresql === false, STOP — this is a legacy NoSQL-only env: switch tono-sql-web-sdkfor browser data andcloud-storage-web(withapp.uploadFile()) for uploads. Do not writeapp.rdb()code, do not enable RLS, do not create a pgstore bucket here. - If both
postgresqlandnosqlaretrue(the common case in a PG environment), they coexist. Apply this skill to NEW business data the task asks you to put in PG (e.g. articles / role tables explicitly described as PG). Existing NoSQL collections, the bucket reported inEnvInfo.Storages[], and anymanagePermissions(resourceType="noSqlDatabase")rules continue to govern the legacy NoSQL data — do NOT migrate or rewrite them unless the task explicitly asks. RuntimeBackends.mysql === falseis the only hard "do not use" signal: when MySQL is absent, do not usemanageMysqlDatabase/queryMysqlDatabaseand do not consult therelational-database-toolskill; those are MySQL-specific and have nothing to do with CloudBase PG.- Note: in a PG env,
EnvInfo.Storages[]is the legacy NoSQL bucket. It still works for legacyapp.uploadFile()flows but is NOT a usable pgstore bucket — never reuse it as the `segment inapp.storage.from('').upload('', file)`.
> Creating a PG-mode environment > > If step 0 shows RuntimeBackends.postgresql === false and you need PostgreSQL, create a new environment with PG enabled: > > - Via MCP: manageEnv(action="create", alias="my-env", packageId="baas_personal", resources=["flexdb","storage","function","postgresql"], confirm="yes") — do not pass region; CreateEnv does not accept it. > - Via CLI: tcb env create --alias my-env --package baas_personal --postgresql --yes > - Via Console: Create environment
- Inspect the existing app surfaces first:
src/lib/backend.*,src/lib/auth.*,src/lib/*service.*, route guards, and the handlers bound to existing forms. - Check PG state through MCP: use
queryPgDatabasefor schema/read-only inspection andmanagePgDatabasefor DDL/DML. Do not switch to MySQL tools. For the complete route map, readreferences/index.md. - Understand PG roles before writing code: Publishable Key maps to
anon; a logged-in user's access token maps toauthenticated; API Key maps toservice_roleand bypasses RLS. Never expose API Key /service_rolecredentials in frontend code. Seereferences/auth-and-rls.md. - Use schema management (
managePgDatabase) before writing CRUD code. Schema DDL (CREATE / ALTER / DROP / TRUNCATE) must go through the versioned migration workflow — never default toexecutefor table creation. Then apply GRANT + RLS (viaexecuteor the same migration SQL bundle) before browser access. The minimum SQL bundle is:CREATE TABLE,GRANT SELECT/INSERT/UPDATE/DELETE TO authenticated,GRANT USAGE, SELECT ON SEQUENCE ... TO authenticatedwhen usingserial/bigserial,ALTER TABLE ... ENABLE ROW LEVEL SECURITY, andCREATE POLICY ... USING / WITH CHECK. Seereferences/auth-and-rls.mdfor the full template.
Default schema-change workflow (local file first, then remote history):
- Choose
migrationVersion= 14-digit UTC timestampYYYYMMDDHHMMSSandmigrationName= snake_case (e.g.add_users). - Write local file
migrations/_.sqlwith the DDL (and optional rollback SQL in comments or a paired file). - Optional preview:
managePgDatabase(action=planMigration, migrationName=..., migrationVersion=..., sql=...). - Apply:
managePgDatabase(action=applyMigration, migrationName=..., migrationVersion=..., sql=..., confirm=true)— reuse the same version/name as the local file. - Verify:
managePgDatabase(action=listMigrations)and confirm the remote history records the samemigrationVersion. - Then write frontend CRUD / RLS checks.
Other migration actions:
managePgDatabase(action=migrationDetail, migrationVersion=...)— inspect a single migrationmanagePgDatabase(action=rollbackMigration, lastN=..., confirm=true)— roll back the last N applied migrationsmanagePgDatabase(action=repairMigration, migrationVersion=..., migrationName=..., repairStatus=..., repairReason=...)— repair history records
execute is for DML and ops SQL, not default DDL: use managePgDatabase(action=execute, confirm=true) for INSERT / UPDATE / DELETE, and for GRANT / CREATE POLICY / storage RLS when those are not part of a migration. If you attempt schema DDL via execute, the tool soft-blocks with DDL_USE_APPLY_MIGRATION unless you explicitly set allowDdlViaExecute=true (escape hatch only).
🚨 CRITICAL: Inspect table existence and column names before CREATE TABLE. CREATE TABLE IF NOT EXISTS silently skips when the table already exists, even if the column names are wrong. Always call queryPgDatabase(action="sql", sql="SELECT column_name, data_type FROM information_schema.columns WHERE table_name='xxx'") first to check whether the table exists and what exact column names it uses. If the table already exists with mismatched column names (e.g. user_id instead of uid), you must either:
ALTER TABLEto add/rename/drop columns (viaapplyMigrationwith a new version), orDROP TABLE IF EXISTS ... CASCADEand recreate viaapplyMigration(only when data loss is acceptable, e.g. disposable/evaluation environments).- Do NOT rely on
CREATE TABLE IF NOT EXISTSsilent skip — it will cause all downstream CRUD queries to fail with wrong field names. - After DDL, re-query the schema and compare every column name used by frontend code, insert/update payloads, filters, ordering, and RLS policies.
- Check username-password auth before coding login:
- Call
queryAppAuth(action="getLoginConfig"). - If
loginMethods.usernamePassword !== true, callmanageAppAuth(action="patchLoginStrategy", patch={ usernamePassword: true }). - In Web login code, use
auth.signInWithPassword({ username, password })for plain usernames likeadminoreditor. - Do not assume
auth.signUp({ username, password })can directly create username/password users. ConfirmqueryAppAuthsdkHintsand the installed@cloudbase/js-sdkbehavior first; if direct username signup is unsupported, implement registration through a backend/management boundary instead of exposing secret keys in the browser.
- Implement Web auth state with
auth.getSession()before writing CRUD:
- Route guards must check
data.session, notauth.getUser()and not deprecatedgetLoginState(). - Treat login as successful only when
signInWithPassword(...)returns noerrorand includesdata.session. - Get the UID for
author_id/ role rows fromdata.session.user.id(fall back tosub/uidonly after inspecting the actual session object). - Do not use
auth.getUser()as proof of login; it can return a non-null wrapper or anonymous-looking user data when there is no real username/password session.
- Implement browser-side business data with the CloudBase JS SDK v3 PostgreSQL API first:
app.rdb().from(table). Use the latest@cloudbase/js-sdkwhenapp.rdbis missing (xxx.rdb is not a functionmeans the SDK is too old). - Do not manually fetch a CloudBase Auth bearer token from browser code for PG CRUD. In particular, do not call non-canonical helpers such as
currentUser.getIdToken()unless you have verified that exact method exists in the installed SDK. Preferapp.rdb()so the SDK carries the active session. - Use the official CloudBase PG SQL auth helpers in policies:
auth.uid()for JWTsub,auth.role()foranon/authenticated/service_role,auth.jwt()for full claims, andauth.email()when email is needed. Still verify the policy through the real app session before claiming it works:
- Log in through the real app path.
- Insert a test row using
author_id = session.user.id. - Read it back with
queryPgDatabase. - If INSERT/SELECT fails, inspect the exact RLS error and fix the policy or switch to a server/RPC boundary. Do not leave browser-facing tables with broken RLS.
- ⚠️ Do NOT use
current_userorcurrent_setting(...)in RLS policies.current_userin PostgreSQL returns the database role name (e.g.authenticated), NOT the CloudBase auth user ID. Always useauth.uid()for user identity checks. If you are unsure whether the auth helpers are available, runSELECT proname FROM pg_proc WHERE pronamespace = 'auth'::regnamespaceto list all availableauth.*functions.
- Use PG HTTP API only as a fallback after reading OpenAPI docs and verifying the auth model in the installed SDK. Do not guess URLs such as
/api/v1/rdb/rest; the documented base ishttps://.api.tcloudbasegateway.com/v1/rdb/rest/and auth isAuthorization: Bearer. - Keep cover images in CloudBase Storage. Store only the final file URL or file metadata in PG.
- Verify both layers before claiming done: project build/typecheck and browser E2E for login/CRUD, then read back rows with
queryPgDatabase. When debugging RLS, run SQL asauthenticated/anonif the tool supports role simulation; admin/default execution can bypass the user-facing failure.
Exploration Budget
- Optimize for a working user flow before broad research.
- If the task is a Web app with PG-backed CRUD, read
references/app-workflow.mdand follow that closure path before looking up optional HTTP API details. - Do not query the same documentation family more than twice for the same question. If the second lookup does not unblock you, inspect the installed SDK surface or the exact runtime error instead.
- Once you choose
app.rdb()for browser CRUD, stop researching raw PG HTTP APIs unlessapp.rdb()is missing or demonstrably fails. - After a DDL failure, retry SQL at most twice. Then call
queryPgDatabase(action="objects")to find the schema-qualified table name, thenqueryPgDatabase(action="schema", objectName="public.your_table"), read the exact error, and simplify the schema or permission plan. - Avoid long task-management loops for targeted repairs. Read the active files, execute the minimum platform setup, edit code, and verify.
- File read budget: Do NOT read the same file more than 2 times. If you need to re-read a file after 2 reads, use
Grepfor targeted search orReadwith explicitoffset/limitto target specific line ranges. Move on to editing or verifying instead of re-reading.
Data Model Rules
- Use CloudBase Auth / CloudBase PG built-in auth identity as the user source. Do not copy an extra identity table unless the app needs one.
- Keep business roles in PG when the app needs admin/editor behavior, e.g.
user_roleswithuid,username, androle. Theuidvalue must be the same value the Web session uses assession.user.id, and must match any database policy expression you use. - Keep content tables in PG, e.g.
articlesorpostswith owner UID columns. - Prefer snake_case physical columns (
author_id,author_name,cover_image,created_at,updated_at) for PG tables. If UI fields are camelCase, map them explicitly at t
…
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: TencentCloudBase
- Source: TencentCloudBase/cloudbase-skills
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.