Write Once, Mage Everywhere: Zero-Boilerplate Build Tooling for Go.
CI / CD Β Β
|
|
Β Β Β Β Quality Β Β
|
|
Security Β Β
|
|
Β Β Β Β Community Β Β
|
|
π§©Β What'sΒ Inside
|
β‘Β QuickΒ Start
|
πΒ Features
|
βοΈΒ Configuration
|
πΒ Documentation
|
πΒ SDD
|
π§ͺΒ ExamplesΒ &Β Tests
|
β‘Β Benchmarks
|
π οΈΒ CodeΒ Standards
|
π€Β AIΒ Usage
|
π€Β Contributing
|
πΒ License
|
MAGE-X revolutionizes Go build tooling with TRUE zero-boilerplate. Unlike traditional Mage which requires writing wrapper functions, MAGE-X provides all commands instantly through the magex binary.
- Truly Zero-Configuration
No magefile.go needed. No imports. No wrappers. Just installmagexand all built-in and custom commands work immediately in any Go project. - Drop-in Mage Replacement
magexis a superset ofmagewith all MAGE-X commands built-in. Your existing magefiles still work, now enhanced with 190+ professional commands. - Cross-Platform Excellence
Full support for Linux, macOS, and Windows with multi-architecture builds, parallel execution, and CPU-aware optimization. - Security-First Architecture
Input validation, secure command execution, and minimal dependencies. Built for environments where security matters. - Graceful Ctrl+C Cancellation
A single Ctrl+C cleanly stops any command β in-flight subprocesses receive SIGINT with a 5s grace window, loops bail on the next iteration, and magex exits with code 130. A second Ctrl+C force-exits as an escape hatch. SIGTERM is honored too (exit 143) so CI runners can cancel jobs cleanly without orphan processes. - Professional Release Tooling
Standardized versioning commands, GitHub integration, GoDocs proxy sync, and release tooling for production deployments. - Smart Documentation System
Hybrid pkgsite/godoc support with auto-detection, port management, and cross-platform browser integration.
MAGE-X automatically detects your project structure and just works:
| Your Project Structure | What MAGE-X Does |
|---|---|
Single Binary main.go in root |
Builds to bin/projectname |
Multi-Binary cmd/*/main.go |
Auto-detects & builds first found |
| Library No main package | Verifies compilation with ./... |
π See the Complete Quick Start Guide for project-specific examples and troubleshooting.
# Install magex (production branch)
go install github.com/mrz1836/mage-x/cmd/magex@latest
# Auto-update to latest stable release (with proper version info)
magex update:install
# MAGE-X automatically checks for updates in the background
# and notifies you when new versions are available
# Now use it in ANY Go project (no setup!)
# Use either 'magex' or its shorter alias 'mgx'
magex build # Automatically detects & builds your project
magex test # Run your tests
magex bench # Run your benchmarks
magex lint:fix # Fix any linting issues
magex format:fix # Format your code
# That's it! No magefile.go needed! π# See what MAGE-X detects in your project:
magex build --dry-run # Shows what will be built without building
# or use the shorter alias:
mgx build --dry-run # Same command, shorter to typemagex help # List all commands & get help
magex -n # Commands by namespace
magex -search test # Find specific commands
# Remember: you can use 'magex' or 'mgx' interchangeablyOnly create a magefile.go if you need project-specific commands:
//go:build mage
package main
// Your custom command (works alongside all MAGE-X commands!)
func Deploy() error {
// Custom deployment logic
return nil
}Now you have both:
magex build # Built-in MAGE-X command
magex deploy # Your custom commandMAGE-X uses a smart hybrid approach that provides the best of both worlds:
- Built-in commands execute directly for speed and consistency (
magex build,magex test, etc.) - Custom commands in your magefile.go are automatically discovered and delegated to
mage - Unified interface - one standardized CLI for all tools
This means:
magex build(ormgx build) always behaves consistently across all projects- Your custom commands work seamlessly without any setup
- No plugin compilation or platform-specific issues
- Zero configuration required
- Command Execution: Secure, interface-based command execution with validation
- Native Logging: Colored output, progress indicators, and structured logging
- Complete Build Toolchain: All essential build, test, lint, and release tasks
- Version Management: Automatic version detection and update infrastructure with sub-module support for multi-module repositories
- Release Tooling: Multi-platform asset building with GitHub integration
- Configuration Management: Flexible mage.yaml with smart defaults
- Command Discovery: Comprehensive CLI with intuitive command structure
- Help System: Built-in documentation and usage examples
- Graceful Cancellation: Ctrl+C stops every command cleanly (exit 130); second press force-exits; CI-friendly SIGTERM handling (exit 143)
- Security Scanning: Vulnerability detection with govulncheck integration
- Configuration Management: Centralized project configuration and validation
- Extensible Architecture: Plugin-ready foundation for custom production needs
MAGE-X works without any configuration, but you can customize behavior with .mage.yaml or environment variables.
π Configuration File (.mage.yaml)
Create .mage.yaml in your project root for custom settings:
project:
name: my-project
binary: myapp
version: v1.0.0
module: github.com/user/my-project
build:
output: bin
trimpath: true
platforms:
- linux/amd64
- darwin/amd64
- darwin/arm64
- windows/amd64
tags:
- prod
ldflags:
- -s -w
- -X main.version={{.Version}}
- -X main.commit={{.Commit}}
test:
parallel: true
timeout: 10m
race: false
cover: true
covermode: atomic
lint:
golangci_version: v2.3.1
timeout: 5m
tools:
golangci_lint: v2.3.1
fumpt: latest
govulncheck: latest
release:
github:
owner: mrz
repo: my-project
platforms:
- linux/amd64
- darwin/amd64
- darwin/arm64
- windows/amd64π Environment Variable Overrides
Override any configuration with environment variables:
# Build configuration
export MAGE_X_BINARY_NAME=myapp
export MAGE_X_BUILD_TAGS=prod,feature1
export GOOS=linux
export GOARCH=amd64
# Test configuration
export MAGE_X_VERBOSE=true
export MAGE_X_TEST_RACE=true
export MAGE_X_TEST_TIMEOUT=15m
# Linting configuration
export MAGE_X_LINT_VERBOSE=true # Enable verbose linting output
export MAGE_X_LINT_TIMEOUT=10m
# Tool configuration
export MAGE_X_PARALLEL=8
# Benchmark timing with parameters
magex bench time=50ms # Quick benchmarks
magex bench time=10s # Full benchmarks
magex bench:cpu time=30s # CPU profiling
magex bench:save time=5s output=results.txt
magex bench time=2s count=5 # With custom count parameter
# Version management examples with new parameter format
magex version:bump bump=patch # Bump patch version
magex version:bump bump=minor push # Bump minor and push
magex version:bump bump=patch branch=master push # Switch to master, bump, and push
magex git:tag version=1.2.3 # Create git tag
magex git:commit message="fix: bug fix" # Commit with messageFor comprehensive documentation, visit the docs directory:
- Getting Started - Complete documentation index
- Namespace Interface Architecture - Modern interface-based namespace system
- API Reference - Complete interface and API documentation
- Quick Start - Get up and running in minutes
- Configuration Reference - Complete configuration guide
MAGE-X provides 190+ commands organized by functionality. All commands work instantly through the magex CLI.
π― Essential Commands
Quick Discovery:
magex help:default # Beautiful command listing with categories and emojis
magex -l # Plain list of all available targets
magex -search test # Find specific commandsMost Used Commands:
magex # Run default build
magex build # Build for current platform
magex test # Run complete test suite
magex bench # Run benchmarks
magex lint:fix # Auto-fix linting issues
magex format:fix # Format code automatically
magex version:bump # Bump version (patch, minor, major)ποΈ Code Generation
magex generate:default # Run go generate
magex generate:clean # Remove generated filesπ¦ Dependencies & Modules
# Dependency Management
magex deps:update # Update dependencies (safe - no major version bumps)
magex deps:update allow-major # Update including major versions (v1βv2, etc)
magex deps:tidy # Clean up go.mod and go.sum
magex deps:download # Download all dependencies
magex deps:outdated # Show outdated dependencies
magex deps:audit # Audit dependencies for vulnerabilities
magex deps:audit exclude=CVE-2024-38513,CVE-2023-45142 # Exclude specific CVEs from audit
# Multi-Module Update (for monorepos with multiple go.mod files)
magex deps:update all-modules # Update all modules in workspace
magex deps:update all-modules dry-run # Preview modules without updating
magex deps:update all-modules fail-fast # Stop on first module error
magex deps:update all-modules verbose # Show detailed update info
magex deps:update all-modules allow-major stable-only verbose fail-fast # All options
# Module Management
magex mod:update # Update go.mod file
magex mod:tidy # Tidy the go.mod file
magex mod:verify # Verify module checksums
magex mod:download # Download modules
magex mod:graph # Visualize dependency graph as tree with relationships
magex mod:why # Show why specific modules are needed
# Dependency Graph Examples
magex mod:graph # Default tree view with versions
magex mod:graph depth=3 # Limit depth to 3 levels
magex mod:graph show_versions=false # Hide version numbers
magex mod:graph format=json # JSON output format
magex mod:graph format=dot # DOT format for graphviz
magex mod:graph format=mermaid # Mermaid diagram format
magex mod:graph filter=github.com depth=2 # Filter + depth combined
magex mod:graph show_versions=false format=tree # Clean tree view
# Module Dependency Analysis Examples
magex mod:why github.com/stretchr/testify # Show why testify is needed
magex mod:why github.com/pkg/errors golang.org/x/sync # Analyze multiple modulesπ¦ Build & Compilation
magex build:default # Build for current platform
magex build:all # Build for all configured platforms
magex build:clean # Clean build artifacts
magex build:generate # Generate code before building
magex build:linux # Build for Linux amd64
magex build:darwin # Build for macOS (amd64 and arm64)
magex build:windows # Build for Windows amd64
magex build:install # Install binary to $GOPATH/bin
magex build:dev # Build and install development version (forced 'dev' version)
magex build:prebuild # Pre-build all packages to warm cache
magex build:prebuild parallel=2 # Pre-build with 2 parallel processes
magex build:prebuild p=4 # Pre-build with 4 parallel processes (short form)
# Memory-efficient prebuild strategies (great for CI/CD environments)
magex build:prebuild strategy=incremental batch=10 # Build in batches of 10 packages
magex build:prebuild strategy=mains-first # Build main packages first, then dependencies
magex build:prebuild strategy=smart # Auto-select best strategy based on available memory
magex build:prebuild strategy=full p=8 # Traditional full build with 8 parallel jobs
# Advanced prebuild options
magex build:prebuild strategy=incremental batch=5 delay=100 # 100ms delay between batches
magex build:prebuild strategy=mains-first mains-only=true # Only build main packages
magex build:prebuild exclude=test verbose=true # Exclude test packages, verbose outputπ§ͺ Testing & Quality
magex test # Run complete test suite with linting
magex test:unit # Run unit tests only
magex test:short # Run short tests (excludes integration tests)
magex test:race # Run tests with race detector
magex test:cover # Run tests with coverage analysis
magex test:coverrace # Run tests with both coverage and race detector
magex test:bench # Run benchmark tests
magex bench # Run benchmarks with default timing
magex bench time=50ms # Run quick benchmarks (50ms duration)
magex bench time=10s count=3 # Run benchmarks with custom time and count
magex test:fuzz # Run fuzz tests (default: 10s)
magex test:fuzz time=30s # Run fuzz tests with custom duration
magex test:fuzzShort time=1s # Run short fuzz tests with custom duration
magex test:integration # Run integration tests
# JSON Output Support for Test Commands
magex test -json # Run tests with JSON output for tooling
magex test:unit -json # Unit tests with JSON output
magex test:race -json # Race detection with JSON output
magex test:cover -json # Coverage tests with JSON output
magex test:coverrace -json # Coverage + race with JSON output
magex test:short -json # Short tests with JSON output
# Advanced Test Options (all commands support these flags)
magex test -v # Verbose output
magex test:cover -count=3 # Run tests 3 times
magex test -failfast # Stop at first failure
magex test -shuffle=on # Randomize test execution
magex test -parallel=4 # Set parallel test execution
# Code Quality & Linting
magex format:fix # Run code formatting
magex lint # Run essential linters
magex lint verbose=true # Run linters with verbose output
magex lint:fix # Auto-fix linting issues + apply formatting
magex lint:issues # Scan for TODOs, FIXMEs, nolint directives, and test skips
magex lint:verbose # Alternative: dedicated verbose linting command
magex lint:version # Show golangci-lint version
magex test:vet # Run go vet static analysis
magex tools:verify # Show tool version informationπ€ CI Test Output Mode
MAGE-X automatically detects CI environments and produces structured test output with precise file:line locations for failures. This eliminates complex bash/jq parsing in CI workflows.
Automatic Detection (Zero Configuration):
# In GitHub Actions (or any CI with CI=true) - works automatically!
magex test:unit # Produces GitHub annotations + JSONL output
# Locally - unchanged behavior
magex test:unit # Standard terminal outputExplicit CI Mode:
magex test:unit ci # Force CI mode locally (preview CI output)
magex test:unit ci=false # Disable CI mode in CI environmentAll test commands support CI mode:
magex test:unit cimagex test:race cimagex test:cover cimagex test:fuzz ci
Output in CI:
- GitHub Annotations: Clickable file:line links in PR sidebar
- Step Summary: Markdown table in
$GITHUB_STEP_SUMMARY - Structured Output:
.mage-x/ci-results.jsonlfor automation
Configuration (optional in .mage.yaml):
test:
ci_mode:
enabled: auto # auto (default), on, or off
format: github # auto, github, or json
context_lines: 20 # Lines of code context around failures
output_path: ".mage-x/ci-results.jsonl"Environment Variables:
export MAGE_X_CI_MODE=auto # auto/on/off
export MAGE_X_CI_FORMAT=github # github/json/auto
export MAGE_X_CI_CONTEXT=20 # Context lines (0-100)β Code Validation & Formatting
# Code Validation
magex vet:default # Run go vet
magex vet:all # Run go vet with all checks
magex vet:parallel # Run go vet in parallel
magex vet:shadow # Check for variable shadowing
magex vet:strict # Run strict vet checks
# Code Formatting
magex format:default # Default formatting (gofmt)
magex format:all # Format all supported file types
magex format:gofmt # Run gofmt
magex format:fumpt # Run gofumpt (stricter formatting)
magex format:imports # Format imports
magex format:go # Format Go files
magex format:yaml # Format YAML files
magex format:json # Format JSON files
magex format:fix # Fix formatting issues automatically
magex format:check # Check if files are properly formattedπ Analysis & Metrics
# Lines of Code Analysis (Multi-language support)
magex metrics:loc # Analyze Go lines of code (default)
magex metrics:loc lang=go # Explicitly analyze Go files
magex metrics:loc lang=js # Analyze JavaScript/TypeScript files (.js, .ts, .jsx, .tsx)
magex metrics:loc lang=yaml # Analyze YAML files (.yaml, .yml)
magex metrics:loc lang=js json # JS metrics with JSON output
# Other Metrics
magex metrics:mage # Analyze magefiles and targets
magex metrics:coverage # Generate coverage reports
magex metrics:complexity # Analyze code complexity
# Performance & Benchmarking
magex bench # Default benchmark operations
magex bench time=50ms # Quick benchmarks (50ms runs)
magex bench time=10s # Comprehensive benchmarks (10s runs)
magex bench count=3 # Run benchmarks 3 times
magex bench:profile # Profile application performance
magex bench:compare # Compare benchmark results
magex bench:regression # Check for performance regressions
magex bench:cpu time=30s # CPU usage benchmarks with custom duration
magex bench:mem time=2s # Memory usage benchmarksπ Documentation
magex docs # Generate and serve documentation (generate + serve in one command)
magex docs:generate # Generate Go package documentation from source code
magex docs:serve # Serve documentation locally with hybrid pkgsite/godoc support
magex docs:build # Build enhanced static documentation files with metadata
magex docs:check # Validate documentation completeness and quality
magex docs:update # Update GoDocs proxy (trigger pkg.go.dev sync)
magex docs:godocs # Update GoDocs proxy (alias for docs:update)π Git & Version Control
# Git Operations
magex git:status # Show git repository status
magex git:commit message="fix: commit message" # Commit changes with message parameter
magex git:tag version=1.2.3 # Create and push a new tag with version parameter
magex git:tagremove version=1.2.3 # Remove a tag
magex git:tagupdate version=1.2.3 # Force update a tag
# Version Management
magex version:show # Display current version information
magex version:modules # List all discovered sub-modules (for multi-module repos)
magex version:check # Check version information and compare with latest
magex version:update # Update to latest version
magex version:bump # Bump version (patch, minor, major)
magex version:changelog # Generate changelog from git history
magex version:tag # Create version tag
magex version:compare # Compare two versions
magex version:validate # Validate version format
# Version Bump Examples (now using parameters)
magex version:bump # Bump patch version (default)
magex version:bump bump=minor # Bump minor version
magex version:bump bump=major major-confirm # Bump major version with confirmation
magex version:bump bump=minor push # Bump minor and push to remote
# Branch Parameter Examples (recommended for virtual branch workflows)
magex version:bump bump=patch branch=master push # Switch to master, bump patch, and push
magex version:bump bump=minor branch=main # Switch to main branch before bumping
magex version:bump bump=major branch=master major-confirm push # Major bump on master with push
# Dry-run mode (preview changes without making them)
magex version:bump dry-run # Preview patch bump
magex version:bump bump=minor dry-run # Preview minor bump
magex version:bump bump=major major-confirm push dry-run # Preview major bump with push
magex version:bump bump=patch branch=master dry-run # Preview branch switch and bump
# Sub-module Versioning (for multi-module repositories like spv-wallet)
magex version:modules # List all discovered sub-modules
magex version:bump module=models bump=patch # Bump specific sub-module
magex version:bump module=all bump=minor # Bump all sub-modules together
magex version:bump module=* bump=patch push # Bump root + all sub-modules
magex version:bump module=models dry-run # Preview sub-module bump
# Important Notes:
# - Uncommitted changes will block version bump operation (safety check)
# - When using branch parameter, you will ALWAYS return to your original branch after completion
# - Branch switch-back happens even if tag creation or push fails (guaranteed cleanup)
# - If network issues occur during pull, operation stops but still switches back to original branchπ Release Management
# Core Release Operations
magex release # Create a new release from the latest tag
magex release godocs # Create a release and update GoDocs proxy
magex release:default # Create a new release from the latest tag
magex release:test # Dry-run release without publishing
magex release:snapshot # Build release artifacts without git tag
magex release:localinstall # Build from latest tag and install locally
# Release Setup & Validation
magex release:init # Initialize .goreleaser.yml configuration
magex release:check # Validate .goreleaser.yml configuration
magex release:validate # Comprehensive release readiness validation
magex release:changelog # Generate changelog from git history
magex release:clean # Clean release artifacts and build cacheβοΈ AWS Credential Management
Manage AWS credentials with MFA authentication. Requires AWS CLI to be installed.
# Smart login - detects if setup is needed, then performs MFA refresh
magex aws:login # Login with default profile
magex aws:login profile=production # Login with specific profile
# Interactive setup - configure credentials and MFA device
magex aws:setup # Setup default profile
magex aws:setup profile=staging # Setup specific profile
# MFA refresh - get temporary session credentials
magex aws:refresh # Refresh default profile
magex aws:refresh profile=prod # Refresh specific profile
magex aws:refresh duration=28800 # Custom session duration (8 hours)
# Status - view credential status
magex aws:status # Show all profiles
magex aws:status profile=dev # Show specific profilePrerequisites:
- AWS CLI must be installed and accessible in your PATH
- macOS:
brew install awscli - Linux (Ubuntu/Debian):
sudo apt-get install awscli - Linux (RHEL/CentOS):
sudo yum install aws-cli - Windows: Download MSI installer
- Official guide: AWS CLI Installation
- macOS:
- IAM user with MFA device configured
Workflow:
- Run
magex aws:setupto configure your Access Key, Secret Key, and MFA device ARN - Run
magex aws:logindaily to refresh your session credentials with MFA
π§ Development Tools
magex tools:update # Update all development tools
magex tools:install # Install all required development tools
magex tools:verify # Check if all required tools are available
magex deps:audit # Run vulnerability check using govulncheck
magex build:install # Install the project binary
magex build:dev # Build and install development version (forced 'dev' version)
magex install:stdlib # Install Go standard library for cross-compilation
magex uninstall # Remove installed binary
# Spec-Kit CLI Management
magex speckit:install # Install spec-kit prerequisites (uv, uvx, specify-cli)
magex speckit:check # Verify spec-kit installation and report version info
magex speckit:upgrade # Upgrade spec-kit with automatic constitution backup/restore
# BMAD CLI Management
magex bmad:install # Install BMAD prerequisites (npm, npx, bmad-method)
magex bmad:check # Verify BMAD installation and report version info
magex bmad:upgrade # Upgrade BMAD to the latest beta version
# Agent OS CLI Management
magex agentos:install # Install Agent OS (base + project)
magex agentos:check # Verify Agent OS installation and report version info
magex agentos:upgrade # Upgrade Agent OS with user data preservationπ» Tmux Session Management
# Claude Code Pairing Sessions
magex tmux:start # Start Claude Code in current directory
magex tmux:start dir=~/projects/foo # Start in specific directory
magex tmux:start model=opus # Start with specific model (opus/sonnet/haiku)
magex tmux:start dir=~/projects/foo name=my-session model=opus # All options
# Session Management
magex tmux:list # List all active tmux sessions
magex tmux:attach name=my-session # Attach to existing session
magex tmux:kill name=my-session # Kill specific session
magex tmux:killall # Kill all sessions (with confirmation)
magex tmux:status # Show session health and status
# Supported Models
# - opus: claude-opus-4-5
# - sonnet: claude-sonnet-4-5 (default)
# - haiku: claude-haiku-4-5
# - gpt: gpt-4o
# - o1: o1
# - o3: o3-mini
# - gemini: gemini-3-flash
# Session auto-attach: If a session already exists, tmux:start will attach to itβοΈ Configuration Management
magex configure:init # Initialize a new mage configuration
magex configure:show # Display the current configuration
magex configure:update # Update configuration values interactively
magex configure:export # Export configuration to file
magex configure:import # Import configuration from file
magex configure:validate # Validate configuration integrity
magex configure:schema # Show configuration schema
# YAML Configuration
magex yaml:init # Create mage.yaml configuration
magex yaml:validate # Validate YAML configuration
magex yaml:show # Show current YAML configuration
magex yaml:template # Generate YAML templates
magex yaml:format # Format YAML files
magex yaml:check # Check YAML syntax
magex yaml:merge # Merge YAML configurations
magex yaml:convert # Convert between YAML formats
magex yaml:schema # Show YAML schemaπ Help & Updates
# Help System
magex help:default # Show general help
magex help:commands # List all available commands
magex help:examples # Show usage examples
magex help:gettingstarted # Getting started guide
magex help:completions # Generate shell completions
# Update Management
magex update:check # Check for updates
magex update:install # Install the latest update
# Installation Management
magex install:default # Default installation
magex install:local # Install locally
magex install:binary # Install project binary
magex install:tools # Install development tools
magex install:go # Install Go
magex install:stdlib # Install Go standard library
magex install:systemwide # Install system-wide
magex install:deps # Install dependencies
magex install:mage # Install mage
magex install:githooks # Install git hooks
magex install:ci # Install CI components
magex install:certs # Install certificates
magex install:package # Install package
magex install:all # Install everything
magex uninstall # Remove installationRun magex -l to see a plain list of all available commands (190+ commands), or use magex help for a beautiful categorized view with descriptions and usage tips.
MAGE-X includes a hybrid documentation system with auto-detection and cross-platform browser integration.
π Documentation Features & Capabilities
- Auto-detection: Automatically detects and uses the best available documentation tool
- Hybrid Support: Supports both
pkgsite(modern) andgodoc(classic) with smart fallback - Auto-installation: Automatically installs missing tools when needed
- Configuration Control: Override tool selection with
docs.toolin .mage.yaml
# Documentation serving
magex docs:serve # Serve documentation locally
magex docs:godocs # Serve with godoc format
magex docs:api # API documentation
magex docs:examples # Example documentation
magex docs:readme # README documentation- Port Management: Automatic port detection and conflict resolution
- Cross-Platform: Browser auto-opening on macOS, Linux, and Windows
- CI/CD Ready: Detects CI environments and disables browser opening
- Comprehensive Generation: Documents all packages with categorization
- Static Building: Enhanced Markdown with metadata and navigation
- Build Artifacts: JSON metadata and organized output structure
MAGE-X includes specialized namespaces for power users. These are opt-in to keep the core installation lightweight.
π§ Advanced Namespace Configuration
Available Specialized Namespaces:
- Bench - Performance benchmarking and profiling
- Releases - Release creation and asset distribution
- Yaml - YAML configuration management and validation
To enable advanced features in your magefile:
//go:build mage
package main
import "github.com/mrz1836/mage-x/pkg/mage"
// Export core namespaces (already included by default)
type (
Build = mage.Build
Test = mage.Test
// ... other default namespaces
)
// Add advanced namespaces as needed
type (
Integrations = mage.Integrations
Bench = mage.Bench
Releases = mage.Releases
)This approach keeps the default installation lightweight while allowing power users to access advanced features when needed.
Example: Production Operations
// Run benchmarking and performance analysis
func PerformanceTest() error {
var bench Bench
return bench.Default()
}
// Run quick benchmarks with custom timing
func QuickBench() error {
var bench Bench
return bench.DefaultWithArgs("time=50ms")
}See the examples directory for more custom magefile implementations.
Integrated support for AI-driven development methodologies. Choose your style:
| π Spec-Kit (Recommended) | π BMAD | π€ Agent OS | |
|---|---|---|---|
| Philosophy | Executable specifications | Agile workflows with AI agents | Structured agentic workflows |
| Interface | CLI slash commands (/commands) |
IDE-based agents (*commands) |
Claude Code commands + agents |
| Workflow | Specify β Plan β Tasks β Implement | PRD β Tech Spec β Architecture β Sprint | Write Spec β Shape β Plan β Tasks β Implement |
| Package | Python (specify-cli) |
npm (bmad-method) |
Shell scripts (curl install) |
| Complexity | Simple, streamlined | Full agile methodology | Flexible, profile-based |
| Best for | Quick start, precise requirements | Large projects, team workflows | Claude Code users, multi-agent workflows |
π Spec-Kit - Executable Specifications (Recommended)
Spec-Kit transforms specifications into working implementations. Simple, streamlined, and perfect for getting started quickly. All feature specs live in specs/.
# Install spec-kit prerequisites
magex speckit:installFollow the spec-kit workflow to create and implement new features:
Establish project principles and development guidelines.
/speckit.constitutionDescribe what and why, not the technology. Focus on requirements and user stories.
/speckit.specifyAddress underspecified areas with targeted questions.
/speckit.clarifyCreate technical implementation strategy with your chosen tech stack.
/speckit.planGenerate actionable, dependency-ordered task lists.
/speckit.tasksValidate cross-artifact consistency before implementation.
/speckit.analyzeExecute all tasks to build the feature according to the plan.
/speckit.implementmagex speckit:install # Install spec-kit prerequisites
magex speckit:check # Check installation and version
magex speckit:upgrade # Upgrade with automatic backup/restoreConfiguration (.mage.yaml):
speckit:
constitution_path: ".specify/memory/constitution.md"
backup_dir: ".specify/backups"
backups_to_keep: 5
owner_repo: "github/spec-kit" # GitHub owner/repo for release lookup
git_url: "https://github.com/github/spec-kit.git" # bare git URL of the spec-kit repo
integration: "claude" # spec-kit integration target (replaces ai_provider)
# ai_provider: "claude" # deprecated; still honored as a fallbackPro tip: Run
/speckit.checklistanytime to generate custom validation criteria.
β οΈ Heads up: The PyPI package literally namedspecify-cliis not the official spec-kit. Per the upstream README, only install from the GitHub repo.magex speckit:installandspeckit:upgradealways install from GitHub at the latest tagged release, andspeckit:upgradeself-heals any prior incorrect PyPI install via--force.
β¬οΈ Upgrading Spec-Kit
magex speckit:upgradeThe upgrade command automatically:
- β
Backs up your constitution to
.specify/backups/with timestamp - β
Resolves the latest official release via the GitHub API (with
ghβ authenticatedcurlβgit ls-remotefallback chain) - β
Reinstalls
specify-clifromgit+https://github.com/github/spec-kit.git@<tag>with--force(self-heals users on the unofficial PyPIspecify-clipackage) - β
Refreshes project files (slash commands, scripts, templates) at the same release tag using the modern
--integrationflag - β Restores your constitution from backup
- β
Tracks version history in
.specify/version.txt - β Cleans old backups (keeps last 5)
- β
Verifies the upgrade with
specify check
How version resolution works: the upgrade resolves the latest tag once and threads it through every install step, so the CLI and project templates always end up on the same release even if a new version ships mid-flow. If all three lookup methods (
gh,curl,git ls-remote) fail, the command exits with an error rather than silently installing from the default branch.
If you prefer manual control, follow upstream's official upgrade guide. Replace vX.Y.Z with the latest tag from Releases:
cp .specify/memory/constitution.md ~/constitution.backup.mduv tool install specify-cli --force --from git+https://github.com/github/spec-kit.git@vX.Y.Z
specify checkDo not run
uv tool install specify-cliwithout--fromβ that pulls an unrelated PyPI package, not the official spec-kit. Likewise,uv tool upgrade specify-clicannot switch sources, so it will keep upgrading whatever was originally installed.
uvx --from git+https://github.com/github/spec-kit.git@vX.Y.Z specify init --here --force --integration claudeThe
--aiflag is deprecated upstream and will be removed in v0.10.0; use--integrationinstead.
If you have custom constitution changes, carefully merge them back from your backup.
π BMAD - AI-Driven Agile Development
BMAD (Build More, Architect Dreams) provides a full agile methodology with AI agents. Best for larger projects or teams wanting structured agile workflows.
# Install BMAD with interactive setup
magex bmad:installAfter installation, work with BMAD agents in your IDE:
Select your development track (greenfield, brownfield, or legacy).
*workflow-init
Create a comprehensive product brief with the PM agent.
*create-product-brief
Create a comprehensive Product Requirements Document with the PM agent.
*prd
Design user flows and wireframes with the UX agent.
*create-ux-design
Design system architecture with the Architect agent.
*create-architecture
Break work into epics, sprints and prioritize stories.
*create-epics-and-stories
Design test plans and cases with the TEA agent.
*testarch-test-design
Validate all artifacts before development begins.
*check-implementation-readiness
Design sprints and get started with development.
*sprint-planning
Check the status of your sprints anytime:
*sprint-status
Create individual user stories for implementation inside each sprint.
*create-story
Implement individual user story.
*dev-story
Review and test completed user story.
*code-review
Reflect on sprint performance and identify improvements.
*retrospective
magex bmad:install # Install BMAD prerequisites
magex bmad:check # Verify installation and version
magex bmad:upgrade # Upgrade to latest versionConfiguration (.mage.yaml):
bmad:
project_dir: "_bmad"
version_tag: "@beta"π€ Agent OS - Structured Agentic Workflows
Agent OS is a system for spec-driven agentic development that provides structured workflows for AI coding agents. It integrates deeply with Claude Code and supports multi-agent delegation.
# Install Agent OS (base + project)
magex agentos:installThe installer will:
- Install the base Agent OS to
~/agent-os(if not already installed) - Run the interactive project installer to set up your project
After installation, use Claude Code slash commands to work through the Agent OS workflow:
Create a detailed specification for your feature.
/write-spec
Shape and refine the specification with targeted questions.
/shape-spec
Create a technical implementation plan.
/plan-product
Generate dependency-ordered tasks from the plan.
/create-tasks
Execute tasks to implement the feature.
/implement-tasks
Coordinate multiple agents for complex implementations.
/orchestrate-tasks
magex agentos:install # Install Agent OS (base + project)
magex agentos:check # Verify installation and version
magex agentos:upgrade # Upgrade with user data preservationConfiguration (.mage.yaml):
agentos:
base_dir: "agent-os"
profile: "default"
claude_code_commands: true
use_claude_code_subagents: true
standards_as_skills: falseAgent OS preserves your important project data during upgrades:
agent-os/specs/- All your feature specificationsagent-os/product/- Your product roadmap and mission
The following are refreshed during upgrades:
agent-os/standards/- Standards from your profile.claude/commands/agent-os/- Claude Code commands.claude/agents/agent-os/- Claude Code agents
Pro tip: Create custom profiles in
~/agent-os/profiles/to customize standards and workflows without losing your changes during updates.
All examples and tests run via GitHub Actions using Go 1.25+. View the examples directory for complete project demonstrations.
# Quick test suite
magex test
# Comprehensive testing
magex test:race test:cover test:fuzz
# JSON output for tooling integration
magex test -json # JSON output for CI/CD tools
magex test:coverrace -json # Coverage + race with JSON output
# Performance benchmarks
magex bench # Default benchmarks (10s duration)
magex bench time=50ms # Quick benchmarks for CI
magex bench time=10s count=3 # Comprehensive benchmarks with count parameter
magex test:bench # Via test namespace
magex test:bench time=30s # Test namespace with custom timing- Basic Project - Zero-configuration MAGE-X usage
- With Configuration - Using .mage.yaml for project customization
- With Custom Commands - Adding project-specific commands
- Zero Config - Instant productivity with magex
Performance benchmarks for core MAGE-X operations:
| Operation | Time | Memory | Notes |
|---|---|---|---|
| Build Detection | 1.2ms | 256KB | Project type and configuration |
| Command Execution | 0.8ms | 128KB | Secure command validation |
| Configuration Loading | 2.1ms | 512KB | YAML parsing and validation |
Benchmarks run on Apple M1 Pro (ARM64) with Go 1.25+ All operations show consistent sub-5ms performance with minimal memory allocation
MAGE-X follows strict coding standards and best practices:
- Code Quality: >80% test coverage, comprehensive linting, and security scanning
- Go Best Practices: Idiomatic Go code following community standards
- Security First: Input validation, secure command execution, minimal dependencies
- Documentation: Comprehensive godoc coverage and usage examples
- AI Compliance: Machine-readable guidelines for AI assistants
Read more about our code standards and contribution guidelines.
Read the AI Usage & Assistant Guidelines for details on how AI is used in this project and how to interact with the AI assistants.
![]() |
|---|
| mrz |
We welcome contributions from the community! Please read our contributing guidelines and code of conduct.
All kinds of contributions are welcome! π
- β Star the project to show your support
- π Report bugs through GitHub issues
- π‘ Suggest features with detailed use cases
- π Improve documentation with examples and clarity
- π§ Submit pull requests with bug fixes or new features
Built with β€οΈ by the Go community
MAGE-X: Write Once, Mage Everywhere

