BrowserOS ts-style-review
Review TypeScript code against the Google TypeScript Style Guide plus team conventions. Use when reviewing TS code for style, naming, imports, type usage, or quality.
install
source · Clone the upstream repo
git clone https://github.com/browseros-ai/BrowserOS
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/browseros-ai/BrowserOS "$T" && mkdir -p ~/.claude/skills && cp -r "$T/packages/browseros-agent/.claude/skills/ts-style-review" ~/.claude/skills/browseros-ai-browseros-ts-style-review && rm -rf "$T"
manifest:
packages/browseros-agent/.claude/skills/ts-style-review/SKILL.mdsource content
TypeScript Style Guide Review
When reviewing TypeScript code, check against these sections. For full rules and examples, see google-ts-styleguide.md.
1. Source File Structure
- File order: copyright,
, imports, implementation@fileoverview - Use named exports only — no default exports
- Use ES6 modules — no
, nonamespacerequire() - Prefer namespace imports for large APIs, named imports for frequently used symbols
- No mutable exports (
) — use getter functions insteadexport let - See google-ts-styleguide.md § 3. Source file structure
2. Variables & Literals
by default,const
when reassigned, neverletvar- One variable per declaration
- Single quotes for strings, template literals for concatenation
- No
orArray()
constructorsObject() - See google-ts-styleguide.md § 4. Language features
3. Classes
- Use
for properties never reassigned after constructorreadonly - Use parameter properties (
)constructor(private readonly foo: Foo) - No
keyword — TypeScript is public by defaultpublic - No
fields — use#private
modifierprivate - No prototype manipulation
- See google-ts-styleguide.md § 4. Classes
4. Functions
- Prefer function declarations for named functions
- Arrow functions for callbacks and nested functions — never function expressions
- Use rest parameters, not
arguments - Use spread syntax, not
Function.prototype.apply - See google-ts-styleguide.md § 4. Functions
5. Control Flow & Error Handling
- Always use braces for control flow blocks
- Always
and===
(exception:!==
for null/undefined check)== null
for arrays, neverfor...offor...in- Only throw
instances (or subclasses), never stringsError - All
must haveswitch
, no fall-throughdefault - See google-ts-styleguide.md § 4. Control structures
6. Naming
: classes, interfaces, types, enums, decorators, TSX componentsUpperCamelCase
: variables, parameters, functions, methods, propertieslowerCamelCase
: global constants, enum valuesCONSTANT_CASE- Descriptive names — no ambiguous abbreviations
- Treat acronyms as words (
, notloadHttpUrl
)loadHTTPURL - See google-ts-styleguide.md § 5. Naming
7. Type System
- Prefer
overinterface
alias for object shapestype - Use
overunknown
— narrow with type guardsany - Use optional (
) over?| undefined
for simple types,T[]
for complexArray<T>- No wrapper types (
,String
,Boolean
) — use primitivesNumber - No
or@ts-ignore@ts-nocheck - See google-ts-styleguide.md § 6. Type system
8. Schema & Type Definitions (Team Convention)
- Use Zod for defining schemas, then derive TypeScript types with
z.infer<typeof schema> - If types are not shared across files, define the Zod schema and inferred type at the top of the same file that uses them
- If types are shared, place them in a shared types/schemas module
- Example:
import { z } from 'zod'; const UserSchema = z.object({ id: z.string(), name: z.string(), email: z.string().email(), }); type User = z.infer<typeof UserSchema>;
9. Comments & Documentation
for public API documentation/** JSDoc */
for implementation comments//- No type annotations in JSDoc — TypeScript handles types
- Mark deprecated code with
@deprecated - See google-ts-styleguide.md § 8. Comments and documentation