---
title: "Coding Standards & Languages"
slug: "coding"
category: "coding"
tags: ["moc", "coding", "principles", "python", "typescript"]
status: "stable"
last_updated: 2026-08-14
summary: "Language-agnostic coding principles, version control, testing, and per-language guides for Python, TypeScript, Swift, Pine Script, and shell."
---

> General coding principles plus per-language pages. Start with [[general-principles]] and then drill into the language you are working in.

## Pages

- [[general-principles]]: Naming, comments, errors, dependencies, testing.
- [[git]]: Commit hygiene, rebase vs merge, Conventional Commits, hooks.
- [[testing]]: Trophy shape, flake budget, determinism, coverage as floor.
- [[python]]: Modern Python: types, ruff, pytest, async.
- [[typescript]]: Strict TypeScript, narrow types, runtime validation.
- [[typescript-strict-mode]]: `strict: true` plus `noUncheckedIndexedAccess` and `exactOptionalPropertyTypes`; migrating a loose codebase.
- [[typescript-types-vs-interfaces]]: `type` by default; `interface` for public, mergeable APIs; intersection vs extension.
- [[typescript-generics]]: Generic functions, `extends` constraints, inference, defaults; Repository and Result patterns.
- [[typescript-narrowing]]: `typeof`, `instanceof`, `in`, discriminated unions, user-defined predicates, `never` exhaustiveness, assertion functions.
- [[coding/typescript-utility-types]]: `Pick`, `Omit`, `Partial`, `Required`, `Readonly`, `Record`, `Exclude`, `Extract`, `NonNullable`, `ReturnType`, `Awaited`; rolling your own.
- [[typescript-runtime-validation]]: Zod by default; Valibot for bundle size; tRPC for typed RPC; validate every boundary.
- [[typescript-tsconfig]]: `target`, `module`, `moduleResolution`, `esModuleInterop`, `skipLibCheck`, `forceConsistentCasingInFileNames`; project references for monorepos.
- [[swift]]: Swift 6 concurrency and idiomatic API design.
- [[swift-actors]]: actors, @MainActor, nonisolated, and Sendable to eliminate data races at compile time.
- [[swift-async-await]]: async/await ergonomics, TaskGroup, cancellation, and bridging callbacks with withCheckedContinuation.
- [[swift-error-handling]]: throws over optionals, group errors by domain, typed throws in Swift 6, handle at the boundary.
- [[swift-modules]]: SPM layout, import semantics, private-by-default access, and resource handling.
- [[swift-optionals]]: never force-unwrap; if let, guard let, and ?? to handle Optional values safely.
- [[swift-protocols]]: protocol-oriented design, associated types, composition, existentials with any, generics vs type erasure.
- [[swift-value-types]]: why structs are the default, when classes are justified, and copy-on-write in collections.
- [[python-async]]: asyncio foundations, TaskGroup for structured concurrency, cancellation, mixing sync and async.
- [[python-dependency-management]]: uv over pip+venv, pyproject.toml extras, pipx for global tools, pip-audit.
- [[python-packaging]]: pyproject.toml as single source of truth, src layout, entry points, wheel building, PyPI with uv.
- [[python-performance]]: profile first, algorithmic wins over micro-optimizations, numpy vectorization, GIL constraints.
- [[python-security]]: Pydantic for input validation, parameterized SQL, pickle avoidance, secrets via env, SSRF prevention.
- [[python-testing]]: pytest fixtures, parametrize, Hypothesis, pytest-cov, monkeypatch over MagicMock.
- [[python-typing]]: TypeVar, Protocol, Self, TypeAlias, Annotated, TypeGuard, and runtime introspection in Python 3.12+.
- [[pine-script]]: Pine v5 for TradingView indicators and strategies.
- [[shell]]: Bash with `set -euo pipefail`, quoting, shellcheck.
- [[pine-script-indicators]]: Declare Pine v6 indicators with indicator(), configure inputs, plot series, and wire alertcondition for chart overlays.
- [[pine-script-libraries]]: Declare Pine v6 libraries with library(), export typed functions, version them, and import them in indicators and strategies.
- [[pine-script-security]]: Avoid repainting in Pine v6: understand request.security lookahead, barmerge modes, and the no-repaint pattern for higher-timeframe data.
- [[pine-script-strategies]]: Declare Pine v6 strategies with strategy(), use strategy.entry and strategy.exit, configure backtesting parameters, and read the Strategy Tester.

## Related MOCs

- [[frontend/index|Frontend]]
- [[backend/index|Backend]]
- [[ios/index|iOS]]
- [[ai-agents/index|AI Agents]]
