mage
Copilot instructions4.7k starsChanged 5 years agoApache-2.0View on GitHub
Mage is a make-like build tool that uses Go functions as build targets. Users write plain Go functions in "magefiles" and mage makes them runnable from the command line. After making changes, always run golangci-lint run ./... before committing to catch lint issues early. Mage builds itself with mage. The bootstrap path (go run bootstrap.go) is for building mage when mage isn't installed yet. The project's own build targets live in magefiles/. Mage works by parsing user Go source files…
We split this copilot-instructions.md into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 26
After making changes, always run golangci-lint run ./...
- Very specific: line 53
Target function signatures: follow strict rules enforced by parse/parse.go (funcType): optional leading context.Context parameter, …
≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Copilot Instructions for Mage
Mage is a make-like build tool that uses Go functions as build targets. Users write plain Go functions in "magefiles" and mage makes them runnable from the command line.
Build, Test, and Lint
# Build
go build ./...
# Test (full suite, including race detector as required by CI)
go test -race ./...
# Test a single package
go test -race ./parse/
# Test a single test function
go test -race ./mage/ -run TestGoCmd
# CI runs tests with: go test -v -vet=all -tags CI -race ./...
# Lint (requires golangci-lint) — run after any code changes
golangci-lint run ./...After making changes, always run golangci-lint run ./... before committing to catch lint issues early.
Mage builds itself with mage. The bootstrap path (go run bootstrap.go) is for building mage when mage isn't installed yet. The project's own build targets live in magefiles/.
Architecture
Mage works by parsing user Go source files and generating a temporary CLI binary that dispatches to the user's target functions:
- Entry —
main.gocallsmage.Main()which parses CLI flags and dispatches commands. - File scanning —
mage/main.gofinds magefiles (files with//go:build mageor// +build magetags) in the current directory. - AST parsing —
parse.PrimaryPackage()usesgo/parserandgo/docto extract exported functions, namespaces (types embeddingmg.Namespace),//mage:importdirectives, aliases, and the default target. - Code generation —
GenerateMainfile()rendersmage/magefile_tmpl.go(a Gotext/template) into a wrappermainpackage that handles flag parsing, help output, and dispatching to user targets. - Compilation & caching —
Compile()runsgo buildon the magefiles plus the generated wrapper. The output binary is cached by content hash in the user's cache directory.
Package Map
mage/— Core library: CLI entry point, file scanning, code generation, compilation, and execution. Can be used as a library (mage.Invoke()).mg/— User-facing API for magefiles:Deps/CtxDepsfor dependency declaration,mg.F()for parameterized targets,mg.Namespacefor grouping targets,Fatal/Fatalffor error handling.parse/— Go AST parser that extracts target metadata (functions, namespaces, imports, aliases, defaults) from magefiles into aparse.PkgInfomodel consumed by code generation.sh/— Shell helper functions (sh.Run,sh.Output,sh.Exec) for use in magefiles.internal/— Shared low-level utilities for command execution and debug output.target/— Timestamp-based rebuild helpers (target.Path,target.Dir,target.Glob) for use in magefiles.
Key Conventions
- Zero external dependencies. Mage uses only the Go standard library. This is intentional — since mage is often vendored into projects, adding dependencies to mage adds them to every project that uses it. Do not add external dependencies.
- Go 1.18 minimum. The
go.modspecifies Go 1.18. CI tests against both Go 1.18 and stable. Avoid language features or stdlib APIs from newer Go versions. - Target function signatures follow strict rules enforced by
parse/parse.go(funcType): optional leadingcontext.Contextparameter, supported arg types (string,int,bool,time.Duration), and must return either nothing orerror. Pointer args become optional CLI arguments. //mage:importcomments on blank imports cause mage to recursively parse imported packages and surface their exported functions as targets.- Namespace targets are methods on types that embed
mg.Namespace. The type name becomes a CLI prefix (e.g.,mage ns:target). - Documentation — All functions, methods, types, package variables, and package constants must have Go doc comments describing their purpose, including unexported ones. Every package must have a detailed package-level doc comment explaining what the package is for and how to use it.
- Formatting uses
goimports(configured in.golangci.toml). - Tests are primarily integration-style:
mage/main_test.gocallsInvoke()against fixture directories undertestdata/. Table-driven unit tests are used inparse/,sh/,internal/, andtarget/. Always run tests with-race.
Trending
Steady talk.about the whole repository
Who's talking about magefile/mage
- golang/go“runtime: 2-3x memory usage when running in container increase in 1.16 vs 1.15 (MADV_DONTNEED related)”GitHub · Feb 23, 2021 · 13 reactions
- golang/go“proposal: create standard tool for running common development scripts”GitHub · Aug 21, 2018 · 10 reactions
- A Hacker News story“Mage: a make/rake-like build tool using Go”Hacker News · Sep 25, 2017 · 10 points
- forkline/ingress-nginx“build(deps): Update go modules”GitHub · Apr 3, 2026 · 4 reactions
- elastic/beats“make: *** No rule to make target 'update', needed by 'setup' when step my own beat”GitHub · Jul 31, 2018 · 4 reactions
The biggest 5 of 53 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 53
Talked about on GitHub, Hacker News and Bluesky (53 times).
On GitHub · 50
- Feb 23, 2021runtime: 2-3x memory usage when running in container increase in 1.16 vs 1.15 (MADV_DONTNEED related) — golang/go13 reactions · 21 comments
- Aug 21, 2018proposal: create standard tool for running common development scripts — golang/go10 reactions · 10 comments
- Apr 3, 2026build(deps): Update go modules — forkline/ingress-nginx4 reactions · 20 comments
- Jul 31, 2018make: *** No rule to make target 'update', needed by 'setup' when step my own beat — elastic/beats4 reactions · 2 comments
- Dec 25, 2021Unable to build project — JordanKnott/taskcafe3 reactions · 4 comments
45 more on GitHub
- Feb 1, 2021Support creating Docker images regardless of arch for all platforms — elastic/beats3 reactions · 9 comments
- Sep 25, 2026chore(deps): update dependency kubernetes-sigs/bom to v0.8.0 (main) — cilium/tetragon2 reactions · 1 comment
- Jul 27, 2023Record the progress of the OSPP 2023 hgctl project — higress-group/higress2 reactions · 6 comments
- Jun 15, 2020Cannot build via binary or docker with go 1.14 — prometheus-community/postgres_exporter2 reactions · 1 comment
- Sep 1, 2018Incorrect instructions for installing from source on website — gohugoio/hugo2 reactions · 2 comments
- Oct 13, 2017Download v1 release of Mage for building — gohugoio/hugo2 reactions · 11 comments
- Sep 9, 2026feat: install and build OLC RTC service — mr-twek-dev/olcrtcwebgui1 reaction
- Jul 28, 2026feat: add CollectionRef[T].Where equality-filter queries — mimu-yu10/Firego1 reaction · 2 comments
- Jul 25, 2026feat: add schema registry cache to internal/metadata — mimu-yu10/Firego1 reaction · 2 comments
- Jul 24, 2026ci: add mage task runner and Dependabot updates — mimu-yu10/Firego1 reaction
- Jul 20, 2026chore(deps): update vikunja/vikunja docker tag to v2.4.0 — hevel86/BrainiacOps1 reaction
- Jul 2, 2026Bump mage to 1.17.2 everywhere, guard dev:up against old mage versions, and fix localdev doc drift — armadaproject/armada1 reaction · 4 comments
- May 1, 2026chore(deps): update dependency gohugoio/hugo to v0.161.1 — googleapis/mcp-toolbox1 reaction · 4 comments
- May 7, 2025Set MAGE VERSION to 1.15.0 for deploy-k8s-pipeline — elastic/beats1 reaction · 3 comments
- Dec 15, 2024マイグレーションツールの導入 — AuroralTech/todo-api_2024121 reaction · 1 comment
- Nov 19, 2024Developing using docker-compose currently doesn't work — grafana-cold-storage/oncall1 reaction
- May 20, 2024Fixes the release build — rwx-research/mint-cli1 reaction
- Apr 11, 2023proposal: go install: allow whitespace delimited package names from separate modules and versions — golang/go1 reaction · 3 comments
- Apr 10, 2023Renovate Dashboard 🤖 — facebookincubator/TTPForge1 reaction
- Oct 28, 2022Update dependency hugo to v0.105.0 — jshmrtn/renovate-asdf-test1 reaction
- Dec 8, 2021Default Dockerfile build fails — gohugoio/hugo1 reaction · 8 comments
- Aug 25, 2021Will "elastic-package" run on ARM? — elastic/elastic-package1 reaction · 8 comments
- Mar 3, 2021Fail to build — cloudflare/cf-terraforming1 reaction · 3 comments
- Feb 19, 2021Empty report generation error — benc-uk/k6-reporter1 reaction · 6 comments
- Jan 31, 2020Install tools (mage, goimports, etc.) from vendor folder — elastic/beats1 reaction · 5 comments
- Oct 7, 2019Random pipeline failures with not possible to fast-forward, aborting error — mysteriumnetwork/node1 reaction
- Mar 13, 2019Simplify process to build Fider from source — getfider/fider1 reaction
- Oct 19, 2026chore(deps): bump github.com/magefile/mage from 1.14.0 to 1.17.2 — AraxyAI/coraza__9db5a595e2050 reactions
- Oct 19, 2026Bump github.com/magefile/mage from 1.11.0 to 1.17.2 — Pakon2543/grafana0 reactions
- Oct 8, 2026fix: limit automatically forwarded resource headers — grafana/grafana-plugin-sdk-go0 reactions · 3 comments
- Sep 28, 2026Bump github.com/magefile/mage from 1.15.0 to 1.17.2 — rSon12/grafana0 reactions
- Sep 28, 2026chore(deps): bump github.com/magefile/mage from 1.15.0 to 1.17.2 — elastic/harp0 reactions
- Sep 23, 2026Adopt mise per-repo (Go + Mage toolchain) — supperjumpin/supperjumpin0 reactions
- Sep 10, 2026chore(deps): bump github.com/magefile/mage from 1.17.0 to 1.17.2 in /magefiles in the go-mod-magefiles group across 1 directory — josephschorr/authzed-go0 reactions · 1 comment
- Aug 17, 2026deps: bump the gomod-all group across 2 directories with 7 updates — oslokommune/ok0 reactions
- Aug 2, 2026Bump github.com/magefile/mage from 1.15.0 to 1.17.2 — uwu-tools/magex0 reactions · 1 comment
- Jun 21, 2026Dependency Dashboard — voxpupuli/openvox-ca0 reactions
- Jun 16, 2026Consolidate and track Mage CLI version across the repo — konflux-ci/caching0 reactions · 6 comments
- Apr 6, 2026chore(deps): bump github.com/magefile/mage from 1.17.0 to 1.17.2 in /magefiles in the go-mod-magefiles group across 1 directory — authzed/authzed-go0 reactions
- Mar 31, 2026fix(deps): update module github.com/magefile/mage to v1.17.2 — aevea/commitsar0 reactions · 2 comments
- Mar 8, 2026Update module github.com/magefile/mage to v1.17.2 — gkwa/frecklehugger0 reactions
- Mar 8, 2026Update module github.com/magefile/mage to v1.17.2 — gkwa/annuallymust0 reactions
- Aug 17, 2025Issue: Default Go packages fail to install with "invalid char ' '" error — asdf-community/asdf-golang0 reactions
- Nov 9, 2024Dependency Dashboard — gkwa/quarterlywin0 reactions
- Oct 31, 2024Dependency Dashboard — gkwa/annuallymust0 reactions
On Hacker News · 2
- Sep 25, 2017Mage: a make/rake-like build tool using Go10 points · 1 comment
- Sep 14, 2019Mage, a make replacement, releases 1.91 point · 2 comments
On Bluesky · 1
- Mar 26, 2026A make-like build tool using Go. You write plain-old go functions, and Mage automatically uses them as Makefile-like runnable targets.… — @golangch.bsky.social2 likes and reposts
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

