
Byted Skillhub Upload
- 30 installs
- 411 repo stars
- Updated August 4, 2026
- bytedance/agentkit-samples
byted-skillhub-upload is a Claude skill that uploads a local skill directory or zip to a private or enterprise SkillHub space.
About
A skill that uploads a local skill (a directory or zip) to a private or enterprise SkillHub space, creating a new skill and version. A developer uses it to publish a local skill to a company SkillHub. It reads the SkillHub API credentials and space ID from injected environment variables and prints the new skill Id and version Id.
- Uploads a local skill directory or zip to SkillHub, creating a new skill and version
- Zips a directory automatically before upload
- Prints the new skill Id and SkillVersionId on success
Byted Skillhub Upload by the numbers
- 30 all-time installs (skills.sh)
- Ranked #416 of 782 Skill Development skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
byted-skillhub-upload capabilities & compatibility
- Capabilities
- skill upload · skill publish
What byted-skillhub-upload says it does
上传 Skill(目录或 zip)到 SkillHub 私有或企业专属空间。当需要把本地技能发布到私有或企业专属 SkillHub 时使用。
python ./scripts/upload_to_skillhub.py --path "./my-skill" --name "my-skill" --description "demo"
npx skills add https://github.com/bytedance/agentkit-samples --skill byted-skillhub-uploadAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 30 |
|---|---|
| repo stars | ★ 411 |
| Last updated | August 4, 2026 |
| Repository | bytedance/agentkit-samples ↗ |
What it does
Zip a local skill directory and upload it to a private or enterprise SkillHub space as a new skill version.
Who is it for?
publishing a local skill to a private or enterprise SkillHub space
When should I use this skill?
user asks to upload or publish a local skill to SkillHub
What you get
A local skill directory or zip is uploaded to SkillHub, creating a new skill and version whose Id and version Id are printed.
- new SkillHub skill Id and SkillVersionId
By the numbers
- 3 injected environment variables
- prints 2 output identifiers (Id, SkillVersionId)
Files
byted-skillhub-upload
用途
- 将本地 Skill(文件夹或 zip 包)上传到 SkillHub,并创建一个新的 Skill 及版本。
- 上传成功后输出
Id与SkillVersionId。
何时调用
- 当用户需求涉及将本地技能上传/发布到 企业 SkillHub 或 私有技能空间 时触发。常见语义包括:
1. 明确要求“上传到 SkillHub / 发布到 SkillHub”。 2. 提到“企业专属技能空间 / 私有技能空间 / 内部技能”。 3. 需要将一个本地目录打包后上传为 Skill。
环境说明 (Agent 必读)
- 无需向用户索要环境变量:当前环境已自动注入以下变量:
ARK_SKILL_API_BASE: SkillHub API 服务地址ARK_SKILL_API_KEY: 企业 SkillHub 访问密钥SKILLHUB_SKILL_SPACE_ID: 企业专属技能空间 ID- 严禁向用户询问参数值:Agent 在触发此技能时,应直接从环境中读取这些变量并执行脚本,不得中断流程向用户确认这些信息。
上传步骤 1. 确定待上传目标
- 目标必须是一个目录,或一个以
.zip结尾的文件 - 若目标是目录,脚本会先将其内容压缩为 zip 包再上传
2. 执行脚本(路径相对于本 SKILL.md 所在目录)
- 上传目录:
python ./scripts/upload_to_skillhub.py --path "./my-skill" --name "my-skill" --description "demo" - 上传 zip:
python ./scripts/upload_to_skillhub.py --path "./my-skill.zip" --name "my-skill" --description "demo"
3. 观察输出
- 成功时会打印两行:
Id: <skill_id>SkillVersionId: <skill_version_id>
示例
- 将
./skills/my-private-skill/上传到 SkillHub: python ./scripts/upload_to_skillhub.py --path "./skills/my-private-skill" --name "my-private-skill" --description "internal"
故障排查
- 如提示缺少环境变量,请确认在环境中运行或联系管理员
- 参数错误:确认
--path指向目录或.zip文件 - 网络或鉴权错误:检查网络连通性与 API Key 是否有效
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.import argparse
import json
import logging
import os
import re
import sys
import tempfile
import urllib.error
import urllib.request
import uuid
import zipfile
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Dict, Iterable, List, Optional, Tuple
logger = logging.getLogger("skillhub_uploader")
def _setup_logging(verbose: bool) -> None:
level = logging.DEBUG if verbose else logging.INFO
logging.basicConfig(
level=level,
format="%(asctime)s %(levelname)s %(message)s",
datefmt="%Y-%m-%dT%H:%M:%S%z",
stream=sys.stderr,
)
def _normalize_api_base(api_base: str) -> str:
formatted = api_base.strip()
if not formatted.startswith("http://") and not formatted.startswith("https://"):
formatted = f"http://{formatted}"
return formatted.rstrip("/")
def _read_env() -> Tuple[str, str, Optional[str]]:
api_host = os.getenv("ARK_SKILL_API_BASE")
api_key = os.getenv("ARK_SKILL_API_KEY")
skill_space_id = os.getenv("SKILLHUB_SKILL_SPACE_ID")
if not api_host or not api_key:
raise SystemExit("缺少必要环境变量: ARK_SKILL_API_BASE, ARK_SKILL_API_KEY")
sid = skill_space_id.strip() if skill_space_id else None
if not sid:
sid = None
logger.info(
"读取环境变量: api_base=%s skill_space_id=%s api_key_len=%s",
_normalize_api_base(api_host),
sid or "-",
len(api_key.strip()),
)
return _normalize_api_base(api_host), api_key.strip(), sid
def _sanitize_filename(name: str) -> str:
base = re.sub(r"[^A-Za-z0-9_.-]+", "-", name).strip("-")
return base or "skill"
def _iter_files(root: Path) -> Iterable[Path]:
for p in root.rglob("*"):
if p.is_file():
yield p
def _zip_directory(src_dir: Path) -> Path:
if not src_dir.is_dir():
raise SystemExit(f"目标不是目录: {src_dir}")
tmp = tempfile.NamedTemporaryFile(prefix="skillhub_", suffix=".zip", delete=False)
tmp_path = Path(tmp.name)
tmp.close()
try:
count = 0
with zipfile.ZipFile(tmp_path, "w", compression=zipfile.ZIP_DEFLATED) as zf:
for file_path in _iter_files(src_dir):
arcname = str(file_path.relative_to(src_dir))
zf.write(file_path, arcname)
count += 1
logger.info("已打包目录: dir=%s files=%s zip=%s", src_dir, count, tmp_path)
except Exception:
try:
tmp_path.unlink(missing_ok=True)
except Exception:
pass
raise
return tmp_path
def _encode_multipart_formdata(
fields: List[Tuple[str, str]],
files: List[Tuple[str, str, bytes, str]],
) -> Tuple[bytes, str]:
boundary = uuid.uuid4().hex
crlf = b"\r\n"
body = bytearray()
def _add_line(line: bytes) -> None:
body.extend(line)
body.extend(crlf)
for name, value in fields:
_add_line(f"--{boundary}".encode("utf-8"))
_add_line(
f'Content-Disposition: form-data; name="{name}"'.encode("utf-8")
)
_add_line(b"")
_add_line(value.encode("utf-8"))
for field_name, filename, content, content_type in files:
_add_line(f"--{boundary}".encode("utf-8"))
_add_line(
(
f'Content-Disposition: form-data; name="{field_name}"; '
f'filename="{filename}"'
).encode("utf-8")
)
_add_line(f"Content-Type: {content_type}".encode("utf-8"))
_add_line(b"")
body.extend(content)
body.extend(crlf)
_add_line(f"--{boundary}--".encode("utf-8"))
content_type = f"multipart/form-data; boundary={boundary}"
return bytes(body), content_type
def _safe_decode(data: bytes, limit: int = 4096) -> str:
chunk = data[:limit]
text = chunk.decode("utf-8", errors="replace")
if len(data) > limit:
return f"{text}...[truncated {len(data) - limit} bytes]"
return text
def _redact_headers(headers: Dict[str, str]) -> Dict[str, str]:
redacted: Dict[str, str] = {}
for k, v in headers.items():
if k.lower() == "authorization":
redacted[k] = "Bearer ***"
else:
redacted[k] = v
return redacted
@dataclass
class HttpResponse:
status: int
headers: Dict[str, str]
body: bytes
def _post_multipart(url: str, data: bytes, content_type: str, api_key: str) -> HttpResponse:
headers = {
"Content-Type": content_type,
"Authorization": f"Bearer {api_key}",
"ServiceName": "skillhub",
"Accept": "application/json",
}
logger.info("发起请求: url=%s bytes=%s", url, len(data))
logger.debug("请求头: %s", _redact_headers(headers))
req = urllib.request.Request(url, data=data, headers=headers, method="POST")
try:
with urllib.request.urlopen(req, timeout=60) as resp:
raw = resp.read()
status = int(getattr(resp, "status", 0) or 0)
resp_headers = {k: v for k, v in getattr(resp, "headers", {}).items()}
logger.info("收到响应: status=%s bytes=%s", status or "-", len(raw))
logger.debug("响应头: %s", resp_headers)
logger.debug("响应体(预览): %s", _safe_decode(raw))
return HttpResponse(status=status, headers=resp_headers, body=raw)
except urllib.error.HTTPError as e:
raw = e.read() if hasattr(e, "read") else b""
status = int(getattr(e, "code", 0) or 0)
resp_headers = {k: v for k, v in getattr(e, "headers", {}).items()}
logger.error("收到 HTTP 错误响应: status=%s bytes=%s", status or "-", len(raw))
logger.debug("响应头: %s", resp_headers)
logger.debug("响应体(预览): %s", _safe_decode(raw))
return HttpResponse(status=status, headers=resp_headers, body=raw)
except urllib.error.URLError as e:
raise SystemExit(f"请求失败: {e}") from e
def _unwrap_response_dict(payload: Dict[str, Any]) -> Dict[str, Any]:
if "Id" in payload or "SkillVersionId" in payload:
return payload
for k in ("Result", "Response", "Data", "data"):
v = payload.get(k)
if isinstance(v, dict) and ("Id" in v or "SkillVersionId" in v):
return v
return payload
@dataclass
class CreateSkillResponse:
Id: str
SkillVersionId: str
RequestId: Optional[str] = None
@classmethod
def from_dict(cls, payload: Dict[str, Any]) -> "CreateSkillResponse":
request_id: Optional[str] = None
meta = payload.get("ResponseMetadata")
if isinstance(meta, dict):
action = meta.get("Action")
if action is not None and action != "CreateSkill":
raise SystemExit(f"CreateSkill 响应 Action 异常: {action}")
request_id_val = meta.get("RequestId")
if isinstance(request_id_val, str) and request_id_val:
request_id = request_id_val
err = meta.get("Error")
if isinstance(err, dict):
code = err.get("Code")
msg = err.get("Message")
if isinstance(code, str) and code and isinstance(msg, str) and msg:
raise SystemExit(f"CreateSkill 失败: {code}: {msg} (RequestId={request_id or '-'})")
obj = payload.get("Result") if isinstance(payload.get("Result"), dict) else _unwrap_response_dict(payload)
logger.debug("CreateSkill 原始 JSON keys=%s", sorted(payload.keys()))
if isinstance(meta, dict):
logger.debug("CreateSkill ResponseMetadata=%s", meta)
logger.debug(
"CreateSkill 解析对象: type=%s keys=%s",
type(obj).__name__,
sorted(obj.keys()) if isinstance(obj, dict) else "-",
)
if isinstance(obj, dict):
skill_id = obj.get("Id") or obj.get("id") or obj.get("SkillId") or obj.get("SkillID")
version_id = (
obj.get("SkillVersionId")
or obj.get("skillVersionId")
or obj.get("SkillVersionID")
or obj.get("VersionId")
)
else:
skill_id = None
version_id = None
if not isinstance(skill_id, str) or not skill_id:
logger.error(
"CreateSkill 响应缺少有效的 Id: request_id=%s payload_keys=%s",
request_id or "-",
sorted(payload.keys()),
)
raise SystemExit("CreateSkill 响应缺少有效的 Id")
if not isinstance(version_id, str) or not version_id:
logger.error(
"CreateSkill 响应缺少有效的 SkillVersionId: request_id=%s payload_keys=%s",
request_id or "-",
sorted(payload.keys()),
)
raise SystemExit("CreateSkill 响应缺少有效的 SkillVersionId")
return cls(Id=skill_id, SkillVersionId=version_id, RequestId=request_id)
def create_skill(
api_host: str,
api_key: str,
name: str,
description: Optional[str],
skill_space_ids: List[str],
zip_bytes: bytes,
) -> CreateSkillResponse:
url = f"{api_host}/CreateSkill"
logger.info(
"准备上传: name=%s description=%s skill_spaces=%s zip_bytes=%s",
name,
"Y" if description else "N",
len(skill_space_ids),
len(zip_bytes),
)
fields: List[Tuple[str, str]] = [("Name", name)]
if description:
fields.append(("Description", description))
for sid in skill_space_ids:
fields.append(("SkillSpaces", sid))
filename = f"{_sanitize_filename(name)}.zip"
body, content_type = _encode_multipart_formdata(
fields=fields,
files=[("Zip", filename, zip_bytes, "application/zip")],
)
http_resp = _post_multipart(url=url, data=body, content_type=content_type, api_key=api_key)
try:
data = json.loads(http_resp.body.decode("utf-8"))
except Exception:
raise SystemExit("CreateSkill 响应不是有效的 JSON")
if not isinstance(data, dict):
raise SystemExit("CreateSkill 响应 JSON 结构异常")
logger.debug("CreateSkill HTTP status=%s headers=%s", http_resp.status or "-", http_resp.headers)
resp = CreateSkillResponse.from_dict(data)
logger.info(
"解析完成: id=%s version_id=%s request_id=%s",
resp.Id,
resp.SkillVersionId,
resp.RequestId or "-",
)
return resp
def main() -> None:
parser = argparse.ArgumentParser(prog="upload_to_skillhub")
parser.add_argument("--path", required=True, help="待上传 skill 路径(目录或 .zip 文件)")
parser.add_argument("--name", help="Skill 名称。默认取目录名/zip 文件名")
parser.add_argument("--description", default="", help="Skill 描述")
parser.add_argument("--verbose", dest="verbose", action="store_true", default=True, help="打印更详细日志")
args = parser.parse_args()
_setup_logging(args.verbose)
api_host, api_key, space_id = _read_env()
target = Path(args.path)
if not target.exists():
raise SystemExit(f"路径不存在: {target}")
zip_path: Optional[Path] = None
temp_zip: Optional[Path] = None
if target.is_dir():
temp_zip = _zip_directory(target)
zip_path = temp_zip
elif target.is_file() and target.suffix.lower() == ".zip":
zip_path = target
else:
raise SystemExit("目标必须是目录或 .zip 文件")
name = (args.name or (target.name if target.is_dir() else target.stem)).strip()
if not name:
raise SystemExit("Skill 名称为空,请通过 --name 指定")
logger.info("参数确认: path=%s name=%s zip=%s", target, name, zip_path)
try:
zip_bytes = zip_path.read_bytes() if zip_path else b""
if not zip_bytes:
raise SystemExit("Zip 内容为空")
resp = create_skill(
api_host=api_host,
api_key=api_key,
name=name,
description=args.description.strip() or None,
skill_space_ids=[space_id] if space_id else [],
zip_bytes=zip_bytes,
)
finally:
if temp_zip:
try:
temp_zip.unlink(missing_ok=True)
except Exception:
pass
print(f"Id: {resp.Id}")
print(f"SkillVersionId: {resp.SkillVersionId}")
if resp.RequestId:
print(f"RequestId: {resp.RequestId}")
if __name__ == "__main__":
try:
main()
except urllib.error.HTTPError as e:
try:
detail = e.read().decode("utf-8")
except Exception:
detail = ""
raise SystemExit(f"HTTP 错误: {e.code} {e.reason} {detail}".strip())
except urllib.error.URLError as e:
raise SystemExit(f"网络错误: {e.reason}")
except KeyboardInterrupt:
raise SystemExit("已中断")
Related skills
FAQ
Does it accept a directory?
Yes. A directory is zipped automatically before upload; a .zip file is uploaded directly.
What does it output on success?
Two lines: the skill Id and the SkillVersionId.