一键导入
early-return-from-functions
Use early returns to reduce nesting and clarify control flow. Use when simplifying conditionals or guard clauses.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use early returns to reduce nesting and clarify control flow. Use when simplifying conditionals or guard clauses.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when the task asks for a visually strong landing page, website, app, prototype, demo, or game UI. This skill enforces restrained composition, image-led hierarchy, cohesive content structure, and tasteful motion while avoiding generic cards, weak branding, and UI clutter.
Automate browser interactions, test web pages and work with Playwright tests.
Advanced guidelines and best practices for writing tests using Vitest. Apply this skill when generating, reviewing, or refactoring test codes to prevent common pitfalls and ensure high performance.
Fixed 1536×864 touch viewport — grid, margins, 8px rhythm, touch targets, typography, components, vertical rhythm, and QA checklist for panel/kiosk/HMI. Use when designing or implementing UIs for this resolution with touch-first input.
Lists available Cursor agents (planner, architect, tdd-guide, code-reviewer, security-reviewer, build-error-resolver, e2e-runner, refactor-cleaner, doc-updater) and when to use each. Use when the user asks which agent to use, how to delegate work, or what agents are available.
Async parallelization patterns — Promise.all, waterfall prevention, dependency-based parallelism, RSC component composition, deferred await. Use when optimizing async operations, API routes, or data fetching.
| name | early-return-from-functions |
| description | Use early returns to reduce nesting and clarify control flow. Use when simplifying conditionals or guard clauses. |
Return early when result is determined to skip unnecessary processing.
Incorrect (processes all items even after finding answer):
function validateUsers(users: User[]) {
let hasError = false;
let errorMessage = '';
for (const user of users) {
if (!user.email) {
hasError = true;
errorMessage = 'Email required';
}
if (!user.name) {
hasError = true;
errorMessage = 'Name required';
}
// Continues checking all users even after error found
}
return hasError ? { valid: false, error: errorMessage } : { valid: true };
}
Correct (returns immediately on first error):
function validateUsers(users: User[]) {
for (const user of users) {
if (!user.email) {
return { valid: false, error: 'Email required' };
}
if (!user.name) {
return { valid: false, error: 'Name required' };
}
}
return { valid: true };
}