Skip to content
Back to skills

Util Function

ASecurity

Creates a well-typed, tested utility function from a description

  • 10 stars
  • 0 votes
  • 0 copies
  • 6 views
  • Added May 27, 2026
data-aitypescriptbashperformance

Security analysis

A100/100

Scanned May 27, 2026

npx -y skills add berkcangumusisik/claude-code-practices --skill util-function --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Util Function?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Util Function
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/berkcangumusisik-util-function/badge)](https://www.skillsdirectory.com/skills/berkcangumusisik-util-function)

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

Download with Pro
SKILL.md
---
name: util-function
description: Creates a well-typed, tested utility function from a description
argument-hint: <description-of-what-it-should-do>
user-invocable: true
allowed-tools: Read Glob Edit
effort: low
---

## Generate Utility Function

Description: **$ARGUMENTS**

1. Check if a similar utility already exists:
```bash
grep -rn "export.*function\|export const" src/utils/ src/lib/ src/helpers/ 2>/dev/null | head -20
```

2. If a similar one exists, consider extending it instead of creating a new one.

3. Implement the function:
   - Pure function (no side effects) where possible
   - Full TypeScript generics/types
   - Handle edge cases: null, undefined, empty arrays/strings, negative numbers
   - Performance-conscious for likely large inputs

4. Write unit tests covering:
   - Normal usage
   - Edge cases
   - Type narrowing behavior

5. Place in the appropriate utils file or create `src/utils/<name>.ts`.

6. Add a usage example in JSDoc.

Example output:
```ts
/**
 * Chunks an array into smaller arrays of the specified size.
 * @example chunk([1,2,3,4,5], 2) // [[1,2],[3,4],[5]]
 */
export function chunk<T>(arr: T[], size: number): T[][] {
  if (size <= 0) return []
  return Array.from({ length: Math.ceil(arr.length / size) }, (_, i) =>
    arr.slice(i * size, i * size + size)
  )
}
```

Attribution

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

Loading comments…