brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
makeImplements systematic build orchestration (Makefile, Nix, Bazel, Just) with dependency tracking, incremental compilation, phony targets, and cross-platform portability for reproducible software construction.
Independent GitHub snapshot · Automated classification · Original documentation governs
name: make description: Implements systematic build orchestration (Makefile, Nix, Bazel, Just) with dependency tracking, incremental compilation, phony targets, and cross-platform portability for reproducible software construction. license: MIT compatibility: opencode metadata: version: "1.0.0" domain: coding triggers: make, build system, makefile, compilation, incremental build, build automation, justfile, phony targets archetypes:
Implements systematic build orchestration to transform source artifacts into reliable, reproducible outputs. A well-designed build system is not just a collection of commands — it is the contract between developers and the compilation pipeline, enforcing correctness through dependency tracking, incremental execution, and explicit phony target separation. Follow the Unix philosophy (KISS) by keeping recipes focused, transparent, and composable.
.PHONY explicitly$@, lt;, $^) to avoid hardcoding file pathsUse this skill when:
Makefile or similar build script for a new projectmake test, make lint, make deploy)Avoid this skill for:
npm run build, cargo build) unless you need orchestration across multiple toolsMap Dependencies — List every input file and required external tool for each output artifact. Checkpoint: Every target must list its exact prerequisites; missing dependencies cause silent build failures.
Define Phony Targets — Mark all non-file targets (like clean, test, install) as .PHONY immediately.
Checkpoint: If a file named clean or test exists, Make will skip the target without .PHONY.
Write Pattern Rules — Use % pattern rules and automatic variables to handle multiple similar targets without repetition.
Checkpoint: Verify $@, lt;, and $^ resolve correctly before adding more source files.
Test Incremental Builds — Touch a single source file and verify only dependent targets rebuild.
Checkpoint: No stale artifacts should remain; make clean must fully reset state.
Enforce Exit Codes — Every recipe step must propagate failures (set -e in shell recipes, explicit checks).
Checkpoint: A failed linting or test step must abort the build immediately, not continue to packaging.
Document & Standardize — Add a help target showing available commands and required environment variables.
Checkpoint: New developers should run make help and understand how to build, test, and clean without reading docs.
A production-ready Makefile separates concerns into logical targets, uses automatic variables, and enforces strict error handling.
# Build configuration
CC ?= gcc
CFLAGS := -Wall -Wextra -O2 $(EXTRA_CFLAGS)
BUILDDIR := build
SRCDIR := src
TARGET := myapp
.PHONY: all clean test install help
all: $(BUILDDIR)/$(TARGET)
$(BUILDDIR)/$(TARGET): $(wildcard $(SRCDIR)/*.c)
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $^ -o $@
clean:
rm -rf $(BUILDDIR)
test: $(BUILDDIR)/$(TARGET)
./run_tests.sh --target=$(BUILDDIR)/$(TARGET)
help:
@echo "Available targets:"
@echo " all - Build the application (default)"
@echo " clean - Remove build artifacts"
@echo " test - Run integration tests"
@echo " install - Copy binary to /usr/local/bin"
# ❌ BAD — hardcodes paths, ignores incremental builds, rebuilds everything every time
build-app:
gcc -o myapp src/main.c src/utils.c
echo "Build complete"
clean:
rm myapp
# ✅ GOOD — pattern rules with automatic variables, incremental dependency tracking
BUILDDIR := build
SRCS := $(wildcard src/*.c)
OBJS := $(patsubst src/%.c,$(BUILDDIR)/%.o,$(SRCS))
TARGET := $(BUILDDIR)/myapp
$(TARGET): $(OBJS)
@mkdir -p $(dir $@)
$(CC) $^ -o $@
$(BUILDDIR)/%.o: src/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c lt; -o $@
clean:
rm -rf $(BUILDDIR)
.PHONY: all clean test
all: $(TARGET)
Makefiles should gracefully detect available tools rather than assuming a specific environment.
# Detect Python version (Unix vs. macOS vs. Windows)
PYTHON := python3
ifeq ($(OS),Windows_NT)
PYTHON := python
endif
# Use `rm` with platform-safe flags
ifdef MSYSTEM
RM_CMD := rm -rf
else
RM_CMD := rm -rf
endif
clean:
$(RM_CMD) build/ dist/ *.egg-info
.PHONY to prevent filename collisions$@, lt;, $^) instead of hardcoding file paths in recipesset -e or explicit exit checks in shell recipeshelp target documenting available commands for new contributors?= for user-overridable variables, := for computed values.PHONY declarations after the targets they reference (Make processes them top-down)system() or shell built-ins that behave differently across platforms without detectionmake calls unnecessarily (make -C subdir) unless building a true multi-component projectWhen implementing or reviewing a build system, produce:
.PHONY declarations| Skill | Purpose |
|---|---|
testing | Define test targets and integrate into build flow |
refactoring | Restructure legacy build scripts into modular patterns |
ci-cd-pipelines | Connect Make outputs to continuous deployment workflows |
Authoritative documentation links for this domain. The model follows markdown links at load time to resolve external references and inline content.