ts-google
Google TypeScript Best Practices
Comprehensive TypeScript style guide based on Google's internal standards, designed for AI agents and LLMs. Contains 45 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.
When to Apply
Reference these guidelines when:
- Writing new TypeScript code
- Organizing modules and imports
- Designing type annotations and interfaces
- Creating classes and functions
- Reviewing code for style consistency
- Refactoring existing TypeScript code
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Module Organization | CRITICAL | module- |
| 2 | Type Safety | CRITICAL | types- |
| 3 | Class Design | HIGH | class- |
| 4 | Function Patterns | HIGH | func- |
| 5 | Control Flow | MEDIUM-HIGH | control- |
| 6 | Error Handling | MEDIUM | error- |
| 7 | Naming & Style | MEDIUM | naming- |
| 8 | Literals & Coercion | LOW-MEDIUM | literal- |
Quick Reference
1. Module Organization (CRITICAL)
module-named-exports- Use named exports over default exportsmodule-no-mutable-exports- Avoid mutable exportsmodule-es6-modules- Use ES6 modules exclusivelymodule-no-namespaces- Avoid TypeScript namespacesmodule-import-paths- Use relative paths for project importsmodule-import-type- Use import type for type-only importsmodule-export-api-surface- Minimize exported API surface
2. Type Safety (CRITICAL)
types-no-any- Never use the any typetypes-prefer-interfaces- Prefer interfaces over type aliases for objectstypes-explicit-structural- Explicitly annotate structural typestypes-nullable-patterns- Handle nullable types correctlytypes-array-syntax- Use consistent array type syntaxtypes-no-wrapper-types- Never use wrapper object typestypes-prefer-map-set- Prefer Map and Set over index signaturestypes-no-empty-object- Avoid empty object type
3. Class Design (HIGH)
class-parameter-properties- Use parameter properties for constructor assignmentclass-readonly-properties- Mark properties readonly when never reassignedclass-no-private-fields- Use TypeScript private over private fieldsclass-no-static-containers- Avoid container classes with only static membersclass-constructor-parens- Always use parentheses in constructor callsclass-no-prototype-manipulation- Never manipulate prototypes directly
4. Function Patterns (HIGH)
func-declarations-over-expressions- Prefer function declarations over expressionsfunc-arrow-concise-bodies- Use concise arrow function bodies appropriatelyfunc-avoid-this-rebinding- Avoid rebinding thisfunc-rest-parameters- Use rest parameters over argumentsfunc-generator-syntax- Use correct generator function syntaxfunc-default-parameters- Use default parameters sparingly
5. Control Flow (MEDIUM-HIGH)
control-always-use-braces- Always use braces for control structurescontrol-triple-equals- Always use triple equalscontrol-for-of-iteration- Prefer for-of over for-in for arrayscontrol-switch-default- Always include default case in switchcontrol-no-assignment-in-condition- Avoid assignment in conditional expressions
6. Error Handling (MEDIUM)
error-throw-errors- Always throw Error instanceserror-catch-unknown- Type catch clause variables as unknownerror-empty-catch-comments- Document empty catch blockserror-avoid-assertions- Avoid type and non-null assertions
7. Naming & Style (MEDIUM)
naming-identifier-styles- Use correct identifier naming stylesnaming-descriptive-names- Use descriptive namesnaming-no-decorative-underscores- Avoid decorative underscoresnaming-no-interface-prefix- No I prefix for interfacesnaming-constants- Use CONSTANT_CASE for true constants
8. Literals & Coercion (LOW-MEDIUM)
literal-single-quotes- Use single quotes for stringsliteral-number-formats- Use correct number literal formatsliteral-explicit-coercion- Use explicit type coercionliteral-array-constructor- Avoid Array constructor
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Reference Files
| File | Description |
|---|---|
| AGENTS.md | Complete compiled guide with all rules |
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |
More from pproenca/dot-skills
zod
Zod schema validation best practices for type safety, parsing, and error handling. This skill should be used when defining z.object schemas, using z.string validations, safeParse, or z.infer. This skill does NOT cover React Hook Form integration patterns (use react-hook-form skill) or OpenAPI client generation (use orval skill).
2.0Kclean-architecture
Clean Architecture principles and best practices from Robert C. Martin's book. This skill should be used when designing software systems, reviewing code structure, or refactoring applications to achieve better separation of concerns. Triggers on tasks involving layers, boundaries, dependency direction, entities, use cases, or system architecture.
1.4Kemilkowal-animations
Emil Kowalski's animation best practices for web interfaces. Use when writing, reviewing, or implementing animations in React, CSS, or Framer Motion. Triggers on tasks involving transitions, easing, gestures, toasts, drawers, or motion.
917vitest
Vitest testing framework patterns for test setup, async testing, mocking with vi.*, snapshots, and test performance (formerly test-vitest). This skill should be used when writing or debugging Vitest tests. This skill does NOT cover TDD methodology (use test-tdd skill), API mocking with MSW (use test-msw skill), or Jest-specific APIs.
906typescript
This skill should be used when the user asks to "optimize TypeScript performance", "speed up tsc compilation", "configure tsconfig.json", "fix type errors", "improve async patterns", or encounters TS errors (TS2322, TS2339, "is not assignable to"). Also triggers on .ts, .tsx, .d.ts file work involving type definitions, module organization, or memory management. Does NOT cover TypeScript basics, framework-specific patterns, or testing.
820nuqs
nuqs (type-safe URL query state) best practices for Next.js applications. This skill should be used when writing, reviewing, or refactoring code that uses nuqs for URL state management. Triggers on tasks involving useQueryState, useQueryStates, search params, URL state, query parameters, nuqs parsers, or Next.js routing with state.
734