makefile
Guidelines when dealing with Makefiles
When & Why to Use This Skill
This Claude skill provides standardized guidelines for Makefile formatting and structure, ensuring build scripts are clean, maintainable, and reliable. It focuses on best practices such as mandatory .PHONY declarations, consistent tab indentation, and clear target separation to optimize development workflows and prevent common build errors.
Use Cases
- Standardizing Build Scripts: Use these guidelines to create new Makefiles that follow industry-standard formatting, making them easier for teams to read and maintain.
- Refactoring Legacy Makefiles: Apply the rules to existing build scripts to ensure all targets are correctly marked as .PHONY, preventing conflicts with local files and improving build reliability.
- Automated Code Review: Integrate these formatting rules into your development process to serve as a quality checklist during code reviews for infrastructure and build automation code.
| name | makefile |
|---|---|
| description | Guidelines when dealing with Makefiles |
Makefile Formatting
Instructions
When writing or modifying Makefiles, follow these formatting guidelines:
- Each target should have a
.PHONYdeclaration - Format should follow this pattern:
.PHONY: target-nameon its own linetarget-name:on the next line- Commands indented with a tab
- Empty line between targets
Example
.PHONY: foo
foo:
@echo 'foo'
.PHONY: bar
bar:
@echo 'bar'
When to Use
Apply these guidelines when:
- Creating new Makefile targets
- Modifying existing Makefiles
- Reviewing Makefile code