mise-tasks

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

mise Tasks Orchestration

mise 任务编排

<!-- ADR: 2025-12-08-mise-tasks-skill -->
Orchestrate multi-step project workflows using mise
[tasks]
section with dependency management, argument handling, and file tracking.
<!-- ADR: 2025-12-08-mise-tasks-skill -->
使用mise的
[tasks]
区块编排多步骤项目工作流,支持依赖管理、参数处理和文件追踪。

When to Use This Skill

何时使用该技能

Explicit triggers:
  • User mentions
    mise tasks
    ,
    mise run
    ,
    [tasks]
    section
  • User needs task dependencies:
    depends
    ,
    depends_post
  • User wants workflow automation in
    .mise.toml
  • User mentions task arguments or
    usage
    spec
AI Discovery trigger (prescriptive):
When
mise-configuration
skill detects multi-step workflows (test suites, build pipelines, migrations), prescriptively invoke this skill to generate appropriate
[tasks]
definitions.
显式触发场景
  • 用户提及
    mise tasks
    mise run
    [tasks]
    区块
  • 用户需要任务依赖功能:
    depends
    depends_post
  • 用户希望在
    .mise.toml
    中实现工作流自动化
  • 用户提及任务参数或
    usage
    规范
AI发现触发场景(推荐性):
mise-configuration
技能检测到多步骤工作流(测试套件、构建流水线、迁移操作)时,主动调用本技能生成合适的
[tasks]
定义。

Quick Reference

快速参考

Task Definition

任务定义

toml
[tasks.build]
description = "Build the project"
run = "cargo build --release"
toml
[tasks.build]
description = "Build the project"
run = "cargo build --release"

Running Tasks

运行任务

bash
mise run build          # Run single task
mise run test build     # Run multiple tasks
mise run test ::: build # Run in parallel
mise r build            # Short form
bash
mise run build          # Run single task
mise run test build     # Run multiple tasks
mise run test ::: build # Run in parallel
mise r build            # Short form

Dependency Types

依赖类型

TypeSyntaxWhen
depends
depends = ["lint", "test"]
Run BEFORE task
depends_post
depends_post = ["notify"]
Run AFTER task succeeds
wait_for
wait_for = ["db"]
Wait only if running

类型语法执行时机
depends
depends = ["lint", "test"]
在当前任务之前执行
depends_post
depends_post = ["notify"]
在当前任务执行成功之后自动执行
wait_for
wait_for = ["db"]
仅当目标任务正在运行时等待

Level 1-2: Basic Tasks

1-2级:基础任务

Minimal Task

最简任务

toml
[tasks.hello]
run = "echo 'Hello, World!'"
toml
[tasks.hello]
run = "echo 'Hello, World!'"

With Description (AI-Agent Context Priming)

带描述的任务(AI-Agent上下文铺垫)

CRITICAL: The
description
field is the single most important field for AI coding agent discoverability. When an AI agent runs
mise tasks ls
, the description is the ONLY context it has to decide whether and how to use a task. Write descriptions that answer: what does it do, what does it need, what are its side effects, and when should it be run?
toml
undefined
关键提示
description
字段是AI编码Agent发现任务的最重要字段。当AI Agent执行
mise tasks ls
时,描述是它判断是否以及如何使用任务的唯一上下文。撰写描述时需回答:该任务的作用是什么、需要什么依赖、有哪些副作用、何时应该执行?
toml
undefined

BAD: Too minimal - AI agent has no context

反面示例:过于简略 - AI Agent无足够上下文

[tasks.test] description = "Run test suite" run = "pytest tests/"
[tasks.test] description = "Run test suite" run = "pytest tests/"

GOOD: Rich context for AI agent decision-making

正面示例:为AI Agent提供丰富的决策上下文

[tasks.test] description = "Run pytest test suite against src/ with coverage reporting. Requires virtualenv activated or uv. Depends on build completing first. Exits non-zero on any test failure. Safe to run repeatedly." run = "pytest tests/"

**Description checklist**:

- What it does (action + scope)
- What it requires (env vars, tools, prerequisites)
- What it produces or modifies (side effects, outputs)
- When to run it (phase context, safety notes)

```toml
[tasks.test] description = "Run pytest test suite against src/ with coverage reporting. Requires virtualenv activated or uv. Depends on build completing first. Exits non-zero on any test failure. Safe to run repeatedly." run = "pytest tests/"

**描述检查清单**:

- 任务作用(动作+范围)
- 所需依赖(环境变量、工具、前置条件)
- 产出或修改的内容(副作用、输出结果)
- 执行时机(阶段上下文、安全说明)

```toml

File-based task equivalent (in .mise/tasks/release/preflight):

基于文件的等效任务(位于.mise/tasks/release/preflight):

#MISE description="Phase 1 of 4: Validate all release prerequisites before version bump. Checks: clean working directory, GH_TOKEN presence and format, GH_ACCOUNT target, plugin validation, and releasable conventional commits since last tag. Exits non-zero on any failure."
undefined
#MISE description="Phase 1 of 4: Validate all release prerequisites before version bump. Checks: clean working directory, GH_TOKEN presence and format, GH_ACCOUNT target, plugin validation, and releasable conventional commits since last tag. Exits non-zero on any failure."
undefined

With Alias

带别名的任务

toml
[tasks.test]
description = "Run pytest test suite with coverage. Requires virtualenv or uv. Exits non-zero on failure."
alias = "t"
run = "pytest tests/"
Now
mise run t
works.
toml
[tasks.test]
description = "Run pytest test suite with coverage. Requires virtualenv or uv. Exits non-zero on failure."
alias = "t"
run = "pytest tests/"
现在可以使用
mise run t
来执行该任务。

Working Directory

指定工作目录

toml
[tasks.frontend]
dir = "packages/frontend"
run = "npm run build"
toml
[tasks.frontend]
dir = "packages/frontend"
run = "npm run build"

Task-Specific Environment

任务专属环境变量

toml
[tasks.test]
env = { RUST_BACKTRACE = "1", LOG_LEVEL = "debug" }
run = "cargo test"
Note:
env
values are NOT passed to dependency tasks.
toml
[tasks.test]
env = { RUST_BACKTRACE = "1", LOG_LEVEL = "debug" }
run = "cargo test"
注意
env
中的值不会传递给依赖任务。

GitHub Token Verification Task

GitHub令牌验证任务

For multi-account GitHub setups, add a verification task:
toml
[tasks._verify-gh-auth]
description = "Verify GitHub token matches expected account"
hide = true  # Hidden helper task
run = """
expected="${GH_ACCOUNT:-}"
if [ -z "$expected" ]; then
  echo "GH_ACCOUNT not set - skipping verification"
  exit 0
fi
actual=$(gh api user --jq '.login' 2>/dev/null || echo "")
if [ "$actual" != "$expected" ]; then
  echo "ERROR: GH_TOKEN authenticates as '$actual', expected '$expected'"
  exit 1
fi
echo "✓ GitHub auth verified: $actual"
"""

[tasks.release]
description = "Create semantic release"
depends = ["_verify-gh-auth"]  # Verify before release
run = "npx semantic-release --no-ci"
See
mise-configuration
skill
for GH_TOKEN setup.
SSH ControlMaster Warning: If using multi-account SSH, ensure
ControlMaster no
is set for GitHub hosts in
~/.ssh/config
. Cached connections can authenticate with the wrong account.
针对多账号GitHub配置,可添加验证任务:
toml
[tasks._verify-gh-auth]
description = "Verify GitHub token matches expected account"
hide = true  # Hidden helper task
run = """
expected="${GH_ACCOUNT:-}"
if [ -z "$expected" ]; then
  echo "GH_ACCOUNT not set - skipping verification"
  exit 0
fi
actual=$(gh api user --jq '.login' 2>/dev/null || echo "")
if [ "$actual" != "$expected" ]; then
  echo "ERROR: GH_TOKEN authenticates as '$actual', expected '$expected'"
  exit 1
fi
echo "✓ GitHub auth verified: $actual"
"""

[tasks.release]
description = "Create semantic release"
depends = ["_verify-gh-auth"]  # Verify before release
run = "npx semantic-release --no-ci"
关于GH_TOKEN的配置,请查看
mise-configuration
技能
SSH ControlMaster警告:如果使用多账号SSH,请确保在
~/.ssh/config
中为GitHub主机设置
ControlMaster no
。缓存的连接可能会导致使用错误的账号进行认证。

Multi-Command Tasks

多命令任务

toml
[tasks.setup]
run = [
  "npm install",
  "npm run build",
  "npm run migrate"
]

toml
[tasks.setup]
run = [
  "npm install",
  "npm run build",
  "npm run migrate"
]

Level 3-4: Dependencies & Orchestration

3-4级:依赖与编排

Pre-Execution Dependencies

执行前依赖

toml
[tasks.deploy]
depends = ["test", "build"]
run = "kubectl apply -f deployment.yaml"
Tasks
test
and
build
run BEFORE
deploy
.
toml
[tasks.deploy]
depends = ["test", "build"]
run = "kubectl apply -f deployment.yaml"
任务
test
build
会在
deploy
之前执行。

Post-Execution Tasks

执行后任务

toml
[tasks.release]
depends = ["test"]
depends_post = ["notify", "cleanup"]
run = "npm publish"
After
release
succeeds,
notify
and
cleanup
run automatically.
toml
[tasks.release]
depends = ["test"]
depends_post = ["notify", "cleanup"]
run = "npm publish"
release
执行成功后,
notify
cleanup
会自动运行。

Soft Dependencies

软依赖

toml
[tasks.migrate]
wait_for = ["database"]
run = "./migrate.sh"
If
database
task is already running, wait for it. Otherwise, proceed.
toml
[tasks.migrate]
wait_for = ["database"]
run = "./migrate.sh"
如果
database
任务正在运行,则等待其完成;否则直接执行当前任务。

Task Chaining Pattern

任务链式调用模式

toml
[tasks.ci]
description = "Full CI pipeline"
depends = ["lint", "test", "build"]
depends_post = ["coverage-report"]
run = "echo 'CI passed'"
Single command:
mise run ci
executes entire chain.
toml
[tasks.ci]
description = "Full CI pipeline"
depends = ["lint", "test", "build"]
depends_post = ["coverage-report"]
run = "echo 'CI passed'"
只需执行单个命令:
mise run ci
即可触发整个链式流程。

Parallel Dependencies

并行依赖

Dependencies without inter-dependencies run in parallel:
toml
[tasks.validate]
depends = ["lint", "typecheck", "test"]  # These can run in parallel
run = "echo 'All validations passed'"

无相互依赖的任务会并行执行:
toml
[tasks.validate]
depends = ["lint", "typecheck", "test"]  # 这些任务可并行执行
run = "echo 'All validations passed'"

Level 5: Hidden Tasks & Organization

5级:隐藏任务与组织

Hidden Tasks

隐藏任务

toml
[tasks._check-credentials]
description = "Verify credentials are set"
hide = true
run = '''
if [ -z "$API_KEY" ]; then
  echo "ERROR: API_KEY not set"
  exit 1
fi
'''

[tasks.deploy]
depends = ["_check-credentials"]
run = "deploy.sh"
Hidden tasks don't appear in
mise tasks
output but can be dependencies.
View hidden tasks:
mise tasks --hidden
toml
[tasks._check-credentials]
description = "Verify credentials are set"
hide = true
run = '''
if [ -z "$API_KEY" ]; then
  echo "ERROR: API_KEY not set"
  exit 1
fi
'''

[tasks.deploy]
depends = ["_check-credentials"]
run = "deploy.sh"
隐藏任务不会出现在
mise tasks
的输出中,但可作为其他任务的依赖。
查看隐藏任务:
mise tasks --hidden

Colon-Prefixed Namespacing

冒号前缀命名空间

toml
[tasks.test]
run = "pytest"

[tasks."test:unit"]
run = "pytest tests/unit/"

[tasks."test:integration"]
run = "pytest tests/integration/"

[tasks."test:e2e"]
run = "playwright test"
Run all test tasks:
mise run 'test:*'
toml
[tasks.test]
run = "pytest"

[tasks."test:unit"]
run = "pytest tests/unit/"

[tasks."test:integration"]
run = "pytest tests/integration/"

[tasks."test:e2e"]
run = "playwright test"
执行所有测试任务:
mise run 'test:*'

Wildcard Patterns

通配符模式

bash
mise run 'test:*'      # All tasks starting with test:
mise run 'db:**'       # Nested: db:migrate:up, db:seed:test

bash
mise run 'test:*'      # All tasks starting with test:
mise run 'db:**'       # Nested: db:migrate:up, db:seed:test

Level 6: Task Arguments

6级:任务参数

Usage Specification (Preferred Method)

使用规范(推荐方法)

toml
[tasks.deploy]
description = "Deploy to environment"
usage = '''
arg "<environment>" help="Target environment" {
  choices "dev" "staging" "prod"
}
flag "-f --force" help="Skip confirmation"
flag "--region <region>" default="us-east-1" env="AWS_REGION"
'''
run = '''
echo "Deploying to ${usage_environment}"
[ "$usage_force" = "true" ] && echo "Force mode enabled"
echo "Region: ${usage_region}"
'''
toml
[tasks.deploy]
description = "Deploy to environment"
usage = '''
arg "<environment>" help="Target environment" {
  choices "dev" "staging" "prod"
}
flag "-f --force" help="Skip confirmation"
flag "--region <region>" default="us-east-1" env="AWS_REGION"
'''
run = '''
echo "Deploying to ${usage_environment}"
[ "$usage_force" = "true" ] && echo "Force mode enabled"
echo "Region: ${usage_region}"
'''

Argument Types

参数类型

Required positional:
toml
usage = 'arg "<file>" help="Input file"'
Optional positional:
toml
usage = 'arg "[file]" default="config.toml"'
Variadic (multiple values):
toml
usage = 'arg "<files>" var=#true'
必填位置参数:
toml
usage = 'arg "<file>" help="Input file"'
可选位置参数:
toml
usage = 'arg "[file]" default="config.toml"'
可变参数(多值):
toml
usage = 'arg "<files>" var=#true'

Flag Types

标志类型

Boolean flag:
toml
usage = 'flag "-v --verbose"'
布尔标志:
toml
usage = 'flag "-v --verbose"'

Access: ${usage_verbose:-false}

Access: ${usage_verbose:-false}


**Flag with value**:

```toml
usage = 'flag "-o --output <file>" default="out.txt"'

**带值的标志**:

```toml
usage = 'flag "-o --output <file>" default="out.txt"'

Access: ${usage_output}

Access: ${usage_output}


**Environment-backed flag**:

```toml
usage = 'flag "--port <port>" env="PORT" default="8080"'

**基于环境变量的标志**:

```toml
usage = 'flag "--port <port>" env="PORT" default="8080"'

Accessing Arguments

访问参数

In
run
scripts, arguments become
usage_<name>
environment variables:
bash
/usr/bin/env bash << 'SKILL_SCRIPT_EOF'
${usage_environment}      # Required arg value
${usage_verbose:-false}   # Boolean flag with default
${usage_output}           # Flag with value
SKILL_SCRIPT_EOF
DEPRECATION WARNING: The Tera template method (
{{arg(name="...")}}
) will be removed in mise 2026.11.0. Use
usage
spec instead.
For complete argument syntax, see: arguments.md

run
脚本中,参数会变为
usage_<name>
格式的环境变量:
bash
/usr/bin/env bash << 'SKILL_SCRIPT_EOF'
${usage_environment}      # Required arg value
${usage_verbose:-false}   # Boolean flag with default
${usage_output}           # Flag with value
SKILL_SCRIPT_EOF
弃用警告:Tera模板方法(
{{arg(name="...")}}
)将在mise 2026.11.0版本中移除,请改用
usage
规范。
完整的参数语法请查看:arguments.md

Level 7: File Tracking & Caching

7级:文件追踪与缓存

Source Files

源文件

toml
[tasks.build]
sources = ["Cargo.toml", "src/**/*.rs"]
run = "cargo build"
Task re-runs only when source files change.
toml
[tasks.build]
sources = ["Cargo.toml", "src/**/*.rs"]
run = "cargo build"
仅当源文件发生变化时,才会重新执行任务。

Output Files

输出文件

toml
[tasks.build]
sources = ["Cargo.toml", "src/**/*.rs"]
outputs = ["target/release/myapp"]
run = "cargo build --release"
If outputs are newer than sources, task is skipped.
toml
[tasks.build]
sources = ["Cargo.toml", "src/**/*.rs"]
outputs = ["target/release/myapp"]
run = "cargo build --release"
如果输出文件比源文件更新,则任务会被跳过

Force Execution

强制执行

bash
mise run build --force  # Bypass caching
bash
mise run build --force  # Bypass caching

Auto Output Detection

自动输出检测

toml
[tasks.compile]
outputs = { auto = true }  # Default behavior
run = "gcc -o app main.c"

toml
[tasks.compile]
outputs = { auto = true }  # Default behavior
run = "gcc -o app main.c"

Level 8: Advanced Execution

8级:高级执行

Confirmation Prompts

确认提示

toml
[tasks.drop-database]
confirm = "This will DELETE all data. Continue?"
run = "dropdb myapp"
toml
[tasks.drop-database]
confirm = "This will DELETE all data. Continue?"
run = "dropdb myapp"

Output Control

输出控制

toml
[tasks.quiet-task]
quiet = true   # Suppress mise's output (not task output)
run = "echo 'This still prints'"

[tasks.silent-task]
silent = true  # Suppress ALL output
run = "background-job.sh"

[tasks.silent-stderr]
silent = "stderr"  # Only suppress stderr
run = "noisy-command"
toml
[tasks.quiet-task]
quiet = true   # Suppress mise's output (not task output)
run = "echo 'This still prints'"

[tasks.silent-task]
silent = true  # Suppress ALL output
run = "background-job.sh"

[tasks.silent-stderr]
silent = "stderr"  # Only suppress stderr
run = "noisy-command"

Raw Mode (Interactive)

原始模式(交互式)

toml
[tasks.edit-config]
raw = true  # Direct stdin/stdout/stderr
run = "vim config.yaml"
Warning:
raw = true
disables parallel execution.
toml
[tasks.edit-config]
raw = true  # Direct stdin/stdout/stderr
run = "vim config.yaml"
警告
raw = true
会禁用并行执行。

Task-Specific Tools

任务专属工具版本

toml
[tasks.legacy-test]
tools = { python = "3.9", node = "18" }
run = "pytest && npm test"
Use specific tool versions for this task only.
toml
[tasks.legacy-test]
tools = { python = "3.9", node = "18" }
run = "pytest && npm test"
仅为该任务使用指定的工具版本。

Custom Shell

自定义Shell

toml
[tasks.powershell-task]
shell = "pwsh -c"
run = "Get-Process | Select-Object -First 5"

toml
[tasks.powershell-task]
shell = "pwsh -c"
run = "Get-Process | Select-Object -First 5"

Level 9: Watch Mode

9级:监听模式

Prefer Runtime-Native Watch

优先使用运行时原生监听

When the runtime has a built-in file watcher, use it instead of
mise watch
/
watchexec
— zero extra memory, zero extra processes.
RuntimeCommandNotes
Bun
bun --watch run src/main.ts
0 MB overhead. Do NOT use
bun --hot
(stale state).
Node.js
node --watch src/main.js
0 MB overhead.
Python
uvicorn app:main --reload
0 MB overhead.
当运行时内置文件监听器时,优先使用它而非
mise watch
/
watchexec
——无需额外内存,无需额外进程。
运行时命令说明
Bun
bun --watch run src/main.ts
0 MB 开销。请勿使用
bun --hot
(存在状态过期问题)。
Node.js
node --watch src/main.js
0 MB 开销。
Python
uvicorn app:main --reload
0 MB 开销。

External Watch (mise watch)

外部监听(mise watch)

Use
mise watch
for runtimes without built-in watchers (Go, Rust, shell) or multi-language orchestration.
bash
mise watch build  # Re-run on source changes
Requires
watchexec
:
mise use -g watchexec@latest
对于无内置监听器的运行时(Go、Rust、Shell)或多语言编排场景,使用
mise watch
bash
mise watch build  # Re-run on source changes
需要安装
watchexec
mise use -g watchexec@latest

Watch Options

监听选项

bash
mise watch build --debounce 500ms  # Wait before re-run
mise watch build --restart          # Kill and restart on change
mise watch build --clear            # Clear screen before run
bash
mise watch build --debounce 500ms  # Wait before re-run
mise watch build --restart          # Kill and restart on change
mise watch build --clear            # Clear screen before run

On-Busy Behavior

任务运行中的行为

bash
mise watch build --on-busy-update=queue    # Queue changes
mise watch build --on-busy-update=restart  # Restart immediately
mise watch build --on-busy-update=do-nothing  # Ignore (default)

bash
mise watch build --on-busy-update=queue    # Queue changes
mise watch build --on-busy-update=restart  # Restart immediately
mise watch build --on-busy-update=do-nothing  # Ignore (default)

Level 10: Monorepo (Experimental)

10级:单仓库多项目(实验性)

Requires:
MISE_EXPERIMENTAL=1
and
experimental_monorepo_root = true
要求
MISE_EXPERIMENTAL=1
experimental_monorepo_root = true

Path Syntax

路径语法

bash
mise run //projects/frontend:build    # Absolute from root
mise run :build                       # Current config_root
mise run //...:test                   # All projects
bash
mise run //projects/frontend:build    # Absolute from root
mise run :build                       # Current config_root
mise run //...:test                   # All projects

Wildcards

通配符

bash
mise run '//projects/...:build'       # Build all under projects/
mise run '//projects/frontend:*'      # All tasks in frontend
bash
mise run '//projects/...:build'       # Build all under projects/
mise run '//projects/frontend:*'      # All tasks in frontend

Discovery

自动发现

Tasks in subdirectories are auto-discovered with path prefix:
  • packages/api/.mise.toml
    tasks →
    packages/api:taskname
For complete monorepo documentation, see: advanced.md

子目录中的任务会自动被发现并添加路径前缀:
  • packages/api/.mise.toml
    中的任务 →
    packages/api:taskname
完整的单仓库多项目文档请查看:advanced.md

Level 11: Polyglot Monorepo with Pants + mise

11级:多语言单仓库与Pants + mise结合

For Python-heavy polyglot monorepos (10-50 packages), combine mise for runtime management with Pants for build orchestration and native affected detection.
针对Python为主的多语言单仓库(10-50个包),可结合mise进行运行时管理,Pants进行构建编排和原生受影响检测。

Division of Responsibility

职责划分

ToolResponsibility
miseRuntime versions (Python, Node, Rust) + environment variables
PantsBuild orchestration + native affected detection + dependency inference
工具职责
mise运行时版本管理(Python、Node、Rust) + 环境变量配置
Pants构建编排 + 原生受影响检测 + 依赖推导

Architecture

架构

monorepo/
├── mise.toml                    # Runtime versions + env vars (SSoT)
├── pants.toml                   # Pants configuration
├── BUILD                        # Root BUILD file (minimal)
├── packages/
│   ├── core-python/
│   │   ├── mise.toml           # Package-specific env (optional)
│   │   └── BUILD               # Auto-generated: python_sources()
│   ├── core-rust/
│   │   └── BUILD               # cargo-pants plugin
│   └── core-bun/
│       └── BUILD               # pants-js plugin
monorepo/
├── mise.toml                    # Runtime versions + env vars (SSoT)
├── pants.toml                   # Pants configuration
├── BUILD                        # Root BUILD file (minimal)
├── packages/
│   ├── core-python/
│   │   ├── mise.toml           # Package-specific env (optional)
│   │   └── BUILD               # Auto-generated: python_sources()
│   ├── core-rust/
│   │   └── BUILD               # cargo-pants plugin
│   └── core-bun/
│       └── BUILD               # pants-js plugin

Pants Native Affected Detection

Pants原生受影响检测

No more manual git scripts - Pants has native affected detection:
bash
undefined
无需再编写手动git脚本 - Pants内置受影响检测:
bash
undefined

Test only affected packages (NATIVE)

Test only affected packages (NATIVE)

pants --changed-since=origin/main test
pants --changed-since=origin/main test

Lint only affected packages

Lint only affected packages

pants --changed-since=origin/main lint
pants --changed-since=origin/main lint

Build only affected packages

Build only affected packages

pants --changed-since=origin/main package
pants --changed-since=origin/main package

See what's affected (dry run)

See what's affected (dry run)

pants --changed-since=origin/main list
undefined
pants --changed-since=origin/main list
undefined

mise.toml Wrapper Tasks (Optional Convenience)

mise.toml包装任务(可选便捷方式)

toml
[tasks."test:affected"]
description = "Test affected packages via Pants"
run = "pants --changed-since=origin/main test"

[tasks."lint:affected"]
description = "Lint affected packages via Pants"
run = "pants --changed-since=origin/main lint"

[tasks.test-all]
description = "Test all packages"
run = "pants test ::"

[tasks."pants:tailor"]
description = "Generate BUILD files"
run = "pants tailor"
toml
[tasks."test:affected"]
description = "Test affected packages via Pants"
run = "pants --changed-since=origin/main test"

[tasks."lint:affected"]
description = "Lint affected packages via Pants"
run = "pants --changed-since=origin/main lint"

[tasks.test-all]
description = "Test all packages"
run = "pants test ::"

[tasks."pants:tailor"]
description = "Generate BUILD files"
run = "pants tailor"

pants.toml Minimal Config

pants.toml最简配置

toml
[GLOBAL]
pants_version = "<version>"
backend_packages = [
    "pants.backend.python",
    "pants.backend.python.lint.ruff",
    "pants.backend.experimental.rust",
    "pants.backend.experimental.javascript",
]

[python]
interpreter_constraints = [">=3.11"]

[source]
root_patterns = ["packages/*"]

[python-bootstrap]
toml
[GLOBAL]
pants_version = "<version>"
backend_packages = [
    "pants.backend.python",
    "pants.backend.python.lint.ruff",
    "pants.backend.experimental.rust",
    "pants.backend.experimental.javascript",
]

[python]
interpreter_constraints = [">=3.11"]

[source]
root_patterns = ["packages/*"]

[python-bootstrap]

Use mise-managed Python (mise sets PATH)

Use mise-managed Python (mise sets PATH)

search_path = ["<PATH>"]
undefined
search_path = ["<PATH>"]
undefined

When to Use Pants + mise

何时使用Pants + mise

ScaleRecommendation
< 10 packagesmise + custom affected (Level 10 patterns)
10-50 packages (Python-heavy)Pants + mise (this section)
50+ packagesConsider Bazel
→ See polyglot-affected.md for complete Pants + mise integration guide and tool comparison

规模推荐方案
< 10个包mise + 自定义受影响检测(10级模式)
10-50个包(Python为主)Pants + mise(本节方案)
50+个包考虑使用Bazel
→ 完整的Pants + mise集成指南和工具对比请查看polyglot-affected.md

Integration with [env]

与[env]区块的集成

Tasks automatically inherit
[env]
values:
toml
[env]
DATABASE_URL = "postgresql://localhost/mydb"
_.file = ".env"  # Load additional env vars

[tasks.migrate]
run = "diesel migration run"  # $DATABASE_URL available
任务会自动继承
[env]
中的值:
toml
[env]
DATABASE_URL = "postgresql://localhost/mydb"
_.file = ".env"  # Load additional env vars

[tasks.migrate]
run = "diesel migration run"  # $DATABASE_URL available

Credential Loading Pattern

凭据加载模式

toml
[env]
_.file = { path = ".env.secrets", redact = true }

[tasks._check-env]
hide = true
run = '[ -n "$API_KEY" ] || { echo "Missing API_KEY"; exit 1; }'

[tasks.deploy]
depends = ["_check-env"]
run = "deploy.sh"

toml
[env]
_.file = { path = ".env.secrets", redact = true }

[tasks._check-env]
hide = true
run = '[ -n "$API_KEY" ] || { echo "Missing API_KEY"; exit 1; }'

[tasks.deploy]
depends = ["_check-env"]
run = "deploy.sh"

Anti-Patterns

反模式

Anti-PatternWhy BadInstead
Replace /itp:go with mise tasksNo TodoWrite, no ADR tracking, no checkpointsUse mise tasks for project workflows, /itp:go for ADR-driven development
Hardcode secrets in tasksSecurity riskUse
_.file = ".env.secrets"
with
redact = true
Giant monolithic tasksHard to debug, no reuseBreak into small tasks with dependencies
Skip or minimal
description
AI agents cannot infer task purpose from name aloneWrite rich descriptions: what it does, requires, produces, when to run
Publish without build
depends
Runtime failure instead of DAG preventionAdd
depends = ["build"]
to publish tasks
Orchestrator without all phases"Run X next" messages get ignoredInclude all phases in
release:full
depends array
For release-specific anti-patterns and patterns, see Release Workflow Patterns.

反模式弊端替代方案
用mise tasks替代/itp:go无TodoWrite支持、无ADR追踪、无检查点mise tasks用于项目工作流,/itp:go用于ADR驱动的开发
在任务中硬编码凭据存在安全风险使用
_.file = ".env.secrets"
并设置
redact = true
巨型单体任务难以调试、无法复用拆分为带依赖的小型任务
省略或极简
description
AI Agent仅通过名称无法推断任务用途撰写详细描述:包含任务作用、所需依赖、产出、执行时机
发布任务未添加build依赖运行时失败而非提前通过DAG阻止为发布任务添加
depends = ["build"]
编排器未包含所有阶段"接下来执行X"的提示会被忽略将所有阶段包含在
release:full
的depends数组中
发布相关的反模式和最佳实践请查看Release Workflow Patterns

Cross-Reference: mise-configuration

交叉参考:mise-configuration

Prerequisites: Before defining tasks, ensure
[env]
section is configured.
PRESCRIPTIVE: After defining tasks, invoke
mise-configuration
skill
to ensure [env] SSoT patterns are applied.
The
mise-configuration
skill covers:
  • [env]
    - Environment variables with defaults
  • [settings]
    - mise behavior configuration
  • [tools]
    - Version pinning
  • Special directives:
    _.file
    ,
    _.path
    ,
    _.python.venv

前置条件:定义任务前,请确保
[env]
区块已配置完成。
推荐操作:定义任务后,调用**
mise-configuration
技能
**确保[env]单一可信源模式已应用。
mise-configuration
技能涵盖:
  • [env]
    - 带默认值的环境变量配置
  • [settings]
    - mise行为配置
  • [tools]
    - 版本固定
  • 特殊指令:
    _.file
    _.path
    _.python.venv

Additional Resources

额外资源

  • Task Patterns - Real-world task examples
  • Task Arguments - Complete usage spec reference
  • Advanced Features - Monorepo, watch, experimental
  • Polyglot Affected - Pants + mise integration guide and tool comparison
  • Bootstrap Monorepo - Autonomous polyglot monorepo bootstrap meta-prompt
  • Release Workflow Patterns - Release task DAG patterns, build-before-publish enforcement

  • Task Patterns - 真实场景任务示例
  • Task Arguments - 完整usage规范参考
  • Advanced Features - 单仓库多项目、监听模式、实验性功能
  • Polyglot Affected - Pants + mise集成指南和工具对比
  • Bootstrap Monorepo - 自治式多语言单仓库初始化元提示
  • Release Workflow Patterns - 发布任务DAG模式、构建前置发布强制校验

Troubleshooting

故障排查

IssueCauseSolution
Task not foundTypo or wrong mise.tomlRun
mise tasks
to list available tasks
Dependencies not runCircular dependencyCheck task depends arrays for cycles
Sources not workingWrong glob patternUse relative paths from mise.toml location
Watch not triggeringFile outside sources listAdd file pattern to sources array
Env vars not availableTask in wrong directoryEnsure mise.toml is in cwd or parent
Run fails with errorScript path issueUse absolute path or relative to mise.toml
问题原因解决方案
任务未找到拼写错误或mise.toml路径错误执行
mise tasks
查看可用任务
依赖未执行循环依赖检查任务的depends数组是否存在循环
源文件追踪不生效通配符路径错误使用相对于mise.toml位置的相对路径
监听未触发文件不在sources列表中将文件路径添加到sources数组
环境变量不可用任务所在目录错误确保mise.toml位于当前工作目录或父目录
运行失败报错脚本路径问题使用绝对路径或相对于mise.toml的相对路径