makefile

Guidelines when dealing with Makefiles

⭐2stars🔀0forks📁View on GitHub🕐Updated Jan 1, 2026

When & Why to Use This Skill

This Claude skill provides standardized guidelines for Makefile formatting and best practices. It ensures build scripts are clean, maintainable, and error-free by enforcing mandatory .PHONY declarations, consistent tab-based indentation, and clear target separation, which are essential for robust build automation and developer productivity.

Use Cases

  • Standardizing Build Scripts: Automatically apply consistent formatting and .PHONY declarations when creating new Makefiles to ensure cross-platform compatibility and prevent file name conflicts.
  • Automated Code Review: Use these guidelines to audit existing Makefiles during the PR process, identifying missing phony targets or improper indentation that could lead to build errors.
  • Refactoring Legacy Projects: Streamline and modernize complex, poorly formatted legacy Makefiles to improve readability and make them easier for new team members to understand and modify.
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