Skip to main content
rule CX Codex

js-cache-property-access — Claude Code rule: how to install

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

no license ★ 1,064 updated 2026-01-21

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/js-cache-property-access.md
Open on GitHub

What js-cache-property-access 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.

What it helps with

  • prevent recurring chained field lookups across iterations
  • store array boundaries prior to executing loops
  • reduce lookup overhead on critical execution paths

Example prompts for the agent

  • 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.

How to install js-cache-property-access

Manually: put the files in place

.claude/rules/js-cache-property-access.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about js-cache-property-access

How do I install js-cache-property-access in Claude Code?

Save the rule file to .claude/rules/js-cache-property-access.md inside your project root.

What does js-cache-property-access do?

It directs the AI to capture array sizes and deeply nested object properties into local constants before entering loops.

What impact does this caching pattern provide?

The impact ranks as low to medium, offering measurable benefits specifically on repetitive iterations in hot code paths.

Similar IDE rules

All IDE rules for Code review and refactoring →

From the same set20

The whole set →
js-min-max-loop js-min-max-loop instructs the agent to pick minimum or maximum values with a single loop instead of sorting. Avoids O(n log n) sorting costs and unnecessary array copies. CX Codex +1 ★ 1,064repo stars interview interview runs a long question-and-answer session about a plan file and writes the finished spec back to the same path. CX Codex +1 ★ 1,064repo stars js-set-map-lookups The js-set-map-lookups rule recommends using a Set when code repeatedly checks array membership. It applies to repeated lookups, such as filtering items by ID. CX Codex +1 ★ 1,064repo stars rendering-activity rendering-activity — a Claude rule that tells the agent to keep costly React components inside <Activity> so hiding them does not throw away state. CX Codex +1 ★ 1,064repo stars rendering-svg-precision rendering-svg-precision — a rule for Claude Code that reduces SVG coordinate precision to one decimal place. Applies when creating icons or editing graphics. CX Codex +1 ★ 1,064repo stars _template _template — a rule-file scaffold with fields for its title and impact, plus sections for contrasting incorrect and correct code. CX Codex +1 ★ 1,064repo stars async-parallel async-parallel — a Claude rule that sends independent async calls through Promise.all() instead of awaiting them one by one. Useful when a handler piles up sequential awaits. CX Codex +1 ★ 1,064repo stars rerender-derived-state The rerender-derived-state rule favors derived boolean state over continuously changing values, reducing React re-renders. It fits responsive UI logic. CX Codex +1 ★ 1,064repo stars

Project sponsors

Companies that keep this analytics open