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
.claude/rules/js-cache-property-access.mdWhat 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.tsto cache nested properties. - Review the loops inside
parser.jsand 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.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/js-cache-property-access.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/js-cache-property-access.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/js-cache-property-access.mdManually: put the files in place
.clinerules/js-cache-property-access.mdStep 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.