smartscan is a CLI tool that runs smartctl on all disk devices, extracts key SMART health metrics (temperature, reallocated sectors, power-on hours, etc.), and stores historical results in SQLite for tracking changes over time. It supports both interactive table output and JSON lines for scripting.
- ALWAYS use
uvfor dependency management and command execution. - Sync dependencies with
uv sync --group dev. - Run tests with
just testoruv run pytest -v tests/. - Lint and format with
just lint; run static typing withjust typecheck. - Build docs with
just docs-buildand preview them withjust docs-serve. - DO NOT use ad hoc
pip installcommands instead of updatingpyproject.toml. - DO NOT edit generated output under
site/; rebuild it from source.
- Do not read or write files that are excluded by
.gitignore, unless a skill or the user explicitly directs you to do so. - Proactively use available agent skills when a task matches a skill's description.
- Application code lives under
src/smartscan. - The CLI uses stdlib
argparsewithargcompletefor shell completion. Subcommands:collect,query, andlsblk. - Terminal output uses Rich for styled tables and formatting.
- Configuration uses Pydantic
BaseModelfor validation. - SMART field structures use
TypedDict(SmartInfo) for type safety. - Custom exceptions (
SmartScanErrorhierarchy) separate error handling from business logic — onlycli.pycallssys.exit(). - Tests live under
tests/and should track public behavior, especially the CLI. - Documentation source lives under
docs/, and docs configuration lives inzensical.toml. - Project metadata and dependency groups are defined in
pyproject.toml; treat that file as the source of truth for tooling changes.
| Module | Responsibility |
|---|---|
constants.py |
Default paths, database migrations, error messages |
exceptions.py |
SmartScanError hierarchy |
models.py |
SmartScanConfig (Pydantic), SmartInfo (TypedDict) |
fields.py |
FieldDef registry — single source of truth for field metadata, DB columns, display labels |
config.py |
load_config() — read TOML config into SmartScanConfig |
logging.py |
setup_logging() |
smartctl.py |
find_disks(), run_smartctl(), extract_fields(), build_device_tree(), helpers |
thresholds.py |
check_thresholds(), Alert dataclass |
output.py |
Rich-powered print_table(), print_query_table(), print_json_output(), print_lsblk_tree() |
database.py |
SQLite init, open, save, query, schema generation |
llm.py |
BaseLLMProvider → OpenAIProvider / AnthropicProvider, call_llm(), _build_prompt() |
commands.py |
do_collect(), do_query(), do_lsblk() |
cli.py |
create_parser(), main() |
- Update tests when CLI behavior, public APIs, or package layout changes.
- Test the CLI via the
create_parser()function or by invokingmain()directly. - Keep docs commands working when changing docs pages, API docs wiring, or navigation structure.
uv sync --group dev # sync development dependencies
just lint # lint and format source plus tests
just typecheck # run Astral ty over src/
just test # run the pytest suite
just all # run lint, typecheck, test, coverage, build, docs-build
just docs-build # build the static docs site with Zensical
just docs-serve # preview docs locally on the configured dev address