Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Ts Clean Functions

ASecurity

Use when writing, fixing, editing, or refactoring TypeScript functions. Enforces Clean Code principles—maximum 3 arguments, single responsibility, no flag parameters. Also trigger on: functions (or React components) with 4+ parameters/props, boolean flag parameters like `isTest`, functions that mutate their parameters (e.g. push to an input array), unused exports or dead helper functions, or asks like "too many props", "split this function", "is this still used". Also trigger on: helpers defi...

2 stars
0 votes
0 copies
0 views
Added 9/19/2026
developmenttypescriptgoreactrefactoringgitapi

Works with

api

Security Analysis

A100/100

Scanned 9/19/2026

$npx -y skills add CasLubbers/code-design-skills --skill ts-clean-functions --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ts Clean Functions?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Ts Clean Functions
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/caslubbers-ts-clean-functions/badge)](https://www.skillsdirectory.com/skills/caslubbers-ts-clean-functions)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: ts-clean-functions
description: Use when writing, fixing, editing, or refactoring TypeScript functions. Enforces Clean Code principles—maximum 3 arguments, single responsibility, no flag parameters. Also trigger on: functions (or React components) with 4+ parameters/props, boolean flag parameters like `isTest`, functions that mutate their parameters (e.g. push to an input array), unused exports or dead helper functions, or asks like "too many props", "split this function", "is this still used". Also trigger on: helpers defined above the exported entry point that calls them, a module that has to be read bottom-up, a function mixing orchestration with low-level detail, or asks like "does this read top-down", "stepdown rule", "should this read like a book", "what order should these functions go in".
---

# Clean Functions

## F1: Too Many Arguments (Maximum 3)

```ts
// Bad - too many parameters
function createUser(
  name: string,
  email: string,
  age: number,
  country: string,
  timezone: string,
  language: string,
  newsletter: boolean
) {
  // ...
}

// Good - use a typed object
type UserData = {
  name: string;
  email: string;
  age: number;
  country: string;
  timezone: string;
  language: string;
  newsletter: boolean;
};

function createUser(data: UserData) {
  // ...
}
```

More than 3 arguments means your function is doing too much or needs
a data structure.

## F2: No Output Arguments

Don't modify arguments as side effects. Return values instead.

```ts
type Report = {
  content: string;
};

// Bad - modifies argument
function appendFooter(report: Report): void {
  report.content += "\n---\nGenerated by System";
}

// Good - returns new value
function withFooter(report: Report): Report {
  return {
    ...report,
    content: `${report.content}\n---\nGenerated by System`,
  };
}
```

## F3: No Flag Arguments

Boolean flags mean your function does at least two things.

```ts
// Bad - function does two different things
function render(isTest: boolean) {
  if (isTest) {
    renderTestPage();
  } else {
    renderProductionPage();
  }
}

// Good - split into two functions
function renderTestPage() {}
function renderProductionPage() {}
```

## F4: Delete Dead Functions

If it's not called, delete it. No "just in case" code. Git preserves history.

## The Stepdown Rule: Code Reads Top-Down

A module should read like a narrative: the highest level of abstraction first, each function
followed by the ones it calls. The reader descends one level at a time and can stop as soon as
they know enough.

```typescript
// Bad - the reader meets escaping details before knowing what the module does
function escapeQuotes(value: string): string { ... }
function serialiseRow(row: Row): string { ... }
export function exportOrders(orders: Order[]): string { ... }  // the point, buried

// Good - exported entry point first, helpers underneath in call order
export function exportOrders(orders: Order[]): string {
  return orders.map(serialiseRow).join("\n")
}

function serialiseRow(row: Row): string {
  return row.fields.map(escapeQuotes).join(",")
}

function escapeQuotes(value: string): string {
  return value.replaceAll('"', '""')
}
```

Two consequences follow:

**One level of abstraction per function.** A function mixing orchestration with string escaping has
no place in the ordering, because it belongs at two levels at once. That is the signal to split it.

```typescript
// Bad - policy and character-level detail in one breath
export async function publish(post: Post): Promise<void> {
  if (post.author.isBanned) return
  const body = post.body.replace(/\r\n/g, "\n").trim().slice(0, 5000)
  await db.posts.insert({ body })
}

// Good - every line is the same size of idea
export async function publish(post: Post): Promise<void> {
  if (!isPublishable(post)) return
  await store(post.author, normalise(post.body))
}
```

**Vertical distance tracks relatedness.** Callee directly below caller. Declarations close to first
use. Exported functions before the module-private helpers they call — a reader opening the file
sees the public surface first. In a React component, the component comes before its hooks-derived
helpers, not after.

If a file cannot be ordered this way, it holds more than one responsibility and wants splitting.

Attribution

CasLubbersCasLubbers
View sourceSee grades on GitHubMore from CasLubbers →
SSkills Directory ProSkills Directory

Get any skill into Claude in one click.

Download any skill as a ZIP for Claude.ai, Claude Desktop, or .claude/skills. $9/mo.

See Pro

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills Directory ProSkills Directory

Get any skill into Claude in one click.

Download any skill as a ZIP for Claude.ai, Claude Desktop, or .claude/skills. $9/mo.

See Pro

Related Skills

Clean Code

Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments

304955 votes

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

285172 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2222 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

10311 votes
View all in development →