devcontainer-setup by trailofbits/skills
npx skills add https://github.com/trailofbits/skills --skill devcontainer-setup创建一个预配置的 devcontainer,包含 Claude Code 和特定语言的工具。
flowchart TB
start([用户请求 devcontainer])
recon[1. 项目侦察]
detect[2. 检测语言]
generate[3. 生成配置]
write[4. 将文件写入 .devcontainer/]
done([完成])
start --> recon
recon --> detect
detect --> generate
generate --> write
write --> done
按顺序检查(使用第一个匹配项):
package.json → name 字段pyproject.toml → 广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
project.nameCargo.toml → package.namego.mod → 模块路径(/ 后的最后一段)转换为 slug:小写,用连字符替换空格/下划线。
| 语言 | 检测文件 |
|---|---|
| Python | pyproject.toml, *.py |
| Node/TypeScript | package.json, tsconfig.json |
| Rust | Cargo.toml |
| Go | go.mod, go.sum |
如果检测到多种语言,按以下优先级顺序配置所有语言:
对于多语言的 postCreateCommand,链接所有设置命令:
uv run /opt/post_install.py && uv sync && npm ci
所有检测到的语言的扩展和设置应合并到配置中。
从 resources/ 目录的基础模板开始。替换:
{{PROJECT_NAME}} → 人类可读的名称(例如 "My Project"){{PROJECT_SLUG}} → 用于卷的 slug(例如 "my-project")然后应用以下语言特定的修改。
基础模板包括:
检测: pyproject.toml, requirements.txt, setup.py, 或 *.py 文件
Dockerfile 添加内容:
基础 Dockerfile 已通过 uv 包含 Python 3.13。如果需要不同版本(从 pyproject.toml 检测到),修改 Python 安装:
# 通过 uv 安装 Python(快速二进制下载,非源码编译)
RUN uv python install <version> --default
devcontainer.json 扩展:
添加到 customizations.vscode.extensions:
"ms-python.python",
"ms-python.vscode-pylance",
"charliermarsh.ruff"
添加到 customizations.vscode.settings:
"python.defaultInterpreterPath": ".venv/bin/python",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
}
postCreateCommand: 如果存在 pyproject.toml,链接命令:
rm -rf .venv && uv sync && uv run /opt/post_install.py
检测: package.json 或 tsconfig.json
无需 Dockerfile 添加内容: 基础模板已通过 fnm(Fast Node Manager)包含 Node 22。
devcontainer.json 扩展:
添加到 customizations.vscode.extensions:
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
添加到 customizations.vscode.settings:
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
postCreateCommand: 从锁文件检测包管理器并与基础命令链接:
pnpm-lock.yaml → uv run /opt/post_install.py && pnpm install --frozen-lockfileyarn.lock → uv run /opt/post_install.py && yarn install --frozen-lockfilepackage-lock.json → uv run /opt/post_install.py && npm ciuv run /opt/post_install.py && npm install检测: Cargo.toml
要添加的功能:
"ghcr.io/devcontainers/features/rust:1": {}
devcontainer.json 扩展:
添加到 customizations.vscode.extensions:
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml"
添加到 customizations.vscode.settings:
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
}
postCreateCommand: 如果存在 Cargo.lock,使用锁定构建:
uv run /opt/post_install.py && cargo build --locked
如果无锁文件,使用标准构建:
uv run /opt/post_install.py && cargo build
检测: go.mod
要添加的功能:
"ghcr.io/devcontainers/features/go:1": {
"version": "latest"
}
devcontainer.json 扩展:
添加到 customizations.vscode.extensions:
"golang.go"
添加到 customizations.vscode.settings:
"[go]": {
"editor.defaultFormatter": "golang.go"
},
"go.useLanguageServer": true
postCreateCommand:
uv run /opt/post_install.py && go mod download
更多指导,请参阅:
references/dockerfile-best-practices.md - 层优化、多阶段构建、架构支持references/features-vs-dockerfile.md - 何时使用 devcontainer 功能 vs 自定义 Dockerfile在 devcontainer.json 中新增挂载的模式:
"mounts": [
"source={{PROJECT_SLUG}}-<purpose>-${devcontainerId},target=<container-path>,type=volume"
]
常见添加项:
source={{PROJECT_SLUG}}-cargo-${devcontainerId},target=/home/vscode/.cargo,type=volume (Rust)source={{PROJECT_SLUG}}-go-${devcontainerId},target=/home/vscode/go,type=volume (Go)在项目的 .devcontainer/ 目录中生成以下文件:
Dockerfile - 容器构建指令devcontainer.json - VS Code/devcontainer 配置post_install.py - 创建后设置脚本.zshrc - Shell 配置install.sh - 用于管理 devcontainer 的 CLI 助手(devc 命令)在向用户展示文件之前,验证:
{{PROJECT_NAME}} 占位符已替换为人类可读的名称{{PROJECT_SLUG}} 占位符已替换为 slug 化的名称devcontainer.json 中的 JSON 语法有效(无尾随逗号,正确嵌套)postCreateCommand 包含所有必需的设置命令(用 && 链接)生成后,告知用户:
devcontainer up --workspace-folder ..devcontainer/install.sh self-install 将 devc 命令添加到 PATH每周安装数
739
仓库
GitHub 星标数
3.9K
首次出现
2026年2月10日
安全审计
安装于
codex661
opencode660
claude-code651
gemini-cli649
cursor639
github-copilot639
Creates a pre-configured devcontainer with Claude Code and language-specific tooling.
flowchart TB
start([User requests devcontainer])
recon[1. Project Reconnaissance]
detect[2. Detect Languages]
generate[3. Generate Configuration]
write[4. Write files to .devcontainer/]
done([Done])
start --> recon
recon --> detect
detect --> generate
generate --> write
write --> done
Check in order (use first match):
package.json → name fieldpyproject.toml → project.nameCargo.toml → package.namego.mod → module path (last segment after /)Convert to slug: lowercase, replace spaces/underscores with hyphens.
| Language | Detection Files |
|---|---|
| Python | pyproject.toml, *.py |
| Node/TypeScript | package.json, tsconfig.json |
| Rust | Cargo.toml |
| Go | go.mod, go.sum |
If multiple languages are detected, configure all of them in the following priority order:
For multi-language postCreateCommand, chain all setup commands:
uv run /opt/post_install.py && uv sync && npm ci
Extensions and settings from all detected languages should be merged into the configuration.
Start with base templates from resources/ directory. Substitute:
{{PROJECT_NAME}} → Human-readable name (e.g., "My Project"){{PROJECT_SLUG}} → Slug for volumes (e.g., "my-project")Then apply language-specific modifications below.
The base template includes:
Detection: pyproject.toml, requirements.txt, setup.py, or *.py files
Dockerfile additions:
The base Dockerfile already includes Python 3.13 via uv. If a different version is required (detected from pyproject.toml), modify the Python installation:
# Install Python via uv (fast binary download, not source compilation)
RUN uv python install <version> --default
devcontainer.json extensions:
Add to customizations.vscode.extensions:
"ms-python.python",
"ms-python.vscode-pylance",
"charliermarsh.ruff"
Add to customizations.vscode.settings:
"python.defaultInterpreterPath": ".venv/bin/python",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
}
postCreateCommand: If pyproject.toml exists, chain commands:
rm -rf .venv && uv sync && uv run /opt/post_install.py
Detection: package.json or tsconfig.json
No Dockerfile additions needed: The base template includes Node 22 via fnm (Fast Node Manager).
devcontainer.json extensions:
Add to customizations.vscode.extensions:
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
Add to customizations.vscode.settings:
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
postCreateCommand: Detect package manager from lockfile and chain with base command:
pnpm-lock.yaml → uv run /opt/post_install.py && pnpm install --frozen-lockfileyarn.lock → uv run /opt/post_install.py && yarn install --frozen-lockfilepackage-lock.json → uv run /opt/post_install.py && npm ciuv run /opt/post_install.py && npm installDetection: Cargo.toml
Features to add:
"ghcr.io/devcontainers/features/rust:1": {}
devcontainer.json extensions:
Add to customizations.vscode.extensions:
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml"
Add to customizations.vscode.settings:
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
}
postCreateCommand: If Cargo.lock exists, use locked builds:
uv run /opt/post_install.py && cargo build --locked
If no lockfile, use standard build:
uv run /opt/post_install.py && cargo build
Detection: go.mod
Features to add:
"ghcr.io/devcontainers/features/go:1": {
"version": "latest"
}
devcontainer.json extensions:
Add to customizations.vscode.extensions:
"golang.go"
Add to customizations.vscode.settings:
"[go]": {
"editor.defaultFormatter": "golang.go"
},
"go.useLanguageServer": true
postCreateCommand:
uv run /opt/post_install.py && go mod download
For additional guidance, see:
references/dockerfile-best-practices.md - Layer optimization, multi-stage builds, architecture supportreferences/features-vs-dockerfile.md - When to use devcontainer features vs custom DockerfilePattern for new mounts in devcontainer.json:
"mounts": [
"source={{PROJECT_SLUG}}-<purpose>-${devcontainerId},target=<container-path>,type=volume"
]
Common additions:
source={{PROJECT_SLUG}}-cargo-${devcontainerId},target=/home/vscode/.cargo,type=volume (Rust)source={{PROJECT_SLUG}}-go-${devcontainerId},target=/home/vscode/go,type=volume (Go)Generate these files in the project's .devcontainer/ directory:
Dockerfile - Container build instructionsdevcontainer.json - VS Code/devcontainer configurationpost_install.py - Post-creation setup script.zshrc - Shell configurationinstall.sh - CLI helper for managing the devcontainer (devc command)Before presenting files to the user, verify:
{{PROJECT_NAME}} placeholders are replaced with the human-readable name{{PROJECT_SLUG}} placeholders are replaced with the slugified namedevcontainer.json (no trailing commas, proper nesting)postCreateCommand includes all required setup commands (chained with &&)After generating, inform the user:
devcontainer up --workspace-folder ..devcontainer/install.sh self-install to add the devc command to PATHWeekly Installs
739
Repository
GitHub Stars
3.9K
First Seen
Feb 10, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykFail
Installed on
codex661
opencode660
claude-code651
gemini-cli649
cursor639
github-copilot639
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
136,300 周安装
Dev Browser:JavaScript沙盒化浏览器控制CLI工具 - 自动化测试与爬虫开发利器
689 周安装
CTF Pwn 二进制漏洞利用技术大全 - 栈溢出、ROP、格式化字符串、内核利用实战指南
690 周安装
Supabase技能创建器指南:构建高效AI技能模块,扩展Claude能力
691 周安装
React 测试命令:运行 Facebook React 代码库测试的完整指南
692 周安装
Apollo Server 5.x 指南:开源GraphQL服务器安装、集成与快速入门教程
693 周安装
产品调查问卷设计指南:9位专家框架,NPS替代方案与MaxDiff优先级排序
693 周安装