makefile

Guidelines when dealing with Makefiles

⭐5stars🔀1forks📁View on GitHub🕐Updated Jan 11, 2026

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.
namemakefile
descriptionGuidelines when dealing with Makefiles

Makefile Formatting

Instructions

When writing or modifying Makefiles, follow these formatting guidelines:

  1. Each target should have a .PHONY declaration
  2. Format should follow this pattern:
    • .PHONY: target-name on its own line
    • target-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