johnqtcg/awesome-skills/skills/go-makefile-writer/SKILL.md
go-makefile-writer
Canonical skill for Go Makefiles. Create/refactor root Makefiles for Go repositories with standardized build/test/lint/run targets, self-documenting help output, predictable artifacts, and maintainable target naming.
- Source repository stars
- 30
- Declared platforms
- 0
- Static risk flags
- 1
- Last source update
- 2026-08-22
- Source checked
- 2026-08-25
Decision brief
What it does: where it fits
Design a practical root Makefile that is readable, reproducible, and aligned with repository layout.
Not for
- No help target or missing self-documenting comments
- No .PHONY declaration for non-file targets
Compatibility matrix
Platform support, with evidence labels
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
Inspect first. Install second.
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/johnqtcg/awesome-skills --skill "skills/go-makefile-writer"Inspect the Agent Skill "go-makefile-writer" from https://github.com/johnqtcg/awesome-skills/blob/d63cf368c1b106871b56454bd73c293701bef500/skills/go-makefile-writer/SKILL.md at commit d63cf368c1b106871b56454bd73c293701bef500. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
What the source asks the agent to do
- 01
Workflow
0. Select mode (Create or Refactor) and record rationale.
Select mode (Create or Refactor) and record rationale.Inspect project structure:discover cmd//main.go entrypoints by running this skill's discovery script against the target repo: bash /scripts/discovergoentrypoints.sh (the script lives in the skill directory, not in the target repo — pass the repo… - 02
Quick Reference
Review the “Quick Reference” section in the pinned source before continuing.
Review and apply the “Quick Reference” source section. - 03
Execution Modes
Select a mode before starting and state it in the output report.
Full target set generated from project inspection.Use golden templates (simple-project.mk / complex-project.mk) as starting points.No backward-compatibility concerns. - 04
Create (new Makefile from scratch)
Full target set generated from project inspection.
Full target set generated from project inspection.Use golden templates (simple-project.mk / complex-project.mk) as starting points.No backward-compatibility concerns. - 05
Refactor (modify existing Makefile)
Minimal-diff edits — change only what is needed; do not rewrite the entire file.
Minimal-diff edits — change only what is needed; do not rewrite the entire file.Backward compatibility: if target names change, keep aliases for at least one transition period and document them in the output report.Preserve existing useful targets unless user explicitly asks to remove them.
Permission review
Static risk signals and limitations
Runs scripts
The documentation asks the agent to run terminal commands or scripts.
→ Run this skill's discovery script against the target repo first — `bash <skill-dir>/scripts/discover_go_entrypoints.sh <project-root>` — to discover `cmd/**/main.go` binary locations and infer project shape (single-binary vs multi-binary)Evidence record
Why each signal appears
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 91/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 30 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Provenance and original SKILL.md
- Repository
- johnqtcg/awesome-skills
- Skill path
- skills/go-makefile-writer/SKILL.md
- Commit
- d63cf368c1b106871b56454bd73c293701bef500
- License
- MIT
- Collected
- 2026-08-25
- Default branch
- main
View the original SKILL.md
Go Makefile Writer
Design a practical root Makefile that is readable, reproducible, and aligned with repository layout.
Quick Reference
| If you need to… | Go to |
|---|---|
| Create a Makefile from scratch for a new Go project | §Execution Modes → Create + §Workflow |
| Refactor or update an existing Makefile (minimal-diff) | §Execution Modes → Refactor |
Decide which targets to include (build, test, lint, ci…) | §Workflow (Plan targets) |
| Get a complete working Makefile example to start from | Load references/golden/simple-project.mk or complex-project.mk |
Check quality rules, variable conventions, .PHONY requirements | Load references/makefile-quality-guide.md |
| Review a Makefile PR quickly | Load references/pr-checklist.md |
| Handle a monorepo or multi-module Go repo | §Monorepo Support |
Execution Modes
Select a mode before starting and state it in the output report.
Create (new Makefile from scratch)
- Full target set generated from project inspection.
- Use golden templates (simple-project.mk / complex-project.mk) as starting points.
- No backward-compatibility concerns.
Refactor (modify existing Makefile)
- Minimal-diff edits — change only what is needed; do not rewrite the entire file.
- Backward compatibility: if target names change, keep aliases for at least one transition period and document them in the output report.
- Preserve existing useful targets unless user explicitly asks to remove them.
- Before editing, snapshot the current target list via
make -qp | awk -F: '/^[a-zA-Z0-9_-]+:/ {print $1}' | sort -ufor comparison. - Validation must include verifying that previously used critical targets still work (or their aliases do).
Workflow
-
Select mode (
CreateorRefactor) and record rationale. -
Inspect project structure:
- discover
cmd/**/main.goentrypoints by running this skill's discovery script against the target repo:bash <skill-dir>/scripts/discover_go_entrypoints.sh <project-root>(the script lives in the skill directory, not in the target repo — pass the repo root as its argument) - if the script cannot run, fall back to
find cmd -name main.go -type f(orrg --files cmd | grep '/main\.go$'when rg is available) - detect quality tools and conventions (
go test,golangci-lint,swag) - detect code generation usage (
go generate, protobuf, wire, mockgen, etc.) - detect containerization (
Dockerfile,docker-compose.yml) - read
go.modfor Go version (godirective) and module path - inspect existing
Makefileif present (Refactor mode) - detect workspace / multi-module layout via the toolchain first:
go env GOWORK(a non-empty path means ago.workworkspace → its modules arego list -m). Only when there is nogo.workfall back to a scopedgo.modsearch (bash <skill-dir>/scripts/discover_go_entrypoints.sh --modules <project-root>, which excludesvendor/,testdata/,examples/). See §Monorepo Support.
- discover
-
Plan target set:
- core targets:
help,fmt,tidy,test,cover,lint,clean - version targets:
version(print embedded version info) - CI target:
ci(fmt-check + lint + test + cover-check in one pass) - optional targets:
swagger,generate,install-tools,test-integration,bench - build targets:
build-allplus per-binary targets (with-ldflagsversion injection) - run targets: per-binary
run-*targets - container targets (when Dockerfile present):
docker-build,docker-push - cross-compile targets (when needed):
build-linux,build-all-platforms - Go version-aware decisions (see Go Version Awareness)
- core targets:
-
Compose and write root Makefile:
- keep targets explicit and predictable
- use variables (
GO,BIN_DIR,VERSION,COMMIT,BUILD_TIME) for repeated paths and build metadata - inject version info via
-ldflagsin all build targets - include
.PHONY - fail early with clear tool checks for optional dependencies
- use target templates from makefile-quality-guide.md
- Refactor mode: apply minimal-diff strategy and backward-compatibility rules from the mode definition above
-
Validate:
- run
make help - run
make test - run one representative
build-*target - build, then run the binary's
--versionto verify injection reached the artifact (make versiononly prints the Make variables, not what the binary embeds) - if possible, run one representative
run-*target in a safe environment - Refactor mode: verify previously used critical targets still work (or provide aliases); compare target list before vs after
- run
Rules
Target Design
- Prefer explicit targets over complex metaprogramming unless the user asks for DRY-heavy style.
- Keep artifact outputs deterministic (under
bin/). - Keep
helpoutput self-documenting via##comments with.DEFAULT_GOAL := help. - Map target names to
cmd/path semantics:cmd/<name>→build-<name>,cmd/<kind>/<name>→build-<kind>-<name>. - Declare all non-file targets in
.PHONY. - Output executable bare
Makefileby default (tabs for recipes, not spaces).
Build Quality
- Inject version metadata via
-ldflagsin build targets:LDFLAGS := -s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.buildTime=$(BUILD_TIME)-Xonly sets an existing package-level string var —-X main.versionassumesvar version stringin packagemain; discover the real package/name first and use its import path if it lives elsewhere (a wrong path silently no-ops).-s -wstrips the symbol table and DWARF (release builds only; keep a debug build without it). - Default the
testtarget to-race— it catches real data races. But-racerequiresCGO_ENABLED=1, a supported OS/arch, and adds ~5–10× memory / 2–20× time. Offer a genuine race-free equivalent,test-norace(go test ./...— the full suite, no race), for cgo-disabled builds and platforms without race support. Do not conflate this withtest-short(go test -short ./...):-shortskipstesting.Short()-gated cases, so it runs a smaller set — it turns off race only as a side effect and is not a substitute for the full suite. CGO_ENABLED=0is the default for pure-Go static builds and containers. For cgo projects (import "C",mattn/go-sqlite3, …) keepCGO_ENABLED=1— and note the two collide: a-racetest target cannot run underCGO_ENABLED=0.- For reproducible release builds add
-trimpath(strips local paths so the binary is checkout-location-independent) and drivebuildTimefromSOURCE_DATE_EPOCH. This raises reproducibility but is not absolute:git describe --dirtymakesVERSIONdepend on tree state, so only a clean checkout with a fixed toolchain is bit-for-bit reproducible. - Pin tool versions in
install-toolsfor CI reproducibility.
Safety
- Fail early with clear tool-presence checks (
command -v <tool>) for optional dependencies. citarget must mirror actual CI pipeline — developers should catch issues before push.- Check for code generation staleness (
generate-check) whengo generateis used.
Go Version Awareness
Read go.mod for the go directive before composing the Makefile. Record as Go version: X.Y in the output report.
| Go Version | Makefile Impact |
|---|---|
| < 1.16 | go install does not support pkg@version; use go get for tool installation |
| ≥ 1.18 | Go workspaces (go.work) and fuzzing (go test -fuzz) available |
| ≥ 1.20 | go build -cover + GOCOVERDIR enable whole-program / integration coverage; consider a cover-integration target |
| ≥ 1.21 | go.mod toolchain directive (automatic toolchain selection); built-in min/max/clear |
| ≥ 1.22 | Per-iteration loop variable semantics; no Makefile impact but note in output |
If go.mod is not found or not readable, record Go version: unknown and use conservative defaults (no version-specific features).
Monorepo Support
When the repo is a Go workspace or multi-module layout (step 1 Inspect), adapt for monorepo:
- Detect via the toolchain, not a bare file search: prefer
go.work(go env GOWORK); when it exists, the modules are itsusedirectives (go list -mrun inside the workspace). Only fall back to searching forgo.modfiles when there is nogo.work, and then excludevendor/,testdata/,examples/, and tool-only modules. - Per-module targets: generate
test-<module>,lint-<module>,build-<module>for each module that has entrypoints - Aggregate targets:
test-all,lint-all,build-allthat iterate over the workspace modules - Per-module
go mod tidy:tidyoperates on a single main module — run it inside each module (for m in $(MODULES); do (cd $$m && go mod tidy); done), never once at the workspace root - Root Makefile pattern:
# Workspace-aware: use go.work's module list when present, else a SCOPED go.mod
# search (a bare `rg go.mod` sweeps in vendor/testdata/examples).
GOWORK := $(shell go env GOWORK 2>/dev/null)
ifeq ($(GOWORK),)
MODULES := $(shell rg --files -g 'go.mod' 2>/dev/null | xargs -I{} dirname {} | grep -Ev '(^|/)(vendor|testdata|examples?)(/|$$)' | sort)
else
MODULES := $(shell go list -m -f '{{.Dir}}' 2>/dev/null)
endif
test-all: ## Run tests for all modules
@for mod in $(MODULES); do \
echo "=== testing $$mod ==="; \
(cd $$mod && go test -race ./...) || exit 1; \
done
lint-all: ## Lint all modules
@for mod in $(MODULES); do \
echo "=== linting $$mod ==="; \
(cd $$mod && golangci-lint run) || exit 1; \
done
- When the project is a single-module repo, this section does not apply — use the standard single-module workflow.
- Record
Layout: monorepo (N modules)orLayout: single-modulein the output report.
Anti-Patterns (DO NOT generate these)
Before writing or reviewing a Makefile, check against these common mistakes. If your output matches any of these patterns, fix it before delivering.
Missing fundamentals:
- No
helptarget or missing##self-documenting comments - No
.PHONYdeclaration for non-file targets - No race testing at all — the default
testshould use-race; providetest-norace(full suite, no race) as the cgo-off / unsupported-platform equivalent.test-shortruns a smaller quick set and is not a substitute. - No
-ldflagsversion injection inbuild-*targets
Naming and layout:
- Target names not matching
cmd/path semantics (e.g.,cmd/consumer/syncbut target isbuild-syncinstead ofbuild-consumer-sync) run-*targets leaving ad-hoc binaries in source directories instead ofbin/
Reproducibility:
install-toolsusing@latestfor all tools in CI (pin specific versions for reproducibility;@latestis acceptable only for local dev convenience)- Hardcoding a tool version without discovering the repo's existing pin — check CI workflows,
.golangci.version/.tool-versions(asdf/mise), and any existinginstall-toolsfirst; use a current compatible version (golangci-lint is now v2, module path.../v2/cmd/golangci-lint) and prefer the tool's official installer where it documents one (go installfrom source is explicitly not guaranteed for golangci-lint) citarget that diverges from the actual CI pipeline —make cishould mirror CI exactly- Hidden assumptions about local paths or OS-specific tools (e.g.,
sed -iwithout considering macOS vs GNU differences)
Cross-compilation:
- Cross-compiling a pure-Go binary without
CGO_ENABLED=0— produces dynamically linked binaries that fail on target machines (cgo projects instead needCGO_ENABLED=1and a cross C toolchain) - Hardcoded
GOOS/GOARCHwithout variable override
Code generation:
- Generated code not checked for staleness before build (missing
generate-checktarget)
Over-engineering:
- Overly dynamic Make metaprogramming (eval/call/define) that reduces readability when explicit targets would be clearer
- Tab-vs-space issues in Makefile recipes (recipes MUST use tabs, not spaces)
Quality Improvements to Offer
- Add
.DEFAULT_GOAL := help. - Add
cover-checktarget with a configurable threshold. - Add
tidytarget forgo mod tidy+go mod verify. - Keep
run-*from polluting source directories; prefergo run ./cmd/...or run frombin/. - Pin tool versions in
install-toolsfor CI reproducibility (see quality-guide §11).
Load References Selectively
When starting any Makefile creation or refactor task:
→ Run this skill's discovery script against the target repo first — bash <skill-dir>/scripts/discover_go_entrypoints.sh <project-root> — to discover cmd/**/main.go binary locations and infer project shape (single-binary vs multi-binary). Add --modules to list workspace/multi-module directories.
When writing or reviewing specific targets (build, test, lint, run, install-tools), or checking quality rules:
→ Load references/makefile-quality-guide.md for canonical target templates, variable conventions, .PHONY rules, self-documenting help output, and the 15-item review checklist.
When reviewing a PR that touches a Makefile:
→ Load references/pr-checklist.md for the fast Makefile-specific PR review checklist (target naming, portability, idempotency, CI compatibility).
When you need a complete working Makefile as a starting point or reference:
→ Load references/golden/simple-project.mk for a single-binary project with minimal tooling.
→ Load references/golden/complex-project.mk for a multi-binary project with Docker, code generation, and cross-compilation targets.
Output Contract
When generating or refactoring a Makefile, always return:
- Mode:
CreateorRefactorwith rationale - Project info: Go version (from
go.mod), layout (single-moduleormonorepo (N modules)), entrypoints discovered - Changed files
- New/updated targets
- Deprecated/aliased targets (Refactor mode — list old name → new name mappings)
- Assumptions or missing tools
- Validation commands executed with pass/fail status
Example Output (Create mode, single-binary)
### Mode
Create — no existing Makefile found
### Project info
- Go version: 1.23 (from go.mod)
- Layout: single-module
- Entrypoints: cmd/api
### Changed files
- `Makefile` (created)
### New targets
help, build-api, build-all, run-api, fmt, fmt-check, tidy,
test, cover, cover-check, lint, ci, version, install-tools,
check-tools, clean
### Deprecated/aliased targets
(none — new Makefile)
### Assumptions
- golangci-lint will be installed via `make install-tools`
- Version info injected into `main.version`, `main.commit`, `main.buildTime`
### Validation
✓ make help — 16 targets listed
✓ make test — all tests pass with -race
✓ make build-api — binary at bin/api
✓ ./bin/api --version — version=v0.1.0-dirty commit=abc1234 buildTime=… (injection reached the artifact)
Self-Validation
Run scripts/run_regression.sh to verify skill integrity:
- Contract tests: structure of SKILL.md, quality guide, golden examples, discovery script
- Golden review tests: all defect/FP fixtures' rules covered in docs
- Coverage matrix: see
scripts/tests/COVERAGE.md
Frequently asked questions
What to verify before installation and use
What does the go-makefile-writer source document cover?
Design a practical root Makefile that is readable, reproducible, and aligned with repository layout.
How do I install go-makefile-writer?
The source record exposes this install command: npx skills add https://github.com/johnqtcg/awesome-skills --skill "skills/go-makefile-writer". Inspect the command and pinned source before running it.
Which permission-related actions were detected?
Static rules flagged exec-script in the source; the page lists the matching lines and excerpts.
Alternatives
Compare before choosing
vasilyu1983/AI-Agents-public
qa-testing-ios
Guides iOS testing with XCTest, XCUITest, Swift Testing, simctl, and xcresult. Use when choosing destinations, controlling flakes, or parsing test artifacts for native apps.
yonatangross/orchestkit
verify
Grade work that already exists and decide whether it can merge. Runs the project's current unit, integration, and E2E suites plus security scanning and type checking, scores every dimension 0-10, and returns a merge verdict with a VERIFIED-vs-CLAIMED evidence manifest. Writes no test files and edits no source. Use when verifying changes are ready to merge. Use /ork:cover instead when the tests still have to be written.
microsoft/Sico
android-tester
Execute Android UI workflows on a sandbox device, review results, and produce a structured execution report.
AI-Unified-Process/marketplace
browserless-test
Creates Vaadin Browserless server-side unit tests for Vaadin views covering navigation, component interactions, form validation, grid operations, and notifications. Use when the user asks to "write Browserless tests", "write Vaadin UI unit tests", "unit test a Vaadin view without a browser", "create view tests with the official Vaadin testing framework", or mentions Browserless testing, SpringBrowserlessTest, browserless-test-junit6, UI Unit Testing, or server-side Vaadin testing.