abuxton/awesome-makefiles/makefile-basics
Claude Code and agent skill by abuxton/awesome-makefiles
- community
Checking that the SKILL.md file is still in the repository.
Core GNU Make concepts, syntax, and best practices for writing effective Makefiles
Install
npx vskill@latest install abuxton/awesome-makefiles/makefile-basicsSKILL.md
The same SKILL.md was published earlier as abuxton/awesome-makefiles/makefile-basics.
Makefile Basics
Instructions for writing and reviewing GNU Make Makefiles following best practices.
When to use
Use this skill when:
- Writing a new Makefile from scratch
- Reviewing or refactoring an existing Makefile
- Explaining Makefile syntax and concepts
- Helping users understand how
makeresolves targets
Instructions
Structure
- Always declare phony targets to avoid conflicts with files of the same name:
``makefile .PHONY: build test clean help ``
- Set a sensible default goal (usually
allorhelp):
``makefile .DEFAULT_GOAL := help ``
- Use
SHELL := /bin/bashat the top to ensure consistent shell behaviour.
- Group variables at the top, targets in logical sections below.
Variables
- Use
?=for overridable defaults (caller can override via environment or CLI). - Use
:=for immediate (simple) expansion to avoid repeated evaluation. - Use
=only when deferred (recursive) expansion is intentional. - Prefer uppercase names for variables set at the Makefile level.
Targets
- Every target recipe line must begin with a tab character (not spaces).
- Prefix recipe lines with
@to suppress echoing, or omit@when the command itself is informative. - Use
$(MAKE)(notmake) to invoke sub-makes so flags and variables propagate.
Self-documenting help target
Add ## comment after each target declaration and generate a help screen:
Error handling
- Use
$(error ...)to abort with a message when required variables are missing. - Use
$(warning ...)for non-fatal notices. - Example guard:
``makefile ifndef REQUIRED_VAR $(error REQUIRED_VAR is not set) endif ``
Including other Makefiles
- Use
-include file.mk(with dash) to silently ignore missing includes. - Use
include file.mkwhen the file is mandatory.
Pattern rules
Prefer static pattern rules over implicit rules for clarity:
Automatic variables
| Variable | Meaning | |
|---|---|---|
$@ | Target name | |
$< | First prerequisite | |
$^ | All prerequisites (deduplicated) | |
$* | Stem matched by % in a pattern rule | |
$(@D) | Directory part of $@ |
Portability
- Test with both GNU Make 3.x and 4.x where possible.
- Avoid GNU-specific extensions when targeting BSD/macOS unless
gmakeis guaranteed. - Use
$(shell ...)sparingly; cache the result in a variable.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/makefile-basics/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/abuxton/awesome-makefiles/makefile-basics)