Localizing Variables

Community

Variables where you need them, when you need them.

Authorbarrydobson
Version1.0.0
Installs0

System Documentation

What problem does it solve?

This Skill reduces cognitive load and prevents bugs by minimizing the "window of vulnerability" for variables. It ensures variables are declared, initialized, and used within the smallest possible scope, making code easier to understand, modify, and debug.

Core Features & Use Cases

  • Smallest Scope: Guides you to declare variables in block or loop scope, rather than function or global scope, whenever possible.
  • Proximity Principle: Encourages initializing variables close to their first use and keeping all references to a variable grouped together.
  • Reduced Live Time & Span: Minimizes the number of lines a variable "lives" and the distance between its uses, preventing accidental modifications.
  • Use Case: Instead of declaring total = 0 at the top of a 100-line function, then using it 50 lines later, this skill guides you to declare total = 0 just before its loop, reducing its live time and making its purpose immediately clear.

Quick Start

Analyze the attached Python function. Identify any variables with wide scope or long live times, and suggest how to localize them by declaring them closer to their first use or reducing their scope.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: Localizing Variables
Download link: https://github.com/barrydobson/dotfiles_extra/archive/main.zip#localizing-variables

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository