一键导入
makefile-creation
Use when creating Makefiles, needing build automation, defining make targets, or implementing standard makefile patterns and recipes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when creating Makefiles, needing build automation, defining make targets, or implementing standard makefile patterns and recipes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when creating or modifying bash shell scripts, needing script templates, error handling patterns, or shell scripting best practices.
Use when creating Justfiles, needing modern command runners, or implementing just command runner patterns for task automation.
Use when you need detailed kitty terminal API reference, remote control commands, window management, or advanced kitty integration patterns.
Comprehensive guide for Python type annotations, type checking, and modern typing patterns. Use when: (1) Adding type hints to Python code, (2) Configuring mypy/pyright/ty type checkers, (3) Understanding generics, protocols, and advanced type patterns, (4) Migrating to modern Python typing, (5) Setting up strict type checking in CI/CD, (6) Building type-safe APIs and libraries. Covers Python 3.10+ modern syntax, type narrowing, structural typing, and best practices.
Use when you need to explore, search, or understand codebases using structural AST patterns. Ideal for finding specific code patterns, understanding code architecture, discovering API usage, or locating code smells across multiple files.
Use when you need to perform code refactoring, semantic transformations, or structural rewrites across multiple files. Ideal for API migrations, code modernization, breaking change adoption, or systematic code transformations.
| name | makefile-creation |
| description | Use when creating Makefiles, needing build automation, defining make targets, or implementing standard makefile patterns and recipes. |
Guide for creating effective Makefiles for build automation and task running.
Make is a powerful build automation tool that tracks file dependencies. This skill provides templates and best practices for creating maintainable Makefiles.
# Project Configuration
PROJECT_NAME := myproject
VERSION := 1.0.0
# Directories
BUILD_DIR := build
SRC_DIR := src
TEST_DIR := tests
# Tools
CC := gcc
CFLAGS := -Wall -Wextra -O2
LDFLAGS :=
# Files
SOURCES := $(wildcard $(SRC_DIR)/*.c)
OBJECTS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SOURCES))
# Phony targets (not actual files)
.PHONY: all clean build test install help
# Default target
.DEFAULT_GOAL := help
# Help target (displays available commands)
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
# Build targets
all: build ## Build the entire project
build: $(BUILD_DIR) $(OBJECTS) ## Build project
@echo "Building $(PROJECT_NAME)..."
$(CC) $(OBJECTS) -o $(BUILD_DIR)/$(PROJECT_NAME) $(LDFLAGS)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
# Test targets
test: build ## Run tests
@echo "Running tests..."
$(TEST_DIR)/run_tests.sh
# Clean target
clean: ## Remove build artifacts
@echo "Cleaning build directory..."
rm -rf $(BUILD_DIR)
# Install target
install: build ## Install the project
@echo "Installing $(PROJECT_NAME)..."
cp $(BUILD_DIR)/$(PROJECT_NAME) /usr/local/bin/
.PHONY: clean build test
Mark targets that don't produce files to prevent conflicts with actual files.
| Variable | Meaning |
|---|---|
$@ | Target name |
$< | First prerequisite |
$^ | All prerequisites |
$? | Prerequisites newer than target |
$* | Stem of pattern rule |
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
# Usage: make target ## Description
# Detect OS
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
CFLAGS += -DMACOS
endif
ifeq ($(UNAME_S),Linux)
CFLAGS += -DLINUX
endif
# Detect if running in CI
ifdef CI
FLAGS += --ci
endif
# Check if variable is set
ifdef DEBUG
CFLAGS += -g -DDEBUG
else
CFLAGS += -O2
endif
# Check if file exists
ifneq (,$(wildcard .env))
include .env
export
endif
subdirs := foo bar baz
$(subdirs):
$(MAKE) -C $@
.PHONY: all $(subdirs)
all: $(subdirs)
## to document targets$@, $<, $^) for cleaner rules.PHONY: install test lint format clean help
VENV := .venv
PYTHON := $(VENV)/bin/python
PIP := $(VENV)/bin/pip
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
$(VENV)/bin/activate: requirements.txt
python -m venv $(VENV)
$(PIP) install -r requirements.txt
install: $(VENV)/bin/activate ## Install dependencies
lint: $(VENV)/bin/activate ## Run linter
$(PYTHON) -m flake8 src/
format: $(VENV)/bin/activate ## Format code
$(PYTHON) -m black src/ tests/
test: $(VENV)/bin/activate ## Run tests
$(PYTHON) -m pytest tests/
clean: ## Remove build artifacts
rm -rf $(VENV) .pytest_cache __pycache__
.PHONY: serve build deploy clean help
DOCS_DIR := docs
BUILD_DIR := site
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
serve: ## Start development server
cd $(DOCS_DIR) && mkdocs serve
build: ## Build documentation
cd $(DOCS_DIR) && mkdocs build -d ../$(BUILD_DIR)
deploy: build ## Deploy to production
cd $(BUILD_DIR) && rsync -avz . user@server:/var/www/docs/
clean: ## Clean build files
rm -rf $(BUILD_DIR)