CLI reference
Run from the workspace root:
dart run karekiPreparation
Use the project’s SDK to install dependencies (dart pub get, flutter pub get,
or workspace bootstrap), then run code generation. Generated and excluded files
still contribute references and must resolve.
The SDK and analyzer must support the project’s language features; parsing experimental syntax alone is not enough. Rules that do not require resolution can run without dependency setup.
Options
| Option | Description |
|---|---|
--root <path> | Workspace root. Defaults to the current directory. |
--sdk-path <path> | Dart SDK root. Required for native executables outside the SDK; relative to the working directory. |
-f, --format <name> | Output format: text or json. Overrides configuration. |
--packages <name> | Report findings only for these packages. References are still collected across the discovered workspace. Repeatable. |
--rule <id> | Enable only these rules. Repeatable. |
--strict | Include dev_dependencies in unused_pub_dependency checks. |
--baseline <path> | Hide findings recorded in this baseline. Overrides the configured baseline path. |
--write-baseline | Save current findings and exit. Requires a baseline path in options or configuration. |
-h, --help | Show usage. |
For example, to run only the declaration-identity rules:
dart run kareki --rule unused_element,test_only_used,unused_parameter_optionalLike --packages, ignore.packages suppresses reports without hiding consumers.
By contrast, packages.exclude excludes packages from discovery.
See configuration
.
Results and exit codes
| Code | Meaning |
|---|---|
0 | No findings remain after filtering, or a baseline was successfully written. |
1 | One or more findings remain after filtering. |
2 | Source resolution or gen-l10n input loading failed, or unknown localization usage blocked a baseline write. No findings or baseline are published. |
64 | Invalid CLI options or kareki configuration. |
Analysis warnings describe uncertain usage, not confirmed unused code.
They go to stderr, separately from text or JSON findings, and have no rule ID
or dedicated exit code. Warnings alone do not cause a nonzero exit:
a normal run can return 0 with warnings. For localization analysis, stderr also shows used, unused, and unknown key
counts. --write-baseline refuses to create or overwrite a baseline while
localization keys remain unknown (exit 2). Other warnings do not block baseline
writes; review stderr before accepting one.
kareki doctor is stricter: warnings prevent safe suppression and baseline
cleanup checks, so it returns 2. See doctor
.
After upgrading, continue using dart run kareki; no migration command or
baseline conversion is needed. Review newly exposed findings before updating
your baseline. If you previously set analysis_mode or --analysis-mode, remove
them: these obsolete options return exit code 64.
Native executable
To reduce startup overhead on repeated runs, build from a kareki checkout:
dart pub get
mkdir -p build
dart compile exe bin/kareki.dart -o build/kareki
./build/kareki --sdk-path /path/to/dart-sdk --root /path/to/workspaceAn installed SDK is still required for analysis; Flutter uses
<flutter>/bin/cache/dart-sdk. The same option works with doctor.
Rebuild after updating kareki or its dependencies. Windows uses build/kareki.exe.