一键导入
1k-code-quality
Code quality standards — lint (eslint/oxlint), type check (tsc), pre-commit hooks, and comment conventions. All comments must be in English.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Code quality standards — lint (eslint/oxlint), type check (tsc), pre-commit hooks, and comment conventions. All comments must be in English.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Create or regenerate a patch-package patch in this monorepo. Use when you edit anything under node_modules/ and need a persisted .patch, or when `npx patch-package <pkg>` fails with "Couldn't find any versions for ... matches ^x@x". Keywords: patch-package, patch a package, regenerate patch, resolutions error.
App-side OneKey Trade/Swap/Market guide for Swap core, Swap Pro, Market speed-swap, K-line/chart, token selectors, cold-start frame-by-frame validation, quote/build/send flows, history/status, provider channels, PrivateSend-like channels, stock-trading channels, limit/order flows, fees, slippage, ETA, and cross-module funding handoffs.
Creates a Pull Request from current changes for OneKey app-monorepo. Use when user wants to create PR, submit changes, or merge feature branch. Handles branch creation, commit, push, and PR creation with conversation context extraction for code review AI.
AI-agent-driven UI verification for OneKey. Use to actually drive the running app and confirm a visual/interactive change works — Electron desktop via Chrome DevTools Protocol (CDP) on port 9222 with playwright-core, and React Native (iOS/Android) via callstack agent-device. Triggers on "verify the UI", "drive the app", "screenshot the change", "check it on desktop/simulator", "CDP 9222", "agent-device", "UI 验证", "跑一下看看", "截图确认".
App-side OneKey DeFi guide for Earn, Borrow, Staking, vaults, lending, protocol integrations, ABI-backed operations, native/provider-backed operations, pending transactions, history, route handoffs, risk display, and DeFi regression review.
Use only for explicit OneKey Perps/Hyperliquid (`views/Perp`, ServiceHyperLiquid, perpetuals, 永续/合约, Perps trading). Covers orderbook/L2/BBO, TWAP, scale/TIF/trigger/reduce-only, Perps TradingView/K-line, Perps Relay deposit, token selector, positions/account state/PnL/funding/margin/liquidation. Exclude generic Swap/Market/TradingView; Swap Relay quote/status/pending/requestId alone is not enough unless Perps deposit/Hyperliquid/`views/Perp`/`usePerpDeposit`/`fetchPerpDeposit*`/`perpsDepositOrderAtom` is explicit.
| name | 1k-code-quality |
| description | Code quality standards — lint (eslint/oxlint), type check (tsc), pre-commit hooks, and comment conventions. All comments must be in English. |
| allowed-tools | Read, Grep, Glob |
Linting, documentation, and general code quality standards for OneKey.
# Pre-commit (fast, only staged files)
yarn lint:staged
yarn tsc:staged
# CI only (full project check)
yarn lint # Comprehensive: TypeScript, ESLint, folder structure, i18n
yarn lint:only # Quick: oxlint only
yarn tsc:only # Full type check
Note: yarn lint is for CI only. For pre-commit, always use yarn lint:staged.
For fast pre-commit validation:
# Lint only modified files (recommended)
yarn lint:staged
# Or with type check
yarn lint:staged && yarn tsc:staged
// Unused variable - prefix with underscore
const { used, unused } = obj; // ❌ Error: 'unused' is defined but never used
const { used, unused: _unused } = obj; // ✅ OK
// Unused parameter - prefix with underscore
function foo(used: string, unused: number) {} // ❌ Error
function foo(used: string, _unused: number) {} // ✅ OK
// Floating promise - add void or await
someAsyncFunction(); // ❌ Error: Promises must be awaited
void someAsyncFunction(); // ✅ OK (fire-and-forget)
await someAsyncFunction(); // ✅ OK (wait for result)
All comments must be written in English:
// ✅ GOOD: English comment
// Calculate the total balance including pending transactions
// ❌ BAD: Chinese comment
// 计算总余额,包括待处理的交易
// ✅ GOOD: JSDoc in English
/**
* Fetches user balance from the blockchain.
* @param address - The wallet address to query
* @returns The balance in native token units
*/
async function fetchBalance(address: string): Promise<bigint> {
// ...
}
// ✅ GOOD: Explain non-obvious logic
// Use 1.5x gas limit to account for estimation variance on this chain
const gasLimit = estimatedGas * 1.5n;
// ✅ GOOD: Explain business logic
// Premium users get 50% discount on transaction fees
const fee = isPremium ? baseFee * 0.5 : baseFee;
// ❌ BAD: Obvious comment
// Set the value to 5
const value = 5;
Each function should perform a single, atomic task:
// ✅ GOOD: Single responsibility
async function fetchUserBalance(userId: string): Promise<Balance> {
const user = await getUser(userId);
return await getBalanceForAddress(user.address);
}
// ❌ BAD: Multiple responsibilities
async function fetchUserBalanceAndUpdateUI(userId: string) {
const user = await getUser(userId);
const balance = await getBalanceForAddress(user.address);
setBalanceState(balance);
showNotification('Balance updated');
logAnalytics('balance_fetched');
}
Don't create helpers for one-time operations:
// ❌ BAD: Over-abstracted
const createUserFetcher = (config: Config) => {
return (userId: string) => {
return fetchWithConfig(config, `/users/${userId}`);
};
};
const fetchUser = createUserFetcher(defaultConfig);
const user = await fetchUser(userId);
// ✅ GOOD: Simple and direct
const user = await fetch(`/api/users/${userId}`).then(r => r.json());
See code-quality.md for comprehensive guidelines:
See fix-lint.md for complete lint fix workflow:
If a technical term triggers spellcheck errors:
# Check if word exists
grep -i "yourword" development/spellCheckerSkipWords.txt
# Add if not present (ask team lead first)
echo "yourword" >> development/spellCheckerSkipWords.txt
yarn lint:staged passesyarn tsc:staged passes/1k-sentry-analysis - Sentry error analysis and fixes/1k-test-version - Test version creation workflow/1k-coding-patterns - General coding patterns