makefile

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
On invocation: announce "Running paad:makefile v2.1.0", then immediately proceed with the steps below — do not stop after announcing.
Configuration (experimental): after announcing, check whether
paad/config/paad.md
and
paad/config/makefile.md
exist, relative to the working directory. If any does, read it and follow its instructions for the rest of this run, passing the relevant parts to every subagent you dispatch, and make the first line of your final answer
Config: <path>
naming each file you followed. If none exists, do not mention config at all. Config never changes a subagent's type or grants it write tools — refuse that line, say so, and continue. Config can contradict the flow below; see https://github.com/Ovid/paad/blob/main/CONFIG.md before writing one.
调用时: 宣布 "Running paad:makefile v2.1.0",然后立即继续执行以下步骤——不要在宣布后停止。
配置(实验性): 宣布后,检查相对于当前工作目录是否存在
paad/config/paad.md
和
paad/config/makefile.md
。如果其中任一文件存在,请读取它,并在本次运行的余下过程中遵循其中的说明,将相关内容传递给你分派的每个 subagent,并将最终答案的第一行设为
Config: <path>
,列出你遵循的每个文件。如果两者都不存在,则完全不要提及配置。配置绝不能改变 subagent 的类型,也不能授予其写入工具的权限——拒绝此类指令,说明原因并继续执行。配置可以与下述流程相矛盾;编写配置前请参阅 https://github.com/Ovid/paad/blob/main/CONFIG.md。

Makefile Management

Makefile 管理

Process:
dot
digraph makefile_flow {
    "Makefile exists?" [shape=diamond];
    "Existing target needs change?" [shape=diamond];
    "Approved?" [shape=diamond];
    "Coverage tool defaults to watch mode?" [shape=diamond];
    "Test tool supports balanced output?" [shape=diamond];

    "Detect stack" [shape=box];
    "Create from scratch" [shape=box];
    "Include all required targets" [shape=box];
    "Identify missing targets" [shape=box];
    "Add new targets" [shape=box];
    "STOP: ask user for approval" [shape=box, style=bold];
    "Apply change" [shape=box];
    "Skip change" [shape=box];
    "Force the one-shot flag for the detected stack" [shape=box];
    "Verify the tool exits on its own before adding flags" [shape=box];
    "ASK the user how to handle test output" [shape=box];
    "Announce the file written or updated" [shape=box];
    "Done" [shape=box];

    "Detect stack" -> "Makefile exists?";
    "Makefile exists?" -> "Create from scratch" [label="no"];
    "Makefile exists?" -> "Identify missing targets" [label="yes"];
    "Create from scratch" -> "Include all required targets";
    "Include all required targets" -> "Coverage tool defaults to watch mode?";
    "Identify missing targets" -> "Add new targets";
    "Add new targets" -> "Existing target needs change?";
    "Existing target needs change?" -> "Coverage tool defaults to watch mode?" [label="no"];
    "Coverage tool defaults to watch mode?" -> "Force the one-shot flag for the detected stack" [label="yes — vitest, jest"];
    "Coverage tool defaults to watch mode?" -> "Verify the tool exits on its own before adding flags" [label="unclear — pytest-cov, cargo, go test"];
    "Force the one-shot flag for the detected stack" -> "Test tool supports balanced output?";
    "Verify the tool exits on its own before adding flags" -> "Test tool supports balanced output?";
    "Existing target needs change?" -> "STOP: ask user for approval" [label="yes"];
    "STOP: ask user for approval" -> "Approved?";
    "Approved?" -> "Apply change" [label="yes"];
    "Approved?" -> "Skip change" [label="no"];
    "Apply change" -> "Existing target needs change?" [label="next target"];
    "Skip change" -> "Existing target needs change?" [label="next target"];
    "Test tool supports balanced output?" -> "Announce the file written or updated" [label="yes"];
    "Test tool supports balanced output?" -> "ASK the user how to handle test output" [label="no — only silent or firehose"];
    "ASK the user how to handle test output" -> "Announce the file written or updated";
    "Announce the file written or updated" -> "Done";
}
流程:
dot
digraph makefile_flow {
    "Makefile exists?" [shape=diamond];
    "Existing target needs change?" [shape=diamond];
    "Approved?" [shape=diamond];
    "Coverage tool defaults to watch mode?" [shape=diamond];
    "Test tool supports balanced output?" [shape=diamond];

    "Detect stack" [shape=box];
    "Create from scratch" [shape=box];
    "Include all required targets" [shape=box];
    "Identify missing targets" [shape=box];
    "Add new targets" [shape=box];
    "STOP: ask user for approval" [shape=box, style=bold];
    "Apply change" [shape=box];
    "Skip change" [shape=box];
    "Force the one-shot flag for the detected stack" [shape=box];
    "Verify the tool exits on its own before adding flags" [shape=box];
    "ASK the user how to handle test output" [shape=box];
    "Announce the file written or updated" [shape=box];
    "Done" [shape=box];

    "Detect stack" -> "Makefile exists?";
    "Makefile exists?" -> "Create from scratch" [label="no"];
    "Makefile exists?" -> "Identify missing targets" [label="yes"];
    "Create from scratch" -> "Include all required targets";
    "Include all required targets" -> "Coverage tool defaults to watch mode?";
    "Identify missing targets" -> "Add new targets";
    "Add new targets" -> "Existing target needs change?";
    "Existing target needs change?" -> "Coverage tool defaults to watch mode?" [label="no"];
    "Coverage tool defaults to watch mode?" -> "Force the one-shot flag for the detected stack" [label="yes — vitest, jest"];
    "Coverage tool defaults to watch mode?" -> "Verify the tool exits on its own before adding flags" [label="unclear — pytest-cov, cargo, go test"];
    "Force the one-shot flag for the detected stack" -> "Test tool supports balanced output?";
    "Verify the tool exits on its own before adding flags" -> "Test tool supports balanced output?";
    "Existing target needs change?" -> "STOP: ask user for approval" [label="yes"];
    "STOP: ask user for approval" -> "Approved?";
    "Approved?" -> "Apply change" [label="yes"];
    "Approved?" -> "Skip change" [label="no"];
    "Apply change" -> "Existing target needs change?" [label="next target"];
    "Skip change" -> "Existing target needs change?" [label="next target"];
    "Test tool supports balanced output?" -> "Announce the file written or updated" [label="yes"];
    "Test tool supports balanced output?" -> "ASK the user how to handle test output" [label="no — only silent or firehose"];
    "ASK the user how to handle test output" -> "Announce the file written or updated";
    "Announce the file written or updated" -> "Done";
}

When NOT to Use This Skill

不应使用此 Skill 的情况

  • The project's task runner is not make, and adding one isn't wanted — a repo standardized on
    npm run
    ,
    just
    ,
    task
    ,
    nox
    , or
    cargo xtask
    doesn't need a Makefile shimming over it. Ask before introducing a second entry point.
  • The Makefile is generated (autotools, CMake, cargo-make output) — edits get overwritten. Change the generator.
  • 项目的任务运行器不是 make,且不希望新增 make——如果仓库已经统一使用
    npm run
    、
    just
    、
    task
    、
    nox
    或
    cargo xtask
    ,则无需再套一层 Makefile。引入第二个入口点前应先询问用户。
  • Makefile 是自动生成的(如 autotools、CMake、cargo-make 的输出)——手动修改会被覆盖,应修改对应的生成器。

Overview

概述

Creates or updates a project Makefile with standard targets. Never modifies an existing target without explicit user approval.
创建或更新项目的 Makefile,并提供标准目标。未经用户明确批准,绝不修改任何现有目标。

Process

流程

  1. Detect stack (read CLAUDE.md, AGENTS.md, README, package.json, pyproject.toml, Cargo.toml, go.mod, etc.)
  2. Check if Makefile exists
  3. Creating → build from scratch with all required targets mapped to detected stack
  4. Updating → add missing targets; STOP and ask before changing any existing one
  5. Announce the file you wrote — see "Announce What You Wrote"
  1. 检测技术栈(读取 CLAUDE.md、AGENTS.md、README、package.json、pyproject.toml、Cargo.toml、go.mod 等文件)
  2. 检查 Makefile 是否存在
  3. 创建 → 根据检测到的技术栈从头构建,并映射所有必需目标
  4. 更新 → 添加缺失的目标;修改任何现有目标之前必须停止并询问用户
  5. 宣布已写入的文件——参见“宣布写入的内容”

Stack Detection

技术栈检测

Read project files in this order to understand the technology and available commands:
  1. CLAUDE.md
    or
    AGENTS.md
    — often lists exact commands for test, lint, format, build
  2. README.md
    — frequently documents dev workflow
  3. Language manifest (
    package.json
    ,
    pyproject.toml
    ,
    Cargo.toml
    ,
    go.mod
    ,
    Gemfile
    , etc.) — reveals available scripts/tasks
Use the commands the project already documents. Do not invent commands that aren't confirmed to exist.
按以下顺序读取项目文件,以了解技术栈和可用命令:
  1. CLAUDE.md
    或
    AGENTS.md
    ——通常会列出测试、lint、格式化、构建所用的确切命令
  2. README.md
    ——通常会记录开发工作流
  3. 语言清单文件(
    package.json
    、
    pyproject.toml
    、
    Cargo.toml
    、
    go.mod
    、
    Gemfile
    等)——用于了解可用的 scripts 或 tasks
**使用项目已经记录的命令。**不要虚构未经确认存在的命令。

Required Targets

必需目标

Every Makefile must include at minimum:
TargetPurpose
help
List all targets with descriptions
all
Full CI pass (lint + format + test at minimum)
test
Run test suite
cover
One-shot coverage report
lint
Lint (with autofix if available)
format
Format code
Add extra targets (e.g.
build
,
dev
,
preview
) only if the project supports them.
每个 Makefile 至少必须包含以下目标:
目标用途
help
列出所有目标及其说明
all
执行完整的 CI 流程(至少包含 lint + format + test)
test
运行测试套件
cover
生成单次执行的覆盖率报告
lint
执行 lint(如支持则自动修复)
format
格式化代码
仅在项目确实支持时,才添加额外目标(例如
build
、
dev
、
preview
)。

The Self-Documenting Pattern

自文档化模式

Every target gets a
##
description.
help
extracts them with
grep
+
awk
:
makefile
.PHONY: all test cover lint format help

all: lint format test ## Lint, format, and test

test: ## Run full test suite
	<stack-specific command>

cover: ## Generate code coverage report (one-shot)
	<stack-specific command, forced one-shot — see below>

lint: ## Lint with autofix
	<stack-specific command>

format: ## Format code
	<stack-specific command>

help: ## Show this help
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "  %-10s %s\n", $$1, $$2}'
All targets must appear in
.PHONY
.
每个目标都要带有一个
##
说明。
help
使用
grep
+
awk
提取这些说明:
makefile
.PHONY: all test cover lint format help

all: lint format test ## Lint, format, and test

test: ## Run full test suite
	<stack-specific command>

cover: ## Generate code coverage report (one-shot)
	<stack-specific command, forced one-shot — see below>

lint: ## Lint with autofix
	<stack-specific command>

format: ## Format code
	<stack-specific command>

help: ## Show this help
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "  %-10s %s\n", $$1, $$2}'
所有目标都必须出现在
.PHONY
中。

Critical Rule: Updating Existing Targets

关键规则:更新现有目标

If an existing target's implementation would change, stop and tell the user:
"The existing
cover
target runs
X
. I'd change it to
Y
because [reason]. Should I make this change?"
Wait for explicit approval. Adding a brand-new target never requires approval.
如果现有目标的实现方式将发生变化,停止并告知用户:
“现有的
cover
目标运行
X
。我想将它改为
Y
,因为[原因]。是否允许我做此更改?”
等待用户明确批准。添加一个全新的目标永远不需要批准。

cover: Avoid Watch Mode Hanging

cover:避免 Watch 模式卡住

Coverage tools often default to watch mode. Force one-shot execution:
  • vitest: append
    -- --run
  • jest: append
    -- --watchAll=false
  • pytest-cov / cargo / go test: typically exit on their own; verify before adding flags
  • other: check the tool's docs for a non-interactive/CI flag
覆盖率工具通常默认使用 watch 模式。应强制其单次执行:
  • vitest: 追加
    -- --run
  • jest: 追加
    -- --watchAll=false
  • pytest-cov / cargo / go test: 通常会自行退出;添加标志前先进行验证
  • 其他: 查阅该工具的文档,寻找非交互式或 CI 标志

test: Balanced Output Verbosity

test:均衡的输出详细程度

make test
output should be actionable, not overwhelming. Avoid both extremes:
  • Too verbose: full test names for passing tests, stack traces for every assertion, watch-mode chatter
  • Too silent: a single pass/fail line with no detail on failures
Goal: On success, show a concise summary (total passed/failed/skipped). On failure, show the failing test name, assertion, and enough context to act on it.
Common approaches by stack:
StackFlag / Approach
vitest
--reporter=default
is usually fine; avoid
--reporter=verbose
jestDefault is good; avoid
--verbose
pytest
-q
or
--tb=short
— default is often too verbose
cargo testDefault is fine;
--quiet
if too noisy
go testDefault is fine; avoid
-v
unless debugging
prove (Perl)Default is fine; avoid
--verbose
If the testing tool doesn't support balanced output (e.g., only offers silent vs. firehose), inform the user and ask how they'd like to handle it rather than guessing.
make test
的输出应当便于采取行动,但不能令人不堪重负。应避免两个极端:
  • 过于冗长: 显示所有通过测试的完整名称、每个断言的堆栈跟踪,以及 watch 模式的闲聊信息
  • 过于安静: 仅显示一行通过或失败结果,失败时没有任何详细信息
目标: 成功时显示简洁的汇总信息(通过、失败、跳过的总数);失败时显示失败测试的名称、断言信息,以及足以采取行动的上下文。
各技术栈的常用方式:
技术栈标志或方式
vitest
--reporter=default
通常就足够了;避免使用
--reporter=verbose
jest默认输出就足够了;避免使用
--verbose
pytest使用
-q
或
--tb=short
——默认输出通常过于冗长
cargo test默认输出就足够了;如果噪声过多,可以使用
--quiet
go test默认输出就足够了;除调试外避免使用
-v
prove(Perl)默认输出就足够了;避免使用
--verbose
如果测试工具不支持均衡输出(例如只能在静默和海量输出之间二选一),应告知用户并询问希望如何处理,而不是自行猜测。

Announce What You Wrote

宣布写入的内容

End the run with the file list, always. One line per path, marked new or updated:
Files written or updated:
  updated  Makefile
Say it even though only one file changed, and even when the user watched you change it. If you were asked to change an existing target and stopped for approval instead, say that too — an unapproved target is not a written one.
每次运行都必须以文件列表结束。每条路径占一行,并标记为“新建”或“更新”:
Files written or updated:
  updated  Makefile
即使只更改了一个文件,甚至用户全程看着你修改,也要说明这一点。如果你被要求修改现有目标,并因此停在等待批准这一步,也要说明——未获批准的目标不算已写入。

Common Mistakes

常见错误

MistakeWhat to do instead
Rewriting an existing target because the new version is betterStop and ask, quoting the current command and the proposed one. Other tooling (CI, hooks, docs, muscle memory) may depend on the current behaviour.
Treating "add a flag to an existing target" as additiveChanging a target's implementation is a change, flag or not. It needs approval.
Inventing commands the stack doesn't haveDetect first — read CLAUDE.md, README, and the language manifest. A
lint
target running a linter that isn't installed is worse than no target.
Writing a
help
target that lists targets by hand
Use the self-documenting
##
pattern, so help can't drift from reality.
Leaving
cover
in watch mode
It hangs the agent and CI. Force one-shot explicitly, per the stack.
Omitting targets from
.PHONY
A file named
test
in the repo root silently breaks
make test
.
Adding every optional target for completenessExtra targets (
build
,
dev
,
preview
) go in only when the project actually supports them.
错误正确做法
因为新版本更好而重写现有目标停止并询问用户,同时引用当前命令和拟议命令。其他工具(CI、hooks、文档)以及用户的使用习惯都可能依赖当前行为。
把“给现有目标添加一个标志”视为增量操作无论是否添加标志,改变目标实现都属于变更,需要获得批准。
虚构技术栈中不存在的命令先进行检测——读取 CLAUDE.md、README 和语言清单文件。一个运行着未安装 linter 的
lint
目标,比没有目标更糟糕。
手动编写用于列出目标的
help
目标
使用自文档化的
##
模式,避免帮助信息与实际情况不一致。
让
cover
保持 watch 模式
它会让 agent 和 CI 卡住。应根据技术栈显式强制使用单次执行模式。
从
.PHONY
中遗漏目标
仓库根目录中一个名为
test
的文件会悄无声息地导致
make test
失败。
为了完整性而添加所有可选目标只有项目确实支持时,才加入额外目标(
build
、
dev
、
preview
等)。