clean-codejs-functions

Function design patterns emphasizing single responsibility and clarity.

damianwrooby/javascript-clean-code-skills130 installsMITSynced Aug 26

Works with

Claude CodeCursorCodex CLIGitHub CopilotGemini CLI

Agent Skills format with YAML frontmatter. Claude Code reads it as-is.

---
name: "clean-codejs-functions"
description: "Function design patterns emphasizing single responsibility and clarity."
license: "MIT"
---

# 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;
}
```

More General & Other skills

← All General & Other skills

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY