Install
openclaw skills install @songhonglei/opensource-skill-to-githubQuickly open-source a local skill to GitHub (primary) and optionally clawhub.com. Workflow: slug pre-check, fork to opensourceskills, strip internal info, normalize SKILL.md, generate LICENSE/README, init git, push to GitHub with configurable token source, and optionally publish to clawhub. Use when the user says "open-source this skill", "把这个 skill 开源", "发到 github", "publish skill publicly", or "把本地 skill 发开源". Hard rules: never modify the original skill in place, never auto-add force/yes flags, never write tokens to git/remote/memory, and ask the user at decision points.
openclaw skills install @songhonglei/opensource-skill-to-github把一个本地 skill 端到端开源到 GitHub(主)+ clawhub.com(可选)。 基于多个 skill 开源实践沉淀的完整方法论(见
references/opensource_playbook.md)+ 11 条剔除清单 + 16 项 checklist。 质量优先:每个决策点(LICENSE / slug 冲突 / 内网信息残留 / token)必须等用户拍板。
opensourceskills/<slug>/,独立 commit / 版本号 / sign。bash scripts/setup_profile.sh
# 交互式问 3 个字段:
# Author name (如 "Evan Song")
# GitHub handle (如 "Songhonglei")
# Author email (推荐 GitHub noreply: "<handle>@users.noreply.github.com")
# 写入 ~/.config/opensource-skill-to-github/profile.env (chmod 600)
为什么这么放:
$HOME 而非 skill 目录 → skill 升级/重装不丢$HOME 而非 workspace → 换 agent / 换 workspace 仍有效(适配 OpenClaw / Claude Code / Cursor 等任意环境)$XDG_CONFIG_HOME 优先),符合 Linux / macOS 用户文件规范身份取值优先级(高 → 低):
OSG_AUTHOR_NAME / OSG_GITHUB_HANDLE / OSG_AUTHOR_EMAIL 环境变量(适合 CI/CD 或临时覆盖)~/.config/opensource-skill-to-github/profile.env ← 主要载体git config --global user.name/user.email 兜底scripts/setup_profile.sh常用命令:
bash scripts/setup_profile.sh # 首次/重新引导
bash scripts/setup_profile.sh --show # 查看当前生效配置 + 来源
bash scripts/setup_profile.sh --path # 打印 profile 路径
bash scripts/setup_profile.sh --non-interactive # CI 模式,从 env 读
GitHub push token 配置(可选):
github_push.sh 支持把 token 做成配置项,避免每次真实 repo 发布都重新让用户粘贴。
优先级为:
GITHUB_TOKEN(一次性环境变量)OSG_GITHUB_TOKEN(长期环境变量或 profile;明文,不推荐)OSG_GITHUB_TOKEN_CMD(推荐;命令 stdout 第一行返回 token)gh auth token(已登录 GitHub CLI 时自动读取)推荐写法:
# 放进 ~/.config/opensource-skill-to-github/profile.env
OSG_GITHUB_TOKEN_CMD="gh auth token"
# 或使用 macOS Keychain,不把 PAT 明文写入 profile
OSG_GITHUB_TOKEN_CMD="security find-generic-password -a $USER -s opensource-skill-to-github.github-token -w"
脚本不会把 token 写入 git remote、命令输出或 memory。若使用一次性 PAT,推送后仍应撤销。
每步后面标注「类型」:🔧 脚本(可直接跑)/ 💬 对话(需用户拍板)/ 🔗 引用(调其他 skill)。
⚠️ 首次使用先跑
scripts/setup_profile.sh配置开源身份(见上节)。已配置过的用户跳过此步。
| 步骤 | 类型 | 工具 |
|---|---|---|
| 0. slug 预检 | 🔧 | scripts/precheck.sh <slug> |
| 1. 决策框架 4 问 | 💬 | 对话 |
| 2. 副本化 | 🔧 | scripts/fork.sh |
| 3. 11 条剔除清单扫描 + 拍板 | 🔧 → 💬 | scripts/strip_scan.sh 跑完用户拍板每处 |
| 4. SKILL.md frontmatter 规范化 | 🔧 → 💬 | scripts/check_frontmatter.py + 手工 edit |
| 5. LICENSE 拍板 + 生成 | 💬 → 🔧 | 对话选类型 → scripts/gen_license.sh(author 自动从 profile 读) |
| 6. README + .gitignore 生成 | 🔧 | scripts/scaffold.sh(author/handle 自动从 profile 读) |
| 7. 本地 git init | 🔧 | scripts/git_init.sh(user.name/email 自动从 profile 读) |
| 8. UGLIC 自审(推荐) | 🔗 | 调 glic-check skill |
| 9. GitHub repo 创建(用户手工)+ push | 💬 → 🔧 | 用户建 repo + scripts/github_push.sh <fork> <repo-name>(handle 自动拼) |
| 10. clawhub 发版(可选)+ memory 沉淀 | 🔧 → 💬 | scripts/clawhub_publish.sh(已登录免 token)+ 沉淀文档 |
| 11. 腾讯 skillhub.cn 发版(可选) | 🔧 | SKILLHUB_CN_TOKEN=skh_xxx scripts/skillhub_cn_publish.sh <fork> |
一键前 6 步:
scripts/run_all.sh <源skill名或绝对路径> [<new-slug>]会串联 precheck→fork→strip_scan→license→scaffold→git_init(strip 命中仍需人工拍板; push / clawhub / skillhub.cn 因需 token + 确认不自动跑,脚本结束打印手动指引)。
本 skill 可移植到非 OpenClaw 的 agent(Claude Code / Cursor 等):
fork.sh 支持传 skill 绝对路径,或按名在多目录探测
($SKILLS_DIR → ~/.claude/skills → ~/.cursor/skills → ./skills → ~/.openclaw/workspace/skills)OPENSOURCE_OUT_DIR 覆盖(默认 ./opensourceskills)git_init.sh 只认 fork 自己的 .git,即使 fork 位于某个已是 git repo 的
工作区内也不会误提交到父仓库(v1.0.3 修复,附二次校验)OSG_STRIP_KEYWORDS env 或 strip_keywords.txt 文件自定义(换公司内网词)-b main,老 git 有 symbolic-ref 兜底)scripts/check_frontmatter.py 使用,零外部包依赖)fork.sh 排除 node_modules 复制,缺失时自动回退 cp -r)clawhub CLI;只在 Step 0 预检和 Step 10 clawhub publish 时需要)npm install -g clawhub,只在用 clawhub 渠道时需要)base64 已做兜底(-w0 BSD 不支持 → 回退 base64 | tr -d '\n')find / grep / sed / awk)使用 POSIX 子集,跨平台兼容默认 slug 沿用源 skill 名(即 <source-skill-name>),先用源 skill 名查重,命中再进入 rename 子流程。
scripts/precheck.sh <source-skill-name>
# 实际执行:clawhub inspect <source-skill-name>
| 命中情况 | 处理 |
|---|---|
| 未注册 | ✅ 安全继续,slug = source-skill-name |
| 同 owner 同名 | 升版本号直接 publish 即可(不需开源新流程) |
| 别人 owner 同名 | 必须换 slug(加品牌前缀 claw- / openclaw- / 自定义)— 让用户拍板新 slug,重跑 precheck 直到通过 |
| 名字不同但概念高度雷同 | 让用户读对方 SKILL.md 决定差异化定位 |
Why:clawhub 不支持 slug rename,一旦 publish 就锁死。agent-memory-manager 真撞过 georges91560 已注册同名,预检省 80+ 分钟返工。
退出码:
0 = 未注册可继续3 = 已注册需用户决策4 = 网络异常(重跑)向用户确认:
默认选副本(本 skill 整套流程围绕"副本"设计)。
scripts/fork.sh <source-skill-name> [<new-slug>]
# 默认:cp -r skills/<source> opensourceskills/<source>
# 若 slug 改名:opensourceskills/<new-slug>
# 自动删:sign.key、.install-source.json、__pycache__/、*.pyc、.skill-data/、skill_meta.json、*.json.md
强约束:副本和内网版独立 commit、独立版本号、独立 sign.key。绝不原地改原 skill。
scripts/strip_scan.sh <fork-path>
# 跑两轮:
# ① 文件层:列必删项当前状态(sign.key / __pycache__ / USAGE.md 重复等)
# ② 字面层:grep 内网关键词(公司内网域名 / 平台代号 / sso_token 等,见 strip_keywords 配置)
# 输出:零命中 / 命中位置清单
完整 11 条清单和替换映射见 references/strip_checklist.md。复杂或大量字面替换的细节场景,可参考 references/opensource_playbook.md 第 3 节做深度处理(progressive disclosure)。
报告输出后必须对话:grep 命中的每一处由用户拍板「保留 / 删除 / 改写」,AI 不自决。
frontmatter 跨 agent 兼容硬约束 3 条(hello-env v1.0.0→v1.0.2 实证):
description 用 > folded scalar(避免引号转义)description ≤ 1024 字节(Anthropic 上限)name + description——version / metadata / author / tags 都搬到 Markdown bodyMarkdown body 顶部 4 行(必加):
- **Version**: 1.0.1
- **License**: MIT
- **Author**: <real name> · [github.com/<handle>](https://github.com/<handle>)
- **Repository**: https://github.com/<handle>/<repo-name>
⚠️ clawhub 卡片只解析 SKILL.md 顶部,README 写得再漂亮都不算。
校验工具:scripts/check_frontmatter.py <skill-path>(4 项校验,0 ERR 才放行)。
必须问用户拍板,AI 不自填:
scripts/gen_license.sh <fork-path> <MIT|Apache-2.0|GPL-3.0> "<real name>" <year>
⚠️ 对外署名规则:用对外身份(如 Jane Doe)+ 公网邮箱(*@gmail.com 等),不用内网邮箱。
⚠️ 脚本会自动清洗作者名中的换行/反引号/分号等危险字符。
scripts/scaffold.sh <fork-path>
# 生成:
# README.md ← 模板含 Quick Start / Features / Install / License / Author
# .gitignore ← 通用安全规则(id_rsa / *.p12 / *.keystore / certs/*.key / .env / node_modules / __pycache__ 等)
README 模板见 references/readme_template.md。
scripts/git_init.sh <fork-path> "<user.name>" "<user.email>"
# 执行:
# git init -b main
# git symbolic-ref HEAD refs/heads/main ← 老 git 兜底
# git config user.name / user.email ← 必须,容器 git 没有默认
# git add . && git commit -m "Initial commit: v1.0.0"
Why:容器/PVC 环境 git 没有默认 user.name/email,commit 直接报"不允许空的姓名"(glic-check 首发踩过)。
调用 glic-check skill 跑 UGLIC 5 维(U/G/L/I/C):
# 引用 glic-check skill 跑
# 不在本 skill 内重复实现
完整规则见本 skill references/uglic_quickref.md 或直接读 glic-check skill。
<repo-name>(勾 main 分支,不勾 README/LICENSE/gitignore)OSG_GITHUB_TOKEN_CMD / gh auth token);若没有配置,再生成 Personal Access Token(PAT)并只通过环境变量传一次⚠️ 用户贴 token 时第一条回复必须:
"我收到了,会用环境变量传一次不落盘,跑完请去 GitHub Settings → Tokens 撤销这个 PAT。"
推荐长期配置:
# profile.env 里配置 token 读取命令,避免每次发布重新粘贴
OSG_GITHUB_TOKEN_CMD="gh auth token"
也支持:
GITHUB_TOKEN=ghp_xxx scripts/github_push.sh <fork-path> <github-handle>/<repo-name>
OSG_GITHUB_TOKEN=ghp_xxx scripts/github_push.sh <fork-path> <github-handle>/<repo-name>
OSG_GITHUB_TOKEN 可写进 profile,但这是明文 token,只在用户明确要求时使用;默认推荐 OSG_GITHUB_TOKEN_CMD 接 GitHub CLI 或 macOS Keychain。
scripts/github_push.sh <fork-path> <github-handle>/<repo-name>
# 实际执行:
# token 来源: GITHUB_TOKEN → OSG_GITHUB_TOKEN → OSG_GITHUB_TOKEN_CMD → gh auth token
# AUTH_B64=$(printf "x-access-token:%s" "$RESOLVED_TOKEN" | base64 -w0)
# git remote add origin https://github.com/<handle>/<repo>.git
# for i in 1..5: timeout 60 git -c http.extraHeader="Authorization: Basic $AUTH_B64" push origin main && break
Why Basic Auth header:某些受限网络环境 push GitHub 时 bearer 已不认,必须用 Basic Auth header 注入;token 不进 remote URL。
push 完成后:如果本次用了临时 PAT,再次提醒用户 去 GitHub Settings 撤销 PAT;如果用的是 GitHub CLI / Keychain 长期配置,不要求每次撤销。
CLAWHUB_TOKEN=clh_xxx scripts/clawhub_publish.sh <fork-abs-path>
# 注意:
# - 必须用绝对路径(相对路径偶发 SKILL.md required 报错)
# - clawhub 强制 LICENSE 为 MIT-0(本地 LICENSE 文件被忽略,平台特性不是 bug)
# - clawhub 没有 visibility 参数,用 hide/unhide 控制
# - rate limit 11999/12000 → sleep 30s 重试
⚠️ CLAWHUB_TOKEN 与 GitHub token 完全独立;临时 token 分别撤销,长期配置分别管理。
某些内网 hub 会把特定用户/部门标记为「受限」,禁止公开可见(常表现为静默降级为 private)。
--visibility private 救场——降级后 PUT edit 也可能改不回来--visibility 参数让发版工具取 Hub 当前值回填提示用户创建 memory/project_<slug>_opensource_fork.md,记录:
通用经验沉淀到 feedback_*.md。
| ❌ 反模式 | ✅ 正确做法 |
|---|---|
| 副本里改的同时改原 skill | 原 skill 不动,只动副本 |
副本目录名带 -os / -opensource 后缀 | 用 opensourceskills/<原名>/,slug 跟原名一致 |
用 v0.1 / v0.x 试探发版 | 直接 v1.0.0(clawhub 期望"成熟" first release) |
GitHub repo 用 dev / master 默认分支 | 必须 main(老 git git symbolic-ref HEAD refs/heads/main 兜底) |
| LICENSE 自填假名字 / 占位贡献者 | 必须问用户拍板 + 真名署名 |
| 把内网 grep 结果直接贴 chat | 任何内网 grep 输出先脱敏再贴 |
| frontmatter 塞 version / metadata / tags | 只留 name + description |
| 凭 response 字段判定 visibility 发版成功 | 必须 detail 接口二次 GET 验真 |
AI 自动加 --force / --yes / --i-am-sure | 必须用户文字确认 |
| token 写入 git remote / memory / 日志 | token 只进环境变量或 OSG_GITHUB_TOKEN_CMD;profile 明文 token 仅在用户明确要求时使用 |
references/strip_checklist.md — 11 条剔除清单 + 字面替换映射references/readme_template.md — README.md 模板references/uglic_quickref.md — UGLIC 5 维速查references/precedents.md — 11 个已开源 skill 先例 + 教学价值references/opensource_playbook.md(16 节全流程 + 快速 checklist)references/opensource_playbook.md 第 3 节 + references/strip_checklist.mdfork.sh cp-fallback
branch only removed node_modules/.git, not the other paths the rsync branch excludes
(.skill-data/output/__pycache__/*.pyc/opensourceskills) — nested dirs leaked into the
copy on systems without rsync; rsync branch also now excludes opensourceskills/skillhub_cn_publish.sh sent the multipart payload as an inline -F string,
which curl truncated into invalid JSON when displayName/summary contained spaces or
parentheses; now writes payload to a temp file and reads via -F "payload=<file"opensourceskills/<slug>/setup_profile.sh → strip_keywords.txt / OSG_STRIP_KEYWORDS).git (never pollutes a parent repo)gh auth token)clawhub_publish.sh (login-aware), skillhub_cn_publish.sh (multipart)run_all.sh chains the first 6 stepsreferences/opensource_playbook.md