Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Command Reference

Every command Kargo accepts. The status marker reflects what runs today — 🟢 implemented, 🟡 partial, ⚪ planned. Planned commands parse and then exit with "this command is not yet implemented". See Implementation Status.

Global flags

These work on every command.

FlagStatusEffect
-v, --verbose🟢Full compiler command lines and resolution detail.
-q, --quiet🟢Print only warnings and errors. Cannot be combined with -v.
--color <when>🟢auto (default), always, or never.

Exit codes

CodeMeaning
0Success
1Failure with no more specific code
2Command invoked incorrectly
3Manifest, lockfile, or config problem
4Dependency resolution failed
5Network or repository failure
6Missing or unusable toolchain
101Compilation, annotation processing, or test failure

kargo run exits with the status of the program it ran.

CommandStatusPurpose
new🟢Create a project
init🟢Add Kargo to an existing directory
build🟢Compile
run🟢Compile and execute
test🟡Run tests
check🟢Type-check only
clean🟢Remove build output
watch🟢Rebuild on change
add🟢Add a dependency
remove🟢Remove a dependency
update🟢Update locked versions
fetch🟢Download without building
lock🟢Regenerate the lockfile
tree🟢Print the dependency graph
outdated🟢Show available updates
audit🟢Scan for vulnerabilities
env🟢Show the resolved environment
toolchain🟢Manage Kotlin, JDK, and Android SDKs
cache🟢Manage the build cache and compile daemon
self🟢Manage the Kargo installation
lint⚪Run the linter
fmt⚪Format sources
fix⚪Apply auto-fixes
doc⚪Generate KDoc
bench⚪Run benchmarks
publish⚪Publish to a Maven repository
package⚪Create a distributable
repl⚪Kotlin REPL
script⚪Run a Kotlin script
metadata⚪Emit the project model as JSON
completions🟢Shell completions
plugin⚪Manage plugins
target⚪Manage targets
variant⚪Inspect build variants
flavor⚪Manage flavors
doctor⚪Diagnose project health
migrate⚪Migrate from Gradle
lsp⚪Language server

kargo new

🟢 Implemented.

kargo new <name> [-t|--template <template>]

Creates a directory named <name> containing a manifest, lockfile, .gitignore, .kargo.env, and source files.

ArgumentDefaultNotes
<name>requiredAlso the package name. Alphanumeric, -, _.
-t, --templatejvmjvm, lib, kmp, cmp, android

See Project Templates.

kargo init

🟢 Implemented.

kargo init [-t|--template <template>]

Adds Kargo to the current directory: manifest, lockfile, .gitignore, .kargo.env. Writes no source files and never overwrites an existing file.

kargo build

🟢 Implemented. 🟡 Flavor and variant flags are accepted but not yet applied.

kargo build [flags]
FlagStatusEffect
-t, --target <name>🟢Build one target.
-p, --profile <name>🟢Build with a named profile.
--release🟢Shorthand for --profile release.
--offline🟢Resolve only from the local cache.
--timings🟢Print per-phase timings.
--flavor <name>🟡Accepted, not applied.
--variant <name>🟡Accepted, not applied.
--all-variants🟡Accepted, not applied.

Output goes to build/<target>/<profile>/. See Building and Running.

kargo run

🟢 Implemented for JVM targets.

kargo run [-t|--target <name>] [--variant <name>] [-- <args>...]

Builds, then executes package.main-class. Everything after -- is passed to your program.

kargo run -- --port 8080

The program runs on Kargo's own streams: its output reaches the terminal while it runs, and it can read stdin. Stopping Kargo stops the program, on SIGTERM as well as Ctrl-C.

kargo test

🟡 Partial — --target and --filter work; the rest are accepted but not implemented.

kargo test [flags]
FlagStatusEffect
-t, --target <name>🟢Test one target.
-f, --filter <pattern>🟢Substring match on the fully qualified test name.
--coverage⚪Instrument and report coverage.
--report <formats>⚪junit, html, comma-separated.
--parallel⚪Run test classes concurrently.
--flavor <name>⚪Test one flavor.
--variant <name>⚪Test one variant.

See Testing.

kargo check

🟢 Implemented.

kargo check [--variant <name>]

Type-checks without producing artifacts.

kargo clean

🟢 Implemented.

kargo clean [--variant <target>/<profile>]

With no flag, removes build/ along with the metadata describing it, .kargo/fingerprints/ and .kargo/incremental/. With --variant, removes that variant's output and incremental state only — for example --variant jvm/dev. Downloaded dependencies under .kargo/dependencies/ are a cache and survive either; kargo cache clean owns them.

kargo watch

🟢 Implemented.

kargo watch [--build-only]

Rebuilds — and by default re-runs — on source or manifest changes. A program still running from the previous cycle is stopped first, so watching a server restarts it on each change rather than waiting for it to exit. Ending the session stops the program too, on SIGTERM as well as Ctrl-C.

kargo add

🟢 Implemented.

kargo add <group:artifact[:version]> [--version <v>] [--rename <key>]
          [--dev] [--target <name>] [--flavor <name>]

Verifies the artifact exists, then updates Kargo.toml and Kargo.lock. Existing formatting and comments are preserved, and the entry is inserted in alphabetical order.

Omit the version and Kargo takes the current release from the first repository that lists the artifact, reporting it as (latest). Snapshots are never chosen. With --offline an omitted version is an error rather than a guess.

FlagEffect
--version <v>The version, instead of naming it in the coordinate. Giving it both ways is an error.
--rename <key>The manifest key to file it under. Defaults to the artifact id.
noneWrites to [dependencies]
--devWrites to [dev-dependencies]
--target jvmWrites to [target.jvm.dependencies]
--flavor freeWrites to [flavor.free.dependencies]

kargo remove

🟢 Implemented. Alias: kargo rm.

kargo remove <key> [--dev] [--target <name>] [--flavor <name>]

Takes the manifest key, not the coordinate.

kargo update

🟢 Implemented.

kargo update [--major] [--dep <key>] [--dry-run]

Updates Kargo.lock to the newest semver-compatible versions. --major allows breaking bumps, --dep limits the update to one dependency, --dry-run reports without writing.

kargo fetch

🟢 Implemented.

kargo fetch [--verify] [--skip-dev | --dev-only] [--offline]

Downloads everything in the lockfile without building.

FlagDoes
--verifyRe-checks the checksums of already-cached artifacts.
--skip-devDownloads everything but the dev-dependencies.
--dev-onlyDownloads only the dev-dependencies.
--offlineReaches no repository, reporting what the cache is missing instead of filling it.

The two scope flags are the halves of one choice and cannot be combined. Both resolve the whole graph and write the whole lockfile — only the downloads narrow, so a partial fetch never leaves a partial Kargo.lock. They are for layered builds: --skip-dev for an image layer that only builds, --dev-only for a test stage on top of it. See Continuous Integration.

A fetch leaves nothing for a later command to download: the test runner and the annotation processing tooling come with the dependency graph, so kargo build and kargo test both work under --offline afterwards.

kargo lock

🟢 Implemented.

kargo lock

Resolves the manifest and rewrites Kargo.lock.

kargo tree

🟢 Implemented.

kargo tree [flags]
FlagShows
--depth <n>Only the first n levels.
--why <name>The path from your manifest to that artifact.
--duplicatesArtifacts present at more than one version.
--conflictsVersion conflicts and how each was resolved.
--licensesThe license of every artifact.
--invertedDependents instead of dependencies.

kargo outdated

🟢 Implemented.

kargo outdated [--major]

Lists dependencies with newer versions available. --major includes breaking bumps.

kargo audit

🟢 Implemented.

kargo audit [--fail-on <severity>]

Checks the resolved graph against OSV. --fail-on takes low, moderate, high, or critical. See Auditing Dependencies.

kargo env

🟢 Implemented.

kargo env [--reveal]

Prints the resolved environment from .kargo.env and the process environment, with secret-looking values masked. --reveal unmasks them.

kargo toolchain

🟢 Implemented.

kargo toolchain install [<kotlin-version>] [--jdk [<major>]] [--android [<level>]]
kargo toolchain list
kargo toolchain remove [<kotlin-version>] [--jdk <major>] [--android]
kargo toolchain use <kotlin-version>
kargo toolchain path
kargo toolchain install 2.4.21
kargo toolchain install --jdk 21
kargo toolchain install --android 36
kargo toolchain install 2.4.21 --jdk --android

use sets the default for new projects; it never overrides a project's package.kotlin. See Toolchains.

kargo cache

🟢 Implemented.

kargo cache stats         # size and entry count, plus the project's .kargo/
kargo cache clean         # clear the local build cache and the project's .kargo/
kargo cache push          # push outputs to the remote cache (⚪ no transport yet)
kargo cache stop-daemon   # stop the Kotlin compile daemon

See The Build Cache.

kargo self

🟢 Implemented.

kargo self update [--check]
kargo self info
kargo self clean

info prints versions, config paths, and cache sizes. clean removes unused toolchains and stale cache entries.

update replaces the running binary with the newest release, after checking the download against the release's published checksums. If it cannot verify the download it installs nothing and leaves the current binary in place. --check only reports whether a newer version exists.

Once the new binary is in place, update regenerates every completion script installed with kargo completions --install, so they describe the version now on disk. A script that cannot be rewritten is a warning: the upgrade itself already succeeded. Nothing is reported when no completions were installed.

kargo lint

⚪ Planned.

kargo lint [--fix]

Runs the built-in linter against [lint] configuration. See Linting and Formatting.

kargo fmt

⚪ Planned.

kargo fmt [--check]

Formats sources per [format]. --check reports without writing and exits non-zero if anything would change.

kargo fix

⚪ Planned.

kargo fix

Applies every auto-fixable lint and formatting suggestion.

kargo doc

⚪ Planned.

kargo doc [--open]

Generates KDoc into build/docs/. --open opens it in a browser.

kargo bench

⚪ Planned.

kargo bench [--compare <baseline>]

Runs kotlinx-benchmark benchmarks. --compare diffs against a stored baseline.

kargo publish

⚪ Planned.

kargo publish

Publishes JAR, POM, sources, and KDoc to a Maven repository, signing if [signing] is configured. See Publishing.

kargo package

⚪ Planned.

kargo package [--docker] [--ios-universal]

Creates a distributable. --docker builds a container image; --ios-universal builds an XCFramework. See Packaging.

kargo repl

⚪ Planned.

kargo repl

Starts a Kotlin REPL with your project's classpath loaded.

kargo script

⚪ Planned.

kargo script <file.kts>

Runs a Kotlin script against the project's dependencies.

kargo metadata

⚪ Planned.

kargo metadata [--format json]

Emits the resolved project model — targets, source sets, classpaths, compiler arguments — for editors and plugins. See Editors and IDEs.

kargo completions

🟢 Implemented.

kargo completions <bash|zsh|fish|powershell|elvish> [--install]

Writes a completion script to stdout, generated from the command surface this binary actually has — so the completions match the version installed rather than the version the docs were written for.

--install writes it where the shell reads it instead, and reports the path. Three shells load it from there on their own; for the other two the output names the one line to add to a profile. Installing again replaces the file, and kargo self update does exactly that for every shell installed this way, so an upgrade does not leave completions describing the old binary.

Shell--install writesLoaded
bash$XDG_DATA_HOME/bash-completion/completions/kargoautomatically
fish$XDG_CONFIG_HOME/fish/completions/kargo.fishautomatically
zsh~/.zfunc/_kargoneeds an fpath line
powershell$KARGO_HOME/completions/kargo.ps1needs a dot-source line
elvish$KARGO_HOME/completions/kargo.elvneeds an eval line

XDG_DATA_HOME and XDG_CONFIG_HOME fall back to ~/.local/share and ~/.config; KARGO_HOME falls back to ~/.kargo.

An unrecognized shell is a usage error, exit 2.

The per-shell setup, in full: Shell completions.

kargo plugin

⚪ Planned.

kargo plugin install <name>
kargo plugin list
kargo plugin remove <name>

See Plugins and Hooks.

kargo target

⚪ Planned.

kargo target add <target>
kargo target list
kargo target remove <target>

Edits [targets] and creates the matching source-set directories.

kargo variant

⚪ Planned.

kargo variant list
kargo variant info <name>

list prints every variant in the flavor-by-profile matrix minus exclusions. info prints one variant's source sets, dependencies, and build config. See Flavors and Variants.

kargo flavor

⚪ Planned.

kargo flavor add <dimension> <name>
kargo flavor remove <dimension> <name>

Edits [flavors].

kargo doctor

⚪ Planned.

kargo doctor

Checks toolchain availability, SDK versions, unused dependencies, missing actual declarations, and cache health. See Troubleshooting.

kargo migrate

⚪ Planned.

kargo migrate

Reads Gradle build files and writes a Kargo.toml, reporting what it could not translate. See Coming from Gradle.

kargo lsp

⚪ Planned.

kargo lsp

Starts a Language Server Protocol server on stdio. See Editors and IDEs.

Exit codes

CodeMeaning
0Success
1The operation failed — compile error, failing test, unresolved dependency
2Invalid usage — unknown flag, bad argument

Audit and lint failures exit 1, which is what makes them usable as CI gates.