This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
dot is a CLI dotfiles manager for Unix-like systems, written in Rust. It manages configuration files by moving them into a centralized repository and creating symbolic links at their original locations. Published to crates.io as dot_rust.
cargo build # Build debug
cargo build --release # Build release
cargo test # Run all tests (unit + integration)
cargo test --lib # Run unit tests only
cargo test --test integration # Run integration tests only
cargo test <test_name> # Run a single test by name
cargo clippy # Lint
cargo fmt # Format codeThe crate exposes both a library (src/lib.rs) and a binary (src/main.rs). The binary uses the library's public modules.
Core modules:
cli— Clap-based CLI definition andrun()entry point. Parses subcommands (init,add,remove,sync) and dispatches to the corresponding command struct.commands/— Each command implements theCommandtrait (execute(self) -> Result<()>). Commands are self-contained structs:InitCommand,AddCommand,RemoveCommand,SyncCommand. Each exposes a static method (e.g.,add_to_manifest,sync_manifest) that separates core logic from I/O for testability.manifest—Manifeststruct wrapping aBTreeMap<PathBuf, PathBuf>serialized as TOML (dot.toml). Maps local filenames to their original paths (stored with~prefix). Methods come in pairs:load/load_from,save/save_to,get/get_with_home— the_with_homevariants allow injecting a fake home directory for testing.path— Tilde expansion/collapse utilities and lexical absolute path resolution. Same_with_homepattern for testability.error—thiserror-basedErrorenum andResulttype alias used throughout.
Key pattern: Functions that depend on the home directory have _with_home variants that accept Option<PathBuf> to enable deterministic testing without relying on the actual home directory.
- Commits follow conventional commits format (
feat:,fix:,refactor:,test:,chore:, etc.). - Unit tests live alongside their modules in
#[cfg(test)] mod tests. Integration tests are intests/integration.rsand usetempfile::TempDirfor isolation. - The manifest file is always named
dot.toml(constantMANIFEST_FILE).