pre-commit-checks
Installation
SKILL.md
Pre-Commit Validation Checks
Run these checks after making changes to SDK packages under sdk/ and before staging, committing, or pushing. These steps may produce additional file changes that must be included in the commit.
General rule: Steps 3–5 are conditional to save time, but if you are unsure whether a step is needed, always run it. It is better to run an unnecessary script than to miss a required regeneration.
1. Determine scope from changed files
- Derive the changed file list from
git status --porcelain(or by combininggit diff --name-only HEADwithgit ls-files -o --exclude-standard) so that untracked (new) files are included. - From the changed file list, extract all unique ServiceDirectories — the first path segment after
sdk/(e.g.,sdk/storage/...→storage,sdk/ai/...→ai). - For each ServiceDirectory, identify all affected packages = distinct
sdk/{ServiceDirectory}/{PackageName}/paths. - For each affected package, identify:
- All csproj files that had changes beneath them (src, tests, samples, perf, stress, or any other project type).
- The src csproj specifically =
sdk/{service}/{package}/src/{Package}.csproj— this is used for GenerateCode.
- The remaining steps must be run for each affected project/ServiceDirectory. If changes span multiple ServiceDirectories or packages, run for each one.
2. Run dotnet format (for every changed csproj)
For every csproj that had files change beneath it — src, tests, samples, perf, stress, or any other project type — run: