top-down-typescript
БесплатноБез исполняемых скриптовНе проверенTypeScript and JavaScript coding style conventions, centered on top-down narrative ordering (caller first, helpers below) and functions over classes. Read…
от paleo★ 91 звезда на GitHubОб этом скилле
Top-Down TypeScript Coding Style
General Rules
- Dead (unused) code SHOULD NOT be kept (YAGNI principle).
- Do not write multiple consecutive blank lines.
- Changes to linter rules MUST be discussed before being implemented.
- Code SHOULD NOT contain commented-out code, unless a comment explains why.
Code Organization
Usage comes first, implementation after. Exception: with inheritance — when an interface extends another, write the parent first.
Order code top-down: each file reads as a story, from entry point to leaves. The reader meets the highest-level thing first, then drills down into its dependencies:
// 1. Imports import { ... } from "..."; // 2. Module-level constants and variables (exported first, then internal) export const PUBLIC_CONST = ...; const INTERNAL_CONST = ...; // 3. Shared types — main type first, then types it references export interface MainType { detail: DetailType; } export interface DetailType { ... } // 4. Entry-point (exported) function export function doThing() { stepOne(); stepTwo(); } // 5. Internal functions called by the entry point, in call order function stepOne() { stepOneHelper(); } function stepOneHelper() { ... } function stepTwo() { ... }Module-level constants and variables (
const,let,varvalue declarations at the top of the file — both exported and internal) MUST be placed immediately after imports, before any type definitions, functions, or classes. The reader sees them first and treats them as the file's configuration surface.Functions: write the caller first, then the functions it calls, recursively. A helper appears just below its caller, not grouped at the bottom of the file. If a helper is called by several siblings, place it after its first caller.
Types: write the main (top-level) type first, then the types it references, recursively. Same top-down rule as functions.
Types attached to a single function (or class, or other declaration) — i.e. used only in that one signature, like a
MyComponentPropsinterface used only byMyComponent— must be placed immediately before that declaration, not in the top type block.Exports are not a sorting criterion on their own: a
functionbeingexported does not pull it to the top — its position is determined by who calls it. The entry points of a file are usually exported, which is why they tend to appear first, but that is a consequence of the top-down rule, not the rule itself.
Code Quality Standards
- Strive for elegant solutions from the first implementation
- Avoid redundant operations, especially expensive ones like image conversion
- Avoid duplicated code and logic
- Pass previously calculated values between functions instead of recalculating
- Use early returns to simplify code flow when possible
- For code that leaves the current flow (
throw,return,continue,break), when it fits on one line, write it on one line (e.g.,if (!condition) return false;instead of multi-line format) - Use function and variable names that clearly convey intent, reducing the need for comments
- Keep functions small with a single responsibility
- Avoid
any; take the time to find the proper type. If you fail to find one, always insert a/* FIXME */after theany. For example:let myVariable: any /* FIXME */;. - Export only functions (or variables, classes) that are imported from elsewhere. By default, do not export.
- Always export locally declared types and interfaces used in public signatures, even if no file imports them yet.
- When a named type describes a public result, use it as the return type (
Promise<T>for async functions).
Imports
- Always use ESM import syntax (e.g.,
import { X } from "y.js"instead ofrequire). - Avoid circular imports between modules.
TypeScript, JavaScript
- Never use
enumandnamespace. - Prefer
constoverlet. - Prefer
undefinedovernull. - Prefer
??over||. - Prefer
++iand--ioveri++andi--. - Prefer
new Error()overError(). - At the top level, prefer the
functionandclassdeclarative syntax over creating them as constants. - Keep an empty line between top-level functions, classes, interfaces.
- Implementation of a getter or setter (EcmaScript 5 syntax) must never throw exceptions.
- Prefer
interfacedeclarations overtypealiases. - Prefer a single capital letter for generics parameters, such as
T,K, etc. - Do not differentiate between an absent property and a property with an
undefinedvalue. - Use camelCase for string literal values in TypeScript union types (e.g.,
"normal" | "gracefulShutdown" | "backupMode"instead of"normal" | "graceful-shutdown" | "backup-mode"). - Never use an empty string as a default value unless you really mean an empty string. If a variable might not have a value, use
undefinedor throw an error if the absence of value indicates a problem. - The existence of st
Установить top-down-typescript в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл top-down-typescript?
TypeScript and JavaScript coding style conventions, centered on top-down narrative ordering (caller first, helpers below) and functions over classes. Read before writing or reviewing TypeScript/JavaScript code, including code inside a spec or a plan.
Как установить скилл top-down-typescript?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл top-down-typescript запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic