Arguments: $ARGUMENTS
Purpose
Run all pre-commit checks in order. One command instead of remembering the sequence.
Silent Execution
- Do NOT ask permission for ANYTHING.
- Do NOT create tasks (no TaskCreate or TaskUpdate).
- If a step fails, stop immediately and show the error. Do not continue to the next step.
Flow
Show the plan once:
====================================
PREFLIGHT
[ ] 1. Format
[ ] 2. Lint
[ ] 3. Translation check
[ ] 4. New component test check
[ ] 5. Test
[ ] 6. Version bump
====================================
Then run each step:
1. Format
yarn format
▶ Step 1: Formatting... OK- If it fails: show error and stop.
2. Lint
yarn linter
▶ Step 2: Linting... OK- If it fails: show the errors. These are real issues that format can't fix (unused variables, missing imports, etc.). Stop.
3. Translation check
Verify that every translation key used in changed files exists in the translation file.
Get changed
.jsand.jsxfiles (hooks and components can both uset()):git diff --name-only --diff-filter=d origin/main -- '*.js' '*.jsx'For each changed file, search for
t('...')andt("...")calls and extract the key strings.For each extracted key, check if it exists in
src/i18n/translations/en.json.Report:
- If all keys found:
▶ Step 3: Translations... OK (N keys verified) - If any key is missing: show the list of missing keys with file:line references. Stop.
- If no files changed or no
t()calls found:▶ Step 3: Translations... OK (no keys to check)
- If all keys found:
4. New component test check
Verify that every new component file has a corresponding test file.
Get newly added
.jsxfiles (excluding test files):git diff --name-only --diff-filter=A origin/main -- '*.jsx' | grep -v '\.test\.' | grep -v 'index\.' | grep -v 'styles'For each new
.jsxfile, check if a corresponding.test.jsxor.test.jsfile exists in the same directory.Report:
- If all new components have tests:
▶ Step 4: New component tests... OK (N new components, all tested) - If any new component is missing a test: show the list of untested components. Stop.
- If no new
.jsxfiles:▶ Step 4: New component tests... OK (no new components)
- If all new components have tests:
5. Test
Identify changed files:
git diff --name-only origin/main -- '*.js' '*.jsx' '*.ts' '*.tsx'
Build the test file list from changed files:
- If the changed file is already a test file (
*.test.js,*.test.jsx), include it directly. - If the changed file is a source file (
X.jsorX.jsx), look forX.test.jsorX.test.jsxin the same directory. - Skip files that never have tests:
styles.js,constants.js,index.js.
Run only the discovered test files:
yarn test:agent <test files>
If no test files found for the changed files, run the full suite:
yarn test:agent
▶ Step 5: Tests... OK (12 passed)- If any test fails: show the failure. Stop.
6. Version bump
git diff origin/main -- package.json
Check if the version field was changed.
- If already bumped:
▶ Step 6: Version bump... OK (5.330.0 → 5.331.0) - If NOT bumped:
▶ Step 6: Version bump... MISSING— Ask the user what type of bump to apply (patch, minor, major). Apply it and show:▶ Step 6: Version bump... OK (5.330.0 → 5.331.0)
Report
====================================
PREFLIGHT — PASSED ✓
====================================
Format: OK
Lint: OK
Translations: OK (8 keys verified)
New tests: OK (no new components)
Tests: OK (12 passed)
Version: 5.330.0 → 5.331.0 (minor)
Files: 20 changed across 2 modules (configuration, returns)
Commits: 2 (feat: added subreasons, refactor: extract SortableList...)
Ready to commit.
====================================
If any step failed:
====================================
PREFLIGHT — FAILED ✗
====================================
Format: OK
Lint: FAILED — 2 errors
src/hooks/useFoo.js:12 — 'unused' is defined but never used
src/components/Bar.jsx:5 — Missing import for useState
Fix the errors and run /preflight again.
====================================
Report Summary Section
At the end of a successful report, always include a summary of the branch changes:
Count changed files and detect modules:
git diff --name-only origin/main -- '*.js' '*.jsx' '*.ts' '*.tsx'Group by top-level
src/directory to identify modules.Show commit history:
git log --oneline origin/main..HEADFormat as:
Files: N changed across M modules (module1, module2) Commits: K (first commit subject, second commit subject...)