1k-cross-platform
This skill provides naming conventions for platform-specific files and usage guidelines for platformEnv in the OneKey monorepo.
Install
mkdir -p .claude/skills/1k-cross-platform && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/4637" && unzip -o skill.zip -d .claude/skills/1k-cross-platform && rm skill.zipInstalls to .claude/skills/1k-cross-platform
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
OneKey cross-platform patterns, platform files, platformEnv, and supported OS/SDK requirements.Key capabilities
- →Implement platform-specific UI logic
- →Structure multi-platform module code
- →Configure platformEnv for cross-platform builds
- →Use platform extensions for file resolution
- →Extract common logic into shared files
How it works
The skill enforces the use of specific file extensions (.native, .web, .desktop, .ext) and the platformEnv object to handle environment-specific code paths.
Inputs & outputs
When to use 1k-cross-platform
- →Implement platform-specific UI logic
- →Structure multi-platform module code
- →Configure platformEnv for cross-platform builds
About this skill
Cross-Platform Development
Patterns for writing platform-specific code in OneKey.
Platform Extensions
Use platform extensions for platform-specific implementations:
| Extension | Platform |
|---|---|
.native.ts | React Native (iOS/Android) |
.web.ts | Web platform |
.desktop.ts | Desktop (Electron) |
.ext.ts | Browser extension |
Platform Detection
ALWAYS use platformEnv for platform detection:
// ✅ CORRECT
import platformEnv from '@onekeyhq/shared/src/platformEnv';
if (platformEnv.isNative) {
// React Native specific code
}
if (platformEnv.isWeb) {
// Web specific code
}
if (platformEnv.isDesktop) {
// Desktop (Electron) specific code
}
if (platformEnv.isExtension) {
// Browser extension specific code
}
// ❌ FORBIDDEN - Direct platform checks
if (typeof window !== 'undefined') { }
if (process.env.REACT_APP_PLATFORM === 'web') { }
Available Platform Flags
platformEnv.isNative // React Native (iOS or Android)
platformEnv.isWeb // Web browser
platformEnv.isDesktop // Electron desktop app
platformEnv.isExtension // Browser extension
platformEnv.isIOS // iOS specifically
platformEnv.isAndroid // Android specifically
platformEnv.isWebEmbed // Embedded web components
Platform-Specific File Structure
MyComponent/
├── index.ts # Main entry, common logic
├── MyComponent.tsx # Shared component
├── MyComponent.native.tsx # React Native specific
├── MyComponent.web.tsx # Web specific
├── MyComponent.desktop.tsx # Desktop specific
└── MyComponent.ext.tsx # Extension specific
The bundler automatically resolves the correct file based on platform.
Example: Platform-Specific Storage
// storage.ts - shared interface
export interface IStorage {
get(key: string): Promise<string | null>;
set(key: string, value: string): Promise<void>;
}
// storage.native.ts
import AsyncStorage from '@react-native-async-storage/async-storage';
export const storage: IStorage = {
get: (key) => AsyncStorage.getItem(key),
set: (key, value) => AsyncStorage.setItem(key, value),
};
// storage.web.ts
export const storage: IStorage = {
get: async (key) => localStorage.getItem(key),
set: async (key, value) => localStorage.setItem(key, value),
};
// storage.desktop.ts
import { ipcRenderer } from 'electron';
export const storage: IStorage = {
get: (key) => ipcRenderer.invoke('storage:get', key),
set: (key, value) => ipcRenderer.invoke('storage:set', key, value),
};
Detailed Guide
For comprehensive cross-platform patterns and platform considerations, see cross-platform.md.
For current development tool and minimum platform versions, see platform-requirements.md. Verify version values against the referenced repository files before relying on them.
Topics covered:
- Platform extensions and file structure
- Platform detection with
platformEnv - Platform-specific imports
- Platform considerations (Extension, Mobile, Desktop, Web)
- Real-world examples
- Cross-platform checklist
Platform Considerations
Extension (Chrome, Firefox, Edge, Brave)
- MV3/service worker lifetimes, permissions, CSP, background script limitations
Mobile (iOS/Android)
- WebView limitations, native modules, background/foreground states, deep linking
Desktop (Electron)
- Security boundaries, IPC communication, file system access
Web
- CORS restrictions, storage limitations, XSS prevention, bundle size
Checklist
- Platform-specific code uses correct file extension
- Uses
platformEnvinstead of direct checks - Common logic extracted to shared files
- Tested on all target platforms
Related Skills
/1k-coding-patterns- General coding patterns/1k-architecture- Project structure and imports
When not to use it
- →When performing direct platform checks like typeof window
- →For projects not using the OneKey monorepo structure
Limitations
- →Requires adherence to specific monorepo file structure
- →Platform-specific code must be tested on all target platforms
How it compares
It mandates a standardized file-based resolution pattern instead of relying on ad-hoc conditional checks within shared files.
Compared to similar skills
1k-cross-platform side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| 1k-cross-platform (this skill) | 1 | 28d | Review | Intermediate |
| react-native-architecture | 55 | 2mo | Review | Advanced |
| react-native-architecture | 0 | 3mo | No flags | Intermediate |
| flutter-expert | 73 | 4mo | No flags | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by OneKeyHQ
View all by OneKeyHQ →You might also like
react-native-architecture
wshobson
Build production React Native apps with Expo, navigation, native modules, offline sync, and cross-platform patterns. Use when developing mobile apps, implementing native integrations, or architecting React Native projects.
react-native-architecture
Anhvu1107
ALWAYS use this when the request matches React Native Architecture: Production-ready patterns for React Native development with Expo, including navigation, state management, native modules, and offline-first architecture.
flutter-expert
sickn33
Master Flutter development with Dart 3, advanced widgets, and multi-platform deployment. Handles state management, animations, testing, and performance optimization for mobile, web, desktop, and embedded platforms. Use PROACTIVELY for Flutter architecture, UI implementation, or cross-platform features.
react-native-design
wshobson
Master React Native styling, navigation, and Reanimated animations for cross-platform mobile development. Use when building React Native apps, implementing navigation patterns, or creating performant animations.
nextjs-best-practices
davila7
Next.js App Router principles. Server Components, data fetching, routing patterns.
flutter
alinaqi
Flutter development with Riverpod state management, Freezed, go_router, and mocktail testing