name: pre-commit description: Run Rust/Python/MCP checks, fix issues, then summarize findings before committing
Pre-Commit
Run all checks, fix any issues found, then present a summary table.
Checks
Rust checks
Run the following checks if there are changes in the tapo/, tapo-py/, or tapo-mcp/ directories. Fix all issues found. Run independent checks (cargo check, cargo clippy, cargo fmt, cargo test) in parallel.
Unless otherwise specified, run checks at the workspace level (no -p flags) with --all-features to ensure cross-crate issues are caught.
Link-free checks (check, clippy) take --workspace so they cover tapo-py too; cargo test must NOT — it links test binaries and examples, which fails with tapo-py's pyo3/extension-module, so it relies on default-members excluding tapo-py.
cargo check --workspace --all-featurescargo clippy --workspace --all-featurescargo fmt --allcargo test --all-featurescargo clean --doc && RUSTDOCFLAGS="-D warnings" cargo doc -p tapo --no-deps --all-features- No
unwrap()in non-test code without a// safe:comment - No
unsafein non-test code without a// SAFETY:comment - No unnecessary clones
- No deeply nested
use(max one level of{}nesting)
Python checks
Run the following checks if there are changes in the tapo/ or tapo-py/ directories. Fix all issues found.
- Update
.pyistubs if Python-exposed Rust types changed - Verify new
#[pyclass]types are imported and registered intapo-py/src/lib.rs - Verify Python examples in
tapo-py/examples/are updated to match corresponding Rust examples intapo/examples/ cd tapo-pyand activate the virtual environmentuv run mypy .— fix all type errorsuv run black .— fix all formatting issues
MCP checks
Run the following checks if there are changes in the tapo-mcp/ directory. Fix all issues found.
- Verify that all
#[derive(JsonSchema)]types haveschemarsannotations — including tool input params, response types, enums, and their fields/variants. Check for descriptions and range constraints where applicable. - Verify that
tapo-mcp/README.mdreflects any MCP API changes (tools, resources, capabilities, env vars, auth) - Verify that the OpenClaw skill reflects any MCP API changes. The skill spans three files — check each:
tapo-mcp/openclaw-skill/SKILL.md— frontmatter (description,version,requires), Setup, Tools section with examplenpx mcporter callinvocationstapo-mcp/openclaw-skill/references/setup.md— verification table (tool, description, parameters)tapo-mcp/openclaw-skill/references/tapo-mcp-setup.md— Tools table, Resources table, Configuration env vars, Authentication, Deployment (kept in sync withtapo-mcp/README.md)
- When device-support categories change (e.g. adding a new family like the H100 hub), verify the device-type enumeration is in sync across both surfaces that list it:
tapo-mcp/src/server.rswith_instructions(...)(e.g."plugs, lights, power strips, hubs and their child sensors, cameras")tapo-mcp/openclaw-skill/SKILL.mdfrontmatterdescription:(e.g.(lights, plugs, power strips, hubs and sensors, cameras))
Documentation checks
Run the following checks if there are changes in the tapo/ or tapo-py/ directories. Fix all issues found.
- Verify that
SUPPORTED_DEVICES.mdis up to date: add, remove, or regroup rows/columns when a handler's public method list changed, a device model was added/removed, or a method's#[cfg(feature = "debug")]gating changed
Code Review
After fixing all issues found in the checks, review the code changes for correctness, readability, and maintainability and propose improvements. Summarize the findings according to severity.