topmindspace/topmind-writing-skills / topmind-wechat-post
topmind-wechat-post
Verified创作、整理和排版公众号文章;支持工具/插件推荐结构、产品实测评测、深度解读与叙事随笔,从选题或底稿到 Markdown,按需导出内联 HTML、预览与上传清单。公众号短文用 topmind-briefs,独立改稿用 topmind-revise。
scripts/audit_skill.py
View on GitHub#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""技能入口审计:SKILL.md 结构完整性(任一不过 → 退出码 1)。"""
from __future__ import annotations
import re
import sys
from pathlib import Path
try:
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
except Exception:
pass
ROOT = Path(__file__).resolve().parent.parent
NAME = ROOT.name
errors: list[str] = []
def check(cond: bool, msg: str) -> None:
print((" ✓ " if cond else " ✗ ") + msg)
if not cond:
errors.append(msg)
def main() -> None:
print(f"[audit_skill] {NAME}")
text = (ROOT / "SKILL.md").read_text(encoding="utf-8")
fm_match = re.match(r"^---\r?\n([\s\S]*?)\r?\n---", text)
fm_text = fm_match.group(1) if fm_match else ""
# Agent Skills 规范:自定义字段放 metadata(字符串值),triggers 写成逗号分隔字符串;
# 兼容旧的顶层 triggers 列表。
triggers: list[str] = []
mm = re.search(r"^metadata:\s*\n((?:[ \t]+.*\n?)+)", fm_text, re.M)
if mm:
tm = re.search(r"^[ \t]+triggers:\s*(.+?)\s*$", mm.group(1), re.M)
if tm:
raw = tm.group(1).strip().strip('"').strip("'")
triggers = [t.strip() for t in re.split(r"[,,]", raw) if t.strip()]
if not triggers:
m = re.search(r"^triggers:\s*\n((?: - .+\n?)+)", fm_text + "\n", re.M)
triggers = re.findall(r"^ - (.+)$", m.group(1), re.M) if m else []
check(len(triggers) >= 1, f"triggers ≥1(实 {len(triggers)})")
top_keys = re.findall(r"^([A-Za-z_][\w-]*):", fm_text, re.M)
allowed = {"name", "description", "license", "compatibility", "metadata", "allowed-tools"}
extra = [k for k in top_keys if k not in allowed]
check(not extra, f"frontmatter 顶层只用规范字段(多出:{', '.join(extra) or '无'})")
# 入口形式由技能决定;审计真实元数据与内容,不要求写固定标题或禁用清单。
check(fm_match is not None, "frontmatter 可读取")
name_match = re.search(r'^name:\s*([^\n]+)', fm_text, re.M)
declared_name = name_match.group(1).strip().strip('\"\'') if name_match else ""
check(bool(re.fullmatch(r"[a-z0-9]+(?:-[a-z0-9]+)*", declared_name)), "name 是有效技能标识")
body = text[fm_match.end():].strip() if fm_match else ""
check(bool(body), "技能正文非空(用途与流程另由实际任务评估)")
fm = re.match(r"^---\r?\n([\s\S]*?)\r?\n---", text)
desc = ""
if fm:
dm = re.search(r'^description:\s*"([^"]*)"\s*$', fm.group(1), re.M)
if dm:
desc = dm.group(1).strip()
else:
dm = re.search(r"^description:\s*>\-\s*\n((?:[ \t]+.*\n?)+)", fm.group(1), re.M)
if dm:
desc = " ".join(l.strip() for l in dm.group(1).splitlines())
check(bool(desc), "description 非空;能力与路由质量由任务评测判断")
check(len(desc) <= 1024, f"description ≤1024(实 {len(desc)})")
if errors:
print(f"\n[audit_skill] {NAME}: {len(errors)} 项失败")
sys.exit(1)
print(f"\n[audit_skill] {NAME}: 全部通过")
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |