1k-coding-patterns

star 1

Coding patterns and best practices for OneKey development. Use when writing React components, handling promises, error handling, or following code conventions. Triggers on react, component, hooks, promise, async, await, error, pattern, convention, typescript.

MikeCheng1208 By MikeCheng1208 schedule Updated 6/3/2026

name: 1k-coding-patterns description: Coding patterns and best practices for OneKey development. Use when writing React components, handling promises, error handling, or following code conventions. Triggers on react, component, hooks, promise, async, await, error, pattern, convention, typescript. allowed-tools: Read, Grep, Glob, Write, Edit

OneKey Coding Patterns and Best Practices

Quick Reference

Topic Guide Key Points
Promise handling promise-handling.md Always await or use void, never floating promises
React components react-components.md Named imports, functional components, no FC type
Restricted patterns restricted-patterns.md Forbidden: toLocaleLowerCase, direct hd-core import

Critical Rules Summary

Promise Handling

// ❌ FORBIDDEN - floating promise
apiCall();

// ✅ CORRECT
await apiCall();
// or
void apiCall(); // intentionally not awaited

React Components

// ❌ FORBIDDEN
import React, { FC } from 'react';
const MyComponent: FC<Props> = () => {};

// ✅ CORRECT
import { useState, useCallback } from 'react';
function MyComponent({ prop }: { prop: string }) {}

Restricted Patterns

// ❌ FORBIDDEN
string.toLocaleLowerCase()
import { x } from '@onekeyfe/hd-core';
import { localDbInstance } from '...';

// ✅ CORRECT
string.toLowerCase()
const { x } = await CoreSDKLoader();
import { localDb } from '...';

Related Skills

  • /1k-date-formatting - Date and time formatting
  • /1k-i18n - Internationalization and translations
  • /1k-error-handling - Error handling patterns
  • /1k-cross-platform - Platform-specific code
  • /1k-code-quality - Linting and code quality
  • /1k-performance - Performance optimization
  • /1k-state-management - Jotai atom patterns
  • /1k-architecture - Project structure and import rules
  • /1k-code-quality - Lint fixes, pre-commit tasks
Install via CLI
npx skills add https://github.com/MikeCheng1208/BattleTree --skill 1k-coding-patterns
Repository Details
star Stars 1
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator
MikeCheng1208
MikeCheng1208 Explore all skills →