# Code Standards

> Standards for project code shape — English identifiers, size limits, parameters, nesting, early returns, declaration site, blank lines, semicolons. Use when writing or reviewing frontend or backend code for size, structure, or style. Don't use for React-specific patterns (use react), JS/TS language idioms (use javascript), folder placement (use folder-structure), or test coverage (use tests).

- Skill: `pedronauck/code-standards` (Agent Skill)
- Install (CLI): `npx skillmds@latest add pedronauck/code-standards`
- Raw SKILL.md: https://api.skillmd.com/api/skills/pedronauck/code-standards/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Web & Frontend
- Author: pedronauck (https://skillmd.com/u/pedronauck)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/pedronauck/code-standards

---


# Code Standards

Apply these shape rules to every frontend and backend change. When the change includes React components or hooks, invoke `react` in full. When it turns on JS/TS language shape (`const`/`let`, async, ESM, typing), invoke `javascript` in full. When placing or moving a file, invoke `folder-structure` in full.

## Reference — shape rules

### English identifiers

Name files, folders, variables, functions, methods, classes, interfaces, types, components, properties, routes, and technical messages in English. User-facing copy may follow the product locale.

### Size limits

Keep each file at most 80 lines (imports, declarations, and blanks included). Keep each function or method at most 30 lines. When a limit breaks, extract a cohesive responsibility into a named module or function — never by packing multiple statements onto one line.

### Parameters

Accept at most three parameters. Past three, take a named options object.

```ts
type CreateReportOptions = {
  title: string;
  ownerId: string;
  format: string;
  includeCharts: boolean;
};

function createReport(options: CreateReportOptions) {}
```

### Nesting and early returns

Stay at most two levels of `if`/`else`. Prefer guard clauses so the happy path stays at the outer level.

```ts
function authorizeUser(user?: User): void {
  if (!user || !user.isActive || !user.hasPermission) return;
  grantAccess(user);
}
```

### Declaration site

Declare each variable immediately before its first use.

### Blank lines inside functions

Keep statements in a function contiguous — no blank lines between them. Separate responsibilities by extracting named functions instead.

### Semicolons

Terminate statements with `;` wherever the syntax allows (assignments, calls, returns, imports, exports, type-property declarations). Omit `;` after control blocks, function/class/interface bodies when the syntax does not require it.

## Reference — review gate

Before finishing a change, confirm every rule above holds for every touched file and function.

