1k coding patterns

From OneKeyHQ/app-monorepo · View interactive version

1k coding patterns is an AI agent skill from the GitHub repository OneKeyHQ/app-monorepo. OneKey coding patterns for TypeScript, React, promises, date formatting, and error handling.

How to use this skill

Skill file

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 |

| Date formatting | date-formatting.md | Use OneKey dateUtils, not native date formatting |

| Error handling | error-handling.md | Preserve errors across RPC/runtime boundaries |

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

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.