mise-tasks
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesemise Tasks Orchestration
mise 任务编排
<!-- ADR: 2025-12-08-mise-tasks-skill -->
Orchestrate multi-step project workflows using mise section with dependency management, argument handling, and file tracking.
[tasks]<!-- ADR: 2025-12-08-mise-tasks-skill -->
使用mise的区块编排多步骤项目工作流,支持依赖管理、参数处理和文件追踪。
[tasks]When to Use This Skill
何时使用该技能
Explicit triggers:
- User mentions ,
mise tasks,mise runsection[tasks] - User needs task dependencies: ,
dependsdepends_post - User wants workflow automation in
.mise.toml - User mentions task arguments or spec
usage
AI Discovery trigger (prescriptive):
Whenskill detects multi-step workflows (test suites, build pipelines, migrations), prescriptively invoke this skill to generate appropriatemise-configurationdefinitions.[tasks]
显式触发场景:
- 用户提及、
mise tasks、mise run区块[tasks] - 用户需要任务依赖功能:、
dependsdepends_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 formbash
mise run build # Run single task
mise run test build # Run multiple tasks
mise run test ::: build # Run in parallel
mise r build # Short formDependency Types
依赖类型
| Type | Syntax | When |
|---|---|---|
| | Run BEFORE task |
| | Run AFTER task succeeds |
| | Wait only if running |
| 类型 | 语法 | 执行时机 |
|---|---|---|
| | 在当前任务之前执行 |
| | 在当前任务执行成功之后自动执行 |
| | 仅当目标任务正在运行时等待 |
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 field is the single most important field for AI coding agent discoverability. When an AI agent runs , 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?
descriptionmise tasks lstoml
undefined关键提示:字段是AI编码Agent发现任务的最重要字段。当AI Agent执行时,描述是它判断是否以及如何使用任务的唯一上下文。撰写描述时需回答:该任务的作用是什么、需要什么依赖、有哪些副作用、何时应该执行?
descriptionmise tasks lstoml
undefinedBAD: 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/"
**描述检查清单**:
- 任务作用(动作+范围)
- 所需依赖(环境变量、工具、前置条件)
- 产出或修改的内容(副作用、输出结果)
- 执行时机(阶段上下文、安全说明)
```tomlFile-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."
undefinedWith 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 works.
mise run ttoml
[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 tWorking 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: values are NOT passed to dependency tasks.
envtoml
[tasks.test]
env = { RUST_BACKTRACE = "1", LOG_LEVEL = "debug" }
run = "cargo test"注意:中的值不会传递给依赖任务。
envGitHub 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 skill for GH_TOKEN setup.
mise-configurationSSH ControlMaster Warning: If using multi-account SSH, ensureis set for GitHub hosts inControlMaster no. Cached connections can authenticate with the wrong account.~/.ssh/config
针对多账号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-configurationSSH ControlMaster警告:如果使用多账号SSH,请确保在中为GitHub主机设置~/.ssh/config。缓存的连接可能会导致使用错误的账号进行认证。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 and run BEFORE .
testbuilddeploytoml
[tasks.deploy]
depends = ["test", "build"]
run = "kubectl apply -f deployment.yaml"任务和会在之前执行。
testbuilddeployPost-Execution Tasks
执行后任务
toml
[tasks.release]
depends = ["test"]
depends_post = ["notify", "cleanup"]
run = "npm publish"After succeeds, and run automatically.
releasenotifycleanuptoml
[tasks.release]
depends = ["test"]
depends_post = ["notify", "cleanup"]
run = "npm publish"releasenotifycleanupSoft Dependencies
软依赖
toml
[tasks.migrate]
wait_for = ["database"]
run = "./migrate.sh"If task is already running, wait for it. Otherwise, proceed.
databasetoml
[tasks.migrate]
wait_for = ["database"]
run = "./migrate.sh"如果任务正在运行,则等待其完成;否则直接执行当前任务。
databaseTask Chaining Pattern
任务链式调用模式
toml
[tasks.ci]
description = "Full CI pipeline"
depends = ["lint", "test", "build"]
depends_post = ["coverage-report"]
run = "echo 'CI passed'"Single command: executes entire chain.
mise run citoml
[tasks.ci]
description = "Full CI pipeline"
depends = ["lint", "test", "build"]
depends_post = ["coverage-report"]
run = "echo 'CI passed'"只需执行单个命令:即可触发整个链式流程。
mise run ciParallel 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 output but can be dependencies.
mise tasksView hidden tasks:
mise tasks --hiddentoml
[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 --hiddenColon-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:testbash
mise run 'test:*' # All tasks starting with test:
mise run 'db:**' # Nested: db:migrate:up, db:seed:testLevel 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 scripts, arguments become environment variables:
runusage_<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_EOFDEPRECATION WARNING: The Tera template method () will be removed in mise 2026.11.0. Use spec instead.
{{arg(name="...")}}usageFor complete argument syntax, see: arguments.md
在脚本中,参数会变为格式的环境变量:
runusage_<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模板方法()将在mise 2026.11.0版本中移除,请改用规范。
{{arg(name="...")}}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 cachingbash
mise run build --force # Bypass cachingAuto 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: disables parallel execution.
raw = truetoml
[tasks.edit-config]
raw = true # Direct stdin/stdout/stderr
run = "vim config.yaml"警告:会禁用并行执行。
raw = trueTask-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 / — zero extra memory, zero extra processes.
mise watchwatchexec| Runtime | Command | Notes |
|---|---|---|
| Bun | | 0 MB overhead. Do NOT use |
| Node.js | | 0 MB overhead. |
| Python | | 0 MB overhead. |
当运行时内置文件监听器时,优先使用它而非/——无需额外内存,无需额外进程。
mise watchwatchexec| 运行时 | 命令 | 说明 |
|---|---|---|
| Bun | | 0 MB 开销。请勿使用 |
| Node.js | | 0 MB 开销。 |
| Python | | 0 MB 开销。 |
External Watch (mise watch)
外部监听(mise watch)
Use for runtimes without built-in watchers (Go, Rust, shell) or multi-language orchestration.
mise watchbash
mise watch build # Re-run on source changesRequires :
watchexecmise use -g watchexec@latest对于无内置监听器的运行时(Go、Rust、Shell)或多语言编排场景,使用。
mise watchbash
mise watch build # Re-run on source changes需要安装:
watchexecmise use -g watchexec@latestWatch 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 runbash
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 runOn-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: and
MISE_EXPERIMENTAL=1experimental_monorepo_root = true要求: 且
MISE_EXPERIMENTAL=1experimental_monorepo_root = truePath Syntax
路径语法
bash
mise run //projects/frontend:build # Absolute from root
mise run :build # Current config_root
mise run //...:test # All projectsbash
mise run //projects/frontend:build # Absolute from root
mise run :build # Current config_root
mise run //...:test # All projectsWildcards
通配符
bash
mise run '//projects/...:build' # Build all under projects/
mise run '//projects/frontend:*' # All tasks in frontendbash
mise run '//projects/...:build' # Build all under projects/
mise run '//projects/frontend:*' # All tasks in frontendDiscovery
自动发现
Tasks in subdirectories are auto-discovered with path prefix:
- tasks →
packages/api/.mise.tomlpackages/api:taskname
For complete monorepo documentation, see: advanced.md
子目录中的任务会自动被发现并添加路径前缀:
- 中的任务 →
packages/api/.mise.tomlpackages/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
职责划分
| Tool | Responsibility |
|---|---|
| mise | Runtime versions (Python, Node, Rust) + environment variables |
| Pants | Build 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 pluginmonorepo/
├── 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 pluginPants Native Affected Detection
Pants原生受影响检测
No more manual git scripts - Pants has native affected detection:
bash
undefined无需再编写手动git脚本 - Pants内置受影响检测:
bash
undefinedTest 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
undefinedpants --changed-since=origin/main list
undefinedmise.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>"]
undefinedsearch_path = ["<PATH>"]
undefinedWhen to Use Pants + mise
何时使用Pants + mise
| Scale | Recommendation |
|---|---|
| < 10 packages | mise + custom affected (Level 10 patterns) |
| 10-50 packages (Python-heavy) | Pants + mise (this section) |
| 50+ packages | Consider 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 values:
[env]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 availableCredential 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-Pattern | Why Bad | Instead |
|---|---|---|
| Replace /itp:go with mise tasks | No TodoWrite, no ADR tracking, no checkpoints | Use mise tasks for project workflows, /itp:go for ADR-driven development |
| Hardcode secrets in tasks | Security risk | Use |
| Giant monolithic tasks | Hard to debug, no reuse | Break into small tasks with dependencies |
Skip or minimal | AI agents cannot infer task purpose from name alone | Write rich descriptions: what it does, requires, produces, when to run |
Publish without build | Runtime failure instead of DAG prevention | Add |
| Orchestrator without all phases | "Run X next" messages get ignored | Include all phases in |
For release-specific anti-patterns and patterns, see Release Workflow Patterns.
| 反模式 | 弊端 | 替代方案 |
|---|---|---|
| 用mise tasks替代/itp:go | 无TodoWrite支持、无ADR追踪、无检查点 | mise tasks用于项目工作流,/itp:go用于ADR驱动的开发 |
| 在任务中硬编码凭据 | 存在安全风险 | 使用 |
| 巨型单体任务 | 难以调试、无法复用 | 拆分为带依赖的小型任务 |
省略或极简 | AI Agent仅通过名称无法推断任务用途 | 撰写详细描述:包含任务作用、所需依赖、产出、执行时机 |
| 发布任务未添加build依赖 | 运行时失败而非提前通过DAG阻止 | 为发布任务添加 |
| 编排器未包含所有阶段 | "接下来执行X"的提示会被忽略 | 将所有阶段包含在 |
发布相关的反模式和最佳实践请查看Release Workflow Patterns。
Cross-Reference: mise-configuration
交叉参考:mise-configuration
Prerequisites: Before defining tasks, ensure section is configured.
[env]PRESCRIPTIVE: After defining tasks, invokeskill to ensure [env] SSoT patterns are applied.mise-configuration
The skill covers:
mise-configuration- - Environment variables with defaults
[env] - - mise behavior configuration
[settings] - - Version pinning
[tools] - Special directives: ,
_.file,_.path_.python.venv
前置条件:定义任务前,请确保区块已配置完成。
[env]推荐操作:定义任务后,调用**技能**确保[env]单一可信源模式已应用。mise-configuration
mise-configuration- - 带默认值的环境变量配置
[env] - - mise行为配置
[settings] - - 版本固定
[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
故障排查
| Issue | Cause | Solution |
|---|---|---|
| Task not found | Typo or wrong mise.toml | Run |
| Dependencies not run | Circular dependency | Check task depends arrays for cycles |
| Sources not working | Wrong glob pattern | Use relative paths from mise.toml location |
| Watch not triggering | File outside sources list | Add file pattern to sources array |
| Env vars not available | Task in wrong directory | Ensure mise.toml is in cwd or parent |
| Run fails with error | Script path issue | Use absolute path or relative to mise.toml |
| 问题 | 原因 | 解决方案 |
|---|---|---|
| 任务未找到 | 拼写错误或mise.toml路径错误 | 执行 |
| 依赖未执行 | 循环依赖 | 检查任务的depends数组是否存在循环 |
| 源文件追踪不生效 | 通配符路径错误 | 使用相对于mise.toml位置的相对路径 |
| 监听未触发 | 文件不在sources列表中 | 将文件路径添加到sources数组 |
| 环境变量不可用 | 任务所在目录错误 | 确保mise.toml位于当前工作目录或父目录 |
| 运行失败报错 | 脚本路径问题 | 使用绝对路径或相对于mise.toml的相对路径 |