explaingit

magefile/mage

4,659GoAudience · developerComplexity · 2/5Setup · easy

TLDR

A build automation tool for Go projects that lets you write build tasks as plain Go functions instead of Makefiles, with no external dependencies and cross-platform support for Windows, macOS, and Linux.

Mindmap

mindmap
  root((mage))
    What it does
      Build automation
      Replaces Makefiles
    How it works
      Go functions as targets
      No extra syntax
    Installation
      go install command
      Prebuilt binaries
    Features
      Cross-platform
      No dependencies
      Multiple magefiles
    Use cases
      Build and test
      CI automation
      Release scripts
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Replace a project's Makefile with Go functions that work consistently on Windows, macOS, and Linux.

USE CASE 2

Define build targets like test, build, and deploy in a Go file that any team member can run with a single mage command.

USE CASE 3

Write cross-platform build scripts that use Go's standard library for file operations and error handling instead of bash syntax.

Tech stack

Go

Getting it running

Difficulty · easy Time to first run · 30min

In plain English

Mage is a build automation tool for Go projects. If you have worked with Makefiles, the concept is similar: you define a set of named tasks, and a tool runs them for you. The difference is that with Mage, those tasks are written in plain Go functions rather than in a separate scripting language. The project lives at magefile.org, where the full documentation is hosted. The motivation for Mage comes from the awkwardness of Makefiles on real projects. Makefiles rely on bash-style syntax that is hard to read, does not behave consistently across operating systems, and is unfamiliar to developers whose main language is Go. Mage removes that friction by letting you write your build logic in the same language as the rest of your code, with access to Go's standard library and all its tools for looping, branching, and error handling. Installing Mage depends on which version of Go you are using. With Go 1.18 or newer, a single go install command fetches and builds it. Older versions can use go get followed by a bootstrap script. You can also download a prebuilt binary from the project's releases page. Mage has no external dependencies beyond the Go standard library itself, and it works on Windows, macOS, and Linux. Once installed, you create one or more magefiles containing ordinary Go functions. Mage reads those files and exposes each exported function as a runnable target. You can name the files whatever you like, and you can maintain separate ones for different purposes. The tool is discussed in a community Slack channel and a Google Group where users share usage patterns and report issues.

Copy-paste prompts

Prompt 1
How do I install mage and create my first magefile.go with build and test targets for a Go project?
Prompt 2
How do I migrate an existing Makefile with build, test, and deploy targets into a mage magefile?
Prompt 3
How does mage handle dependencies between targets so that build always runs generate first?
Prompt 4
How do I organize multiple magefiles in a Go project to separate build, test, and release tasks?
Open on GitHub → Explain another repo

← magefile on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.