1k-cross-platform

Cross-platform development patterns for OneKey. Use when writing platform-specific code, handling platform differences, or working with native/web/desktop/extension platforms. Triggers on platform, native, web, desktop, extension, iOS, Android, Electron, platformEnv, .native.ts, .web.ts, .desktop.ts, .ext.ts, cross-platform, multi-platform.

181 stars

Best use case

1k-cross-platform is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Cross-platform development patterns for OneKey. Use when writing platform-specific code, handling platform differences, or working with native/web/desktop/extension platforms. Triggers on platform, native, web, desktop, extension, iOS, Android, Electron, platformEnv, .native.ts, .web.ts, .desktop.ts, .ext.ts, cross-platform, multi-platform.

Teams using 1k-cross-platform should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/1k-cross-platform/SKILL.md --create-dirs "https://raw.githubusercontent.com/majiayu000/claude-skill-registry/main/skills/data/1k-cross-platform/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/1k-cross-platform/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How 1k-cross-platform Compares

Feature / Agent1k-cross-platformStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Cross-platform development patterns for OneKey. Use when writing platform-specific code, handling platform differences, or working with native/web/desktop/extension platforms. Triggers on platform, native, web, desktop, extension, iOS, Android, Electron, platformEnv, .native.ts, .web.ts, .desktop.ts, .ext.ts, cross-platform, multi-platform.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# 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:**

```typescript
// ✅ 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

```typescript
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

```typescript
// 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](references/rules/cross-platform.md).

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 `platformEnv` instead 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

Related Skills

add_platform

181
from majiayu000/claude-skill-registry

Adds a new AI platform to DeepWork with adapter, templates, and tests. Use when integrating Cursor, Windsurf, or other AI coding tools.

add_platform.verify

181
from majiayu000/claude-skill-registry

Sets up platform directories and verifies deepwork install works correctly. Use after implementation to confirm integration.

add_platform.research

181
from majiayu000/claude-skill-registry

Captures CLI configuration and hooks system documentation for the new platform. Use when starting platform integration.

add_platform.implement

181
from majiayu000/claude-skill-registry

Creates platform adapter, templates, tests with 100% coverage, and README documentation. Use after adding hook capabilities.

add_platform.add_capabilities

181
from majiayu000/claude-skill-registry

Updates job schema and adapters with any new hook events the platform supports. Use after research to extend DeepWork's hook system.

1k-platform-requirements

181
from majiayu000/claude-skill-registry

Documents minimum SDK/OS version requirements for all OneKey platforms. Use when checking platform compatibility, understanding deployment targets, verifying version requirements, or when user asks if their device can run the project. Triggers on minimum version, SDK version, API level, deployment target, platform requirements, iOS version, Android version, Chrome version, Electron version, can I run, environment check, device compatibility, check environment.

lets-go-rss

159
from majiayu000/claude-skill-registry

A lightweight, full-platform RSS subscription manager that aggregates content from YouTube, Vimeo, Behance, Twitter/X, and Chinese platforms like Bilibili, Weibo, and Douyin, featuring deduplication and AI smart classification.

Content & Documentation

modal-deployment

159
from majiayu000/claude-skill-registry

Run Python code in the cloud with serverless containers, GPUs, and autoscaling using Modal. This skill enables agents to generate code for deploying ML models, running batch jobs, serving APIs, and scaling compute-intensive workloads.

DevOps & Infrastructure

astro

159
from majiayu000/claude-skill-registry

This skill provides essential Astro framework patterns, focusing on server-side rendering (SSR), static site generation (SSG), middleware, and TypeScript best practices. It helps AI agents implement secure authentication, manage API routes, and debug rendering behaviors within Astro projects.

Coding & Development

tech-blog

159
from majiayu000/claude-skill-registry

Generates comprehensive technical blog posts, offering detailed explanations of system internals, architecture, and implementation, either through source code analysis or document-driven research.

Content & DocumentationClaude

thor-skills

159
from majiayu000/claude-skill-registry

An entry point and router for AI agents to manage various THOR-related cybersecurity tasks, including running scans, analyzing logs, troubleshooting, and maintenance.

SecurityClaude

whisper-transcribe

159
from majiayu000/claude-skill-registry

Transcribes audio and video files to text using OpenAI's Whisper CLI, enhanced with contextual grounding from local markdown files for improved accuracy.

Media Processing