English | ζ₯ζ¬θͺ
ζ―ζ¨ (kareki): dead wood in Japanese β the unused branches that need pruning.
A workspace-wide dead code finder for Dart and Flutter. Unlike dart analyze, which only flags private unused declarations inside a single package, kareki resolves cross-package references across Melos / pub workspaces to surface the dead code that actually accumulates in real projects: public APIs no one calls, files nobody imports, and pub dependencies that ride along unused.
| What you get | |
|---|---|
| π² | Workspace-wide. Resolves references across every package in Melos / pub workspaces β not just one. |
| π | Public APIs too. Finds the public classes, methods, and fields dart analyze ignores. |
| 𧬠| Codegen-friendly. Built-in presets for freezed, json_serializable, riverpod, auto_route, go_router, drift, hive. |
| π§ͺ | test_only_used. Catches lib/ code that only its own tests still use. |
| π | Baseline. Adopt on legacy code without fixing everything first β CI fails only on new findings. |
| π©Ί | Doctor. kareki doctor flags stale ignore entries, dead excludes, and orphan suppression comments. |
| βοΈ | CI-ready. JSON output, deterministic exit codes, portable baselines. |
| Rule | Detects |
|---|---|
unused_element |
Public classes / functions / methods / getters / setters / fields / enums / enum values / top-level variables / extensions / extension types / typedefs with no caller anywhere in the workspace. |
unused_file |
.dart files that are not import-ed, part-ed, or export-ed from any other file. |
unused_pub_dependency |
Packages declared in pubspec.yaml with no recognized source, analyzer configuration, native plugin, or font asset use. |
test_only_used |
Public declarations under lib/ that are only referenced from test code (*_test.dart, files under test/ or integration_test/). The implementation has no production consumer β typically its tests are the only thing keeping it alive. |
unused_parameter |
Parameters of a function, method, or named constructor that are never referenced in the body or initializers. Covers required and public-API parameters that Dart's built-in unused_element_parameter doesn't reach. |
unused_parameter_optional |
Optional parameters (named or positional optional) of a function, method, or constructor that are never passed at any call site in the workspace. The public / cross-package counterpart to Dart's built-in unused_element_parameter, which only inspects private optional parameters within a single library. |
Six key features at a glance. β Supported (including opt-in features), β no equivalent feature.
| Feature | kareki | ciach | Dart Code Linter | dependency_validator | Dart standard analysis |
|---|---|---|---|---|---|
| Unused public declarations and members | β | β | β | β | β |
| Unused private declarations and members | β | β | β | β | β |
| Public declaration cycles unreachable from entry points | β | β | β | β | β |
| Unused Dart files | β | β | β | β | β |
| Unused pub dependencies | β | β | β | β | β |
| Report only new findings using a baseline | β | β | β | β | β |
See the full comparison for other features, required settings, limitations, and versions compared.
# pubspec.yaml
dev_dependencies:
kareki: ^0.7.0dart pub getInstall the project's dependencies and run code generation, then execute from the workspace root:
dart run karekiSee the CLI reference for preparation, options, and analysis warnings.
You can adopt kareki without fixing all existing findings. Review the results, save them as a baseline, and commit it so CI reports only new findings:
dart run kareki --baseline .kareki-baseline.json --write-baselineSee doc/baseline.md.
File moves and dependency changes can leave obsolete exclusions and suppressions.
kareki doctor checks which entries no longer apply:
dart run kareki doctorSee doc/doctor.md.
Browse the documentation site or read the Markdown sources directly:
- CLI reference β every option, every exit code
- Configuration β
kareki-config.yaml, defaults, built-in presets, custom presets, suppression, full example - Baseline β incremental adoption
- Doctor β obsolete exclusions and suppressions
- How it works β analysis flow, entry points, limits, and supported versions
- Comparing similar tools β ciach, Dart Code Linter, and other Dart tools
- Best practices β scheduled cleanup pull requests with an AI agent
MIT. See LICENSE.