Marketplace

preflight-checks

Comprehensive code quality verification system for running type checking, linting, and tests. Use when validating code quality, preparing commits, running CI checks locally, or when the user mentions preflight, verify, lint, typecheck, or test commands.

$ 安裝

git clone https://github.com/charlesjones-dev/claude-code-plugins-dev /tmp/claude-code-plugins-dev && cp -r /tmp/claude-code-plugins-dev/plugins/ai-workflow/skills/preflight-checks ~/.claude/skills/claude-code-plugins-dev

// tip: Run this command in your terminal to install the skill


name: preflight-checks description: Comprehensive code quality verification system for running type checking, linting, and tests. Use when validating code quality, preparing commits, running CI checks locally, or when the user mentions preflight, verify, lint, typecheck, or test commands.

Preflight Code Quality Checks

This skill provides comprehensive guidance for discovering and running code quality checks across different project types.

Overview

Preflight checks are the quality gates that verify code before commits, PRs, or deployments. They typically include:

  1. Type Checking - Static type verification (TypeScript, MyPy, etc.)
  2. Linting - Code quality and style enforcement
  3. Formatting - Consistent code style
  4. Testing - Unit, integration, and e2e tests

Quick Reference

Node.js / TypeScript Projects

CheckCommandAuto-fix
TypeScriptnpx tsc --noEmitN/A (manual)
ESLintnpx eslint .npx eslint . --fix
Biomenpx biome check .npx biome check . --write
Prettiernpx prettier --check .npx prettier --write .
Jestnpx jestN/A
Vitestnpx vitest runN/A

Prefer npm scripts when available:

# Check package.json scripts first
npm run lint        # if exists
npm run typecheck   # if exists
npm run test        # if exists
npm run check       # often runs all checks

Python Projects

CheckCommandAuto-fix
MyPymypy .N/A (manual)
Ruff lintruff check .ruff check . --fix
Ruff formatruff format --check .ruff format .
Blackblack --check .black .
isortisort --check .isort .
PytestpytestN/A

With pyproject.toml (modern Python):

# Check for [tool.X] sections
ruff check . && ruff format --check .  # Ruff (fast, recommended)
mypy src/                               # Type checking
pytest                                  # Tests

.NET Projects

CheckCommandAuto-fix
Builddotnet buildN/A
Build strictdotnet build --warnaserrorN/A
Format checkdotnet format --verify-no-changesdotnet format
Testsdotnet testN/A
AnalyzersConfigured in .editorconfigN/A

.NET specific considerations:

  • Warnings as errors: Add <TreatWarningsAsErrors>true</TreatWarningsAsErrors> to .csproj
  • Enable nullable: <Nullable>enable</Nullable> for null safety
  • Analyzers run during build automatically

Go Projects

CheckCommandAuto-fix
Buildgo build ./...N/A
Vetgo vet ./...N/A
golangci-lintgolangci-lint rungolangci-lint run --fix
gofmtgofmt -l .gofmt -w .
Testsgo test ./...N/A

Rust Projects

CheckCommandAuto-fix
Checkcargo checkN/A
Clippycargo clippy -- -D warningscargo clippy --fix
Formatcargo fmt --checkcargo fmt
Testscargo testN/A

Discovery Strategy

Step 1: Identify Project Type(s)

Check for presence of key files:

# JavaScript/TypeScript
package.json, tsconfig.json, deno.json

# Python
pyproject.toml, setup.py, requirements.txt, Pipfile

# .NET
*.csproj, *.sln, *.fsproj

# Go
go.mod

# Rust
Cargo.toml

Step 2: Check for Configured Scripts/Tasks

package.json scripts (Node.js):

{
  "scripts": {
    "lint": "eslint .",
    "typecheck": "tsc --noEmit",
    "test": "vitest",
    "check": "npm run lint && npm run typecheck && npm run test"
  }
}

pyproject.toml (Python):

[tool.ruff]
line-length = 100

[tool.mypy]
strict = true

[tool.pytest.ini_options]
testpaths = ["tests"]

Makefile targets:

lint:
    ruff check .

test:
    pytest

check: lint test

Step 3: Detect CI Configuration

Check for CI files to align local checks with CI:

  • .github/workflows/*.yml - GitHub Actions
  • .gitlab-ci.yml - GitLab CI
  • azure-pipelines.yml - Azure DevOps
  • Jenkinsfile - Jenkins
  • .circleci/config.yml - CircleCI

Best Practices

Execution Order

Run checks in order of speed and feedback value:

  1. Format check (fastest, catches style issues)
  2. Type checking (fast, catches type errors)
  3. Linting (medium, catches quality issues)
  4. Tests (slowest, catches logic errors)

This order provides fastest feedback on failures.

Handling Monorepos

For monorepos, check for workspace configuration:

  • pnpm-workspace.yaml
  • lerna.json
  • package.json with workspaces field
  • Cargo.toml with [workspace]

Run checks at workspace root or iterate through packages.

CI Alignment

Ensure local preflight matches CI:

# Good: Use same commands as CI
npm run lint    # Same as CI step

# Avoid: Different commands locally vs CI
eslint . --max-warnings=0  # If CI uses npm run lint

Exit Codes

Respect exit codes for CI integration:

  • 0 - Success, no issues
  • 1 - Failure, issues found
  • 2 - Configuration error

Caching

For faster subsequent runs:

  • ESLint: Uses .eslintcache with --cache flag
  • TypeScript: Uses tsconfig.tsbuildinfo with incremental: true
  • Pytest: Uses .pytest_cache
  • Rust: Uses target/ directory

Error Messages Reference

TypeScript Common Errors

TS2339: Property 'x' does not exist on type 'Y'
-> Add property to interface or use type assertion

TS2322: Type 'X' is not assignable to type 'Y'
-> Check type definitions, may need union type

TS7006: Parameter 'x' implicitly has an 'any' type
-> Add explicit type annotation

ESLint Common Errors

@typescript-eslint/no-unused-vars
-> Remove unused variable or prefix with _

@typescript-eslint/no-explicit-any
-> Replace 'any' with specific type

import/order
-> Auto-fixable: eslint --fix

Python Common Errors

mypy: Incompatible return value type
-> Check return type annotation matches actual return

ruff: E501 Line too long
-> Auto-fixable or configure line-length

ruff: F401 Module imported but unused
-> Remove unused import

Integration with Pre-commit Hooks

Preflight checks can be configured as pre-commit hooks:

.pre-commit-config.yaml:

repos:
  - repo: local
    hooks:
      - id: preflight
        name: Preflight Checks
        entry: npm run check
        language: system
        pass_filenames: false

Husky (Node.js):

# .husky/pre-commit
npm run lint
npm run typecheck

When to Skip Checks

Some scenarios where partial checks are acceptable:

  • --no-verify for emergency fixes (use sparingly)
  • WIP commits on feature branches
  • Exploratory/spike work

Always run full preflight before:

  • Opening PRs
  • Merging to main/master
  • Deploying to production

Repository

charlesjones-dev
charlesjones-dev
Author
charlesjones-dev/claude-code-plugins-dev/plugins/ai-workflow/skills/preflight-checks
9
Stars
0
Forks
Updated1w ago
Added1w ago