postgresql-development-cloudbase
Use when building, debugging, or evaluating CloudBase PostgreSQL / CloudBase PG / PG mode apps, including Postgres schema setup, queryPgDatabase/managePgDatabase, JS SDK v3 app.rdb() CRUD/RPC, PG HTTP API fallback, RLS-style permissions, username-password auth, and Web CMS/admin CRUD flows backed by CloudBase PG.
npx skills add TencentCloudBase/CloudBase-AI-Toolkit --skill postgresql-development-cloudbase --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
The skill instructs the agent to work with CloudBase PostgreSQL/PG mode, covering schema setup, DDL/DML via managePgDatabase and execute, migrations workflow, GRANT and RLS policies, and frontend CRUD using the CloudBase JS SDK v3 (app.rdb()). It enforces PG-specific APIs over NoSQL patterns, emphasizes using migration-based schema changes, and prescribes how to handle authentication (user/password, session retrieval) and authorization (auth.uid(), auth.role(), auth.jwt()). It also specifies how to verify table existence before CREATE, how to fetch and inspect schema, and how to validate RLS through inserting and querying with session-derived user IDs. The workflow includes inspecting surfaces, using queryPgDatabase and managePgDatabase for schema state, and using migration tooling for DDL.
How it works
- Verify environment supports PostgreSQL via envQuery(action="info", envId=...).
- Use PG tools: queryPgDatabase for reads, managePgDatabase for DDL/DML; do not use MySQL tools.
- Understand roles: map publishable keys to anon; authenticated tokens to authenticated; API keys to service_role; never expose secret keys in frontend.
- Perform schema changes through the versioned migration workflow: create a local file cloudbase/migrations/<version>_<name>.sql, preview with managePgDatabase(action=planMigration, ...), apply with managePgDatabase(action=applyMigration, ...), then verify with listMigrations.
- Before CREATE TABLE, check existing schema with queryPgDatabase(action="sql", sql="SELECT column_name, data_type FROM information_schema.columns WHERE table_name='xxx'") and adjust with ALTER or DROP/RECREATE via a new migration if mismatches
- Authentication: fetch login config via queryAppAuth(action="getLoginConfig"); enable usernamePassword if needed via manageAppAuth(action="patchLoginStrategy", patch={ usernamePassword: true }). Use auth.signInWithPassword(...) in web login, and rely on auth.getSession() for state in route guards.
- Frontend data access via CloudBase JS SDK v3: app.rdb().from(table); upgrade SDK if app.rdb is missing.
- Do not fetch a Bearer token manually; rely on app.rdb() session handling.
- RLS policies: use auth.uid() and auth.role() helpers; test by inserting with author_id = session.user.id and reading back via queryPgDatabase; adjust policy if necessary.
- HTTP API fallback only after reading OpenAPI and ensuring auth model compatibility; base URL is documented, not guessed.
- Keep cover images in CloudBase Storage; store only final URLs/metadata in PG.
- Validate end-to-end: build/typecheck and browser E2E for login/CRUD, then re-read with queryPgDatabase.
When to use it
- Use when building, debugging, or evaluating CloudBase PostgreSQL / CloudBase PG / PG mode apps, including schema setup, RLS-style permissions, and Web CMS/admin CRUD flows backed by CloudBase PG.
What it can touch
- Tools explicitly named:
queryPgDatabase,managePgDatabase,app.rdb(),auth.getSession(),auth.uid(),auth.role(),auth.jwt(),auth.email(),queryAppAuth,manageAppAuth.
Caveats
- Emphasizes that PG mode API differs from NoSQL; avoid legacy NoSQL patterns in code.
- DDL should go through migration workflow; using execute for DDL is blocked unless allowDdlViaExecute=true is set.
auth.uid()returns text, not uuid; adjust comparisons accordingly.- Do not use
current_userin RLS policies; useauth.uid()for identity checks. - If environment is not PG-enabled, STOP and switch to NoSQL/document-database or storage flows as appropriate.
## Sibling skills (local only) Sibling CloudBase skills ship beside this skill. Use local relative paths such as `../auth-tool-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. # 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`, or `managePgDatabase`. - 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-cloudbase/SKILL.md` - Web login implementation -> `../auth-web-cloudbase/SKILL.md` - General Web implementation and verification -> `../web-development/SKILL.md` - Browser storage upload -> `../cloud-storage-web/SKILL.md` - Raw HTTP API details only when SDK coverage is blocked -> `../http-api-cloudbase/SKILL.md` - PG reference index -> `references/index.md` - PG mode overview -> `references/pg-mode-overview.md` - Auth / GRANT / RLS deta
- Sibling skills (local only)
- Activation Contract
- Use this first when
- Then also read
- Do NOT use first
- Required Flow
- 🚨 CRITICAL: PG mode API is NOT the same as NoSQL
- Exploration Budget
- Data Model Rules
- JS SDK v3 PostgreSQL Patterns
- ⚠️ Critical: PG API is NOT the same as CloudBase NoSQL or other ORMs
- Bucket existence is mandatory (Supabase parity)
- ExecutePGSql / DDL Troubleshooting
- HTTP API Fallback
What does the postgresql-development-cloudbase skill do?
Use when building, debugging, or evaluating CloudBase PostgreSQL / CloudBase PG / PG mode apps, including Postgres schema setup, queryPgDatabase/managePgDatabase, JS SDK v3 app.rdb() CRUD/RPC, PG HTTP API fallback, RLS-style permissions, username-password auth, and Web CMS/admin CRUD flows backed by CloudBase PG.
How do I install it?
Run `npx skills add TencentCloudBase/CloudBase-AI-Toolkit --skill postgresql-development-cloudbase --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From TencentCloudBase/CloudBase-AI-Toolkit, a repository with 1,066 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
