Dead Code Cleanup
Frontend (TypeScript/React)
1. Run knip
bunx knip
Reports: unused exports, unused files, unused dependencies, unused types, configuration hints.
2. Verify each finding
Grep before removing — especially for:
- Tauri plugin deps (e.g.
@tauri-apps/plugin-*): May be used only from Rust backend. If no JS imports exist butlib.rsregisters the plugin, the npm package is safe to remove. - Unused exports: If the symbol is used internally in the same file, just remove
exportinstead of deleting.
3. Apply fixes
- Remove
exportkeyword from internally-used-only symbols - Delete entirely unused functions/types
bun remove <pkg>for unused dependencies- Remove empty directories
4. Iterate until bunx knip is clean
Backend (Rust/Tauri)
1. Find unused Tauri commands
Compare generate_handler![] entries in lib.rs against actual frontend imports:
- List all commands from
generate_handler![] - Map to camelCase TypeScript names in
src/generated/commands.ts - Grep
src/(excludingsrc/generated/,src/paraglide/) for each name - Zero imports = unused command
2. Trace the dead code chain
For each unused command, trace downward through each architectural layer:
handler → service → repo → model
At each level, grep to verify no other callers exist before removing:
grep -r "service::module::fn_name" src-tauri/src/
3. Remove in order
- Delete handler functions from
handler/*.rs - Remove entries from
generate_handler![]inlib.rs - Delete dead service functions from
service/*.rs - Delete dead repo functions from
repo/*.rs - Delete dead model types from
model/*.rs - Clean up
useimports in each modified file - Delete or rewrite tests that reference removed functions
4. Verify with clippy
cargo clippy
If clippy reports new dead_code warnings from transitive removal, repeat the trace-and-remove cycle until clean.
5. Regenerate frontend bindings
cargo tauri-typegen generate
Fix any TS errors in regenerated bindings (e.g. unused Channel import).
Final Verification Checklist
bunx knip # frontend: zero issues
bun run build # frontend: compiles
cargo clippy # backend: zero warnings
cargo test # backend: all tests pass