agentleFS
magefilemagefile/mage/.github/copilot-instructions.md

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
  1. Very specific:

    After making changes, always run golangci-lint run ./...

    line 26
  2. Very specific:

    Target function signatures: follow strict rules enforced by parse/parse.go (funcType): optional leading context.Context parameter, …

    line 53

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

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:

  1. Entry — main.go calls mage.Main() which parses CLI flags and dispatches commands.
  2. File scanning — mage/main.go finds magefiles (files with //go:build mage or // +build mage tags) in the current directory.
  3. AST parsing — parse.PrimaryPackage() uses go/parser and go/doc to extract exported functions, namespaces (types embedding mg.Namespace), //mage:import directives, aliases, and the default target.
  4. Code generation — GenerateMainfile() renders mage/magefile_tmpl.go (a Go text/template) into a wrapper main package that handles flag parsing, help output, and dispatching to user targets.
  5. Compilation & caching — Compile() runs go build on 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/CtxDeps for dependency declaration, mg.F() for parameterized targets, mg.Namespace for grouping targets, Fatal/Fatalf for error handling.
  • parse/ — Go AST parser that extracts target metadata (functions, namespaces, imports, aliases, defaults) from magefiles into a parse.PkgInfo model 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.mod specifies 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 leading context.Context parameter, supported arg types (string, int, bool, time.Duration), and must return either nothing or error. Pointer args become optional CLI arguments.
  • //mage:import comments 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.go calls Invoke() against fixture directories under testdata/. Table-driven unit tests are used in parse/, sh/, internal/, and target/. Always run tests with -race.

Download now (ZIP)

Trending

Steady talk.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 4 mentionsApr 2026: 2 mentionsMay 2026: 1 mentionJun 2026: 2 mentionsJul 2026: 5 mentionsAug 2026: 2 mentionsSep 2026: 6 mentionsOct 2026: 3 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the magefile/mage repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about magefile/mage

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

45 more on GitHub

On Hacker News · 2

  • 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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.