mojo-build-package
Build Mojo packages (.mojopkg files) for distribution. Use when creating distributable libraries or during packaging phase.
When & Why to Use This Skill
This Claude skill automates the compilation of Mojo source code into distributable .mojopkg files. It streamlines the packaging phase of software development by ensuring modular components are correctly structured, validated, and optimized for reuse. By handling entry-point verification and dependency checks, it facilitates a robust build pipeline for Mojo-based projects.
Use Cases
- Library Distribution: Compiling Mojo source code into binary .mojopkg files for sharing across different projects or public repositories.
- CI/CD Pipeline Automation: Integrating the package build process into automated workflows to ensure every code change results in a valid, deployable artifact.
- Modular Software Development: Organizing large-scale Mojo applications into smaller, compiled modules to improve build times and maintainability.
- Pre-release Validation: Automatically verifying that public APIs are correctly exported and that no circular dependencies exist before final packaging.
| name | mojo-build-package |
|---|---|
| description | "Build Mojo packages (.mojopkg files) for distribution. Use when creating distributable libraries or during packaging phase." |
| mcp_fallback | none |
| category | mojo |
| agent | test-engineer |
| user-invocable | false |
Mojo Build Package Skill
Build compiled Mojo packages for distribution and reuse.
When to Use
- Creating distributable libraries
- Packaging phase of development
- Preparing for package installation
- Building modular components
Quick Reference
# Build single package
mojo package src/tensor -o packages/tensor.mojopkg
# Build and test
./scripts/build_package.sh tensor --test
# Build all packages
./scripts/build_all_packages.sh
Workflow
- Verify structure - Check
__init__.mojoexists - Build package - Run
mojo packageor script - Test imports - Verify package can be imported
- Verify exports - Check
__all__in__init__.mojo
Mojo-Specific Notes
- Every package needs
__init__.mojoentry point - Export public API in
__all__list - Packages compile to
.mojopkgbinary format - No circular dependencies allowed
Error Handling
| Error | Cause | Solution |
|---|---|---|
Missing __init__.mojo |
No package entry point | Add __init__.mojo to package dir |
Circular dependency |
Modules depend on each other | Refactor to break cycle |
Export not found |
Missing from __all__ |
Add name to __all__ list |
Build failed |
Syntax errors in module | Fix syntax before building |
References
.claude/shared/mojo-guidelines.md- Function definition patterns- Package metadata template:
templates/package_toml.toml