makefile
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOn 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 and 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 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.
paad/config/paad.mdpaad/config/makefile.mdConfig: <path>调用时: 宣布 "Running paad:makefile v2.1.0",然后立即继续执行以下步骤——不要在宣布后停止。
配置(实验性): 宣布后,检查相对于当前工作目录是否存在 和 。如果其中任一文件存在,请读取它,并在本次运行的余下过程中遵循其中的说明,将相关内容传递给你分派的每个 subagent,并将最终答案的第一行设为 ,列出你遵循的每个文件。如果两者都不存在,则完全不要提及配置。配置绝不能改变 subagent 的类型,也不能授予其写入工具的权限——拒绝此类指令,说明原因并继续执行。配置可以与下述流程相矛盾;编写配置前请参阅 https://github.com/Ovid/paad/blob/main/CONFIG.md。
paad/config/paad.mdpaad/config/makefile.mdConfig: <path>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, ornoxdoesn't need a Makefile shimming over it. Ask before introducing a second entry point.cargo xtask - The Makefile is generated (autotools, CMake, cargo-make output) — edits get overwritten. Change the generator.
- 项目的任务运行器不是 make,且不希望新增 make——如果仓库已经统一使用 、
npm run、just、task或nox,则无需再套一层 Makefile。引入第二个入口点前应先询问用户。cargo xtask - 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
流程
- Detect stack (read CLAUDE.md, AGENTS.md, README, package.json, pyproject.toml, Cargo.toml, go.mod, etc.)
- Check if Makefile exists
- Creating → build from scratch with all required targets mapped to detected stack
- Updating → add missing targets; STOP and ask before changing any existing one
- Announce the file you wrote — see "Announce What You Wrote"
- 检测技术栈(读取 CLAUDE.md、AGENTS.md、README、package.json、pyproject.toml、Cargo.toml、go.mod 等文件)
- 检查 Makefile 是否存在
- 创建 → 根据检测到的技术栈从头构建,并映射所有必需目标
- 更新 → 添加缺失的目标;修改任何现有目标之前必须停止并询问用户
- 宣布已写入的文件——参见“宣布写入的内容”
Stack Detection
技术栈检测
Read project files in this order to understand the technology and available commands:
- or
CLAUDE.md— often lists exact commands for test, lint, format, buildAGENTS.md - — frequently documents dev workflow
README.md - Language manifest (,
package.json,pyproject.toml,Cargo.toml,go.mod, etc.) — reveals available scripts/tasksGemfile
Use the commands the project already documents. Do not invent commands that aren't confirmed to exist.
按以下顺序读取项目文件,以了解技术栈和可用命令:
- 或
CLAUDE.md——通常会列出测试、lint、格式化、构建所用的确切命令AGENTS.md - ——通常会记录开发工作流
README.md - 语言清单文件(、
package.json、pyproject.toml、Cargo.toml、go.mod等)——用于了解可用的 scripts 或 tasksGemfile
**使用项目已经记录的命令。**不要虚构未经确认存在的命令。
Required Targets
必需目标
Every Makefile must include at minimum:
| Target | Purpose |
|---|---|
| List all targets with descriptions |
| Full CI pass (lint + format + test at minimum) |
| Run test suite |
| One-shot coverage report |
| Lint (with autofix if available) |
| Format code |
Add extra targets (e.g. , , ) only if the project supports them.
builddevpreview每个 Makefile 至少必须包含以下目标:
| 目标 | 用途 |
|---|---|
| 列出所有目标及其说明 |
| 执行完整的 CI 流程(至少包含 lint + format + test) |
| 运行测试套件 |
| 生成单次执行的覆盖率报告 |
| 执行 lint(如支持则自动修复) |
| 格式化代码 |
仅在项目确实支持时,才添加额外目标(例如 、、)。
builddevpreviewThe Self-Documenting Pattern
自文档化模式
Every target gets a description. extracts them with + :
##helpgrepawkmakefile
.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每个目标都要带有一个 说明。 使用 + 提取这些说明:
##helpgrepawkmakefile
.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}'所有目标都必须出现在 中。
.PHONYCritical Rule: Updating Existing Targets
关键规则:更新现有目标
If an existing target's implementation would change, stop and tell the user:
"The existingtarget runscover. I'd change it toXbecause [reason]. Should I make this change?"Y
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- 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:
| Stack | Flag / Approach |
|---|---|
| vitest | |
| jest | Default is good; avoid |
| pytest | |
| cargo test | Default is fine; |
| go test | Default is fine; avoid |
| prove (Perl) | Default is fine; avoid |
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 | |
| jest | 默认输出就足够了;避免使用 |
| pytest | 使用 |
| cargo test | 默认输出就足够了;如果噪声过多,可以使用 |
| go test | 默认输出就足够了;除调试外避免使用 |
| prove(Perl) | 默认输出就足够了;避免使用 |
如果测试工具不支持均衡输出(例如只能在静默和海量输出之间二选一),应告知用户并询问希望如何处理,而不是自行猜测。
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 MakefileSay 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
常见错误
| Mistake | What to do instead |
|---|---|
| Rewriting an existing target because the new version is better | Stop 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 additive | Changing a target's implementation is a change, flag or not. It needs approval. |
| Inventing commands the stack doesn't have | Detect first — read CLAUDE.md, README, and the language manifest. A |
Writing a | Use the self-documenting |
Leaving | It hangs the agent and CI. Force one-shot explicitly, per the stack. |
Omitting targets from | A file named |
| Adding every optional target for completeness | Extra targets ( |
| 错误 | 正确做法 |
|---|---|
| 因为新版本更好而重写现有目标 | 停止并询问用户,同时引用当前命令和拟议命令。其他工具(CI、hooks、文档)以及用户的使用习惯都可能依赖当前行为。 |
| 把“给现有目标添加一个标志”视为增量操作 | 无论是否添加标志,改变目标实现都属于变更,需要获得批准。 |
| 虚构技术栈中不存在的命令 | 先进行检测——读取 CLAUDE.md、README 和语言清单文件。一个运行着未安装 linter 的 |
手动编写用于列出目标的 | 使用自文档化的 |
让 | 它会让 agent 和 CI 卡住。应根据技术栈显式强制使用单次执行模式。 |
从 | 仓库根目录中一个名为 |
| 为了完整性而添加所有可选目标 | 只有项目确实支持时,才加入额外目标( |