Mark Pitt
claude-skills
  1. claude-skills
  2. Developer environment
  3. mise
  4. references/task-runner.md

A file in mise

references/task-runner.md

Markdown 9.3 KB
task-runner.mdMarkdown, rendered

Mise Task Runner

Mise includes a built-in task runner that replaces Makefile, package.json scripts, and just. Tasks are defined in mise.toml and run with mise run <task>. They automatically inherit the tool versions and environment variables from mise.toml.

---

Defining Tasks

Inline Tasks

Short tasks defined directly in mise.toml:

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

[tasks.test]
description = "Run tests"
run = "cargo test"

[tasks.lint]
description = "Run linter"
run = "cargo clippy"

Multi-line Tasks

[tasks.setup]
description = "Full project setup"
run = """
npm install
dotnet restore ./src/MyApp.sln
echo "Setup complete"
"""

Task with Arguments (Preferred: usage)

Prefer usage to declare task arguments and flags. Values are exposed as $usage_<name> environment variables.

[tasks.greet]
description = "Greet a person"
usage = 'arg "<name>" help="Name to greet"'
run = 'echo "Hello, ${usage_name?}"'
mise run greet Alice

Use this same pattern for dynamic inputs like per-skill testing:

[tasks."skill:test:skill"]
description = "Run tests for one skill"
usage = 'arg "<skill>" help="Skill name (kebab-case)"'
run = 'mise run skill:test:triggers:skill "${usage_skill?}"'

Important: mise supports dynamic input values (arguments), but not wildcard dynamic task names unless you predefine each task name.

---

Task Properties

PropertyTypeDescription
descriptionstringHuman-readable summary shown in mise run --list
runstring or arrayShell command(s) to execute
dependsarrayTask names that must complete before this task
depends_postarrayTask names to run after this task completes
wait_forarrayDefer to already-running tasks without requiring them (no error if not running)
envtableExtra environment variables for this task only
dirstringWorking directory (default: project root)
sourcesarrayFile globs; task is skipped if sources unchanged
outputsarrayFile globs for output artifacts
shellstringOverride the shell used (e.g., powershell, bash)
hideboolHide from mise run --list (still runnable directly)
rawboolStream output unbuffered; disables parallel execution (for interactive tasks)
outputstringOutput mode: prefix (default), interleave, or quiet

---

Task Dependencies

Use depends to declare task prerequisites. Mise runs independent dependencies in parallel by default.

[tasks.build]
run = "dotnet build ./src/MyApp.sln"

[tasks.frontend]
run = "npm run build --prefix ./src/Frontend"

[tasks.test]
description = "Run all tests"
depends = ["build", "frontend"]   # runs build and frontend in parallel, then test
run = "dotnet test && npx playwright test"

[tasks.ci]
description = "Full CI pipeline"
depends = ["test", "lint"]
run = "echo CI complete"

Sequential Dependencies

For dependencies that must run in order, use depends_post or chain with && inside run:

[tasks.release]
depends = ["test"]           # test runs first
run = "cargo build --release && cargo publish"

---

Running Tasks

# Run a task
mise run build
mise run test
mise run ci

# List all tasks with descriptions
mise run --list
mise tasks ls      # alias

# Pass arguments to a task via usage schema
mise run deploy production --force

# Run multiple tasks (each can have its own args)
mise run lint ::: test ::: build
mise run unit-tests path/to/test_a.py ::: unit-tests path/to/test_b.py

# Run with verbose output
mise run --verbose build

# Dry run (show what would execute without running)
mise run --dry-run build

---

File-based Tasks

Tasks can also be defined as standalone script files in a mise/tasks/ or .mise/tasks/ directory. Mise discovers these automatically.

project/
├── mise.toml
└── mise/
    └── tasks/
        ├── build        # executable shell script
        ├── test.py      # Python script
        └── deploy.ts    # TypeScript script (requires deno or ts-node)

File tasks are made executable and run directly. The description is read from the first comment line of the file:

#!/usr/bin/env bash
# Builds the production Docker image
set -euo pipefail

docker build -t myapp:latest .

Use file tasks when:

  • The task logic is complex (many lines)
  • The task requires a specific language (Python, TypeScript)
  • You want the task to be independently testable

---

Skipping Unchanged Tasks (Source Tracking)

Mise can skip task execution if source files haven't changed since the last run. Similar to make file tracking.

[tasks.build]
sources = ["src/**/*.rs", "Cargo.toml"]
outputs = ["target/release/myapp"]
run = "cargo build --release"

Mise hashes the source files and only runs the task if they've changed.

---

Task Namespacing

Use colons to namespace tasks. Wildcards work in mise run:

# Define
[tasks."test:unit"]
[tasks."test:integration:local"]
[tasks."test:integration:ci"]

# Run with wildcard
mise run "test:**:local"   # matches test:integration:local
mise tasks ls              # shows all tasks including namespaced ones

---

Task Environment Variables

Every task run receives these automatic variables:

VariableValue
MISE_PROJECT_ROOTRoot directory (where the top-level mise.toml lives)
MISE_CONFIG_ROOTDirectory of the mise.toml that defined this task
MISE_ORIGINAL_CWDDirectory mise run was called from
MISE_TASK_NAMEName of the currently-running task
MISE_TASK_DIRDirectory of the task file (for file-based tasks)
MISE_TASK_FILEFull path to the task file (for file-based tasks)

Use MISE_PROJECT_ROOT in tasks to build paths that work regardless of where mise run is called from:

[tasks.build]
run = "dotnet build $MISE_PROJECT_ROOT/src/MyApp.sln"

---

Environment Variables in Tasks

Tasks inherit all environment variables from [env] in mise.toml. You can also add task-scoped variables:

[tasks.test-integration]
env = { TEST_DB_URL = "postgres://localhost/test_db", LOG_LEVEL = "debug" }
run = "pytest tests/integration"

---

Monorepo Task Support

For monorepos, mise supports running tasks across sub-projects. Requires experimental = true in settings.

# root mise.toml
[settings]
experimental = true

Monorepo Task Globs

# Run 'build' task in a specific app
mise //apps/frontend:build

# Run 'test' task in all packages
mise //packages/*:test

# Run 'lint' everywhere
mise //...:lint

Per-Package Task Definition

Each package has its own mise.toml with local task definitions:

monorepo/
├── mise.toml       # root config (shared tools, root tasks)
├── apps/
│   └── frontend/
│       └── mise.toml    # frontend-specific tasks
└── packages/
    └── ui/
        └── mise.toml    # UI library tasks

---

Usage: Tab Completion for Task Arguments

Mise bundles the Usage library for declaring task argument schemas, enabling shell tab-completion.

[tasks.deploy]
description = "Deploy to an environment"
usage = '''
  flag "-f --force" help="Force deployment even if health checks fail"
  flag "--dry-run" help="Print what would happen without deploying"
  arg "<env>" choices="staging|production" help="Target environment"
'''
run = """
if [ "$usage_force" = "true" ]; then
  echo "Force deploying to $usage_env"
fi
./scripts/deploy.sh "$usage_env"
"""

Arguments are available as $usage_<name> variables in the run command. Flags become $usage_force, $usage_dry_run, etc.

Notes:

  • The usage field is the recommended method for task arguments.
  • Older template-function styles are deprecated upstream.
  • For per-target workflows (for example one skill/package/service), use one stable task name plus a required arg "<target>" rather than duplicating many static task names.

Anti-patterns (Avoid)

  • Assuming wildcard task names exist: mise run skill:test:tdd-guru fails unless that exact task is explicitly defined.
  • Using positional shell args in TOML tasks: patterns like $1 are brittle; use usage and ${usage_target?} variables instead.
  • Duplicating dozens of near-identical tasks: prefer one argument-driven task (skill:test:skill <skill>) over many static aliases.
  • Mixing old template-function argument styles with usage: keep argument definitions in usage only for clarity and forward compatibility.

Enable completions in shell:

# Add to shell profile
eval "$(mise completion zsh)"
# or
eval "$(mise completion bash)"

---

Comparison with Alternatives

Featuremise tasksMakefilepackage.json scriptsjust
Environment variable sharingYes (from mise.toml)NoNoPartial
Dependency graphYesYesNoYes
Parallel executionYes (automatic)ManualNoManual
Cross-platformYesPartialYesYes
Tab completionYes (via Usage)NoNoYes
Language runtimesAutomaticNoManualNo
Monorepo supportYesNoPartialNo