QR Bridge
Entry point reconnaissance tool. Decode QR codes, trace redirect chains, inspect gated destinations, and explain what the link actually needs.
When to Use This Skill
Activate when the user asks to:
- - Decode / scan / read a QR code from an image
- Trace where a short URL redirects to
- Check if a link requires WeChat / WeCom / login / app
- Diagnose why a link "doesn't work"
- Generate a QR code from text or URL
Setup (First Run Only)
Before first use, compile the Swift decoder binary:
CODEBLOCK0
If setup was already run, the binary exists at ~/.claude/skills/qr-bridge/scripts/qr-decode. Skip setup if it exists.
Commands
1. DECODE - Extract QR code content from an image
Step 1: Check if binary exists
CODEBLOCK1
If NEED_SETUP, run:
CODEBLOCK2
Step 2: Run decoder (compiled binary - fast)
CODEBLOCK3
Step 3: If compiled binary fails, use interpreted mode (slower but always works)
CODEBLOCK4
Step 4: If CoreImage fails, try pyzbar fallback
CODEBLOCK5
Output format (JSON):
CODEBLOCK6
2. TRACE - Follow redirect chains
After decoding a URL from a QR code (or given a URL directly), trace the full redirect chain:
CODEBLOCK7
For the full chain with each hop, use:
CODEBLOCK8
Parse the Location: headers from the output to build the chain:
CODEBLOCK9
3. INSPECT - Detect gated destinations
After tracing, inspect the final URL for access gates. Check for these patterns:
WeChat/WeCom Gates (common in Chinese QR codes):
- - Domain contains:
weixin.qq.com, work.weixin.qq.com, mp.weixin.qq.com, INLINECODE5 - Redirect to INLINECODE6
- Response contains:
请在微信客户端打开, INLINECODE8 - Response header
logicret: -2 = article not found / deleted / unpublished - User-Agent gating: returns different content for WeChat UA vs browser UA
- WeChat mini-program links:
weixin://dl/business/?appid= — cannot be opened outside WeChat
App-Gated Links:
- - Taobao:
tb.cn, m.tb.cn — returns 200 with JS redirect to Taobao app. Look for tbopen:// scheme or s_status: STATUS_NORMAL header - Douyin:
v.douyin.com — 302 redirect to www.douyin.com, then 404 for invalid links. Valid links redirect to INLINECODE17 - Xiaohongshu:
xhslink.com — 307 → www.xiaohongshu.com. Look for snssdk:// or xhsdiscover:// deep-link schemes - Alipay:
ur.alipay.com — redirects to alipays:// scheme - Response contains deep-link schemes:
weixin://, alipays://, tbopen://, snssdk://, INLINECODE28 - Meta refresh or JavaScript redirect to app store
Login Walls:
- - HTTP 401 or 403 status
- Redirect to
/login, /signin, INLINECODE31 - Response contains login form elements
Content Validity Check (run AFTER gate detection):
- - WeChat: header
logicret value — -2 means content invalid/deleted - Douyin: final destination is 404 = video removed or link expired
- Taobao: response body contains
对不起 or 宝贝不存在 = product delisted
Detection commands:
CODEBLOCK10
Header signals to check:
- -
logicret: -2 → WeChat article invalid - INLINECODE37 → Taobao link active
- INLINECODE38 containing app deep-link schemes → app-gated redirect
4. DIAGNOSE - Explain and suggest next steps
Based on decode + trace + inspect results, provide a structured diagnosis:
Output format:
CODEBLOCK11
Common diagnoses to provide:
| Gate Type | Why It Fails | What It Needs |
|---|
| WeChat | Link requires WeChat's built-in browser | Open in WeChat app > scan QR |
| WeChat (invalid) |
logicret: -2 — article deleted/unpublished | Request a valid article link |
| WeCom | Enterprise WeChat only | Must be a WeCom member of that org |
| Taobao | JS redirect to Taobao app | Open link in Taobao/淘宝 app |
| Douyin | 302→douyin.com, content requires app | Open in Douyin/抖音 app |
| Xiaohongshu | 307→xiaohongshu.com, app deep-link | Open in 小红书 app |
| Alipay |
alipays:// scheme redirect | Open in Alipay/支付宝 app |
| Mini Program |
weixin://dl/business/ scheme | Open in WeChat > scan QR to launch mini-program |
| Login Wall | Requires authentication | Sign in at [domain] first |
| App-Only | Deep link to native app | Install [app name] and scan in-app |
| Expired | Short link no longer resolves | Link has expired, request a new one |
| Geo-blocked | Returns different content by region | May need VPN to [region] |
5. GENERATE - Create QR codes from text/URLs
CODEBLOCK12
If qrcode is not installed:
CODEBLOCK13
Full Workflow
When the user provides a QR code image, run the full pipeline automatically:
- 1. DECODE the image
- If the decoded content is a URL:
a.
TRACE the redirect chain
b.
INSPECT the final destination for gates
c.
DIAGNOSE with full report
- 3. If the decoded content is NOT a URL (plain text, WiFi config, vCard, etc.):
a. Present the content with type identification
b. Skip trace/inspect
Always present results in the structured diagnosis format above.
Error Handling
Image cannot be read:
- - Verify the file exists and path is correct
- Check format (PNG, JPEG, HEIC, TIFF supported)
- Suggest converting if format is unusual: INLINECODE42
No QR code detected:
- - Image may be too low resolution
- QR code may be partially obscured
- Suggest: crop to QR region, improve contrast, try a screenshot instead of photo
- Try pyzbar fallback (different algorithm may succeed)
Redirect fails (timeout/DNS):
- - Short link service may be down
- Link may have expired
- Try again with longer timeout: INLINECODE43
Cannot determine gate type:
- - Fetch page content and look for clues in HTML/JS
- Check response headers for
X-Powered-By, Server, custom headers - Report what IS known and suggest manual inspection
Notes
- - This skill is macOS-native. CoreImage is the primary decoder (zero external dependencies).
- The Swift binary is compiled once and reused for speed (~10ms vs ~2s interpreted).
- For batch processing, loop the binary over multiple files.
- All output is designed to be actionable: never just say "it failed" -- explain WHY and WHAT TO DO.
QR Bridge
入口点侦察工具。 解码二维码、追踪重定向链、检查受限目标,并解释链接实际需要什么。
何时使用此技能
当用户要求以下操作时激活:
- - 从图像中解码/扫描/读取二维码
- 追踪短链接重定向到何处
- 检查链接是否需要微信/企业微信/登录/应用
- 诊断链接无法打开的原因
- 从文本或URL生成二维码
设置(仅首次运行)
首次使用前,编译Swift解码器二进制文件:
bash
bash ~/.claude/skills/qr-bridge/scripts/setup.sh
如果已运行过设置,二进制文件位于 ~/.claude/skills/qr-bridge/scripts/qr-decode。如果文件已存在,跳过设置。
命令
1. 解码 - 从图像中提取二维码内容
步骤1:检查二进制文件是否存在
bash
ls ~/.claude/skills/qr-bridge/scripts/qr-decode 2>/dev/null && echo COMPILED || echo NEED_SETUP
如果需要设置,运行:
bash
swiftc ~/.claude/skills/qr-bridge/scripts/qr-decode.swift -o ~/.claude/skills/qr-bridge/scripts/qr-decode -O
步骤2:运行解码器(编译后的二进制文件 - 快速)
bash
~/.claude/skills/qr-bridge/scripts/qr-decode /path/to/image.png
步骤3:如果编译后的二进制文件失败,使用解释模式(较慢但始终有效)
bash
swift ~/.claude/skills/qr-bridge/scripts/qr-decode.swift /path/to/image.png
步骤4:如果CoreImage失败,尝试pyzbar回退
python
python3 -c
from pyzbar.pyzbar import decode
from PIL import Image
import json, sys
img = Image.open(sys.argv[1])
results = decode(img)
out = [{message: r.data.decode(), symbology: r.type} for r in results]
print(json.dumps({ok: bool(out), count: len(out), results: out}, indent=2))
/path/to/image.png
输出格式(JSON):
json
{
ok: true,
count: 1,
results: [
{
message: https://example.com/path,
symbology: QRCode,
bounds: { x: 0, y: 0, width: 200, height: 200 }
}
],
file: /path/to/image.png,
error: null
}
2. 追踪 - 跟踪重定向链
从二维码解码URL后(或直接给定URL),追踪完整重定向链:
bash
curl -sIL -o /dev/null -w %{urleffective}\n --max-redirs 15 --connect-timeout 10 URLHERE 2>&1
要获取包含每个跳转的完整链,使用:
bash
curl -sIL --max-redirs 15 --connect-timeout 10 -w \n--- FINAL: %{urleffective} (HTTP %{httpcode}) ---\n URL_HERE 2>&1
从输出中解析Location:头以构建链:
- 1. https://short.link/abc → 302
- https://tracking.example.com → 301
- https://final-destination.com → 200
3. 检查 - 检测受限目标
追踪后,检查最终URL的访问限制。检查以下模式:
微信/企业微信限制(中文二维码常见):
- - 域名包含:weixin.qq.com、work.weixin.qq.com、mp.weixin.qq.com、open.weixin.qq.com
- 重定向到 open.weixin.qq.com/connect/oauth2/authorize
- 响应包含:请在微信客户端打开、请在企业微信客户端打开
- 响应头 logicret: -2 = 文章未找到/已删除/未发布
- User-Agent限制:对微信UA和浏览器UA返回不同内容
- 微信小程序链接:weixin://dl/business/?appid= — 无法在微信外打开
应用限制链接:
- - 淘宝:tb.cn、m.tb.cn — 返回200并带JS重定向到淘宝应用。查找tbopen://协议或sstatus: STATUSNORMAL头
- 抖音:v.douyin.com — 302重定向到www.douyin.com,无效链接返回404。有效链接重定向到www.douyin.com/video/
- 小红书:xhslink.com — 307 → www.xiaohongshu.com。查找snssdk://或xhsdiscover://深度链接协议
- 支付宝:ur.alipay.com — 重定向到alipays://协议
- 响应包含深度链接协议:weixin://、alipays://、tbopen://、snssdk://、xhsdiscover://
- Meta刷新或JavaScript重定向到应用商店
登录墙:
- - HTTP 401或403状态码
- 重定向到/login、/signin、/oauth/authorize
- 响应包含登录表单元素
内容有效性检查(在限制检测后运行):
- - 微信:头logicret值 — -2表示内容无效/已删除
- 抖音:最终目标为404 = 视频已移除或链接已过期
- 淘宝:响应体包含对不起或宝贝不存在 = 商品已下架
检测命令:
bash
步骤1:检查响应头中的平台信号
curl -sI --max-redirs 10 --connect-timeout 10 URL_HERE 2>&1
步骤2:使用类似浏览器的UA检查
curl -sL --max-redirs 10 --connect-timeout 10 \
-H User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 \
URL_HERE | head -c 5000
步骤3:使用微信UA检查(揭示微信限制的内容)
curl -sL --max-redirs 10 --connect-timeout 10 \
-H User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 MicroMessenger/8.0.0 \
URL_HERE | head -c 5000
步骤4:比较 — 如果步骤2和步骤3返回不同内容,则链接受UA限制
要检查的头信号:
- - logicret: -2 → 微信文章无效
- sstatus: STATUSNORMAL → 淘宝链接有效
- Location: 包含应用深度链接协议 → 应用限制重定向
4. 诊断 - 解释并建议后续步骤
基于解码+追踪+检查结果,提供结构化诊断:
输出格式:
QR Bridge 诊断
来源: [图像文件名]
解码内容: [二维码原始内容]
类型: [URL | 文本 | vCard | WiFi | 其他]
重定向链
- 1. [url] → [状态]
- [url] → [状态]
- [url] → [最终状态]
访问限制
- - 限制类型: [微信 | 企业微信 | 登录 | 仅应用 | 无]
- 失败原因: [通俗易懂的解释]
- 所需条件: [具体要求]
后续步骤
常见诊断结果:
| 限制类型 | 失败原因 | 所需条件 |
|---|
| 微信 | 链接需要微信内置浏览器 | 在微信应用中打开 > 扫描二维码 |
| 微信(无效) |
logicret: -2 — 文章已删除/未发布 | 请求有效的文章链接 |
| 企业微信 | 仅限企业微信 | 必须是该组织的企业微信成员 |
| 淘宝 | JS重定向到淘宝应用 | 在淘宝应用中打开链接 |
| 抖音 | 302→douyin.com,内容需要应用 | 在抖音应用中打开 |
| 小红书 | 307→xiaohongshu.com,应用深度链接 | 在小红书应用中打开 |
| 支付宝 | alipays:// 协议重定向 | 在支付宝应用中打开 |
| 小程序 | weixin://dl/b