This skill should be used when the user asks about splitting a Makefile into multiple files, using the include or -include directive, organizing a large Makefile into modules, creating environment-specific configurations (dev/prod/staging), sharing Makefile configuration across projects, or when a Makefile exceeds 150 lines. Also applies when the user mentions config.mk, rules.mk, modular Makefile structure, or asks how to reduce Makefile size and improve maintainability.
From gnu-makenpx claudepluginhub therealbill/mynet --plugin gnu-makeThis skill uses the workspace's default tool permissions.
references/module-patterns.mdreferences/shared-configuration.mdGuides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Analyzes BMad project state from catalog CSV, configs, artifacts, and query to recommend next skills or answer questions. Useful for help requests, 'what next', or starting BMad.
Suggest modular structure for large projects (>150 lines). Use include directive to split concerns into focused files, not maintain everything in one monolithic Makefile. Even if user prefers "one file", explain trade-offs and show modular alternative.
# DON'T DO THIS - 500+ line single file
# Lines 1-100: Variables and configuration
VERSION = 1.0.0
CC = gcc
CFLAGS = -Wall -Wextra
PREFIX = /usr/local
... (80 more variable definitions)
# Lines 101-250: Core library rules
lib_sources = $(wildcard src/core/*.c)
lib_objects = $(lib_sources:.c=.o)
... (140 more lines of lib rules)
# Lines 251-400: API server rules
api_sources = $(wildcard src/api/*.c)
... (140 more lines of API rules)
# Lines 401-500: CLI tool rules, install, clean, etc.
... (100 more lines)
Problems:
When user shows this pattern: Don't accept it. Suggest modular structure even if they prefer "one file for simplicity".
# Makefile (main orchestrator - 50 lines)
include config.mk
include rules.mk
include targets.mk
.PHONY: all clean install
all: $(TARGETS)
clean:
$(RM) $(OBJECTS) $(TARGETS)
# config.mk (100 lines) - All configuration
VERSION := 1.0.0
CC := gcc
CFLAGS := -Wall -Wextra -std=c11
PREFIX := /usr/local
# Component-specific configs
CORE_CFLAGS := $(CFLAGS) -fPIC
API_CFLAGS := $(CFLAGS) -pthread
# rules.mk (150 lines) - Pattern rules
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
$(LIBDIR)/%.a: $(OBJECTS)
$(AR) rcs $@ $^
# targets.mk (200 lines) - Specific targets
TARGETS := libcore.a api-server cli-tool
libcore.a: $(CORE_OBJECTS)
api-server: $(API_OBJECTS) libcore.a
cli-tool: $(CLI_OBJECTS) libcore.a
Benefits:
include config.mk in other projectsinclude Directiveinclude filename
include file1.mk file2.mk file3.mk
include *.mk
include $(CONFIG_FILE)
Behavior:
-include for Optional Files# Include if exists, silent if not
-include local-config.mk
-include dev.mk
-include $(wildcard *.d) # Auto-dependencies
Use when: File might not exist (local overrides, auto-generated deps).
| Lines | Recommendation |
|---|---|
| < 50 | Monolithic okay |
| 50-150 | Consider modules if multiple concerns |
| 150-300 | Suggest modules |
| 300+ | Strongly recommend modules |
Even if < 150 lines, suggest modules when project has:
If 2+ checkboxes: Suggest modular structure.
# Project metadata
PROJECT := myapp
VERSION := 1.0.0
# Tools
CC := gcc
AR := ar
INSTALL := install
# Flags
CFLAGS := -Wall -Wextra -std=c11
LDFLAGS := -lpthread
PREFIX := /usr/local
# Paths
SRCDIR := src
BUILDDIR := build
BINDIR := $(PREFIX)/bin
Contains: Variables only, no rules or targets.
# Compilation rules
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
# Library creation
%.a: $(OBJECTS)
$(AR) rcs $@ $^
# Linking
%: %.o
$(CC) -o $@ $^ $(LDFLAGS)
Contains: Pattern rules only, generic transformations.
# Concrete targets
TARGETS := libcore.a api-server cli-tool
libcore.a: $(CORE_OBJECTS)
api-server: $(API_OBJECTS) libcore.a
$(CC) -o $@ $^ $(LDFLAGS)
cli-tool: $(CLI_OBJECTS) libcore.a
$(CC) -o $@ $^ $(LDFLAGS)
Contains: Specific targets and their dependencies.
.PHONY: install uninstall
install: all
$(INSTALL) -d $(BINDIR)
$(INSTALL) -m 755 $(TARGETS) $(BINDIR)
uninstall:
$(RM) $(addprefix $(BINDIR)/,$(TARGETS))
Contains: Installation, uninstallation, distribution.
# Makefile - select configuration
ENV ?= dev
include config/$(ENV).mk
include rules.mk
all: $(TARGET)
# config/dev.mk
CFLAGS := -g -O0 -DDEBUG
TARGET := myapp-dev
# config/prod.mk
CFLAGS := -O3 -DNDEBUG
LDFLAGS := -s
TARGET := myapp
Usage:
make # Uses dev (default)
make ENV=prod # Uses production config
make ENV=staging # Uses staging config
Benefits:
-include# Makefile - defaults
CFLAGS := -Wall -Wextra
# Override with environment-specific
-include dev.mk
-include prod.mk
all: $(TARGET)
# Build with specific config
make -f dev.mk # or
touch dev.mk && make # if dev.mk exists, it's included
For patterns on sharing configuration across multiple projects using include ../common/common.mk, see references/shared-configuration.md.
When the user prefers a single file, acknowledge the convenience for small projects, then explain the trade-offs at scale: navigating 500 lines vs opening the right focused file, merge conflicts when multiple people edit one file, and inability to share configuration across projects. Create both versions with the modular structure as the default, and let the user compare.
If project description suggests >150 lines:
If project is clearly simple (< 50 lines):
If file is >150 lines:
If file is 50-150 lines but has multiple concerns:
Four patterns (Three-File Foundation, Component-Based, Environment + Component, Shared Common) are documented in references/module-patterns.md. Choose based on project complexity.
When reviewing any Makefile:
If 2+ red flags present: Strongly suggest modular structure.
✅ Simple, everything visible ✅ No include overhead ✅ Good for small, focused projects
✅ Easier navigation (focused files) ✅ Better for teams (less conflicts) ✅ Reusable across projects ✅ Clearer organization ✅ Easier to maintain ✅ Simpler to understand (smaller chunks)
includeUse for:
Don't need for:
config.mk # Variables, configuration
rules.mk # Pattern rules
targets.mk # Specific targets
install.mk # Installation rules
test.mk # Testing targets
dev.mk # Development config
prod.mk # Production config
common.mk # Shared across projects
If a module exceeds 300 lines: Consider splitting further.
Monolithic Makefiles don't scale. A 50-line file is fine. A 500-line file is unmaintainable.
Don't accept "one file is simpler" for large projects. Modular structure:
Suggest modular structure proactively at 150+ lines. Show concrete comparison. Explain trade-offs even if user has preference.
"One file" feels simpler until you're searching through 500 lines. Then modular becomes obviously better.