# Clean Codejs Functions

> Function design patterns emphasizing single responsibility and clarity.

- Skill: `damianwrooby/clean-codejs-functions` (Agent Skill)
- Install (CLI): `npx skillmds@latest add damianwrooby/clean-codejs-functions`
- Raw SKILL.md: https://api.skillmd.com/api/skills/damianwrooby/clean-codejs-functions/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: damianwrooby (https://skillmd.com/u/damianwrooby)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/damianwrooby/clean-codejs-functions

---


# Clean Code JavaScript – Function Patterns

## Table of Contents
- Single Responsibility
- Function Size
- Parameters
- Side Effects

## Single Responsibility

```js
// ❌ Bad
function handleUser(user) {
  saveUser(user);
  sendEmail(user);
}

// ✅ Good
function saveUser(user) {}
function notifyUser(user) {}
```

## Function Size

Keep functions small (ideally < 20 lines).

## Parameters

```js
// ❌ Bad
function createUser(name, age, city, zip) {}

// ✅ Good
function createUser({ name, age, address }) {}
```

## Side Effects

```js
// ❌ Bad
let total = 0;
function add(value) {
  total += value;
}

// ✅ Good
function add(total, value) {
  return total + value;
}
```

