util-function

util-function is a skill for Claude Code from berkcangumusisik/claude-code-practices. It costs 15 tokens per session (352 once invoked), scanned A, original, MIT.

A workflow for creating a typed utility function from a description, along with tests and a usage example. It checks for similar code and covers unusual inputs such as empty values or negative numbers.

In plain words
What is it for?
Use it to add reusable TypeScript helper functions with generics, input handling, unit tests, and documentation.
Why use it?
It helps avoid duplicated helpers and catches edge cases before the function is used elsewhere.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it to add reusable TypeScript helper functions with generics, input handling, unit tests, and documentation.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/berkcangumusisik/claude-code-practices/util-function
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add berkcangumusisik/claude-code-practices --skill util-function
Clone the repo
git clone --depth 1 https://github.com/berkcangumusisik/claude-code-practices

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for util-function

README.md
[![agentmods](https://agentmods.dev/badge/skills/berkcangumusisik/claude-code-practices/util-function.svg)](https://agentmods.dev/skills/berkcangumusisik/claude-code-practices/util-function)
Your own site
<a href="https://agentmods.dev/skills/berkcangumusisik/claude-code-practices/util-function"><img src="https://agentmods.dev/badge/skills/berkcangumusisik/claude-code-practices/util-function.svg" alt="Measured on agentmods" height="20"></a>
Per session 15 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 352 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00015 $0.00352
Opus 5 $0.00008 $0.00176
Sonnet 5 $0.00003 $0.00070
Haiku 4.5 $0.00002 $0.00035

Measured 4d ago against content hash 5c888c86a5d3, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

util-function scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/util-function/SKILL.md · 49 lines

What it actually says

Generate Utility Function

Description: $ARGUMENTS

  1. Check if a similar utility already exists:
grep -rn "export.*function\|export const" src/utils/ src/lib/ src/helpers/ 2>/dev/null | head -20
  1. If a similar one exists, consider extending it instead of creating a new one.

  2. 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
  3. Write unit tests covering:

    • Normal usage
    • Edge cases
    • Type narrowing behavior
  4. Place in the appropriate utils file or create src/utils/<name>.ts.

  5. Add a usage example in JSDoc.

Example output:

/**
 * 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)
  )
}
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 49 lines · 15 tokens per session scan A 5c888c86a5d3

Subscribe to this mod's changes

util-function is a skill published in the GitHub repository berkcangumusisik/claude-code-practices (10 stars, last pushed 4mo ago), licensed MIT. It adds 15 tokens to every session and 352 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.