release-code
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRelease Code
代码发布
Prepare a research code repository for public release: audit for security issues, generate missing assets (README, citation, license), tag the version, and create a GitHub release.
为研究代码仓库的公开发布做准备:审计安全问题、生成缺失资源(README、引用文件、许可证)、标记版本并创建GitHub版本。
Skill Directory Layout
技能目录结构
<installed-skill-dir>/
├── SKILL.md
├── checklist.md # Detailed item-by-item checklist reference
└── templates/
├── README_ml_paper.md # README template for ML paper repos
└── CITATION.cff # Citation file template<installed-skill-dir>/
├── SKILL.md
├── checklist.md # 详细的逐项检查清单参考
└── templates/
├── README_ml_paper.md # 机器学习论文仓库的README模板
└── CITATION.cff # 引用文件模板Steps to Follow
执行步骤
1. Understand the release context
1. 了解发布背景
Ask the user in a single message:
- Paper info: Title, authors, venue/year (e.g. "CVPR 2025"), arXiv ID or URL (if available)
- Release type: Full code release / minimal reproducibility package / anonymous conference submission?
- License: MIT / Apache-2.0 / CC-BY-4.0 / other? (default: MIT for code, CC-BY-4.0 for models/data)
- What's included: Training code? Evaluation? Pre-trained weights? Datasets? Demo?
- Version tag: e.g. (default:
v1.0.0for first release)v1.0.0 - GitHub release?: Create a GitHub release with release notes? (yes/no)
- Model weights: Are pre-trained weights available? If so, where will they be hosted? (HuggingFace Hub / Google Drive / project page)
用一条消息询问用户:
- 论文信息:标题、作者、会议/年份(例如“CVPR 2025”)、arXiv编号或链接(如有)
- 发布类型:完整代码发布 / 最小可复现包 / 匿名会议提交?
- 许可证:MIT / Apache-2.0 / CC-BY-4.0 / 其他?(默认:代码用MIT,模型/数据用CC-BY-4.0)
- 包含内容:训练代码?评估代码?预训练权重?数据集?演示程序?
- 版本标签:例如(默认:首次发布用
v1.0.0)v1.0.0 - 是否创建GitHub版本?:是否创建带发布说明的GitHub版本?(是/否)
- 模型权重:是否有预训练权重?如果有,将托管在哪里?(HuggingFace Hub / Google Drive / 项目页面)
2. Audit the repository
2. 审计仓库
Run the following checks (read output silently, report summary to user):
运行以下检查(静默读取输出,向用户报告总结):
2a. Security scan — secrets and credentials
2a. 安全扫描——密钥和凭证
bash
undefinedbash
undefinedCheck for common secret patterns
检查常见密钥模式
git -C "$(git rev-parse --show-toplevel)" log --all --oneline | head -5
grep -rI --include=".py" --include=".yaml" --include=".json" --include=".env"
-E "(password|secret|api_key|token|credential|private_key)\s*=\s*['"][^'"]{6}"
"$(git rev-parse --show-toplevel)" 2>/dev/null | head -20
-E "(password|secret|api_key|token|credential|private_key)\s*=\s*['"][^'"]{6}"
"$(git rev-parse --show-toplevel)" 2>/dev/null | head -20
undefinedgit -C "$(git rev-parse --show-toplevel)" log --all --oneline | head -5
grep -rI --include=".py" --include=".yaml" --include=".json" --include=".env"
-E "(password|secret|api_key|token|credential|private_key)\s*=\s*['"][^'"]{6}"
"$(git rev-parse --show-toplevel)" 2>/dev/null | head -20
-E "(password|secret|api_key|token|credential|private_key)\s*=\s*['"][^'"]{6}"
"$(git rev-parse --show-toplevel)" 2>/dev/null | head -20
undefined2b. Large files check
2b. 大文件检查
bash
undefinedbash
undefinedFind large files that shouldn't be in the repo
查找不应存在于仓库中的大文件
find "$(git rev-parse --show-toplevel)" -type f -size +50M
! -path "/.git/" ! -path "/outputs/" ! -path "/wandb/" 2>/dev/null
! -path "/.git/" ! -path "/outputs/" ! -path "/wandb/" 2>/dev/null
undefinedfind "$(git rev-parse --show-toplevel)" -type f -size +50M
! -path "/.git/" ! -path "/outputs/" ! -path "/wandb/" 2>/dev/null
! -path "/.git/" ! -path "/outputs/" ! -path "/wandb/" 2>/dev/null
undefined2c. Sensitive file patterns
2c. 敏感文件模式
bash
undefinedbash
undefinedCheck for files that should not be public
检查不应公开的文件
find "$(git rev-parse --show-toplevel)" -type f (
-name ".env" -o -name ".pem" -o -name ".key" -o
-name "secrets.yaml" -o -name "credentials.json"
) ! -path "/.git/" 2>/dev/null
-name ".env" -o -name ".pem" -o -name ".key" -o
-name "secrets.yaml" -o -name "credentials.json"
) ! -path "/.git/" 2>/dev/null
undefinedfind "$(git rev-parse --show-toplevel)" -type f (
-name ".env" -o -name ".pem" -o -name ".key" -o
-name "secrets.yaml" -o -name "credentials.json"
) ! -path "/.git/" 2>/dev/null
-name ".env" -o -name ".pem" -o -name ".key" -o
-name "secrets.yaml" -o -name "credentials.json"
) ! -path "/.git/" 2>/dev/null
undefined2d. Check what already exists
2d. 检查已存在的文件
bash
ROOT="$(git rev-parse --show-toplevel)"
for f in README.md LICENSE CITATION.cff .gitignore requirements.txt pyproject.toml setup.py; do
[ -f "$ROOT/$f" ] && echo "EXISTS: $f" || echo "MISSING: $f"
donebash
ROOT="$(git rev-parse --show-toplevel)"
for f in README.md LICENSE CITATION.cff .gitignore requirements.txt pyproject.toml setup.py; do
[ -f "$ROOT/$f" ] && echo "EXISTS: $f" || echo "MISSING: $f"
done2e. Git status
2e. Git状态
bash
git -C "$(git rev-parse --show-toplevel)" status --short
git -C "$(git rev-parse --show-toplevel)" log --oneline -5Report audit findings to the user as a checklist:
- 🔴 BLOCKER — must fix before release (secrets found, credentials, large binaries)
- 🟡 WARNING — recommended to address (missing README, no license, no .gitignore)
- 🟢 OK — already in good shape
Ask the user to fix any blockers before continuing.
bash
git -C "$(git rev-parse --show-toplevel)" status --short
git -C "$(git rev-parse --show-toplevel)" log --oneline -5将审计结果以检查清单形式报告给用户:
- 🔴 阻塞项 — 发布前必须修复(发现密钥、凭证、大型二进制文件)
- 🟡 警告 — 建议处理(缺失README、无许可证、无.gitignore)
- 🟢 正常 — 状态良好
要求用户修复所有阻塞项后再继续。
3. Generate missing files
3. 生成缺失文件
Based on the 2d audit, generate any missing files. Ask the user's preference before overwriting existing files.
基于2d的审计结果,生成任何缺失的文件。覆盖现有文件前需询问用户偏好。
LICENSE
LICENSE
If missing, generate the appropriate license file:
- MIT (most common for ML code):
MIT License Copyright (c) {YEAR} {AUTHORS} [standard MIT text] - Apache-2.0: Use standard Apache 2.0 text
- CC-BY-4.0: For data/models if user specified
Write to .
{PROJECT_ROOT}/LICENSE如果缺失,生成合适的许可证文件:
- MIT(机器学习代码最常用):
MIT License Copyright (c) {YEAR} {AUTHORS} [标准MIT文本] - Apache-2.0:使用标准Apache 2.0文本
- CC-BY-4.0:如果用户指定,用于数据/模型
写入。
{PROJECT_ROOT}/LICENSECITATION.cff
CITATION.cff
Read the template from .
<installed-skill-dir>/templates/CITATION.cffFill in placeholders:
| Placeholder | Value |
|---|---|
| paper title |
| authors as YAML list (see template format) |
| publication year |
| conference/journal name |
| arXiv ID (if available) |
| |
| today's date (YYYY-MM-DD) |
Write to .
{PROJECT_ROOT}/CITATION.cff从读取模板。
<installed-skill-dir>/templates/CITATION.cff填充占位符:
| 占位符 | 值 |
|---|---|
| 论文标题 |
| 作者列表(YAML格式,参考模板) |
| 发表年份 |
| 会议/期刊名称 |
| arXiv编号(如有) |
| |
| 今日日期(YYYY-MM-DD) |
写入。
{PROJECT_ROOT}/CITATION.cffREADME.md
README.md
If README is missing or skeletal (< 50 lines):
Read the template from .
<installed-skill-dir>/templates/README_ml_paper.mdFill in all placeholders. Leave markers where the user must provide content (e.g., exact performance numbers, dataset download links).
[TODO: ...]Do NOT overwrite a substantial existing README — instead, identify what sections are missing and offer to append them.
如果README缺失或内容简略(少于50行):
从读取模板。
<installed-skill-dir>/templates/README_ml_paper.md填充所有占位符。对于用户必须提供的内容(例如精确性能数据、数据集下载链接),保留标记。
[TODO: ...]请勿覆盖内容完善的现有README — 而是识别缺失的部分,提供追加建议。
.gitignore
.gitignore
If missing, generate a Python/ML :
.gitignoreundefined如果缺失,生成适用于Python/机器学习的:
.gitignoreundefinedPython
Python
pycache/
*.py[cod]
*.egg-info/
.eggs/
dist/
build/
.venv/
venv/
pycache/
*.py[cod]
*.egg-info/
.eggs/
dist/
build/
.venv/
venv/
ML outputs (keep jobs/ but ignore outputs/)
ML输出(保留jobs/但忽略outputs/)
outputs/
wandb/
*.ckpt
*.pt
*.pth
*.pkl
runs/
lightning_logs/
outputs/
wandb/
*.ckpt
*.pt
*.pth
*.pkl
runs/
lightning_logs/
Data (large files)
数据(大文件)
data/
datasets/
data/
datasets/
Secrets
密钥
.env
*.pem
*.key
secrets.yaml
credentials.json
.env
*.pem
*.key
secrets.yaml
credentials.json
IDE
IDE
.vscode/settings.json
.idea/
*.DS_Store
undefined.vscode/settings.json
.idea/
*.DS_Store
undefined4. Pre-release checklist review
4. 预发布检查清单回顾
Read for the full item list.
<installed-skill-dir>/checklist.mdPresent the user with a condensed checklist grouped by category. For each item, report status (✅ done / ⚠️ needs attention / ❌ missing):
📁 Repository hygiene
✅ .gitignore covers outputs/, wandb/, *.ckpt
⚠️ outputs/ directory exists — confirm not committed
📄 Documentation
✅ README.md present (142 lines)
❌ No CITATION.cff — will generate
⚠️ README missing "Pre-trained Models" section
🔐 Security
✅ No secrets detected
✅ No large files in git history
📦 Reproducibility
✅ requirements.txt / pyproject.toml present
⚠️ No environment.yml for conda users
⚠️ No Dockerfile
⚖️ Legal
✅ LICENSE (MIT) presentAsk: "Are you ready to proceed with tagging and publishing, or do you want to fix any of the above first?"
读取获取完整项目列表。
<installed-skill-dir>/checklist.md向用户展示按类别分组的精简检查清单。对于每个项目,报告状态(✅ 已完成 / ⚠️ 需要注意 / ❌ 缺失):
📁 仓库卫生
✅ .gitignore已覆盖outputs/, wandb/, *.ckpt
⚠️ 存在outputs/目录 — 确认未提交
📄 文档
✅ README.md已存在(142行)
❌ 无CITATION.cff — 将生成
⚠️ README缺失“预训练模型”部分
🔐 安全
✅ 未检测到密钥
✅ git历史中无大文件
📦 可复现性
✅ requirements.txt / pyproject.toml已存在
⚠️ 无conda用户所需的environment.yml
⚠️ 无Dockerfile
⚖️ 合规性
✅ LICENSE(MIT)已存在询问:“您是否准备好继续进行标记和发布,还是想先修复上述问题?”
5. Commit and tag
5. 提交并标记版本
Once the user confirms:
bash
ROOT="$(git rev-parse --show-toplevel)"用户确认后:
bash
ROOT="$(git rev-parse --show-toplevel)"Stage only new/modified tracked files (not untracked outputs)
仅暂存新的/修改过的已跟踪文件(不包括未跟踪的输出文件)
git -C "$ROOT" add LICENSE CITATION.cff README.md .gitignore 2>/dev/null || true
git -C "$ROOT" diff --staged --stat
Ask the user to confirm the staged changes, then commit:
```bash
git -C "$ROOT" commit -m "chore: prepare code for public release ({VERSION})"Create annotated tag:
bash
git -C "$ROOT" tag -a "{VERSION}" -m "$(cat <<'EOF'
Release {VERSION} — {PAPER_TITLE}
Published at {VENUE}
Paper: {PAPER_URL}
Includes: {WHAT_INCLUDED}
EOF
)"Ask: "Push commit and tag to origin?"
bash
CURRENT_BRANCH="$(git -C "$ROOT" branch --show-current)"
git -C "$ROOT" push origin "$CURRENT_BRANCH"
git -C "$ROOT" push origin "{VERSION}"git -C "$ROOT" add LICENSE CITATION.cff README.md .gitignore 2>/dev/null || true
git -C "$ROOT" diff --staged --stat
询问用户确认暂存的更改,然后提交:
```bash
git -C "$ROOT" commit -m "chore: prepare code for public release ({VERSION})"创建带注释的标签:
bash
git -C "$ROOT" tag -a "{VERSION}" -m "$(cat <<'EOF'
Release {VERSION} — {PAPER_TITLE}
Published at {VENUE}
Paper: {PAPER_URL}
Includes: {WHAT_INCLUDED}
EOF
)"询问:“是否将提交和标签推送到origin?”
bash
CURRENT_BRANCH="$(git -C "$ROOT" branch --show-current)"
git -C "$ROOT" push origin "$CURRENT_BRANCH"
git -C "$ROOT" push origin "{VERSION}"6. GitHub Release (optional)
6. GitHub版本(可选)
If the user requested a GitHub release:
Check if is available:
ghbash
gh --version 2>/dev/null && echo "gh available" || echo "gh not found"If available, draft the release notes and create the release:
bash
gh release create "{VERSION}" \
--title "{PAPER_TITLE} ({VERSION})" \
--notes "$(cat <<'EOF'如果用户要求创建GitHub版本:
检查是否可用:
ghbash
gh --version 2>/dev/null && echo "gh available" || echo "gh not found"如果可用,起草发布说明并创建版本:
bash
gh release create "{VERSION}" \
--title "{PAPER_TITLE} ({VERSION})" \
--notes "$(cat <<'EOF'{PAPER_TITLE}
{PAPER_TITLE}
{VENUE} | Paper | Project Page
{VENUE} | Paper | Project Page
What's included
包含内容
{INCLUDED_ITEMS}
{INCLUDED_ITEMS}
Installation
安装
```bash
pip install -r requirements.txt
```
```bash
pip install -r requirements.txt
```
Citation
引用
```bibtex
{BIBTEX}
```
EOF
)"
If `gh` is not available, print the release notes as text for the user to paste into GitHub.```bibtex
{BIBTEX}
```
EOF
)"
如果`gh`不可用,将发布说明打印为文本,供用户粘贴到GitHub。7. Summary and next steps
7. 总结与后续步骤
Print a final summary:
✅ Release {VERSION} complete!
Files generated/updated:
• LICENSE
• CITATION.cff
• README.md
• .gitignore
Git:
• Commit: {COMMIT_HASH}
• Tag: {VERSION} → pushed to origin
GitHub:
• Release: https://github.com/{REPO}/releases/tag/{VERSION}
Recommended next steps:
□ Upload pre-trained weights to HuggingFace Hub / project page
□ Add repo link to the paper's arXiv abstract page
□ Tweet / post about the release
□ Email the mailing list / post to r/MachineLearning
□ Add a "Code" badge to the paper PDF (camera-ready only)打印最终总结:
✅ 版本{VERSION}发布完成!
已生成/更新的文件:
• LICENSE
• CITATION.cff
• README.md
• .gitignore
Git操作:
• 提交:{COMMIT_HASH}
• 标签:{VERSION} → 已推送到origin
GitHub操作:
• 版本链接:https://github.com/{REPO}/releases/tag/{VERSION}
推荐后续步骤:
□ 将预训练权重上传到HuggingFace Hub / 项目页面
□ 将仓库链接添加到论文的arXiv摘要页面
□ 发推文/发布关于版本的消息
□ 发送邮件到邮件列表 / 发布到r/MachineLearning
□ 在论文PDF中添加“代码”徽章(仅终稿版本)Handling Anonymous Submissions
匿名提交处理
When the user says this is for an anonymous conference submission:
- Do NOT create a public GitHub release.
- Do NOT include author names in any committed files.
- Generate an anonymous zip package instead:
bash
ROOT="$(git rev-parse --show-toplevel)" PROJ=$(basename "$ROOT") git -C "$ROOT" archive --format=zip HEAD -o "/tmp/${PROJ}-anonymous.zip" echo "Anonymous zip: /tmp/${PROJ}-anonymous.zip" - Check the zip contents for any author-identifying information before submission.
- Remind the user to anonymize: commit messages visible via git log, personal paths in configs, email addresses in code comments.
当用户表示这是匿名会议提交时:
- 请勿创建公开的GitHub版本。
- 请勿在任何已提交的文件中包含作者姓名。
- 生成匿名压缩包替代:
bash
ROOT="$(git rev-parse --show-toplevel)" PROJ=$(basename "$ROOT") git -C "$ROOT" archive --format=zip HEAD -o "/tmp/${PROJ}-anonymous.zip" echo "Anonymous zip: /tmp/${PROJ}-anonymous.zip" - 提交前检查压缩包内容是否包含任何可识别作者的信息。
- 提醒用户需匿名化:git日志中可见的提交消息、配置文件中的个人路径、代码注释中的邮箱地址。
Common Patterns
常见场景
HuggingFace Hub model upload
HuggingFace Hub模型上传
When the user wants to push weights to HuggingFace:
bash
undefined当用户想要将权重推送到HuggingFace时:
bash
undefinedRequires: pip install huggingface_hub
需安装:pip install huggingface_hub
python -c "
from huggingface_hub import HfApi
api = HfApi()
api.upload_folder(
folder_path='checkpoints/',
repo_id='username/model-name',
repo_type='model',
)
"
undefinedpython -c "
from huggingface_hub import HfApi
api = HfApi()
api.upload_folder(
folder_path='checkpoints/',
repo_id='username/model-name',
repo_type='model',
)
"
undefinedAdding a "Code" badge to README
为README添加“代码”徽章
markdown
[](https://github.com/username/repo)
[](https://arxiv.org/abs/2401.00000)
[](LICENSE)markdown
[](https://github.com/username/repo)
[](https://arxiv.org/abs/2401.00000)
[](LICENSE)Paper with Code link
Paper with Code链接
After release, submit to paperswithcode.com to link the repository to the paper automatically.
发布后,提交到paperswithcode.com,自动将仓库与论文关联。