magus-run
Run a target for selected projects
Synopsis
magus run <target> [flags] [project...]
Description
Run a named target for the selected projects. With no project arguments, selects the project containing the current directory, or all projects if the current directory is not inside a project. Explicit project paths on the command line select exactly those projects.
--skip subtracts from whatever that selection resolved to, so a CI step can gate every project except a named few without any shell filtering. It takes the same project reference a positional does, and refuses a reference no project matches rather than skipping nothing quietly.
The target ci is an ordinary magusfile-defined target - magus does not hardcode its steps; your magusfile composes them with magus.needs. magus keeps ci as the anchor that the affected set keys off, and always runs it read-only; apply the rw charm (e.g. 'magus run format:rw') to mutate files.
Options
- --depth int
- With --graph: cap displayed depth (0 = unlimited)
- --detach
- Hand the run to the daemon and return immediately; follow it with magus status --watch
- --graph
- Render the dependency graph for the selected scope instead of executing
- --n-shards int
- Total shard count for this CI matrix run; paired with --shard
- --no-cache
- Force a fresh run even on a cache hit; still refreshes the entry
- --no-default-charms
- Ignore magus.yaml default_charms for this run
- --no-redundancy-check
- Run the ci gate even when an identical-or-equivalent gate already passed for this branch on this machine (MGS3010); ci target only
- --no-volatility-retry
- Disable volatility auto-retry for this run
- --open
- Open this run in the browser log viewer and stream to it as it goes (loopback; never leaves your machine)
- --race string
- Race-condition diagnostics (watch|replay, comma-combinable); omit to disable. watch: attribution-gated fsnotify detection (MGS4001/4002/4004), emitting only when >=2 projects' output snapshots confirm a shared write. replay: re-runs cacheable output-declaring projects sequentially to content-hash outputs for non-determinism (MGS4003); roughly doubles wall-clock.
- --shard string
- This run's shard index within a CI matrix; paired with --n-shards
- --skip string
- Exclude projects from the selection; repeatable or comma-separated. Takes project references like positionals, or a doublestar glob over project paths (libs/*); a value matching nothing is an error
- --step
- Pause before each subprocess for interactive stepping (needs a TTY; implies --concurrency=1)
- --timeout duration
- Abort if the run has not finished within this duration (e.g. 5m, 1h30m)
- --upstream
- With --graph: show dependents instead of dependencies
- --wait
- With --detach, block until the run finishes and exit with its status
Targets
- ls
- Print selected projects without executing anything
- build
- Build selected projects
- test
- Test selected projects
- lint
- Lint selected projects (read-only)
- format
- Format source files in selected projects
- clean
- Remove declared outputs from selected projects
- generate
- Run code generation for selected projects
- ci
- Run the magusfile's ci target read-only (affected-set anchor)
Exit status
- 0
- Every selected project's target succeeded, whether it ran or replayed from cache.
- 1
- At least one target failed. The failure was already reported with the path to its captured log, so there is no second error line here. This is the default failure status, not the only one: a magusfile calling os.exit(code) has that code honored verbatim, so a target may exit with a status this list does not name.
- 2
- Misuse: an unknown target, no project matched the filters, or a flag that does not apply to this invocation.
- 75
- Nothing ran, and trying again later would succeed; 75 is EX_TEMPFAIL, the transient-failure convention. Either MAGUS_NO_WAIT found a selected project's workspace lock held by another magus process (the error names the holding pid, command and directory), or a ci gate was deferred as redundant under load (MGS3010; the error names the green gate it found and --no-redundancy-check overrides).
Examples
Build everything
magus run build
Test one project
magus run test api/gateway
Build two specific projects
magus run build api/gateway web/studio
Every project that declares generate except two
magus run generate --skip docs --skip console
Dry-run: show what would run
magus run build --dry-run
Force a fresh rebuild past a cache hit
magus run build --no-cache
Full CI pipeline
magus run ci
Show dependency graph for build target
magus run build --graph
Graph in Mermaid format
magus run build --graph -o mermaid
Graph dependents of api/gateway
magus run build api/gateway --graph --upstream
Stream JSONL target events to a file
magus run build -o jsonl --tee build.jsonl
See Also
magus(1), magus-ls(1), magus-describe(1), magus-x(1), magus-where(1), magus-affected(1), magus-graph(1), magus-query(1), magus-explain(1), magus-path(1), magus-refs(1), magus-watch(1), magus-events(1), magus-status(1), magus-clean(1), magus-vcs(1), magus-doctor(1), magus-config(1), magus-session(1), magus-memory(1), magus-notes(1), magus-diff(1), magus-server(1), magus-mcp(1), magus-buzz(1), magus-completion(1), magus-man(1), magus-init(1), magus-agent(1), magus-self(1), magus-version(1)