About 1k-coding-patterns
A OneKey repository skill that documents coding patterns and rules for promises, React components, restricted APIs, date formatting, and error handling. It is intended for contributors and coding agents implementing or reviewing OneKey code.
Key features
- 01Promise handling rules
- 02React component conventions
- 03Restricted API and import patterns
- 04OneKey date formatting guidance
- 05Error handling across RPC and runtime boundaries
Use cases
- 01Check promise handling during implementation
- 02Follow repository conventions for React components
- 03Choose the approved date formatting approach
- 04Review imports and error propagation
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ onekeyhq/ app-monorepo --skill 1k-coding-patternsAfter installing, type/1k-coding-patternsin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
references/date-formatting.mderror-handling.mdreferences/rules/date-formatting.mderror-handling.mdpromise-handling.mdreact-components.mdrestricted-patterns.mdDetails
From the project READMEOneKey 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
/1k-i18n- Internationalization and translations/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
Comments
Markdown supported