homebrew-formula-generator
npx machina-cli add skill a5c-ai/babysitter/homebrew-formula-generator --openclawHomebrew Formula Generator
Generate Homebrew formula for CLI distribution.
Generated Patterns
class Myapp < Formula
desc "My CLI application"
homepage "https://github.com/myuser/myapp"
url "https://github.com/myuser/myapp/releases/download/v1.0.0/myapp-1.0.0.tar.gz"
sha256 "abc123..."
license "MIT"
depends_on "node" => :build
def install
system "npm", "install", *std_npm_args
bin.install_symlink Dir["#{libexec}/bin/*"]
end
test do
assert_match "myapp v#{version}", shell_output("#{bin}/myapp --version")
end
end
Target Processes
- package-manager-publishing
- cli-binary-distribution
Source
git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/cli-mcp-development/skills/homebrew-formula-generator/SKILL.mdView on GitHub Overview
This skill creates a ready-to-publish Homebrew formula for a CLI distribution, filling in standard fields like desc, homepage, url, sha256, and license. It follows the pattern shown in the SKILL.md, including a build dependency on node, an install block that runs npm install with std_npm_args, and a test that verifies the CLI version. The result enables macOS and Linux users to install the CLI via brew with a reproducible workflow.
How This Skill Works
The generator outputs a Ruby Homebrew formula class named after your app and populates metadata such as description, homepage, tarball URL, sha256, and license. It can include a build dependency like node, defines an install block that uses npm install with std_npm_args, and creates a bin symlink from libexec to the user PATH. A test block checks the installed CLI version to ensure the formula works as expected.
When to Use It
- When you publish a Node-based CLI to GitHub Releases and want a Homebrew install path.
- When you need a reproducible, version-locked install via brew on macOS or Linux.
- When you want a test block that asserts the CLI version after installation.
- When your distribution provides a tarball URL and sha256 for verification.
- When a build step uses npm and you want std_npm_args to handle npm-based installs.
Quick Start
- Step 1: Gather release metadata including name, description, homepage, tarball URL, sha256, and license.
- Step 2: Implement the install block using npm install with std_npm_args and set up bin via libexec.
- Step 3: Add a test that asserts the CLI version to ensure the formula works after brew install.
Best Practices
- Provide an accurate tarball URL and sha256 hash to ensure integrity.
- Include a license field to clarify distribution rights.
- Keep the class name and formula filename aligned with the package name.
- Include a test that validates the CLI outputs its version to verify functionality.
- Use the npm-based install pattern with std_npm_args for Node CLIs and symlink the binaries from libexec.
Example Use Cases
- Example 1 uses a tarball from GitHub Releases v1.0.0 with a Node build and a version check in the test.
- Example 2 demonstrates a MIT-licensed CLI distributed via a tarball, with npm install and a version assertion.
- Example 3 covers a CLI published under a GitHub release with a build dependency on node and a version test.
- Example 4 shows a CLI where the install block uses std_npm_args and creates a symlink to the bin directory.
- Example 5 illustrates a Linux-friendly Homebrew formula that uses the same pattern for macOS and Linux installations.