Preflight

From linuxfoundation/insights · View interactive version

Preflight is an AI agent skill from the GitHub repository linuxfoundation/insights. Pre-PR validation — license headers, format, lint, TypeScript check, build, and protected file check. Use before submitting any PR, to check if code is ready, validate changes, or verify a branch before review.

How to use this skill

Skill file

Pre-Submission Preflight Check

You are running a comprehensive validation before submitting a pull request.

Run each check in order, report results clearly, and help fix any issues found.

All script commands run from the frontend/ directory unless otherwise noted.

Check 0: Working Tree Status

Before running any validation, check the state of the working tree:

git status
git diff --stat origin/main...HEAD
git log --format="%h %s%n%b" origin/main..HEAD

Evaluate:

Resolve any issues before proceeding.

Check 1: License Headers

Every source file (.ts, .vue, .js, .scss) must have the copyright header. Check for files missing it:

# From repo root
find frontend/app frontend/server -type f \( -name "*.ts" -o -name "*.vue" -o -name "*.js" -o -name "*.scss" \) | \
  xargs grep -rL "Copyright" 2>/dev/null | grep -v node_modules | grep -v ".nuxt" | head -20

The correct headers are:

If any files are missing headers, add them using the scripts/add-license.js script or manually.

Check 2: Formatting

# From repo root
pnpm format

This applies oxfmt formatting. Run format before lint to eliminate whitespace noise from the lint step.

If files were modified, stage them:

git add -p

Check 3: Linting

# From repo root
pnpm lint

If there are lint errors, fix them. Common issues:

Re-validation

If any fixes were applied in Checks 1–3, re-run lint to confirm fixes are clean:

cd frontend && pnpm lint

Check 4: TypeScript Check

cd frontend && pnpm tsc-check

Fix any type errors before proceeding. Common issues:

Check 5: Build Verification

cd frontend && pnpm build

The build must succeed. If it fails:

Check 6: Protected Files Check

The authoritative list of protected files is maintained in .claude/hooks/guard-protected-files.sh. Cross-reference the diff against that hook — do not rely on any hardcoded list here, which may be stale.

# Get changed files
git diff --name-only origin/main...HEAD

# Extract the protected path patterns from the hook
grep -E "^\s+(frontend/|\.husky/|\.oxlintrc|\.oxfmtrc|AGENTS|\.claude/|scripts/|COPYRIGHT|package\.json|pnpm-lock)" .claude/hooks/guard-protected-files.sh

For each changed file, check whether it matches any case pattern or glob ([[ ... == glob ]]) in the hook. If it does, flag it — those files should NOT be modified without code owner approval.

If protected files appear in the diff, warn the contributor and ask them to revert or get code owner approval.

Check 7: Commit Verification

git status
git log --format="%h %s%n%b" origin/main..HEAD

Check 8: Change Summary

Generate a summary of all changes for the PR description:

git diff --stat origin/main...HEAD

List:

  1. New files created — with their purpose
  2. Modified files — with what changed
  3. Server API changes — any new or modified routes in server/api/
  4. Component changes — any new or modified components
  5. Data/query changes — any TanStack Query or Pinia store changes

Results Report

Present a clear report:

PREFLIGHT RESULTS
─────────────────────────────────
✓ Working tree        — Clean, N commits ahead of main
✓ License headers     — All files have headers
✓ Formatting          — Applied
✓ Linting             — No errors
✓ TypeScript          — No errors
✓ Build               — Succeeded
✓ Protected files     — None modified
✓ Commits             — Conventions followed, signed off
─────────────────────────────────
READY FOR PR

Or if there are issues:

PREFLIGHT RESULTS
─────────────────────────────────
✓ Working tree        — Clean, N commits ahead of main
✗ License headers     — 2 files missing headers (see above)
✓ Formatting          — Applied
✗ Linting             — 3 errors (see above)
✓ TypeScript          — No errors
✗ Build               — Failed (see above)
✓ Protected files     — None modified
✓ Commits             — Conventions followed, signed off
─────────────────────────────────
ISSUES FOUND — Fix before submitting

If All Checks Pass

Suggest creating the PR:

"All preflight checks passed! Ready to create a PR. Would you like me to create it with gh pr create?"

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.