The programming skill must be used for any work involving .py, .pyi, .rs, .ts, .tsx, .mts, .cts, or .go files. It follows a strict philosophy of type-safety, modern toolchains, and architectural honesty.
Core Principles:
- Strict Types: Use the type system as a proof system to make illegal states unrepresentable.
- Parse, Don't Validate: Untrusted input is parsed into typed values at the boundary (using Pydantic v2,
serde, or Zod) and never re-validated inside the logic layer. - Semantic Primitives: Use
NewType (Python), newtype tuple structs (Rust), or branded types (TypeScript) so that distinct concepts (e.g., UserId vs string) cannot be mixed. - Exhaustive Matching: Always use exhaustive variant matching for enums/discriminated unions. Avoid
if/elif/else for discriminating on tagged variants. - Minimalism: The best code is the code never written. Prioritize YAGNI, reuse existing patterns, and leverage standard libraries or dependencies before writing new code.