# js-cache-property-access

js-cache-property-access guides Claude Code to store deep object properties and array bounds in local variables before executing JavaScript loops.

- rule · `type=rule` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline · ★ 1064 repo stars
- Author: jarrodwatts
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/jarrodwatts/claude-code-config/tree/HEAD/skills/vercel-react-best-practices/rules/js-cache-property-access.md
- Updated: 2026-01-21
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/rules/js-cache-property-access

## What it does

This guideline targets performance in critical execution loops. Reading chained fields like `obj.config.settings.value` or checking `arr.length` during every iteration adds recurring property resolution overhead.

The rule establishes a straightforward pattern. The assistant extracts needed values and list dimensions into constants prior to running the loop. Inside the loop block, the code references those pre-calculated constants directly.

Expected performance impact remains low to medium. For rarely triggered logic the gain is negligible, so the pattern matters mainly across intensive loops handling large datasets.

## Install

### Claude Code (native platform)

**Manually: put the files in place**
- File: `.claude/rules/js-cache-property-access.md` — The paths frontmatter field limits the files

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### Cursor

**Manually: put the files in place**
- File: `.cursor/rules/js-cache-property-access.mdc` — Frontmatter: description, globs, alwaysApply

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/instructions/js-cache-property-access.instructions.md` — The applyTo field sets which files it applies to

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/js-cache-property-access.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/js-cache-property-access.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/jarrodwatts/claude-code-config/tree/HEAD/skills/vercel-react-best-practices/rules/js-cache-property-access.md

## When to use it
- prevent recurring chained field lookups across iterations
- store array boundaries prior to executing loops
- reduce lookup overhead on critical execution paths

## Example prompts
- Refactor the iteration logic in `processQueue.ts` to cache nested properties.
- Review the loops inside `parser.js` and extract deep object references into local constants.

## Similar
- [js-cache-storage](https://affpapa.org/en/nevibecode/rules/js-cache-storage.md) — rule · ★ 7191 repo stars
- [react-fetch-cache-patterns](https://affpapa.org/en/nevibecode/skills/react-fetch-cache-patterns.md) — skill · 180 installs
- [cache-components](https://affpapa.org/en/nevibecode/skills/laguagu-cache-components.md) — skill · 222 installs
- [performance-optimization](https://affpapa.org/en/nevibecode/skills/mindrally-performance-optimization.md) — skill · 907 installs
- [nextjs-cache-architecture](https://affpapa.org/en/nevibecode/skills/nextjs-cache-architecture.md) — skill · 5100 installs
- [js-cache-function-results](https://affpapa.org/en/nevibecode/rules/js-cache-function-results.md) — rule · ★ 7191 repo stars

From the same set: [jarrodwatts/claude-code-config](https://affpapa.org/en/nevibecode/by/jarrodwatts/claude-code-config.md) — 20 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
