0
# Task Execution
1
2
Core task execution functionality for running scripts across monorepo packages with intelligent scheduling, dependency management, and parallel execution.
3
4
## Capabilities
5
6
### Run Command
7
8
Execute tasks across packages in your monorepo with intelligent dependency resolution and caching.
9
10
```bash { .api }
11
turbo run <tasks...> [options]
12
turbo <tasks...> [options] # shorthand form
13
14
# Execute specific tasks
15
turbo run build test lint
16
17
# Execute with package filtering
18
turbo run build --filter="@myorg/web-app"
19
20
# Execute in parallel
21
turbo run build --parallel
22
23
# Execute with custom concurrency
24
turbo run build --concurrency=5
25
```
26
27
**Task Execution Options:**
28
29
```bash { .api }
30
# Execution control
31
--concurrency <number> # Limit task concurrency (default: 10)
32
--continue[=<mode>] # Continue on errors (never|dependencies-successful|always, default: never)
33
--parallel # Execute all tasks in parallel
34
--only # Only execute specified tasks, skip dependencies
35
36
# Package selection
37
--filter <selector> / -F # Package selector (pnpm syntax)
38
--affected # Only run affected packages
39
--single-package # Run in single-package mode
40
41
# Environment and dependencies
42
--env-mode <mode> # Environment mode (strict|loose)
43
--framework-inference <bool> # Enable/disable framework inference
44
--global-deps <glob> # Global file dependencies
45
```
46
47
**Usage Examples:**
48
49
```bash
50
# Basic task execution
51
turbo run build
52
53
# Multiple tasks with dependency resolution
54
turbo run build test lint
55
56
# Run tasks for specific packages
57
turbo run build --filter="./apps/web"
58
turbo run test --filter="@myorg/ui-lib"
59
60
# Run tasks for changed packages only
61
turbo run build --filter="...[HEAD~1]"
62
63
# Execute with custom environment mode
64
turbo run build --env-mode=loose
65
66
# Run tasks in strict serial execution
67
turbo run build --concurrency=1
68
69
# Continue execution even if some tasks fail
70
turbo run test --continue=dependencies-successful
71
```
72
73
### Watch Command
74
75
EXPERIMENTAL: Watch for file changes and automatically re-run tasks.
76
77
```bash { .api }
78
turbo watch <tasks...> [options]
79
80
# Watch for changes and re-run build
81
turbo watch build
82
83
# Watch with custom cache behavior
84
turbo watch build --experimental-write-cache
85
```
86
87
**Watch Options:**
88
89
```bash { .api }
90
# Watch-specific options
91
--experimental-write-cache # Write to cache in watch mode
92
93
# All task execution options are also available
94
--filter <selector> # Package filtering
95
--concurrency <number> # Concurrency control
96
--env-mode <mode> # Environment mode
97
```
98
99
### Output and Logging
100
101
Control how task output is displayed and logged during execution.
102
103
```bash { .api }
104
# Output control
105
--output-logs <mode> # Log output mode (full|none|hash-only|new-only|errors-only)
106
--log-order <mode> # Log ordering (auto|stream|grouped)
107
--log-prefix <mode> # Log prefix mode (auto|none|task)
108
```
109
110
**Output Mode Options:**
111
112
- `full` - Show all task output (default)
113
- `none` - Hide all task output, show only hashes
114
- `hash-only` - Show only task hashes for cached results
115
- `new-only` - Show output only for newly executed tasks
116
- `errors-only` - Show output only for failed tasks
117
118
**Log Order Options:**
119
120
- `auto` - Let turbo decide based on environment (default)
121
- `stream` - Show output as soon as available
122
- `grouped` - Show output after task completion
123
124
**Usage Examples:**
125
126
```bash
127
# Show only errors during execution
128
turbo run build --output-logs=errors-only
129
130
# Group output by task
131
turbo run build test --log-order=grouped
132
133
# Disable task prefixes
134
turbo run build --log-prefix=none
135
```
136
137
### Task Arguments
138
139
Pass arguments through to the underlying tasks being executed.
140
141
```bash { .api }
142
turbo run <tasks> [options] -- [forwarded-args...]
143
144
# Pass arguments to npm scripts
145
turbo run test -- --coverage --watch
146
147
# Pass multiple arguments
148
turbo run build -- --production --source-maps
149
```
150
151
**Usage Examples:**
152
153
```bash
154
# Pass Jest arguments to test scripts
155
turbo run test -- --coverage --verbose
156
157
# Pass webpack arguments to build scripts
158
turbo run build -- --mode=production --analyze
159
160
# Pass arguments to multiple tasks
161
turbo run build test -- --production
162
```
163
164
### Dry Run
165
166
Preview what tasks would be executed without actually running them.
167
168
```bash { .api }
169
--dry-run <mode> # Dry run mode (text|json)
170
--dry / --dry-run # Shorthand for text mode
171
172
# Preview task execution
173
turbo run build --dry-run
174
175
# Get JSON output for programmatic use
176
turbo run build --dry-run=json
177
```
178
179
**Usage Examples:**
180
181
```bash
182
# Preview what would be executed
183
turbo run build test --dry-run
184
185
# Get structured output for automation
186
turbo run build --filter="@myorg/*" --dry-run=json
187
```
188
189
## Task Configuration Types
190
191
```typescript { .api }
192
interface ExecutionArgs {
193
tasks: string[];
194
cache_dir?: string;
195
concurrency?: string;
196
continue_execution: "never" | "dependencies-successful" | "always";
197
single_package: boolean;
198
framework_inference: boolean;
199
global_deps: string[];
200
env_mode?: "loose" | "strict";
201
filter: string[];
202
affected: boolean;
203
output_logs?: "full" | "none" | "hash-only" | "new-only" | "errors-only";
204
log_order?: "auto" | "stream" | "grouped";
205
only: boolean;
206
log_prefix: "auto" | "none" | "task";
207
pass_through_args: string[];
208
}
209
210
interface RunArgs extends ExecutionArgs {
211
cache?: string;
212
force?: boolean;
213
remote_only?: boolean;
214
remote_cache_read_only?: boolean;
215
no_cache: boolean;
216
cache_workers: number;
217
dry_run?: "text" | "json";
218
graph?: string;
219
daemon?: boolean;
220
no_daemon?: boolean;
221
profile?: string;
222
anon_profile?: string;
223
summarize?: boolean;
224
parallel: boolean;
225
}
226
```