| name | preflight |
| description | Run all preflight checks (format, lint, build, tests) to make sure the current work is ready for review. Auto-detects project type. |
Preflight Checks
Run all preflight checks to make sure the current work is ready for review.
Execute each step sequentially and stop immediately if any step fails.
Arguments
all -- Run all discovered test suites without filters, instead of only
running tests affected by the change. Usage: /preflight all
Current State
- Branch: !
git branch --show-current
- Status: !
git status --short
Steps
0. Check branch
Detect the default branch:
BASE=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@refs/remotes/origin/@@' || echo "main")
If on the default branch, create a new branch off of it before proceeding (use
a descriptive branch name based on the changes).
1. Detect project type
Identify the project type by checking for config files in the repo root:
| File | Project type |
|---|
pyproject.toml / setup.py / setup.cfg | Python |
package.json | JavaScript/TypeScript |
Cargo.toml | Rust |
go.mod | Go |
CMakeLists.txt / Makefile | C/C++ |
If multiple are present, run checks for each detected type. Announce the
detected project type(s) before proceeding.
2. Format code
Run the appropriate formatter. If formatting changes any files, stage and
include them in the commit later.
| Project type | Command |
|---|
| Python | ruff format . or black . (whichever is configured) |
| JavaScript/TypeScript | npx prettier --write . or per package.json scripts (npm run format if it exists) |
| Rust | cargo fmt |
| Go | gofmt -w . |
| C/C++ | find . -name '*.cpp' -o -name '*.h' | xargs clang-format -i (if .clang-format exists) |
3. Lint
Run the appropriate linter. Fix any issues found and re-run until it passes.
| Project type | Command |
|---|
| Python | ruff check . --fix or flake8 . |
| JavaScript/TypeScript | npx eslint . or per package.json scripts (npm run lint if it exists) |
| Rust | cargo clippy -- -D warnings |
| Go | golangci-lint run or go vet ./... |
| C/C++ | (skip if no linter config found) |
4. Commit if needed
Check git status. If there are any uncommitted changes (staged, unstaged, or
untracked files relevant to the work), create a commit. The commit message
should be short and succinct, describing what was done. If there are no changes,
skip this step.
DO NOT include any Co-Authored-By line in commit messages.
5. Build
Run the appropriate build command. If it fails, fix the build errors, amend the
commit, and retry.
| Project type | Command |
|---|
| Python | (skip — Python has no build step unless setup.py / pyproject.toml defines one) |
| JavaScript/TypeScript | npm run build (if the script exists in package.json) |
| Rust | cargo build |
| Go | go build ./... |
| C/C++ | cmake --build build or make |
6. Run tests
If the all argument was provided: Run the full test suite.
Otherwise (default): Determine which tests are affected by the changes in
this branch (compare against the base branch). Look at the changed files and
identify the corresponding test files or test targets.
| Project type | Full suite | Filtered / affected |
|---|
| Python | pytest | pytest <test_files> |
| JavaScript/TypeScript | npm test | npx jest --findRelatedTests <changed_files> or npx vitest run <test_files> |
| Rust | cargo test | cargo test <test_name> |
| Go | go test ./... | go test ./<changed_packages> |
| C/C++ | ctest --test-dir build | ctest --test-dir build -R <test_name> |
If no tests are affected, note that and move on.
7. Re-run checks if fixes were needed
If any step required fixes (build errors, test failures, format/lint issues),
amend the commit with the fixes and re-run checks until everything passes
cleanly.
Important
- Stop and report if any step fails after exhausting reasonable fix attempts.
- Report a summary of results when all steps complete successfully.