Improve code clarity and maintainability by assigning each variable one purpose.
The material indicates a prompt-only coding-guideline skill with no required secrets, no remote endpoints, and no stated execution, file, or network capabilities, so overall risk is low. For supply chain, it is open-source on GitHub, but adoption is low and the license/maintenance status are unclear, so it is best used after manual review.
The material explicitly states that no keys or environment variables are required; there is no indication of credential collection, storage, transmission, or misuse.
The material explicitly lists no remote endpoints, and the content is a variable-design guideline with no described networking, API calls, or external data transmission.
The system flags it as prompt-only; the README contains only example code and guidance, with no stated ability to spawn processes, run scripts, or access system capabilities.
No access to filesystems, databases, clipboards, or local resources is declared; based on the material, this is static guidance content and does not involve reading or writing user data.
The source is an open-source GitHub repository, which is a positive sign for auditability; however, there is no declared license, community adoption is 0 stars, and maintenance status is unknown, so supply-chain confidence is limited and manual review is advisable before use.
Copy the install command and let the AI configure it · recommended for beginners
Please install the "Single Purpose Variables" skill from askskill: 1. Download https://raw.githubusercontent.com/obra/clank/main/skills/coding/single-purpose-variables/SKILL.md 2. Save it as ~/.claude/skills/single-purpose-variables/SKILL.md 3. Reload skills and tell me it's ready
Review this code, identify variables that carry multiple meanings or are reused across different stages, and refactor them into single-purpose variables. Explain each change and provide the rewritten code.
A list of problematic variables, refactoring rationale, and clearer rewritten code.
Write a team coding guideline for single-purpose variables. Explain what mixed-responsibility variables are, why to avoid them, naming recommendations, bad and good examples, and a practical review checklist.
A well-structured team guideline with principles, examples, and code review checkpoints.
Analyze this code from a code review perspective. Focus on whether variables serve exactly one purpose, and identify hidden state, reused variables with new meanings, or bloated temporary variables. Suggest improvements.
A review-oriented diagnosis highlighting risks and providing actionable improvement suggestions.
Each variable should represent exactly ONE thing. No reusing for different purposes. No hidden meanings.
Core principle: If variable represents count sometimes and error other times, use two variables.
From baseline, agents use special values to indicate errors:
❌ Hybrid coupling (baseline):
def process_file_pages(filename):
try:
pages_processed = 0 # Count (integer purpose)
# ... processing ...
return pages_processed
except:
return -1 # Error flag (boolean purpose as -1)
Problem: pages_processed represents TWO things:
This is hybrid coupling: Variable moonlights as different type.
✅ Separate concerns:
def process_file_pages(filename):
try:
pages_processed = 0
# ... processing ...
return (True, pages_processed) # Success, count
except Exception as e:
return (False, str(e)) # Failure, error message
Or raise exception:
def process_file_pages(filename):
# Let exceptions propagate - no hybrid variable needed
pages_processed = 0
# ... processing (raises on error) ...
return pages_processed # Always a count, never an error
❌ What agents naturally do:
page_count = 15 # Number of pages
page_count = -1 # Wait, now it means error!
customer_id = 1234 # Customer number
customer_id = 500001 # Wait, > 500000 means delinquent (subtract 500000)!
bytes_written = 1024 # Bytes written
bytes_written = -5 # Wait, negative means disk drive number!
✅ Separate variables:
page_count = 15
processing_failed = True # Separate boolean for error state
customer_id = 1234
is_delinquent = False # Separate boolean for status
bytes_written = 1024
disk_drive = 5 # Separate variable for drive number
Good reuse (same purpose, same meaning):
# ✅ GOOD: total_sales used for multiple related calculations
total_sales = sum(sales)
average = total_sales / len(sales) # Same value, same meaning
percentage = (total_sales / target) * 100 # Same value, same meaning
Bad reuse (different purposes):
# ❌ BAD: temp reused for unrelated purposes
temp = sqrt(b*b - 4*a*c) # Discriminant
root1 = (-b + temp) / (2*a)
# ...
temp = root1 # Now reused for swapping (different purpose!)
root1 = root2
root2 = temp
✅ Separate variables:
discriminant = sqrt(b*b - 4*a*c) # Clear purpose
root1 = (-b + discriminant) / (2*a)
# ...
old_root = root1 # Clear purpose (swapping)
root1 = root2
root2 = old_root
| Violation | Example | Fix |
|---|---|---|
| Hybrid coupling | count=-1 means error | Separate: count + error_occurred boolean |
| Hidden meanings | id > 500000 means delinquent | Separate: id + is_delinquent |
| Temp reuse | temp for discriminant, then swapping | Use: discriminant, old_root |
| State changes | Variable means X, then means Y | Two variables with clear names |
temp, result, value for unrelated purposesFix: Create separate variable with clear name for each purpose.
From Code Complete:
From baseline:
-1 to indicate error in count variable (hybrid coupling)With this skill: Separate variables for separate purposes.
…
Write evergreen comments focused on what and why, not historical context.
Compare 2-3 approaches before execution to choose a stronger solution.
Plan with pseudocode first, refine approaches, then translate into working code.
Search past Claude Code chats to recover facts, decisions, and context.
Design systems by hiding implementation details behind domain-level interfaces.
Name code by domain meaning to improve clarity and team alignment.
Help developers limit variable scope to improve code clarity and maintainability.
Choose clear, accurate variable names that improve code readability and maintenance.
Helps you spot multi-purpose routines and refactor them into single-responsibility units.
Help developers simplify nested conditionals for clearer, more maintainable code.
Analyze code vibes and suggest more stylish naming alternatives.
Helps developers write code comments explaining intent, rationale, and key tradeoffs.