extract-variable
Apply Extract Variable: name a complex or repeated expression with a local variable.
Works with
--- name: extract-variable description: Apply Extract Variable: name a complex or repeated expression with a local variable. license: MIT --- # Extract Variable (refactoring) Replace an expression with a named variable that holds the expression's value. Comply with `PRINCIPLES.md`. Often invoked by: `long-method` (when names would help readability), `decompose-conditional`. ## Inputs ```yaml target: path/to/Class.ext:line # required; the location of the expression expression: <the expression> # required (informal) variable_name: meaningfulName # required ``` ## Pre flight (in addition to PRINCIPLES.md) 1. Read the target method. 2. Confirm the expression has no side effects, or that extracting once preserves order. 3. Identify all occurrences if you want to deduplicate. ## Mechanics 1. Insert a `$variable = <expression>;` line before the first use. 2. Replace each occurrence of the expression with `$variable`. 3. Run tests; report. ## Safety rules * Expression has side effects and appears in multiple places: extracting changes semantics. Surface. * Expression is large and used once: extraction may not add value; consider `extract-method` instead. * Single-file change; multi-file impact unusual. ## Example (PHP) Before. ```php return $order->subtotal() * (1 - $order->customer()->loyaltyTier()->discountRate()); ``` After. ```php $discountRate = $order->customer()->loyaltyTier()->discountRate(); return $order->subtotal() * (1 - $discountRate); ``` ## Pitfalls and when to skip | Pitfall | Skip in favor of | |---|---| | Expression has side effects | Surface and reconsider | | Expression is trivial | Skip; inline is clearer | | Expression deserves a method, not a variable | `extract-method` or `replace-temp-with-query` | ## Output Post-edit report per `PRINCIPLES.md`. Stop reasons. * `side-effects`: expression mutates state. * `read-failed`: target could not be read. * `tests-failed`: tests ran and failed after the edit.
More Accessibility skills
skill-creator
anthropics/skills
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
hyperframes-core
heygen-com/hyperframes
The HyperFrames composition contract — build one renderable project. Use for composition structure, the `data-*` timing attributes, `class="clip"`, tracks, sub-compositions, variables, framework-owned media playback, deterministic-render rules, and validation. Also covers Tailwind projects and the STORYBOARD.md / SCRIPT.md plan formats. Read before writing composition HTML.
ui-ux-pro-max
nextlevelbuilder/ui-ux-pro-max-skill
UI/UX design intelligence for web, mobile, and desktop. This skill should be used when designing, building, reviewing, or fixing interfaces, including pages, components, design systems, accessibility, interaction, responsive layout, typography, color, charts, and stack-specific UI implementation. Searchable local data: 79 searchable styles (50 active), 192 product palettes and reasoning profiles, 74 font pairings, 119 UX guidelines, 105 icons, 17 GSAP presets, 25 chart types, and 22 stacks.

