Skip to main content
skill CX Codex

auth-wechat-miniprogram — Claude Code skill: WeChat Mini Program auth

A skill that tells the agent how native auth works in CloudBase WeChat Mini Programs: openid and unionid arrive in the cloud function on their own.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add TencentCloudBase/skills --skill auth-wechat-miniprogram -a claude-code
Open on GitHub

What auth-wechat-miniprogram does

Reach for this skill when the project is a WeChat Mini Program on CloudBase and the question is about caller identity, not about configuring a login provider. The agent gets a description of how WeChat injects the caller's identity into a cloud function, so it stops proposing a web login page with token exchange.

The file carries an activation contract: when to read it first, when to read it before writing code, and when not to use it at all. Common mistakes are listed too — generating a web-style login for wx.cloud, treating mini program auth as provider configuration, forgetting that caller identity is already injected. For client code and cloud functions it points to sibling files ../miniprogram-development/SKILL.md and ../cloud-functions/SKILL.md via local relative paths.

Those siblings have to sit next to it. If a file is missing, the skill asks you to install the full CloudBase plugin instead of pulling markdown over HTTP into the agent context. You will need the CloudBase environment ID and a Mini Program linked to that environment. UNIONID is only available when the Mini Program is bound to a WeChat Open Platform account.

What it helps with

  • read the caller's openid inside a cloud function
  • drop a token exchange the Mini Program never needed
  • tell native Mini Program auth apart from web WeChat login
  • match one user across several Mini Programs by unionid
  • remove a leftover login page from the client code

Example prompts for the agent

  • Show me how to get the openid of the calling user inside a CloudBase cloud function
  • Check my Mini Program code for a token exchange that native auth already handles
  • I need the unionid in a cloud function — what has to be set up for that

How to install auth-wechat-miniprogram

1Skills CLI (Vercel)

npx skills add TencentCloudBase/skills --skill auth-wechat-miniprogram -a claude-code

2Manually: put the files in place

~/.claude/skills/auth-wechat-miniprogram/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/auth-wechat-miniprogram/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about auth-wechat-miniprogram

How do I install auth-wechat-miniprogram in Claude?

Run npx skills add TencentCloudBase/skills --skill auth-wechat-miniprogram -a claude-code. The skill lands at ~/.claude/skills/auth-wechat-miniprogram/SKILL.md.

What does auth-wechat-miniprogram do?

It explains native WeChat Mini Program auth on CloudBase to the agent: how the caller is identified in a cloud function and what openid, appid and unionid mean.

When should I not use this skill?

For web-based WeChat login, server-side auth with the Node SDK, or provider setup in the console — those belong to other CloudBase skills.

Source text

SKILL.md · MIT
---
name: auth-wechat-miniprogram
description: CloudBase WeChat Mini Program native authentication guide. This skill should be used when users need mini program identity handling, OPENID/UNIONID access, or `wx.cloud` auth behavior in projects where login is native and automatic.
version: 2.36.1
license: MIT
alwaysApply: false
---

## 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.

## Activation Contract

### Use this first when

- The task is about WeChat Mini Program auth behavior, `wx.cloud` identity, `OPENID` / `UNIONID`, or how a mini program caller is identified in CloudBase.
- The project is a CloudBase mini program and the auth question is about native mini program identity rather than provider configuration.

### Read before writing code if

- The request mentions mini program login, user identity in cloud functions, or `wx.cloud` auth assumptions.
- The user expects a Web-style login page or explicit token exchange in a mini program; route them back to native mini program auth behavior.

### Then also read

- Mini program project implementation -> `../miniprogram-development/SKILL.md`
- Cloud function implementation -> `../cloud-functions/SKILL.md`

### Do NOT use for

- Web-based WeChat login or Web auth UI.
- Provider enable/disable or auth console setup.
- Generic Node-side auth flows outside mini program identity handling.

### Common mistakes / gotchas

- Generating a Web-style login page for a `wx.cloud` mini program.
- Treating mini program auth as a provider-configuration problem.
- Forgetting that caller identity is injected in cloud functions automatically.

## When to use this skill

Use this skill for **WeChat Mini Program (小程序) authentication** in a CloudBase project.

Use it when you need to:

- Implement identity-aware WeChat Mini Program flows with CloudBase
- Access user identity (openid, unionid) in cloud functions
- Understand how WeChat authentication integrates with CloudBase
- Build Mini Program features that require user identification

**Key advantage:** WeChat Mini Program authentication with CloudBase is **seamless and automatic** - no complex OAuth flows needed. When a Mini Program calls a cloud function, the user's `openid` is automatically injected and verified by WeChat.

**Do NOT use for:**

- Web-based WeChat login (use the **auth-web** skill)
- Server-side auth with Node SDK (use the **auth-nodejs** skill)
- Non-WeChat authentication methods (use appropriate auth skills)

---

## How to use this skill (for a coding agent)

1. **Confirm CloudBase environment**
   - Ask the user for:
     - `env` – CloudBase environment ID
     - Confirm the Mini Program is linked to the CloudBase environment

2. **Understand the authentication flow**
   - WeChat Mini Program authentication is **native and automatic**
   - No explicit login API calls needed in most cases
   - User identity is automatically available in cloud functions
   - CloudBase handles all authentication verification

3. **Pick a scenario from this file**
   - For basic user identity in cloud functions, use **Scenario 2**
   - For Mini Program initialization, use **Scenario 1**
   - For calling a cloud function from the Mini Program and receiving user identity, use **Scenario 3**
   - For testing authentication, use **Scenario 4**

4. **Follow CloudBase API shapes exactly**
   - Use `wx-server-sdk` in cloud functions
   - Use `wx.cloud` in Mini Program client code
   - Treat method names and parameter shapes in this file as canonical

5. **If you're unsure about an API**
   - Consult the official CloudBase Mini Program documentation
   - Only use methods that appear in official documentation

---

## Core concepts

### How WeChat Mini Program authentication works with CloudBase

1. **Automatic authentication:**
   - When a Mini Program user calls a cloud function, WeChat automatically injects the user's identity
   - No need for complex OAuth flows or token management
   - CloudBase verifies the authenticity of the identity

2. **User identifiers:**
   - `OPENID` – Unique identifier for the user in this specific Mini Program
   - `APPID` – The Mini Program's App ID
   - `UNIONID` – (Optional) Unique identifier across all apps under the same WeChat Open Platform account
     - Only available when the Mini Program is bound to a WeChat Open Platform account
     - Useful for identifying the same user across multiple Mini Programs or Official Accounts

3. **Security:**
   - The `openid`, `appid`, and `unionid` are **verified and trustworthy**
   - WeChat has already completed authentication
   - Developers can directly use these identifiers without additional verification

4. **No explicit login required:**
   - Users are automatically authenticated when they use the Mini Program
   - No need to call login APIs in most cases
   - Identity is available immediately in cloud functions

---

## Extended guide

For detailed scenarios, examples, and patterns, read [extended-guide.md](references/extended-guide.md).

## Reference index

All packaged reference files (required for skill lint reachability):

- [extended-guide.md](references/extended-guide.md)

© TencentCloudBase · MIT · TencentCloudBase/skills

Similar skills

Everything for Mobile →

From the same set18

miniprogram-development Guides the creation, debugging, preview, and deployment of WeChat Mini Programs. Ideal when configuring project structure, CloudBase, and wechatide CLI workflows. CX Codex +1 4,400installs ui-design Makes the agent output a design specification — palette, fonts, layout — before it writes any interface code. CX Codex +1 1,800installs web-development A skill for implementing, debugging and shipping a web frontend once the product direction is settled. React, Vue, Vite, routing, browser checks. CX Codex +1 1,800installs cloudbase-document-database-in-wechat-miniprogram A skill that steers the agent through CloudBase document database work in a WeChat Mini Program: queries, pagination, aggregation, geolocation. CX Codex +1 1,500installs spec-workflow Guides coding agents through phased planning in specs/: EARS requirements, system design, and tasks. Useful when acceptance criteria must be explicit before coding. CX Codex +1 1,200installs cloud-functions Guides the agent through building, deploying and debugging CloudBase Event and HTTP Functions. Useful when you need your own runtime code, not platform API calls. CX Codex +1 1,200installs ai-model-wechat A skill for calling AI models in WeChat Mini Programs through wx.cloud.extend.AI. Useful when you add text generation to a mini app and don't want to guess the call shapes. CX Codex +1 1,100installs auth-tool-cloudbase Readies CloudBase authentication before you write client code: checks providers, publishable keys and login methods. CX Codex +1 1,000installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor