bazel-build-optimization
它能做什么
这个技能可以帮你优化 Bazel(一款构建工具)在大型项目中的运行方式。它会讲解生产环境中的实践模式,让你的项目构建得更快、更可靠。
适用场景
- ✓首次在大型项目中配置 Bazel 时。
- ✓想让 Bazel 调用远程计算机来加快构建速度时。
- ✓想弄清楚为什么构建耗时过长时。
技能链接
https://github.com/wshobson/agents/blob/main/plugins/developer-essentials/skills/bazel-build-optimization/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我们的项目规模很大,怎样配置 Bazel 才能让构建更快?”
每周 5 个新技能,1 分钟读完。
工作原理
它会提供项目文件组织和 Bazel 配置方面的示例与最佳实践,帮助 Bazel 更好地理解如何构建你的代码,从而让整个过程更高效。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Bazel Build Optimization
Production patterns for Bazel in large-scale monorepos.
When to Use This Skill
- Setting up Bazel for monorepos
- Configuring remote caching/execution
- Optimizing build times
- Writing custom Bazel rules
- Debugging build issues
- Migrating to Bazel
Core Concepts
1. Bazel Architecture
workspace/
├── WORKSPACE.bazel # External dependencies
├── .bazelrc # Build configurations
├── .bazelversion # Bazel version
├── BUILD.bazel # Root build file
├── apps/
│ └── web/
│ └── BUILD.bazel
├── libs/
│ └── utils/
│ └── BUILD.bazel
└── tools/
└── bazel/
└── rules/
2. Key Concepts
| Concept | Description |
|---|---|
| Target | Buildable unit (library, binary, test) |
| Package | Directory with BUILD file |
| Label | Target identifier //path/to:target |
| Rule | Defines how to build a target |
| Aspect | Cross-cutting build behavior |
Templates and detailed worked examples
Full template library and detailed worked examples live in references/details.md. Read that file when you need the concrete templates.
Best Practices
Do's
- Use fine-grained targets - Better caching
- Pin dependencies - Reproducible builds
- Enable remote caching - Share build artifacts
- Use visibility wisely - Enforce architecture
- Write BUILD files per directory - Standard convention
Don'ts
- Don't use glob for deps - Explicit is better
- Don't commit bazel-* dirs - Add to .gitignore
- Don't skip WORKSPACE setup - Foundation of build
- Don't ignore build warnings - Technical debt
常见问题
什么是 Bazel?
Bazel 是一款帮助构建软件项目的工具,也就是把代码转换为可执行程序,尤其适用于大型和复杂的项目。
什么是“monorepo”?
monorepo(单一代码仓库)是指把许多不同的项目放在同一个代码仓库中。
“优化构建”是什么意思?
意思是让软件的构建过程更快,并且占用更少的计算机资源。
详情
作者的原始描述
Optimize Bazel builds for large-scale monorepos. Use when configuring Bazel, implementing remote execution, or optimizing build performance for enterprise codebases.
repo: wshobson/agents
热度
- GitHub 星标
- 41k
- 排名
- #6675
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …