| name | preflight-check |
| description | Run a comprehensive pre-PR validation sweep for the Rexio flight controller. Checks HAL discipline, topic sync, test coverage, CHANGELOG, build system integrity, and code conventions. Use before creating a PR, or when the user says /preflight-check. |
Run a comprehensive validation of the current branch before PR creation. Report ALL findings — do NOT fix them. The user decides what to act on.
Setup
- Determine the current PR scope by reading git log and diff against main
- Identify which components were added or modified
Check 1: Build Verification
Run make lint and make test (in that order). Both must pass. If either fails, report the failure and continue with remaining checks — do not stop.
Check 2: HAL Discipline
Grep all .c files under components/ for direct ESP-IDF hardware calls that should go through the HAL vtable instead. Run the check script if it exists:
bash .claude/skills/preflight-check/scripts/check_hal_discipline.sh
If the script doesn't exist, manually grep for these patterns in components/ source files (excluding components/rexio_hal/src/hal_*_esp.c which ARE the HAL implementations):
esp_timer_get_time — should use g_hal_time->get_time_us()
gpio_set_level / gpio_get_level — should use g_hal_gpio->set_level() / get_level()
i2c_master_ — should use g_hal_i2c->write_read() / write()
rmt_transmit / rmt_receive — should use g_hal_rmt->transmit() / receive()
vTaskDelay inside component logic (acceptable in task functions, not in component libraries)
esp_rom_delay_us — should use g_hal_time->delay_us()
Exceptions: code guarded by #if !defined(REXIO_HOST) or #ifdef REXIO_TARGET is acceptable in HAL implementation files only.
Report: list each violation with file:line.
Check 3: No Dynamic Allocation in Flight Path
Grep these flight-critical component directories for heap calls:
components/rexio_controller/
components/rexio_mixer/
components/rexio_estimator/
components/rexio_ahrs/
components/rexio_topics/
components/rexio_commander/
Search for: malloc, calloc, realloc, free, strdup, asprintf, new (C++ leak).
Exceptions: none. These components must be statically allocated.
Report: list each violation with file:line.
Check 4: Topic Contract Sync
Verify that every topic in the enum has all required artifacts. Run the check script if it exists:
bash .claude/skills/preflight-check/scripts/check_topic_sync.sh
If the script doesn't exist, manually check:
- Read
components/rexio_topics/include/topic_data.h
- Extract every
TOPIC_* entry from the topic_id_t enum (before TOPIC_COUNT)
- For each topic, verify:
a. A corresponding
typedef struct { ... } topic_{name_lower}_t; exists in topic_data.h
b. A [TOPIC_{NAME}] = sizeof(topic_{name_lower}_t) entry exists in topics.c metadata table
c. A row exists in docs/architecture.md section 5.3 Topic Registry table
- Check that
TOPIC_COUNT equals the number of enum entries
Report: list any missing artifacts per topic.
Check 5: Test Coverage
For each .c file in components/*/src/:
- Extract the component name
- Verify
test/test_{component}.c exists
- Verify at least one
RUN_TEST(test_{component}_ entry exists in test/test_main.c
Report: list any components missing tests or test runner wiring.
Check 6: CHANGELOG Updated
Check if CHANGELOG.md has been modified in the current branch compared to main:
git diff --name-only main...HEAD | grep CHANGELOG.md
If not modified, emit a WARNING (not a failure — some infrastructure PRs may legitimately skip this).
Check 7: CMakeLists.txt Sync
For each .c file in components/*/src/:
- Verify it appears in the component's
CMakeLists.txt SRCS list
- Verify it appears in
test/CMakeLists.txt source list (for host build)
Report: list any source files missing from either build system.
Check 8: Unit Convention Spot-Check
Read all topic struct definitions in topic_data.h. For each float field, verify it has either:
- A recognized unit suffix (
_m, _rad, _pa, _us, _v, _a, _pct, _hz)
- A comment documenting the unit on the same line
- A recognized exception (quaternion
q[4], motor[4], temperature, mag_x/y/z)
Report: list any fields with unclear units.
Output Format
Print a summary table:
PREFLIGHT CHECK RESULTS
═══════════════════════
[PASS/FAIL] Build verification (lint + test)
[PASS/FAIL] HAL discipline (N violations)
[PASS/FAIL] No malloc in flight path (N violations)
[PASS/FAIL] Topic contract sync (N missing artifacts)
[PASS/FAIL] Test coverage (N components missing tests)
[PASS/WARN] CHANGELOG updated
[PASS/FAIL] CMakeLists.txt sync (N missing entries)
[PASS/WARN] Unit conventions (N unclear fields)
Overall: N passed, N failed, N warnings
Then list details for any non-PASS items.
Scope Boundaries
- Report only. Do NOT fix any issues found.
- Do NOT run
make build (ESP-IDF build) — only host lint + test.
- Do NOT check Python ground station code.
- Do NOT block on warnings — only failures are blockers.