编写项目构建与任务执行文件
依据仓库现有命令选择任务工具,生成含帮助说明和危险操作确认的文件并验证。
完整提示词
<context>
A task file is the front door to a repo, and small mistakes make it fail on someone else's machine. In Make, recipe lines must start with a tab; every line runs in a new shell, so `cd dir` on one line does not affect the next; targets that are not files need `.PHONY` or they silently stop running once a file of that name exists; `=` versus `:=` changes when a variable is evaluated; and `$` must be written `$$` for the shell. Make is not installed by default on Windows. A justfile avoids most of these but needs `just` installed. Task files also drift when they duplicate commands already in `package.json` scripts, `pyproject.toml` or CI.
</context>
<task>
Write a task file for this repo.
{{#tasks}}
Tasks: {{tasks}}
{{/tasks}}
Tool: {{tool}}
1. Read the repo: README setup steps, package manager scripts, CI workflow commands, Dockerfile and compose files, existing Makefile or justfile, and contributors' platforms if documented.
2. If tool is "decide", pick Make when it is already used or files are actually built from sources (real dependency tracking), and just when the file is only a command menu and contributors use Windows or prefer simpler syntax. State why.
3. List the tasks: from the input, or derived from what README and CI actually run. Each target wraps the existing command (for example `npm run test`) rather than copying its flags, so there is one source of truth.
4. Make: start with `SHELL := bash`, `.SHELLFLAGS := -eu -o pipefail -c`, `.DEFAULT_GOAL := help` and `MAKEFLAGS += --no-builtin-rules`; declare `.PHONY` for every non-file target; use `?=` for overridable variables (for example `PORT ?= 3000`); use `$(MAKE)` for recursion; join dependent shell lines with `&&` or use `.ONESHELL`; use real file targets with prerequisites where outputs are files (for example generated code from a schema).
5. just: `set shell := ["bash", "-euo", "pipefail", "-c"]` (or the Windows shell setting if needed), recipes with parameters and defaults, `set dotenv-load` only if the project uses `.env`, and a default recipe that lists recipes.
6. Self-document: a `help` target that prints each target with a one-line description (from `##` comments in Make; `just --list` with doc comments in just).
7. Guard destructive targets (clean volumes, reset database, deploy) with a confirmation prompt or a required variable such as `CONFIRM=1`, and never make them the default.
8. Run `make help` or `just --list`, then run the safe targets (lint, test, build) and report results. Do not run destructive or deploy targets.
</task>
<constraints>
- Do not duplicate long commands that already live in package scripts or CI; call them.
- Do not hard-code local paths, usernames or secrets; read secrets from the environment.
- Use tabs for Make recipe lines and say so in a comment at the top.
{{> guardrails/scope-discipline}}
{{> guardrails/investigate-before-answering}}
{{> guardrails/verify-before-done}}
</constraints>
<output_format>
## Choice
Make or just, and why, in two or three lines.
## File
The complete file in one code block.
## Targets
Table: Target | What it runs | Notes.
## Verification
Commands run and their real results; which targets were not run and why.
</output_format>可替换内容
- {{#tasks}}
- {{tasks}}
- {{/tasks}}
- {{tool}}
- {{> guardrails/scope-discipline}}
- {{> guardrails/investigate-before-answering}}
- {{> guardrails/verify-before-done}}
- ["bash", "-euo", "pipefail", "-c"]
分类与标签
编程开发、构建脚本、任务自动化、跨平台开发、仓库配置