Cosmos SDK Pre-Commit Checks
When to use this skill
Use this skill when:
- Reviewing or validating changes in the Cosmos SDK
- Running pre-commit checks locally before pushing
- Performing focused code review on
sdk/cosmos/**
Behavior
Follow these steps strictly:
Determine the target path:
- If the
scopeargument is specified and is not equal (case-insensitive) toallor*, set the target path tosdk/cosmos/<scope>(for example, ifscopeisazure_data_cosmos, usesdk/cosmos/azure_data_cosmosas the target path). - Otherwise, set the target path to
sdk/cosmos.
- If the
Determine file scope:
- If
changed-onlyistrue(the default), restrict scanning to.rsfiles that differ between the current local branch andmain. Usegit diff --name-only main -- <target path>(and include per-cratetests/directories) to obtain the list. Only.rsfiles in the result set are scanned; all other files are skipped. - If
changed-onlyisfalse, scan all.rsfiles under the target path(s). - In both modes, skip files in
generated/subdirectories — these are produced by external tools and must never be modified.
- If
Validate using the Pre-Completion Validation Checklist in
sdk/cosmos/AGENTS.md:- Formatting checks
- Build succeeds for affected crates
- Clippy lints pass for affected crates, with warnings treated as errors (
-D warnings) to match CI behavior. Run clippy withRUSTFLAGS=-D warningsset:- Bash:
RUSTFLAGS='-D warnings' cargo clippy -p <crate> --all-features --all-targets - PowerShell:
$env:RUSTFLAGS='-D warnings'; cargo clippy -p <crate> --all-features --all-targets; $env:RUSTFLAGS=$null
- Bash:
- Re-run formatting after any auto-fix: if
auto-fixis true and clippy or other tools modified files, re-runcargo fmtto ensure the auto-fixed code is properly formatted (e.g.,cargo clippy --fixcan leave trailing blank lines when removing unused imports). - Documentation builds successfully where applicable
- Spell check (cspell): CI runs cspell on all changed files using the config at
.vscode/cspell.jsonwith the Cosmos-specific dictionary atsdk/cosmos/.dict.txt. Run locally with:npx cspell lint --config .vscode/cspell.json --no-must-find-files <target path>/**Ifauto-fixis true and unknown words are legitimate (e.g., API type names, technical terms), add them tosdk/cosmos/.dict.txt. - Unit and emulator tests relevant to the touched modules and crates
- CI-gated tests: Tests gated by
test_category(e.g., emulator, multi-write) are always compiled but are ignored at runtime unless the corresponding cfg is set viaRUSTFLAGS. This meanscargo check --testsandcargo testwill compile these tests without any special flags, so build errors are caught locally.RUSTFLAGSis only needed when you want to actually run the tests:RUSTFLAGS='--cfg test_category="emulator"' cargo test -p azure_data_cosmos --features fault_injection,key_auth --testsRUSTFLAGS='--cfg test_category="multi_write"' cargo test -p azure_data_cosmos --features fault_injection,key_auth --testsOn Windows (PowerShell), set the env var first:$env:RUSTFLAGS='--cfg test_category="emulator"'then run thecargo testcommand, and clear it afterwards with$env:RUSTFLAGS=$null. These tests require a live Cosmos DB emulator or multi-region account to run. Ifscopetargets a specific crate other thanazure_data_cosmos, skip these checks.
Report results:
- Summarize failures concisely
- Include exact file paths and commands to reproduce
- Do NOT auto-fix unless
auto-fixargument istrue
Notes
- Never run repo-wide checks outside
sdk/cosmos - Avoid long-running integration tests unless explicitly requested
Source: Azure/azure-sdk-for-rust — distributed by TomeVault.