AgentSkillsCN

code-style

涵盖函数声明、async/await 模式,以及客户端与服务器端的错误处理等代码风格规范。当需要编写或审查代码、实现函数逻辑、处理错误、格式化代码,或当用户提及代码风格、模式、async、await、错误处理、try/catch、比较运算,或命名规范时,可调用此技能。

SKILL.md
--- frontmatter
name: code-style
description: Code style patterns including function declarations, async/await patterns, and error handling for both client and server. Use when writing or reviewing code, implementing functions, handling errors, formatting code, or when user mentions style, patterns, async, await, error handling, try/catch, comparisons, or naming conventions.
license: Unlicense

Code Style

Core code style patterns for consistent codebase.

Quick Reference

  • Functions: See functions.md - named functions over arrow functions for declarations
  • Async/Await: See async.md - always async/await, never .then()
  • Error Handling: See errors.md - try/catch/finally with type guards
  • Comparisons: See comparisons.md - explicit comparisons, no implicit coercion
  • Formatting: See formatting.md - code formatting rules (Drizzle schemas, Vue files, spacing)
  • Naming: See naming.md - no abbreviations, descriptive names

Core Principles

  • Named functions for exports and declarations
  • Arrow functions only for inline callbacks
  • async/await always, never .then()
  • try/catch/finally for proper cleanup
  • Type guards for client-side errors
  • createError for server-side errors
  • Explicit return types on exported functions
  • Explicit comparisons (=== undefined, === null, === false !==) over implicit (!value)