Write Makefiles for any project type. Use when setting up build automation, defining multi-target builds, managing dependencies between tasks, creating project task runners, or using Make for non-C projects (Go, Python, Docker, Node.js). Also covers Just and Task as modern alternatives.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install makefile-build或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install makefile-build⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/makefile-build/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: makefile-build description: Write Makefiles for any project type. Use when setting up build automation, defining multi-target builds, managing dependencies between tasks, creating project task runners, or using Make for non-C projects (Go, Python, Docker, Node.js). Also covers Just and Task as modern alternatives. metadata: {"clawdbot":{"emoji":"🔨","requires":{"anyBins":["make","just","task"]},"os":["linux","darwin","win32"]}} ---
Write Makefiles for project automation across any language. Covers targets, dependencies, variables, pattern rules, phony targets, and using Make for Go, Python, Docker, and Node.js projects. Includes Just and Task as modern alternatives.
make build && make test && make deploy workflow# target: prerequisites
# recipe (MUST be indented with TAB, not spaces)
build: src/main.go
go build -o bin/app src/main.go
test: build
go test ./...
clean:
rm -rf bin/
# First target is the default (runs with bare `make`)
# Simple assignment
CC = gcc
CFLAGS = -Wall -O2
# Deferred assignment (expanded when used)
FILES = $(wildcard src/*.go)
# Immediate assignment (expanded when defined)
VERSION := $(shell git describe --tags --always)
# Conditional assignment (only if not already set)
PORT ?= 8080
# Use variables
build:
$(CC) $(CFLAGS) -o app main.c
@echo "Version: $(VERSION)"
# $@ = target name
# $< = first prerequisite
# $^ = all prerequisites
# $* = stem (pattern match)
# $(@D) = directory of target
# $(@F) = filename of target
bin/app: src/main.go src/util.go
go build -o $@ $^
# $@ = bin/app
# $^ = src/main.go src/util.go
# $< = src/main.go
# Pattern rule
%.o: %.c
$(CC) -c -o $@ $<
# For foo.o: $@ = foo.o, $< = foo.c, $* = foo
# Without .PHONY, if a file named "clean" exists, `make clean` does nothing
.PHONY: build test clean lint fmt help
build:
go build -o bin/app ./cmd/app
test:
go test ./...
clean:
rm -rf bin/ dist/
# List all targets
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help
build: ## Build the application
go build -o bin/app ./cmd/app
test: ## Run all tests
go test -v ./...
lint: ## Run linters
golangci-lint run
clean: ## Remove build artifacts
rm -rf bin/ dist/
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
BINARY_NAME := myapp
VERSION := $(shell git describe --tags --always --dirty)
LDFLAGS := -ldflags "-X main.version=$(VERSION)"
GOFILES := $(shell find . -name '*.go' -not -path './vendor/*')
.PHONY: all build test lint clean run
all: lint test build
build: ## Build binary
CGO_ENABLED=0 go build $(LDFLAGS) -o bin/$(BINARY_NAME) ./cmd/$(BINARY_NAME)
test: ## Run tests
go test -race -coverprofile=coverage.out ./...
test-coverage: test ## Show coverage report
go tool cover -html=coverage.out
lint: ## Run linters
golangci-lint run ./...
fmt: ## Format code
gofmt -w $(GOFILES)
run: build ## Build and run
./bin/$(BINARY_NAME)
clean: ## Clean build artifacts
rm -rf bin/ coverage.out
# Cross-compilation
build-linux: ## Build for Linux
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-linux-amd64 ./cmd/$(BINARY_NAME)
build-all: ## Build for all platforms
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-linux-amd64 ./cmd/$(BINARY_NAME)
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-darwin-arm64 ./cmd/$(BINARY_NAME)
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-windows-amd64.exe ./cmd/$(BINARY_NAME)
PYTHON := python3
VENV := .venv
BIN := $(VENV)/bin
.PHONY: all install test lint fmt clean run
all: install lint test
$(VENV)/bin/activate:
$(PYTHON) -m venv $(VENV)
$(BIN)/pip install --upgrade pip
install: $(VENV)/bin/activate ## Install dependencies
$(BIN)/pip install -r requirements.txt
$(BIN)/pip install -r requirements-dev.txt
test: ## Run tests
$(BIN)/pytest -v --cov=src --cov-report=term-missing
lint: ## Run linters
$(BIN)/ruff check src/ tests/
$(BIN)/mypy src/
fmt: ## Format code
$(BIN)/ruff format src/ tests/
run: ## Run application
$(BIN)/python -m src.main
clean: ## Remove venv and caches
rm -rf $(VENV) __pycache__ .pytest_cache .mypy_cache .ruff_cache
find . -type d -name '__pycache__' -exec rm -rf {} + 2>/dev/null || true
.PHONY: all install build test lint clean dev
all: install lint test build
node_modules: package.json
npm install
@touch node_modules
install: node_modules ## Install dependencies
build: node_modules ## Build TypeScript
npx tsc
test: node_modules ## Run tests
npx vitest run
test-watch: node_modules ## Run tests in watch mode
npx vitest
lint: node_modules ## Lint code
npx eslint src/ --ext .ts,.tsx
npx tsc --noEmit
fmt: node_modules ## Format code
npx prettier --write 'src/**/*.{ts,tsx}'
dev: node_modules ## Run in development mode
npx tsx watch src/index.ts
clean: ## Clean build artifacts
rm -rf dist/ node_modules/.cache
IMAGE_NAME := myapp
VERSION := $(shell git describe --tags --always)
REGISTRY := ghcr.io/myorg
.PHONY: build push run stop clean
build: ## Build Docker image
docker build -t $(IMAGE_NAME):$(VERSION) -t $(IMAGE_NAME):latest .
push: build ## Push to registry
docker tag $(IMAGE_NAME):$(VERSION) $(REGISTRY)/$(IMAGE_NAME):$(VERSION)
docker tag $(IMAGE_NAME):latest $(REGISTRY)/$(IMAGE_NAME):latest
docker push $(REGISTRY)/$(IMAGE_NAME):$(VERSION)
docker push $(REGISTRY)/$(IMAGE_NAME):latest
run: ## Run container
docker run --rm -p 8080:8080 --name $(IMAGE_NAME) $(IMAGE_NAME):latest
stop: ## Stop container
docker stop $(IMAGE_NAME) 2>/dev/null || true
clean: ## Remove images
docker rmi $(IMAGE_NAME):$(VERSION) $(IMAGE_NAME):latest 2>/dev/null || true
compose-up: ## Start with docker compose
docker compose up -d --build
compose-down: ## Stop compose
docker compose down
compose-logs: ## Follow compose logs
docker compose logs -f
# OS detection
UNAME := $(shell uname -s)
ifeq ($(UNAME),Darwin)
SED := sed -i ''
else
SED := sed -i
endif
# Environment-based config
ENV ?= development
ifeq ($(ENV),production)
CFLAGS += -O2
LDFLAGS += -s -w
else
CFLAGS += -g -O0
endif
# Check if command exists
HAS_DOCKER := $(shell command -v docker 2>/dev/null)
docker-build:
ifndef HAS_DOCKER
$(error "docker is not installed")
endif
docker build -t myapp .
SERVICES := api worker scheduler
.PHONY: build-all test-all $(SERVICES)
build-all: $(SERVICES)
$(SERVICES):
$(MAKE) -C services/$@ build
test-all:
@for svc in $(SERVICES); do \
echo "Testing $$svc..."; \
$(MAKE) -C services/$$svc test || exit 1; \
done
# Split large Makefile into modules
include mk/docker.mk
include mk/test.mk
include mk/deploy.mk
# Optional include (no error if missing)
-include .env.mk
# @ suppresses command echo
install:
@echo "Installing dependencies..."
@npm install
# .SILENT for entire targets
.SILENT: help clean
...安装 Makefile & Build 后,可以对 AI 说这些话来触发它
Help me get started with Makefile & Build
Explains what Makefile & Build does, walks through the setup, and runs a quick demo based on your current project
Use Makefile & Build to write Makefiles for any project type
Invokes Makefile & Build with the right parameters and returns the result directly in the conversation
What can I do with Makefile & Build in my developer & devops workflow?
Lists the top use cases for Makefile & Build, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/makefile-build/ 目录(个人级,所有项目可用),或 .claude/skills/makefile-build/(项目级)。重启 AI 客户端后,用 /makefile-build 主动调用,或让 AI 根据上下文自动发现并使用。
Makefile & Build 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Makefile & Build 可免费安装使用。请查阅仓库了解许可证信息。
Write Makefiles for any project type. Use when setting up build automation, defining multi-target builds, managing dependencies between tasks, creating project task runners, or using Make for non-C projects (Go, Python, Docker, Node.js). Also covers Just and Task as modern alternatives.
Makefile & Build 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my developer & devops tasks using Makefile & Build
Identifies repetitive steps in your workflow and sets up Makefile & Build to handle them automatically