Generate custom WeChat CSS themes from natural language descriptions, WeChat article URLs, or recent articles from a WeChat Official Account. Produces a valid CSS file conforming to wenyan and ready for wx-mp-publisher.
60
72%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Low
Low-risk findings worth noting
Fix and improve this skill with Tessl
tessl review fix ./crews/main/skills/generate-wenyan-theme/SKILL.md根据用户的自然语言需求,生成符合微信公众号排版规范的自定义 CSS 样式表,保存为本地文件。
https://mp.weixin.qq.com 文章链接时,调用 wx-mp-hunter fetch <url> --html 获取正文 HTML,分析原文排版特征后生成 wenyan CSSwx-mp-hunter search + account-posts + fetch --html 采集近期文章 HTML,抽取共性后生成模板./skills/wx-mp-publisher/SKILL.md 的主题列表,方便后续发布优先选用#wenyan 命名空间约束,确保样式能完美注入微信公众号 DOM 结构::before/::after)、渐变背景 (linear-gradient)、内联 SVG/Base64 图片等高级 CSS 特性本技能支持三种模式,按以下优先级判断:
https://mp.weixin.qq.com 开头的链接。通过 PATH 调用 wrapper:generate-wenyan-theme <cmd>,无需拼接脚本路径。
调用方式:generate-wenyan-theme ...
该脚本会调用全局 wx-mp-hunter wrapper:
wx-mp-hunter fetch <url> --htmlwx-mp-hunter search <account> → account-posts <fakeid> → 对候选文章逐篇 fetch --htmlgenerate-wenyan-theme --url <mp.weixin.qq.com-url> --output wenyan-theme/sources.json输出 JSON 中 articles[0].content_html 为文章正文 HTML。
generate-wenyan-theme --account <公众号名> --count 10 --output wenyan-theme/sources.json如果用户同时给出关键词或筛选信息,传入 --keywords:
generate-wenyan-theme --account <公众号名> --keywords "关键词1,关键词2" --count 10 --scan-batch 20 --max-scan 100 --output wenyan-theme/sources.json筛选规则:
--max-scan。fetch --html 获取 content_html。若
wx-mp-hunter返回SESSION_EXPIRED,按wx-mp-hunter技能的扫码登录流程处理后重试原命令。
从 content_html 中抽取共性时,只分析可迁移到 wenyan CSS 的视觉规律,不复制微信原文中不可控或依赖原始 DOM 的实现细节:
所有 CSS 选择器 必须 以 #wenyan 开头,中间用空格隔开。缺少 #wenyan 前缀的样式将失效。
#wenyan h1 { color: red; }h1 { color: red; }| 目标元素 | CSS 选择器 | 常用定制属性 |
|---|---|---|
| 全局默认 | #wenyan | background-image, line-height, color |
| 各级标题 | #wenyan h1 ~ #wenyan h6 | font-size, text-align, border-bottom, margin |
| 标题文字 | #wenyan h1 span | color, font-weight, background |
| 标题装饰 | #wenyan h1::before | content, display, width, height, background-image |
| 段落文本 | #wenyan p | text-indent, letter-spacing, color |
| 引用块 | #wenyan blockquote | border-left, background-color, padding |
| 代码块外层 | #wenyan pre | background-color, border-radius, padding, overflow-x: auto |
| 代码块内容 | #wenyan pre code | color |
| 分割线 | #wenyan hr | border, border-top-style, border-color |
| 超链接 | #wenyan a | color, text-decoration, border-bottom |
url("./bg.png") 等本地路径url("data:image/svg+xml;utf8,<svg>...</svg>")url(https://example.com/bg.jpg)@font-face,只能使用系统字体所有产物(采集 JSON + 生成的 CSS)统一放工作区下专用子目录 wenyan-theme/,不要散落工作区根。 脚本会自动 mkdir -p 该子目录。
.json 路径,可含子目录(如 wenyan-theme/sources.json);禁止绝对路径和 .. 上跳。wenyan-theme/ 子目录下的相对 .css 路径(如 wenyan-theme/custom-theme.css);禁止绝对路径、.. 上跳、隐藏目录和非 .css 后缀。/* 全局属性 */
#wenyan {
line-height: 1.75;
font-size: 16px;
}
/* 标题与段落间距 */
#wenyan h1,
#wenyan h2,
#wenyan h3,
#wenyan h4,
#wenyan h5,
#wenyan h6,
#wenyan p {
margin: 1em 0;
}
/* 一级标题 */
#wenyan h1 {
text-align: center;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
font-size: 1.5em;
}
/* 二级标题 */
#wenyan h2 {
text-align: center;
font-size: 1.2em;
border-bottom: 1px solid #f7f7f7;
font-weight: bold;
}
/* 列表 */
#wenyan > ul,
#wenyan > ol {
padding-left: 1rem;
}
#wenyan ul,
#wenyan ol {
margin-left: 1rem;
font-size: 0.9rem;
}
/* 图片 */
#wenyan img {
max-width: 100%;
height: auto;
margin: 0 auto;
display: block;
}
/* 表格 */
#wenyan table {
border-collapse: collapse;
margin: 1.4em auto;
max-width: 100%;
table-layout: fixed;
text-align: left;
overflow: auto;
display: table;
}
/* 引用块 */
#wenyan blockquote {
background: #afb8c133;
border-left: 0.5em solid #ccc;
margin: 1.5em 0;
padding: 0.5em 10px;
font-style: italic;
font-size: 0.9em;
}
/* 行内代码 */
#wenyan p code {
color: #ff502c;
padding: 4px 6px;
font-size: 0.78em;
}
/* 代码块外围 */
#wenyan pre {
border-radius: 5px;
line-height: 2;
margin: 1em 0.5em;
padding: .5em;
box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px;
font-size: 12px;
}
/* 代码块 */
#wenyan pre code {
display: block;
overflow-x: auto;
margin: .5em;
padding: 0;
}
/* 分割线 */
#wenyan hr {
border: none;
border-top: 1px solid #ddd;
margin-top: 2em;
margin-bottom: 2em;
}
/* 链接 */
#wenyan a {
word-wrap: break-word;
color: #0069c2;
}wenyan-theme/ 子目录(如 wenyan-theme/custom-theme.css)./skills/wx-mp-publisher/SKILL.md 的“主题选择”表格,追加或更新该自定义主题记录wx-mp-publisher 技能的第二个位置参数传入自定义 CSS 路径进行发布https://mp.weixin.qq.com 开头的文章 URL。generate-wenyan-theme --url <url> --output wenyan-theme/sources.jsonarticles[0].content_html 分析标题、段落、引用、分割线、强调、图片周边等样式特征。#wenyan 选择器体系,不复制无效的微信原始 class 或 inline style。--keywords。generate-wenyan-theme --account <公众号名> --count 10 --output wenyan-theme/sources.jsongenerate-wenyan-theme --account <公众号名> --keywords "关键词1,关键词2" --count 10 --scan-batch 20 --max-scan 100 --output wenyan-theme/sources.json仅公众号账号模式需要生成前确认。确认消息应包含:
用户确认“继续/可以/确认”后,才能写 CSS 文件。
generate-wenyan-theme 与 wx-mp-publisher 都是你的私有技能,目录相对位置固定。因此每次成功生成自定义 CSS 后,必须同步更新:
./skills/wx-mp-publisher/SKILL.md在 wx-mp-publisher/SKILL.md 的“主题选择”表格中追加或更新一行自定义主题记录:
| `<theme-id>` | 用户自定义:<风格摘要>(文件:`<css-file>`) | 用户明确指定参考该主题时优先采用;相似内容可优先建议 |登记表是 client 侧 id → 本地 CSS 路径映射,relay 不存主题。 CSS 内容随发布请求上传(custom_theme 字段)。
注册要求:
theme-id 使用 CSS 文件名去掉 .css 后缀,例如 wenyan-theme/custom-theme.css → custom-theme。wenyan-theme/ 子目录),优先使用当前 crew workspace 内路径。theme-id 已存在,更新原行,不重复追加。注册后,wx-mp-publisher 发布时通过第二个位置参数引用自定义主题,两种写法等价:
# 1) 直接传 CSS 文件路径
wx-mp-publisher article.md wenyan-theme/custom-theme.css
# 2) 传登记在主题表里的 theme-id(脚本自动解析出 CSS 路径)
wx-mp-publisher article.md custom-theme生成 CSS 文件后,用 wx-mp-publisher 发布,第二个位置参数即主题(CSS 路径或登记的 theme-id 均可):
wx-mp-publisher article.md wenyan-theme/custom-theme.css
# 或
wx-mp-publisher article.md custom-theme注:发布统一走
publish_wx_mp.py,当 theme 参数指向本地.css文件路径、或为主题表中登记的自定义 id 时,脚本读出 CSS 内容作custom_theme字段随 multipart 上传 relay;relay 侧请求结束即清理,不持久化、不落盘、不按用户存主题。
bcef823
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.