Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
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

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Prefer For Of

ASecurity

Write for-of loops rather than callback-taking Array methods (map, filter, forEach, reduce, some, every, find, flatMap and the like). Applies whenever writing or editing any code in src.

5 stars
0 votes
0 copies
1 views
Added 9/20/2026
developmentgoreactexpressaws

Security Analysis

A100/100

Scanned 9/28/2026

Install to Claude Code

$npx -y skills add lxsmnsyc/overwander --skill prefer-for-of --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Prefer For Of?

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

Security grade badge for Prefer For Of
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/lxsmnsyc-prefer-for-of-overwander/badge)](https://www.skillsdirectory.com/skills/lxsmnsyc-prefer-for-of-overwander)

More formats (shields.io, HTML) on the badges page.

Download with Pro
Files
SKILL.md
---
name: prefer-for-of
description: Write for-of loops rather than callback-taking Array methods (map, filter, forEach, reduce, some, every, find, flatMap and the like). Applies whenever writing or editing any code in src.
---

# Prefer for-of over Array methods

Iterate with `for...of` rather than an Array method that takes a callback. A callback is a closure, which allocates and captures state, and the methods are generally slower than a plain loop. That matters here: the board draws every frame, the world is generated on every step, and the battle engine runs in real time.

## What becomes a loop

`map`, `filter`, `forEach`, `reduce`, `reduceRight`, `some`, `every`, `find`, `findIndex`, `findLast`, `findLastIndex`, `flatMap`, and `Array.from(items, mapper)`. The same goes for `forEach` on a `Map` or a `Set`.

- A chain becomes one loop: `filter` then `map` is one pass with a `continue`.
- `some`, `every` and `find` keep their short circuit with `return` or `break`.
- A callback that reads the index iterates `entries()`, or uses a counted `for`.
- `Promise.all(items.map(async ...))` becomes a loop that pushes the promises, then `Promise.all` over them.
- `new Map(items.map(...))` becomes an empty `Map` filled in the loop.

```ts
// Before
const names = party.filter((unit) => unit.alive).map((unit) => unit.name);
const fainted = party.some((unit) => unit.hp === 0);

// After
const names: string[] = [];
let fainted = false;

for (const unit of party) {
  if (unit.hp === 0) {
    fainted = true;
  }
  if (unit.alive) {
    names.push(unit.name);
  }
}
```

## What stays

- Methods that take no per-item callback: `sort`, `join`, `slice`, `includes`, `indexOf`, `concat`, `push`, `at`.
- A `sort` comparator, which no loop replaces.
- A list rendered in Solid JSX, which is `<For each={...}>` rather than an inline `map`.
- Anything that only shares a name with an Array method: a promise's `.then(...)`, a string's `.includes(...)`.

## Traps

- **Reactivity.** In a Solid component a loop hoisted out of a JSX expression, a memo or an effect stops being tracked. Keep the loop inside the same tracked scope, as the body of the accessor or memo it came from.
- **Types.** An accumulator gets its type written out (`const names: string[] = []`), so what the method inferred is still what callers see.
- **Readonly results.** Where the method's result was a fresh array the caller may keep, the loop builds a fresh array too, never a shared one.

Attribution

lxsmnsyclxsmnsyc
View sourceMore from lxsmnsyc →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

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 DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

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.

284972 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

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →