Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Cross Platform Development?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/iracedeck-cross-platform-development)
---
name: cross-platform-development
description: Use when working with native dependencies, handling platform differences, or when build/install/test issues arise on non-Windows platforms
---
# Cross-Platform Development
## Why the mock exists
**The mock is development tooling, not a support claim.** iRaceDeck ships Windows-only — all three plugin manifests declare `windows` and nothing else (#994) — because iRaceDeck exists to control iRacing, which has no macOS build. The mock exists so the repo can still be installed, built, and tested on a Mac or Linux machine; it is not there to make the plugin usable off Windows, and it is not a reason to re-add a `mac` entry to a manifest. `scripts/manifest-platform.test.mjs` fails the build if one comes back.
`@iracedeck/iracing-native` wraps the iRacing SDK (Windows-only C++ N-API addon). Without the mock layer, `pnpm install`, `pnpm build`, and `pnpm test` all fail on macOS/Linux because:
- `node-gyp` can't compile the Windows-specific C++ code
- Package `"os"` restrictions blocked installation entirely
## Architecture
### Platform detection in `iracing-native/src/index.ts`
```text
platform() === "win32"?
├── Yes → try loading native .node addon
│ ├── Success → use real addon
│ └── Failure → fall back to IRacingNativeMock
└── No → use IRacingNativeMock (never attempts to load .node)
```
- `platform()` check is the primary guard
- `try/catch` around `require()` is the safety net
- No top-level await — synchronous module loading preserved
- `IRacingNative` class delegates to either `addon` or `IRacingNativeMock` transparently
### Forcing mock mode on Windows
For development/testing without iRacing running, mock mode can be forced on Windows:
1. **File-based** (recommended for Stream Deck): Create an empty `.mock` file in the sdPlugin folder (e.g., `com.iracedeck.sd.core.sdPlugin/.mock`). Delete it to return to native mode.
2. **Environment variable**: Set `IRACEDECK_MOCK=1` before launching (useful for CLI/terminal testing).
- Note: `pnpm test` sets this for you (#1084) — test workers and the child processes they spawn always run against the mocks, on every platform. The main Vitest process is not covered. `IRACEDECK_REAL_NATIVE=1` opts back in.
The `.mock` file is gitignored. The mock rotates through telemetry snapshots (including flag states) every 5 seconds.
### Native dependencies
- Keyboard input goes through `@iracedeck/iracing-native` only (scan codes via `SendInput`), so it is mocked with the rest of that addon. The Windows-only `keysender` module that once sent keys by name was removed in #1495, and with it the plugins' only optional, compiled-at-install `bin/` dependency
- `@resvg/resvg-js` ships prebuilt binaries for every platform and needs no mock
- `node-gyp` is skipped on non-Windows via `iracing-native/scripts/build.mjs`
## When adding new native methods
You must update the mock alongside the native addon:
1. `addon.cc` — C++ implementation
2. `src/index.ts` — Add delegation in `IRacingNative` class (both `addon` and `getMock()` paths)
3. `src/mock-impl.ts` — Add mock implementation to `IRacingNativeMock`
4. Continue with the standard cross-package sync (keyboard-service, plugin-runtime's `initInput`, tests, rules)
## Mock data
Located in `packages/iracing-native/src/mock-data/`:
| File | Content |
|------|---------|
| `session-info.ts` | YAML string — Spa practice, 3 drivers |
| `telemetry.ts` | Variable headers with computed offsets, `buildTelemetryBuffer()` |
| `snapshots.ts` | 6 rotating snapshots (mid-straight, braking, pit entry, yellow flag, blue flag, yellow+blue) |
Mock data is placeholder. To update with real telemetry, capture snapshots on Windows using the telemetry-snapshot CLI tool in `@iracedeck/iracing-sdk`.
## Build scripts
| Script | Behavior |
|--------|----------|
| `pnpm build` (root) | Runs `turbo run build`. Stops no deck host; `pnpm build:with-restart` is the variant that stops Stream Deck around the build and restarts it. |
| `iracing-native build` | Runs `node-gyp rebuild` on Windows (first moving aside a `.node` a running deck host has loaded, #1258), skips on other platforms; always runs `tsc` |
## Design doc
See `docs/plans/2026-03-01-cross-platform-native-mock-design.md` for the full design rationale.