makefile

Generate standard Makefile for Go projects with test, lint, clean, fmt, tidy, ci, and coverage targets following best practices

⭐2stars🔀0forks📁View on GitHub🕐Updated Nov 23, 2025⬇️1downloads

When & Why to Use This Skill

This Claude skill automates the generation of standardized, best-practice Makefiles specifically tailored for Go (Golang) projects. It streamlines the development lifecycle by providing ready-to-use targets for testing, linting, dependency management, and continuous integration, ensuring consistent code quality and efficient workflows across development teams.

Use Cases

  • Project Initialization: Quickly bootstrap a professional build system for new Go repositories with standardized commands for building and testing.
  • CI/CD Pipeline Standardization: Utilize the 'ci' target to unify linting, formatting, and testing steps within automated pipelines like GitHub Actions or GitLab CI.
  • Code Quality Enforcement: Automate 'go fmt', 'golangci-lint', and 'go mod tidy' checks to maintain a clean codebase and prevent unformatted code from being committed.
  • Testing and Coverage Analysis: Generate comprehensive HTML coverage reports to visualize untested code paths and ensure high software reliability.
namemakefile
descriptionGenerate standard Makefile for Go projects with test, lint, clean, fmt, tidy, ci, and coverage targets following best practices

Generate Standard Makefile

Generate a Makefile with standard targets for Go projects.

Required Targets

  1. test: Run go test -v ./... to execute all tests
  2. lint: Run golangci-lint run ./... for linting
  3. clean: Run go clean and remove coverage files (coverage.out, coverage.html)
  4. fmt: Run go fmt ./... and verify no changes with git diff --exit-code
  5. tidy: Run go mod tidy and verify no changes with git diff --exit-code
  6. ci: Run all checks (tidy, fmt, lint, test) and display success message
  7. coverage: Generate coverage report and HTML output

Format Requirements

  • Use .PHONY declaration for all targets
  • Each command should use tab indentation
  • The ci target should display a green success message: "EVERYTHING PASSED!"
  • Coverage target should output the location of the HTML report

Template

.PHONY: test lint clean fmt tidy ci coverage

test:
	go test -v ./...

lint:
	golangci-lint run ./...

clean:
	go clean
	rm -f coverage.out coverage.html

fmt:
	go fmt ./... && git diff --exit-code

tidy:
	go mod tidy && git diff --exit-code

ci: tidy fmt lint test
	@echo
	@echo "\033[32mEVERYTHING PASSED!\033[0m"

coverage:
	go test -coverprofile=coverage.out ./...
	go tool cover -html=coverage.out -o coverage.html
	@echo "Coverage report: coverage.html"

Create this Makefile at the root of the project. If the project needs additional targets (like proto for protocol buffers), ask the user first.