/devops-skills:makefile-validatorfrom devops-skills
Validates, lints, and optimizes Makefiles for syntax errors, best practices, security vulnerabilities, and formatting consistency using mbake and custom checks.
Ships in devops-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This skill provides comprehensive validation for Makefiles, checking for syntax errors, formatting consistency, best practices, security vulnerabilities, and optimization opportunities. It uses the mbake tool (Makefile formatter and linter) along with custom validation checks to ensure high-quality build configurations.
Use this skill when:
make -n --dry-runmake is used directly instead of $(MAKE) for recursive calls# Validate a Makefile
bash scripts/validate_makefile.sh Makefile
# The validator will:
# 1. Check dependencies (python3, pip3, make)
# 2. Create isolated venv and install mbake
# 3. Run syntax validation with GNU make
# 4. Run mbake validation
# 5. Check formatting consistency
# 6. Perform custom security/best practice checks
# 7. Auto-cleanup venv on exit
# 8. Generate detailed report
========================================
MAKEFILE VALIDATOR
========================================
File: Makefile
[ENVIRONMENT SETUP]
Creating temporary venv at: /tmp/makefile-validator-venv-12345
Installing mbake...
✓ Environment ready
[SYNTAX CHECK (GNU make)]
✓ No syntax errors found
[MBAKE VALIDATION]
Running mbake validate...
✓ mbake validation passed
[MBAKE FORMAT CHECK]
Checking formatting consistency...
⚠ Formatting issues found
Run 'mbake format Makefile' to fix formatting issues
Or run 'mbake format --diff Makefile' to preview changes
[CUSTOM CHECKS]
⚠ No .PHONY declarations found
Consider adding .PHONY for targets that don't create files
Example: .PHONY: clean test install
✗ Potential spaces instead of tabs in recipes detected
Makefiles require TAB characters for recipe indentation
ℹ No VPATH/vpath declarations found
Consider using VPATH for better source file organization
[CLEANUP]
Removing temporary venv...
========================================
VALIDATION SUMMARY
========================================
File: Makefile
Errors: 1
Warnings: 2
Info: 1
⚠ Validation PASSED with warnings
When validating Makefiles, Claude will automatically:
User: "Check this Makefile for issues"
Claude:
1. Runs validate_makefile.sh on the Makefile
2. Identifies issues (e.g., missing .PHONY, spaces instead of tabs)
3. References best-practices.md for standards
4. Suggests specific fixes with corrected code
5. Explains why each fix improves the build
6. Recommends mbake format for automatic fixes
The validator creates an isolated Python virtual environment:
Robust cleanup mechanism:
trap cleanup EXIT INT TERM ensures cleanup always runs# macOS
brew install make
# Ubuntu/Debian
apt-get install make
# Fedora
dnf install make
checkmake: For additional linting coverage
# With Go (1.16+)
go install github.com/checkmake/checkmake/cmd/checkmake@latest
checkmake rules include:
minphony: Checks for minimum required phony targets (all, test, clean)phonydeclared: Ensures targets are properly declared as .PHONYcheckmake.iniunmake: For POSIX portability checks
# See: https://github.com/mcandre/unmake
unmake features:
# Validate Makefile before committing
bash .claude/skills/makefile-validator/scripts/validate_makefile.sh Makefile
# Fix any errors found
# Re-validate until clean
# Check formatting
mbake format --check Makefile
# Preview formatting changes
mbake format --diff Makefile
# Apply formatting
mbake format Makefile
# Re-validate
bash .claude/skills/makefile-validator/scripts/validate_makefile.sh Makefile
The validator automatically checks for:
Reference common-mistakes.md for detailed explanations.
Identifies:
Reference best-practices.md for optimization techniques.
# 1. Validate current Makefile
bash scripts/validate_makefile.sh legacy.mk
# 2. Fix critical errors (tabs, syntax)
# 3. Apply mbake formatting
mbake format legacy.mk
# 4. Add .PHONY declarations
mbake format --auto-insert-phony-declarations legacy.mk
# 5. Re-validate
bash scripts/validate_makefile.sh legacy.mk
# 6. Reference best-practices.md for modernization
#!/bin/bash
# .git/hooks/pre-commit
for file in $(git diff --cached --name-only --diff-filter=ACM | grep -E '(Makefile|makefile|.*\.mk)$'); do
if ! bash .claude/skills/makefile-validator/scripts/validate_makefile.sh "$file"; then
echo "Validation failed for $file"
exit 1
fi
done
# GitHub Actions example
name: Validate Makefiles
on: [push, pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Validate Makefiles
run: |
find . -type f \( -name "Makefile" -o -name "makefile" -o -name "*.mk" \) \
-exec bash .claude/skills/makefile-validator/scripts/validate_makefile.sh {} \;
.PHONY: validate-makefile
validate-makefile:
@bash .claude/skills/makefile-validator/scripts/validate_makefile.sh $(MAKEFILE_LIST)
.PHONY: format-makefile
format-makefile:
@mbake format --diff $(MAKEFILE_LIST)
@read -p "Apply formatting? [y/N] " -n 1 -r; \
echo; \
if [[ $$REPLY =~ ^[Yy]$$ ]]; then \
mbake format $(MAKEFILE_LIST); \
fi
Use the included documentation to:
best-practices.mdcommon-mistakes.mdbake-tool.mdmakefile-validator/
├── skill.md # This file
├── scripts/
│ └── validate_makefile.sh # Main validation script
├── docs/
│ ├── best-practices.md # Makefile best practices
│ ├── common-mistakes.md # Common Makefile mistakes
│ └── bake-tool.md # mbake tool reference
└── examples/
├── good-makefile.mk # Well-written example
└── bad-makefile.mk # Anti-patterns example
Security Checks:
Best Practice Checks:
Optimization Checks:
Create ~/.bake.toml for project-wide settings:
space_around_assignment = true
space_after_colon = true
normalize_line_continuations = true
remove_trailing_whitespace = true
fix_missing_recipe_tabs = true
auto_insert_phony_declarations = true
group_phony_declarations = true
phony_at_top = false
# bake-format off
legacy-target:
# Preserve legacy formatting
echo "custom spacing"
# bake-format on
modern-target:
@echo "Standard formatting applies"
# Validate specific Makefile
bash scripts/validate_makefile.sh src/Makefile
# Validate all .mk files
find . -name "*.mk" -exec bash scripts/validate_makefile.sh {} \;
# Validate only in specific directories
find src/ -type f -name "Makefile" -exec bash scripts/validate_makefile.sh {} \;
The mbake tool has some known limitations that this validator handles:
Unknown Special Targets: mbake doesn't recognize some valid GNU Make special targets:
.DELETE_ON_ERROR - Reported as unknown but is valid and critical.SUFFIXES - Reported as unknown but is valid.ONESHELL - Reported as unknown but is valid.POSIX - Reported as unknown but is validThe validator filters these false positives and shows them as informational messages instead of errors.
format --check vs format inconsistency: The mbake format --check command may report different issues than what mbake format actually fixes. This is a known upstream issue.
POSIX Make compatibility: mbake is designed for GNU Make and may not work correctly with pure POSIX make syntax.
For additional linting coverage, consider installing checkmake alongside mbake.
All documentation is included in the docs/ directory for offline reference and context loading.
Note: This skill automatically loads relevant documentation based on validation results, providing Claude with the necessary context to explain issues and suggest fixes effectively. The venv isolation and trap-based cleanup ensure clean, safe validation without affecting your system or project dependencies.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
Generated from the plugin's indexed repository (gitjfmd/ansible-skills) — no native marketplace selected
npx claudepluginhub p/gitjfmd-devops-skills-devops-skills-plugin31 skills in this plugin
/ansible-generatorComprehensive toolkit for generating best practice Ansible playbooks, roles, tasks, and inventory files./ansible-validatorComprehensive toolkit for validating, linting, testing, and automating Ansible playbooks, roles, and collections. Use this skill when working with Ansible files (.yml, .yaml playbooks, roles, inventories), validating automation code, debugging playbook execution, performing dry-run testing with check mode, or working with custom modules and collections./azure-pipelines-generatorComprehensive toolkit for generating best practice Azure DevOps Pipelines following current standards and conventions. Use this skill when creating new Azure Pipelines, implementing CI/CD workflows, or building deployment pipelines./azure-pipelines-validatorComprehensive toolkit for validating, linting, and securing Azure DevOps Pipeline configurations./bash-script-generatorComprehensive toolkit for generating best practice bash scripts following current standards and conventions. Use this skill when creating new bash scripts, implementing shell automation, text processing workflows, or building production-ready command-line tools./bash-script-validatorComprehensive toolkit for validating, linting, and optimizing bash and shell scripts. Use this skill when working with shell scripts (.sh, .bash), validating script syntax, checking for best practices, identifying security issues, or debugging shell script problems.