[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6HSB8SMR3083GN4MF1T3Z50":3,"skill-same:01M6HSB8SMR3083GN4MF1T3Z50":62},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":36,"linkOnly":37,"markdownContent":38,"markdownBody":39,"frontMatter":40,"refName":41,"commitSha":42,"skillDirectory":43,"forksCount":44,"repositoryHtmlUrl":45,"repositoryHomepageUrl":6,"ownerHtmlUrl":46,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":47,"install":48,"resources":61},"01M6HSB8SMR3083GN4MF1T3Z50","auth-wechat-miniprogram",null,"Complete guide for WeChat Mini Program authentication with CloudBase - native login, user identity, and cloud function integration.","welflau\u002Fai-dev-system","welflau","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F7010385?v=4","01M6HPTDGF18RFY07M229P8CTM","01M6HPTDMRMZCJPYBFEA9XVVYT",3,"MIT","https:\u002F\u002Fgithub.com\u002Fwelflau\u002Fai-dev-system\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fmarketplace\u002Fcodebuddy-plugins-official\u002Fplugins\u002Fcloudbase\u002Fskills\u002Fcloudbase\u002Freferences\u002Fauth-wechat\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35],"wechat miniprogram","auth wechat miniprogram","wechat","auth","complete","program","cloudbase","for","login","with","native","false","guide","user","cloud","integration","authentication","identity","2026-11-10 10:12:30",false,"---\nname: auth-wechat-miniprogram\ndescription: Complete guide for WeChat Mini Program authentication with CloudBase - native login, user identity, and cloud function integration.\nalwaysApply: false\n---\n\n## When to use this skill\n\nUse this skill for **WeChat Mini Program (小程序) authentication** in a CloudBase project.\n\nUse it when you need to:\n\n- Implement WeChat Mini Program login with CloudBase\n- Access user identity (openid, unionid) in cloud functions\n- Understand how WeChat authentication integrates with CloudBase\n- Build Mini Program features that require user identification\n\n**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.\n\n**Do NOT use for:**\n\n- Web-based WeChat login (use the **auth-web** skill)\n- Server-side auth with Node SDK (use the **auth-nodejs** skill)\n- Non-WeChat authentication methods (use appropriate auth skills)\n\n---\n\n## How to use this skill (for a coding agent)\n\n1. **Confirm CloudBase environment**\n   - Ask the user for:\n     - `env` – CloudBase environment ID\n     - Confirm the Mini Program is linked to the CloudBase environment\n\n2. **Understand the authentication flow**\n   - WeChat Mini Program authentication is **native and automatic**\n   - No explicit login API calls needed in most cases\n   - User identity is automatically available in cloud functions\n   - CloudBase handles all authentication verification\n\n3. **Pick a scenario from this file**\n   - For basic user identity in cloud functions, use **Scenario 2**\n   - For Mini Program initialization, use **Scenario 1**\n   - For calling a cloud function from the Mini Program and receiving user identity, use **Scenario 3**\n   - For testing authentication, use **Scenario 4**\n\n4. **Follow CloudBase API shapes exactly**\n   - Use `wx-server-sdk` in cloud functions\n   - Use `wx.cloud` in Mini Program client code\n   - Treat method names and parameter shapes in this file as canonical\n\n5. **If you're unsure about an API**\n   - Consult the official CloudBase Mini Program documentation\n   - Only use methods that appear in official documentation\n\n---\n\n## Core concepts\n\n### How WeChat Mini Program authentication works with CloudBase\n\n1. **Automatic authentication:**\n   - When a Mini Program user calls a cloud function, WeChat automatically injects the user's identity\n   - No need for complex OAuth flows or token management\n   - CloudBase verifies the authenticity of the identity\n\n2. **User identifiers:**\n   - `OPENID` – Unique identifier for the user in this specific Mini Program\n   - `APPID` – The Mini Program's App ID\n   - `UNIONID` – (Optional) Unique identifier across all apps under the same WeChat Open Platform account\n     - Only available when the Mini Program is bound to a WeChat Open Platform account\n     - Useful for identifying the same user across multiple Mini Programs or Official Accounts\n\n3. **Security:**\n   - The `openid`, `appid`, and `unionid` are **verified and trustworthy**\n   - WeChat has already completed authentication\n   - Developers can directly use these identifiers without additional verification\n\n4. **No explicit login required:**\n   - Users are automatically authenticated when they use the Mini Program\n   - No need to call login APIs in most cases\n   - Identity is available immediately in cloud functions\n\n---\n\n## Scenarios – WeChat Mini Program auth patterns\n\n### Scenario 1: Initialize CloudBase in Mini Program\n\nUse this in your Mini Program's `app.js` or entry point:\n\n```js\n\u002F\u002F app.js\nApp({\n  onLaunch: function () {\n    \u002F\u002F Initialize CloudBase\n    wx.cloud.init({\n      env: 'your-env-id',  \u002F\u002F Your CloudBase environment ID\n      traceUser: true      \u002F\u002F Optional: track user access in console\n    })\n  }\n})\n```\n\n**Key points:**\n\n- Call `wx.cloud.init()` once when the Mini Program launches\n- Set `env` to your CloudBase environment ID\n- `traceUser: true` enables user access tracking in CloudBase console (optional but recommended)\n\n---\n\n### Scenario 2: Get user identity in a cloud function\n\nUse this when you need to know **who is calling** your cloud function:\n\n```js\n\u002F\u002F Cloud function: cloudfunctions\u002FgetUserInfo\u002Findex.js\nconst cloud = require('wx-server-sdk')\n\n\u002F\u002F Initialize cloud with dynamic environment\ncloud.init({\n  env: cloud.DYNAMIC_CURRENT_ENV\n})\n\nexports.main = async (event, context) => {\n  \u002F\u002F Get user identity - this is automatically injected by WeChat\n  const { OPENID, APPID, UNIONID } = cloud.getWXContext()\n\n  console.log('User identity:', { OPENID, APPID, UNIONID })\n\n  \u002F\u002F Use OPENID for user-specific operations\n  \u002F\u002F For example: query user data, check permissions, etc.\n\n  return {\n    openid: OPENID,\n    appid: APPID,\n    unionid: UNIONID  \u002F\u002F May be undefined if not available\n  }\n}\n```\n\n**Key points:**\n\n- Use `cloud.getWXContext()` to get user identity\n- `OPENID` is always available and uniquely identifies the user\n- `APPID` identifies the Mini Program\n- `UNIONID` is only available when:\n  - The Mini Program is bound to a WeChat Open Platform account\n  - The user has authorized the Mini Program\n- These values are **verified and trustworthy** - no need to validate them\n- Use `cloud.DYNAMIC_CURRENT_ENV` to automatically use the current environment\n\n**Best practices:**\n\n- Store `OPENID` in your database to associate data with users\n- Use `OPENID` for authorization and access control\n- Use `UNIONID` when you need to identify users across multiple Mini Programs or Official Accounts\n- Never expose `OPENID` to other users (it's a private identifier)\n\n---\n\n### Scenario 3: Call cloud function from Mini Program\n\nUse this in your Mini Program to call a cloud function and get user identity:\n\n```js\n\u002F\u002F In Mini Program page\nPage({\n  onLoad: function() {\n    this.getUserInfo()\n  },\n\n  getUserInfo: function() {\n    wx.cloud.callFunction({\n      name: 'getUserInfo',  \u002F\u002F Cloud function name\n      data: {},             \u002F\u002F Optional parameters\n      success: res => {\n        console.log('User info from cloud function:', res.result)\n        \u002F\u002F res.result contains { openid, appid, unionid }\n\n        \u002F\u002F Use the user info\n        this.setData({\n          openid: res.result.openid\n        })\n      },\n      fail: err => {\n        console.error('Failed to get user info:', err)\n      }\n    })\n  }\n})\n```\n\n**Key points:**\n\n- Use `wx.cloud.callFunction()` to call cloud functions\n- User identity is automatically passed to the cloud function\n- No need to manually send user credentials\n- Handle both success and error cases\n\n---\n\n### Scenario 4: Test authentication - Simple test function\n\n**Cloud function (cloudfunctions\u002Ftest\u002Findex.js):**\n\n```js\nconst cloud = require('wx-server-sdk')\n\ncloud.init({\n  env: cloud.DYNAMIC_CURRENT_ENV\n})\n\nexports.main = async (event, context) => {\n  \u002F\u002F Get verified user identity - automatically injected by WeChat\n  const { OPENID, APPID, UNIONID } = cloud.getWXContext()\n\n  console.log('User identity:', { OPENID, APPID, UNIONID })\n\n  return {\n    success: true,\n    message: 'Authentication successful',\n    identity: {\n      openid: OPENID,\n      appid: APPID,\n      unionid: UNIONID || 'Not available'\n    },\n    timestamp: new Date().toISOString()\n  }\n}\n```\n\n**Mini Program code:**\n\n```js\n\u002F\u002F pages\u002Findex\u002Findex.js\nPage({\n  data: {\n    userIdentity: null\n  },\n\n  onLoad: function() {\n    this.testAuth()\n  },\n\n  testAuth: function() {\n    console.log('Testing authentication...')\n\n    wx.cloud.callFunction({\n      name: 'test',\n      success: res => {\n        console.log('Authentication test result:', res.result)\n\n        this.setData({\n          userIdentity: res.result.identity\n        })\n\n        wx.showToast({\n          title: 'Auth successful',\n          icon: 'success'\n        })\n      },\n      fail: err => {\n        console.error('Authentication test failed:', err)\n        wx.showToast({\n          title: 'Auth failed',\n          icon: 'error'\n        })\n      }\n    })\n  }\n})\n```\n\n**Key points:**\n\n- No explicit login API call needed\n- User identity is automatically available in cloud function\n- `OPENID` is always present and verified\n- `UNIONID` may be undefined if not available\n- Use this pattern to verify authentication is working correctly\n\n---\n\n## Best practices\n\n### 1. Always use cloud.DYNAMIC_CURRENT_ENV\n\n```js\ncloud.init({\n  env: cloud.DYNAMIC_CURRENT_ENV\n})\n```\n\nThis ensures the cloud function uses the correct environment automatically.\n\n### 2. Store OPENID for user identification\n\n- Use `OPENID` as the primary user identifier\n- Store it in your database to associate data with users\n- Never expose `OPENID` to other users\n\n### 3. Handle UNIONID availability\n\n```js\nconst { OPENID, UNIONID } = cloud.getWXContext()\n\nif (UNIONID) {\n  \u002F\u002F User has UNIONID - can be used for cross-app identification\n  console.log('UNIONID available:', UNIONID)\n} else {\n  \u002F\u002F UNIONID not available - use OPENID only\n  console.log('Using OPENID only:', OPENID)\n}\n```\n\n### 4. Use OPENID for user-specific operations\n\n- Use `OPENID` to identify and authorize users\n- Store `OPENID` when you need to associate data with users\n- Use `OPENID` in queries to ensure users only access their own data\n\n### 5. Error handling\n\nAlways handle errors when calling cloud functions:\n\n```js\nwx.cloud.callFunction({\n  name: 'myFunction',\n  success: res => {\n    \u002F\u002F Handle success\n  },\n  fail: err => {\n    console.error('Cloud function error:', err)\n    \u002F\u002F Show user-friendly error message\n    wx.showToast({\n      title: 'Operation failed',\n      icon: 'error'\n    })\n  }\n})\n```\n\n### 6. Initialize CloudBase early\n\nInitialize CloudBase in `app.js` `onLaunch`:\n\n```js\nApp({\n  onLaunch: function () {\n    wx.cloud.init({\n      env: 'your-env-id',\n      traceUser: true\n    })\n  }\n})\n```\n\n---\n\n## Common patterns\n\n### Pattern 1: Get and return user identity\n\n```js\nconst cloud = require('wx-server-sdk')\ncloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })\n\nexports.main = async (event, context) => {\n  const { OPENID, APPID, UNIONID } = cloud.getWXContext()\n\n  return {\n    openid: OPENID,\n    appid: APPID,\n    unionid: UNIONID || null\n  }\n}\n```\n\n### Pattern 2: Use OPENID for authorization\n\n```js\nconst cloud = require('wx-server-sdk')\ncloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })\n\nexports.main = async (event, context) => {\n  const { OPENID } = cloud.getWXContext()\n\n  \u002F\u002F Check if user is authorized\n  if (OPENID === event.resourceOwnerId) {\n    \u002F\u002F User is authorized to access this resource\n    return { authorized: true }\n  } else {\n    return { authorized: false, error: 'Unauthorized' }\n  }\n}\n```\n\n### Pattern 3: Handle UNIONID availability\n\n```js\nconst cloud = require('wx-server-sdk')\ncloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })\n\nexports.main = async (event, context) => {\n  const { OPENID, UNIONID } = cloud.getWXContext()\n\n  if (UNIONID) {\n    \u002F\u002F Can use UNIONID for cross-app user identification\n    console.log('User has UNIONID:', UNIONID)\n  } else {\n    \u002F\u002F Fall back to OPENID only\n    console.log('Using OPENID only:', OPENID)\n  }\n\n  return { openid: OPENID, hasUnionId: !!UNIONID }\n}\n```\n\n---\n\n## Summary\n\nWeChat Mini Program authentication with CloudBase is **simple and secure**:\n\n1. **No explicit login needed** - authentication is automatic\n2. **User identity is verified** - `OPENID`, `APPID`, and `UNIONID` are trustworthy\n3. **Easy to use** - just call `cloud.getWXContext()` in cloud functions\n4. **Secure by default** - WeChat handles all authentication verification\n\n**Key takeaways:**\n\n- Initialize CloudBase with `wx.cloud.init()` in Mini Program\n- Use `cloud.getWXContext()` to get user identity in cloud functions\n- Use `OPENID` for user identification and authorization\n- Handle `UNIONID` availability appropriately\n- No explicit login API calls needed - authentication is automatic\n\nFor more complex authentication scenarios or integration with other systems, consider using CloudBase custom login in combination with WeChat authentication.\n","## When to use this skill\n\nUse this skill for **WeChat Mini Program (小程序) authentication** in a CloudBase project.\n\nUse it when you need to:\n\n- Implement WeChat Mini Program login with CloudBase\n- Access user identity (openid, unionid) in cloud functions\n- Understand how WeChat authentication integrates with CloudBase\n- Build Mini Program features that require user identification\n\n**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.\n\n**Do NOT use for:**\n\n- Web-based WeChat login (use the **auth-web** skill)\n- Server-side auth with Node SDK (use the **auth-nodejs** skill)\n- Non-WeChat authentication methods (use appropriate auth skills)\n\n---\n\n## How to use this skill (for a coding agent)\n\n1. **Confirm CloudBase environment**\n   - Ask the user for:\n     - `env` – CloudBase environment ID\n     - Confirm the Mini Program is linked to the CloudBase environment\n\n2. **Understand the authentication flow**\n   - WeChat Mini Program authentication is **native and automatic**\n   - No explicit login API calls needed in most cases\n   - User identity is automatically available in cloud functions\n   - CloudBase handles all authentication verification\n\n3. **Pick a scenario from this file**\n   - For basic user identity in cloud functions, use **Scenario 2**\n   - For Mini Program initialization, use **Scenario 1**\n   - For calling a cloud function from the Mini Program and receiving user identity, use **Scenario 3**\n   - For testing authentication, use **Scenario 4**\n\n4. **Follow CloudBase API shapes exactly**\n   - Use `wx-server-sdk` in cloud functions\n   - Use `wx.cloud` in Mini Program client code\n   - Treat method names and parameter shapes in this file as canonical\n\n5. **If you're unsure about an API**\n   - Consult the official CloudBase Mini Program documentation\n   - Only use methods that appear in official documentation\n\n---\n\n## Core concepts\n\n### How WeChat Mini Program authentication works with CloudBase\n\n1. **Automatic authentication:**\n   - When a Mini Program user calls a cloud function, WeChat automatically injects the user's identity\n   - No need for complex OAuth flows or token management\n   - CloudBase verifies the authenticity of the identity\n\n2. **User identifiers:**\n   - `OPENID` – Unique identifier for the user in this specific Mini Program\n   - `APPID` – The Mini Program's App ID\n   - `UNIONID` – (Optional) Unique identifier across all apps under the same WeChat Open Platform account\n     - Only available when the Mini Program is bound to a WeChat Open Platform account\n     - Useful for identifying the same user across multiple Mini Programs or Official Accounts\n\n3. **Security:**\n   - The `openid`, `appid`, and `unionid` are **verified and trustworthy**\n   - WeChat has already completed authentication\n   - Developers can directly use these identifiers without additional verification\n\n4. **No explicit login required:**\n   - Users are automatically authenticated when they use the Mini Program\n   - No need to call login APIs in most cases\n   - Identity is available immediately in cloud functions\n\n---\n\n## Scenarios – WeChat Mini Program auth patterns\n\n### Scenario 1: Initialize CloudBase in Mini Program\n\nUse this in your Mini Program's `app.js` or entry point:\n\n```js\n\u002F\u002F app.js\nApp({\n  onLaunch: function () {\n    \u002F\u002F Initialize CloudBase\n    wx.cloud.init({\n      env: 'your-env-id',  \u002F\u002F Your CloudBase environment ID\n      traceUser: true      \u002F\u002F Optional: track user access in console\n    })\n  }\n})\n```\n\n**Key points:**\n\n- Call `wx.cloud.init()` once when the Mini Program launches\n- Set `env` to your CloudBase environment ID\n- `traceUser: true` enables user access tracking in CloudBase console (optional but recommended)\n\n---\n\n### Scenario 2: Get user identity in a cloud function\n\nUse this when you need to know **who is calling** your cloud function:\n\n```js\n\u002F\u002F Cloud function: cloudfunctions\u002FgetUserInfo\u002Findex.js\nconst cloud = require('wx-server-sdk')\n\n\u002F\u002F Initialize cloud with dynamic environment\ncloud.init({\n  env: cloud.DYNAMIC_CURRENT_ENV\n})\n\nexports.main = async (event, context) => {\n  \u002F\u002F Get user identity - this is automatically injected by WeChat\n  const { OPENID, APPID, UNIONID } = cloud.getWXContext()\n\n  console.log('User identity:', { OPENID, APPID, UNIONID })\n\n  \u002F\u002F Use OPENID for user-specific operations\n  \u002F\u002F For example: query user data, check permissions, etc.\n\n  return {\n    openid: OPENID,\n    appid: APPID,\n    unionid: UNIONID  \u002F\u002F May be undefined if not available\n  }\n}\n```\n\n**Key points:**\n\n- Use `cloud.getWXContext()` to get user identity\n- `OPENID` is always available and uniquely identifies the user\n- `APPID` identifies the Mini Program\n- `UNIONID` is only available when:\n  - The Mini Program is bound to a WeChat Open Platform account\n  - The user has authorized the Mini Program\n- These values are **verified and trustworthy** - no need to validate them\n- Use `cloud.DYNAMIC_CURRENT_ENV` to automatically use the current environment\n\n**Best practices:**\n\n- Store `OPENID` in your database to associate data with users\n- Use `OPENID` for authorization and access control\n- Use `UNIONID` when you need to identify users across multiple Mini Programs or Official Accounts\n- Never expose `OPENID` to other users (it's a private identifier)\n\n---\n\n### Scenario 3: Call cloud function from Mini Program\n\nUse this in your Mini Program to call a cloud function and get user identity:\n\n```js\n\u002F\u002F In Mini Program page\nPage({\n  onLoad: function() {\n    this.getUserInfo()\n  },\n\n  getUserInfo: function() {\n    wx.cloud.callFunction({\n      name: 'getUserInfo',  \u002F\u002F Cloud function name\n      data: {},             \u002F\u002F Optional parameters\n      success: res => {\n        console.log('User info from cloud function:', res.result)\n        \u002F\u002F res.result contains { openid, appid, unionid }\n\n        \u002F\u002F Use the user info\n        this.setData({\n          openid: res.result.openid\n        })\n      },\n      fail: err => {\n        console.error('Failed to get user info:', err)\n      }\n    })\n  }\n})\n```\n\n**Key points:**\n\n- Use `wx.cloud.callFunction()` to call cloud functions\n- User identity is automatically passed to the cloud function\n- No need to manually send user credentials\n- Handle both success and error cases\n\n---\n\n### Scenario 4: Test authentication - Simple test function\n\n**Cloud function (cloudfunctions\u002Ftest\u002Findex.js):**\n\n```js\nconst cloud = require('wx-server-sdk')\n\ncloud.init({\n  env: cloud.DYNAMIC_CURRENT_ENV\n})\n\nexports.main = async (event, context) => {\n  \u002F\u002F Get verified user identity - automatically injected by WeChat\n  const { OPENID, APPID, UNIONID } = cloud.getWXContext()\n\n  console.log('User identity:', { OPENID, APPID, UNIONID })\n\n  return {\n    success: true,\n    message: 'Authentication successful',\n    identity: {\n      openid: OPENID,\n      appid: APPID,\n      unionid: UNIONID || 'Not available'\n    },\n    timestamp: new Date().toISOString()\n  }\n}\n```\n\n**Mini Program code:**\n\n```js\n\u002F\u002F pages\u002Findex\u002Findex.js\nPage({\n  data: {\n    userIdentity: null\n  },\n\n  onLoad: function() {\n    this.testAuth()\n  },\n\n  testAuth: function() {\n    console.log('Testing authentication...')\n\n    wx.cloud.callFunction({\n      name: 'test',\n      success: res => {\n        console.log('Authentication test result:', res.result)\n\n        this.setData({\n          userIdentity: res.result.identity\n        })\n\n        wx.showToast({\n          title: 'Auth successful',\n          icon: 'success'\n        })\n      },\n      fail: err => {\n        console.error('Authentication test failed:', err)\n        wx.showToast({\n          title: 'Auth failed',\n          icon: 'error'\n        })\n      }\n    })\n  }\n})\n```\n\n**Key points:**\n\n- No explicit login API call needed\n- User identity is automatically available in cloud function\n- `OPENID` is always present and verified\n- `UNIONID` may be undefined if not available\n- Use this pattern to verify authentication is working correctly\n\n---\n\n## Best practices\n\n### 1. Always use cloud.DYNAMIC_CURRENT_ENV\n\n```js\ncloud.init({\n  env: cloud.DYNAMIC_CURRENT_ENV\n})\n```\n\nThis ensures the cloud function uses the correct environment automatically.\n\n### 2. Store OPENID for user identification\n\n- Use `OPENID` as the primary user identifier\n- Store it in your database to associate data with users\n- Never expose `OPENID` to other users\n\n### 3. Handle UNIONID availability\n\n```js\nconst { OPENID, UNIONID } = cloud.getWXContext()\n\nif (UNIONID) {\n  \u002F\u002F User has UNIONID - can be used for cross-app identification\n  console.log('UNIONID available:', UNIONID)\n} else {\n  \u002F\u002F UNIONID not available - use OPENID only\n  console.log('Using OPENID only:', OPENID)\n}\n```\n\n### 4. Use OPENID for user-specific operations\n\n- Use `OPENID` to identify and authorize users\n- Store `OPENID` when you need to associate data with users\n- Use `OPENID` in queries to ensure users only access their own data\n\n### 5. Error handling\n\nAlways handle errors when calling cloud functions:\n\n```js\nwx.cloud.callFunction({\n  name: 'myFunction',\n  success: res => {\n    \u002F\u002F Handle success\n  },\n  fail: err => {\n    console.error('Cloud function error:', err)\n    \u002F\u002F Show user-friendly error message\n    wx.showToast({\n      title: 'Operation failed',\n      icon: 'error'\n    })\n  }\n})\n```\n\n### 6. Initialize CloudBase early\n\nInitialize CloudBase in `app.js` `onLaunch`:\n\n```js\nApp({\n  onLaunch: function () {\n    wx.cloud.init({\n      env: 'your-env-id',\n      traceUser: true\n    })\n  }\n})\n```\n\n---\n\n## Common patterns\n\n### Pattern 1: Get and return user identity\n\n```js\nconst cloud = require('wx-server-sdk')\ncloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })\n\nexports.main = async (event, context) => {\n  const { OPENID, APPID, UNIONID } = cloud.getWXContext()\n\n  return {\n    openid: OPENID,\n    appid: APPID,\n    unionid: UNIONID || null\n  }\n}\n```\n\n### Pattern 2: Use OPENID for authorization\n\n```js\nconst cloud = require('wx-server-sdk')\ncloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })\n\nexports.main = async (event, context) => {\n  const { OPENID } = cloud.getWXContext()\n\n  \u002F\u002F Check if user is authorized\n  if (OPENID === event.resourceOwnerId) {\n    \u002F\u002F User is authorized to access this resource\n    return { authorized: true }\n  } else {\n    return { authorized: false, error: 'Unauthorized' }\n  }\n}\n```\n\n### Pattern 3: Handle UNIONID availability\n\n```js\nconst cloud = require('wx-server-sdk')\ncloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })\n\nexports.main = async (event, context) => {\n  const { OPENID, UNIONID } = cloud.getWXContext()\n\n  if (UNIONID) {\n    \u002F\u002F Can use UNIONID for cross-app user identification\n    console.log('User has UNIONID:', UNIONID)\n  } else {\n    \u002F\u002F Fall back to OPENID only\n    console.log('Using OPENID only:', OPENID)\n  }\n\n  return { openid: OPENID, hasUnionId: !!UNIONID }\n}\n```\n\n---\n\n## Summary\n\nWeChat Mini Program authentication with CloudBase is **simple and secure**:\n\n1. **No explicit login needed** - authentication is automatic\n2. **User identity is verified** - `OPENID`, `APPID`, and `UNIONID` are trustworthy\n3. **Easy to use** - just call `cloud.getWXContext()` in cloud functions\n4. **Secure by default** - WeChat handles all authentication verification\n\n**Key takeaways:**\n\n- Initialize CloudBase with `wx.cloud.init()` in Mini Program\n- Use `cloud.getWXContext()` to get user identity in cloud functions\n- Use `OPENID` for user identification and authorization\n- Handle `UNIONID` availability appropriately\n- No explicit login API calls needed - authentication is automatic\n\nFor more complex authentication scenarios or integration with other systems, consider using CloudBase custom login in combination with WeChat authentication.\n",{"name":5,"alwaysApply":37,"description":7},"main","18d0e63d1313ca87098f614aa7c1e2dcf6de79c7","backend\u002Fskills\u002Fmarketplace\u002Fcodebuddy-plugins-official\u002Fplugins\u002Fcloudbase\u002Fskills\u002Fcloudbase\u002Freferences\u002Fauth-wechat",1,"https:\u002F\u002Fgithub.com\u002Fwelflau\u002Fai-dev-system","https:\u002F\u002Fgithub.com\u002Fwelflau","2026-11-12 14:55:20",{"source":8,"skillName":5,"commands":49,"prompt":59,"zipAvailable":60},[50,53,56],{"tool":51,"command":52},"npx","npx skills add welflau\u002Fai-dev-system --skill auth-wechat-miniprogram",{"tool":54,"command":55},"bunx","bunx skills add welflau\u002Fai-dev-system --skill auth-wechat-miniprogram",{"tool":57,"command":58},"pnpm","pnpm dlx skills add welflau\u002Fai-dev-system --skill auth-wechat-miniprogram","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fwelflau\u002Fai-dev-system\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fmarketplace\u002Fcodebuddy-plugins-official\u002Fplugins\u002Fcloudbase\u002Fskills\u002Fcloudbase\u002Freferences\u002Fauth-wechat\u002FSKILL.md",true,[],[63,96,126,152,182,207],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":67,"licenseFileUrl":68,"sourceHtmlUrl":69,"categories":70,"keywords":79,"publishedAt":95},"01M6HS9Z4B0YA8CJCS2Y2F04Y3","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fwelflau\u002Fai-dev-system\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fmarketplace\u002Fcodebuddy-plugins-official\u002Fexternal_plugins\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fwelflau\u002Fai-dev-system\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fmarketplace\u002Fcodebuddy-plugins-official\u002Fexternal_plugins\u002Fwebapp-testing\u002FSKILL.md",[71,76],{"categoryNo":72,"categoryName":73,"taxonomyType":74,"taxonomyTypeDesc":75},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",{"categoryNo":77,"categoryName":78,"taxonomyType":74,"taxonomyTypeDesc":75},"01JBSEEDCAT000000000000009","前端开发",[80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,27,25],"testing","webapp testing","webapp","frontend","screenshots","playwright","web","debugging","toolkit","browser","ui","logs","applications","behavior","local","2026-11-11 15:11:14",{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":67,"licenseFileUrl":100,"sourceHtmlUrl":101,"categories":102,"keywords":106,"publishedAt":95},"01M6HRAGMG7JF0HXYHMA5QHS8A","internal-comms","A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).","https:\u002F\u002Fgithub.com\u002Fwelflau\u002Fai-dev-system\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fmarketplace\u002Fcodebuddy-plugins-official\u002Fexternal_plugins\u002Finternal-comms\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fwelflau\u002Fai-dev-system\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fmarketplace\u002Fcodebuddy-plugins-official\u002Fexternal_plugins\u002Finternal-comms\u002FSKILL.md",[103],{"categoryNo":104,"categoryName":105,"taxonomyType":74,"taxonomyTypeDesc":75},"01JBSEEDCAT000000000000005","邮件与沟通",[107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125],"internal comms","comms","status","help","SET","write","use","reports","me","incident","leadership","project","resources","communications","internal communications","formats","sort","my","updates",{"skillNo":127,"name":128,"nameZh":6,"description":129,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":67,"licenseFileUrl":130,"sourceHtmlUrl":131,"categories":132,"keywords":134,"publishedAt":36},"01M6HSTDP4M3JFXEBK91VFB4PA","web-artifacts-builder","Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn\u002Fui). Use for complex artifacts requiring state management, routing, or shadcn\u002Fui components - not for simple single-file HTML\u002FJSX artifacts.","https:\u002F\u002Fgithub.com\u002Fwelflau\u002Fai-dev-system\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fmarketplace\u002Fcodebuddy-plugins-official\u002Fplugins\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fwelflau\u002Fai-dev-system\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fmarketplace\u002Fcodebuddy-plugins-official\u002Fplugins\u002Fweb-artifacts-builder\u002FSKILL.md",[133],{"categoryNo":77,"categoryName":78,"taxonomyType":74,"taxonomyTypeDesc":75},[135,86,136,137,138,83,139,140,141,142,143,144,145,146,113,147,148,149,150,25,151],"web artifacts builder","artifacts","artifacts builder","builder","css","components","react","routing","state management","state","file","Tailwind","single-file","simple","ui components","multi","single",{"skillNo":153,"name":154,"nameZh":6,"description":155,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":67,"licenseFileUrl":156,"sourceHtmlUrl":157,"categories":158,"keywords":168,"publishedAt":36},"01M6HSDXH0JSP8R3QTNY9XZ8HN","frontend-design","Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML\u002FCSS layouts, or when styling\u002Fbeautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.","https:\u002F\u002Fgithub.com\u002Fwelflau\u002Fai-dev-system\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fmarketplace\u002Fcodebuddy-plugins-official\u002Fplugins\u002Ffrontend-design\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fwelflau\u002Fai-dev-system\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fmarketplace\u002Fcodebuddy-plugins-official\u002Fplugins\u002Ffrontend-design\u002FSKILL.md",[159,160,163],{"categoryNo":77,"categoryName":78,"taxonomyType":74,"taxonomyTypeDesc":75},{"categoryNo":161,"categoryName":162,"taxonomyType":74,"taxonomyTypeDesc":75},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":164,"categoryName":165,"taxonomyType":166,"taxonomyTypeDesc":167},"01JBSEEDCAT000000000000032","设计师","PROFESSION","适用职业",[83,169,170,139,86,140,141,171,172,173,136,174,92,175,113,176,177,178,179,27,180,181],"design","frontend design","react components","create","code","examples","landing","ui design","pages","aesthetics","web ui","generic","when",{"skillNo":183,"name":184,"nameZh":6,"description":185,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":67,"licenseFileUrl":186,"sourceHtmlUrl":187,"categories":188,"keywords":190,"publishedAt":36},"01M6HSA77QYVP7A72HREGTDN2C","algorithmic-art","Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.","https:\u002F\u002Fgithub.com\u002Fwelflau\u002Fai-dev-system\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fmarketplace\u002Fcodebuddy-plugins-official\u002Fplugins\u002Falgorithmic-art\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fwelflau\u002Fai-dev-system\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fmarketplace\u002Fcodebuddy-plugins-official\u002Fplugins\u002Falgorithmic-art\u002FSKILL.md",[189],{"categoryNo":161,"categoryName":162,"taxonomyType":74,"taxonomyTypeDesc":75},[191,192,193,172,173,194,195,196,197,113,198,199,200,201,27,202,203,204,205,206,181],"algorithmic art","Art","algorithmic","flow","js","work","interactive","generative art","exploration","systems","users","Existing","request","generative","copyright","fields",{"skillNo":208,"name":209,"nameZh":6,"description":210,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":67,"licenseFileUrl":211,"sourceHtmlUrl":212,"categories":213,"keywords":215,"publishedAt":36},"01M6HS9HE0X390Y6RQKTY1YNGJ","theme-factory","Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors\u002Ffonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.","https:\u002F\u002Fgithub.com\u002Fwelflau\u002Fai-dev-system\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fmarketplace\u002Fcodebuddy-plugins-official\u002Fexternal_plugins\u002Ftheme-factory\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fwelflau\u002Fai-dev-system\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fmarketplace\u002Fcodebuddy-plugins-official\u002Fexternal_plugins\u002Ftheme-factory\u002FSKILL.md",[214],{"categoryNo":161,"categoryName":162,"taxonomyType":74,"taxonomyTypeDesc":75},[216,217,218,219,88,220,136,111,221,222,175,223,224,177,225,27,226,227,228,25,229,230],"theme factory","factory","theme","docs","generate","fly","slides","styling","artifact","themes","you","fonts","can","apply","new"]