prefer-named-functions

Installation
SKILL.md

Prefer Named Functions Over Anonymous Functions

Goal

When defining a function, prefer a named function over an anonymous one, regardless of the technology stack.

A named function is any callable whose definition is bound to an explicit, descriptive identifier visible at its definition site (a function declaration, a named function expression, an arrow function or lambda assigned to a const/val/let with a meaningful name, a named method, or a named local helper). An anonymous function is a callable defined inline without a stable, descriptive identifier — typically a lambda, arrow function, block, or function expression passed directly as an argument or returned without being bound to a name.

Named functions improve stack traces, code navigation, searchability, reuse, testability, and the reader's ability to understand intent without parsing the body. Anonymous functions are still appropriate when the stack expects them or when naming would actively hurt readability.

What Counts as In Scope

Apply this skill to code that does one or more of these things:

  • defines a callback, handler, listener, mapper, predicate, comparator, reducer, effect, or task as an inline anonymous function
  • assigns an anonymous function or lambda to a variable without a meaningful name
  • passes an inline lambda or arrow function with non-trivial logic as an argument
  • defines an event handler, route handler, middleware, or job as an anonymous function
  • exports an anonymous function or anonymous default export from a module
Related skills

More from code-sherpas/agent-skills

Installs
3
First Seen
Apr 17, 2026