SuperAPI AI Directory

code-principles

General & other

View repository

Updated 10-16 08:49

About this skill

Code Principles

This skill provides multi-language code standard guidance to help write high-quality code that follows best practices.

Usage scenarios

Refer to the corresponding language's standards when performing the following tasks:

  • Writing new code - When creating new functions, classes, or modules
  • Refactoring code - When improving existing code structure and quality
  • Code review - When checking whether code conforms to standards
  • Adding features - When extending functionality on top of existing code
  • Fixing bugs - When modifying code to solve problems

Language standard mapping

Select the corresponding standard file based on the file extension:

File type Reference document Key principles
.py py-principles.md Type safety, modern syntax, immutability, exception handling
.rs rust-principles.md Ownership safety, zero-cost abstractions, idiomatic syntax, concurrency safety
.ts, .tsx, .js, .jsx ts-principles.md Type safety, modern JS/TS, React best practices, accessibility

Core principles

Training data becomes outdated. When in doubt about framework usage, API features, or best practices, consult official documentation first rather than making decisions from memory.

Workflow

  1. Identify the language - Determine the target language based on the file path
  2. Read the standard - Use the Read tool to read the corresponding reference file
  3. Apply the principles - Based on the standard, ensure the code meets requirements such as type safety, error handling, and naming conventions
  4. Self-check - Before completion, check whether it conforms to the language's best practices

Core checkpoints

Focus dimensions common to all languages:

  • Type annotations/signatures are complete and accurate
  • Error handling is appropriate (catch specific exceptions, do not ignore errors)
  • Naming is clear, intent is explicit
  • Functions have a single responsibility and controllable complexity
  • No obvious performance or security issues

Framework/library-specific code must reference official documentation; see the "Reference when uncertain" subsection of each language file for details.