16-wechat-sdk

16-wechat-sdk is a cursor rule for Cursor from neoshopcn/neo-admin. It costs 4,124 tokens per session, scanned A, original, MIT.

A set of rules for connecting a Laravel application to WeChat, a widely used Chinese messaging and services platform, through the EasyWeChat software library. It requires application code to use the project's WechatManager wrappers instead of calling the library directly.

In plain words
What is it for?
It is for implementing WeChat mini programs, public accounts, and payments, including orders, refunds, callbacks, configuration lookup, and clearing cached service instances.
Why use it?
It keeps WeChat configuration and access in one place, avoiding duplicated integrations and secrets stored in the wrong locations.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/neoshopcn/neo-admin/16-wechat-sdk
Clone the repo
git clone --depth 1 https://github.com/neoshopcn/neo-admin

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for 16-wechat-sdk

README.md
[![agentmods](https://agentmods.dev/badge/rules/neoshopcn/neo-admin/16-wechat-sdk.svg)](https://agentmods.dev/rules/neoshopcn/neo-admin/16-wechat-sdk)
Your own site
<a href="https://agentmods.dev/rules/neoshopcn/neo-admin/16-wechat-sdk"><img src="https://agentmods.dev/badge/rules/neoshopcn/neo-admin/16-wechat-sdk.svg" alt="Measured on agentmods" height="20"></a>
Per session 4,124 This file is loaded in full into every session.
When invoked 4,124 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.04124 $0.04124
Opus 5 $0.02062 $0.02062
Sonnet 5 $0.00825 $0.00825
Haiku 4.5 $0.00412 $0.00412

Measured 4d ago against content hash bb38e207ce6b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

16-wechat-sdk scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/16-wechat-sdk.mdc · 404 lines

How it starts

The opening of the file, as written. The whole thing — 404 lines — stays where its author put it; the contents beside it link to each section on GitHub.

微信 SDK

微信相关接口使用 w7corp/easywechat 6.17+

composer require w7corp/easywechat:^6.17

参考文档:EasyWeChat 6.x 总览


架构约定(必须实现)

业务代码不得直接使用 EasyWeChat SDK,必须通过以下封装访问:

路径 职责
App\Support\WechatManager 统一入口;进程内单例缓存 Application / 封装实例
App\Support\Wechat\ConfigMapper config_center('api.wechat.*') 映射为 EasyWeChat 配置数组
App\Support\Wechat\MiniProgram 小程序
App\Support\Wechat\Payment 支付(下单、退款、回调)
App\Support\Wechat\OfficialAccount 公众号

WechatManager 对外静态方法(固定命名):

WechatManager::miniProgram();      // → MiniProgram
WechatManager::payment();          // → Payment
WechatManager::officialAccount();  // → OfficialAccount
WechatManager::forgetInstances();  // 测试 / Octane / 配置变更后清缓存

配置读取

微信配置必须通过配置中心读取:

config_center('api.wechat.mini', []); // 小程序
config_center('api.wechat.mp', []);   // 公众号
config_center('api.wechat.pay', []); // 微信支付

配置项定义见 database/seeders/Admin/ConfigCenterDataSeeder.phpseedWechatConfig()

禁止

  • config('wechat') 或 Laravel 静态配置文件承载密钥
  • 业务层手写 ConfigItem::query() 查微信密钥
  • 硬编码 appid、secret、mch_id、PEM 等

配置变更后:ConfigCenter::forgetCache() + WechatManager::forgetInstances()


配置中心 → EasyWeChat 映射

ConfigMapper 集中完成,业务代码禁止散落映射逻辑。

配置中心 key EasyWeChat key 说明
appid app_id 小程序 / 公众号
secret secret
token token 服务端消息校验,可选
encoding_aes_key aes_key 消息加解密,可选
mch_id mch_id 商户号
secret_key secret_key APIv3 密钥
private_key private_key 商户 API 私钥
certificate certificate 商户 API 证书
platform_cert_id + platform_cert platform_certs [id => pem],见下文
notify_url 作为下单/退款请求字段,不是 Application 构造参数

小程序 / 公众号 Application 额外建议:

'http' => ['throw' => true, 'timeout' => 5.0, 'retry' => true],

支付 Application 额外建议:

'http' => ['throw' => true, 'timeout' => 5.0], // 支付模块禁止开启 retry

Read the full file on GitHub · 404 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 404 lines · 4,124 tokens per session scan A bb38e207ce6b

Subscribe to this mod's changes

16-wechat-sdk is a cursor rule published in the GitHub repository neoshopcn/neo-admin (12 stars, last pushed 2mo ago), licensed MIT. It adds 4,124 tokens to every session, about $0.0206 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.