makectl
Generate and manage targets in your Makefiles.
makectl is a command-line tool that helps you create, lint, format, and manage Makefiles with reusable templates for multiple languages and frameworks.
Features
- Template library - Built-in templates for Python, Rust, Go, Node.js, Docker, and more
- Makefile linting - Detect common issues like missing
.PHONY, spaces instead of tabs, duplicate targets - Makefile formatting - Auto-format for consistent style
- Syntax validation - Check for errors before running make
- Managed blocks - Add and remove targets without breaking custom rules
- Self-documenting help - Every generated Makefile includes a
make helptarget - Shell completions - Tab completion for bash, zsh, fish, and PowerShell
Installation
Or build from source:
Quick Start
# Create a new Makefile for a Python project
# See what targets were added
# Add more templates
# Lint your Makefile
# Format it
Commands
makectl init
Create a new Makefile from scratch. Optionally include all templates for a specific language.
makectl add
Add template targets to an existing Makefile. Targets are wrapped in managed block markers so they can be tracked and removed later.
Adding the same template twice is a no-op (deduplication).
makectl remove
Remove managed targets from a Makefile. Only targets added by makectl (inside managed blocks) can be removed.
makectl list
List available templates or inspect targets in an existing Makefile.
makectl lint
Check a Makefile for common issues and best practices. Exits with code 1 if errors are found (useful in CI).
Lint rules:
- missing-phony - Targets like
test,clean,buildshould be.PHONY - spaces-instead-of-tabs - Recipe lines must use tabs, not spaces
- duplicate-targets - Same target defined more than once
- missing-help-target - No self-documenting
helptarget - empty-recipes - Target with no recipe and no prerequisites
- hardcoded-paths - Absolute paths that should be variables
makectl validate
Validate Makefile syntax (strict subset of lint - only errors, no suggestions).
makectl fmt
Format a Makefile for consistent style. Removes trailing whitespace, collapses blank lines, ensures the file ends with a newline.
makectl tips
Display Makefile best practices and tips.
makectl completions
Generate shell completion scripts.
Available Templates
| Category | Templates |
|---|---|
| generic | help, clean, docker, docker-compose, git-hooks |
| python | venv, test, lint, format, clean, publish |
| rust | build, test, fmt, clippy, release, doc |
| go | build, test, fmt, vet, lint, clean |
| node | install, build, test, lint, format, dev, clean |
Use makectl list for full descriptions.
Interactive Mode
Add -i (or --interactive) to get prompted with menus instead of passing arguments:
Global Options
-f, --file <FILE> Path to Makefile (default: ./Makefile)
-i, --interactive Interactive mode (prompts for selections)
-h, --help Show help
-V, --version Show version
How Managed Blocks Work
When makectl adds a target, it wraps it in markers:
# MAKECTL MANAGED START test python/test
: : ## Run tests# MAKECTL MANAGED END test
This allows makectl to:
- Track which targets it manages
- Remove targets cleanly with
makectl remove - Prevent duplicate additions
- Never touch your custom targets
License
MIT