# Naming Improve

> Improve variable and function naming with semantic analysis

- Skill: `majiayu000/naming-improve` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds add majiayu000/naming-improve`
- Raw SKILL.md: https://api.skillmd.com/api/skills/majiayu000/naming-improve/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: majiayu000 (https://skillmd.com/u/majiayu000)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/majiayu000/naming-improve

---


# Naming Improvement

I'll analyze your code and suggest better, more semantic names for variables, functions, and classes.

Arguments: `$ARGUMENTS` - specific files or naming focus (e.g., "functions", "variables", "types")

## Strategic Analysis Process

<think>
Improving naming requires careful consideration:

1. **Code Understanding**
   - What does this variable/function actually do?
   - What's its purpose in the broader context?
   - How is it used throughout the codebase?
   - What domain concepts does it represent?

2. **Naming Problems to Fix**
   - Generic names (data, temp, obj, result, item)
   - Single letters (x, y, i beyond simple loops)
   - Unclear abbreviations (usr, msg, cfg)
   - Misleading names (getName that modifies state)
   - Inconsistent naming patterns
   - Hungarian notation remnants (strName, arrItems)

3. **Language Conventions**
   - JavaScript/TypeScript: camelCase for variables/functions, PascalCase for classes
   - Python: snake_case for variables/functions, PascalCase for classes
   - Go: camelCase with exported names capitalized
   - Rust: snake_case for variables/functions, PascalCase for types
   - Follow project's existing conventions

4. **Semantic Naming Principles**
   - Intention-revealing names
   - Pronounceable and searchable names
   - Avoid mental mapping
   - Use domain terminology
   - Be specific and descriptive
   - Avoid encodings and prefixes
</think>

## Phase 1: Naming Analysis

**MANDATORY FIRST STEPS:**
1. Analyze code to find poorly named identifiers
2. Understand usage context for each identifier
3. Detect language and naming conventions
4. Categorize naming issues by severity

Let me analyze naming in your code:

```bash
# Detect programming language
echo "=== Code Analysis ==="

# Find common poorly named identifiers
echo "Checking for generic/unclear names..."

# Look for single-letter variables (excluding loop counters)
# Look for generic names like data, temp, obj, result, item
# Look for unclear abbreviations

# Analyze file types
FILE_COUNT=$(find . -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" -o -name "*.py" -o -name "*.go" -o -name "*.rs" \) 2>/dev/null | wc -l)
echo "Source files to analyze: $FILE_COUNT"

# Detect primary language
if [ -f "package.json" ]; then
    if grep -q "\"typescript\"" package.json; then
        echo "Primary language: TypeScript"
    else
        echo "Primary language: JavaScript"
    fi
elif [ -f "requirements.txt" ] || [ -f "setup.py" ]; then
    echo "Primary language: Python"
elif [ -f "go.mod" ]; then
    echo "Primary language: Go"
elif [ -f "Cargo.toml" ]; then
    echo "Primary language: Rust"
fi
```

## Phase 2: Pattern Detection

I'll identify common naming anti-patterns:

**Generic Names:**
- `data`, `info`, `obj`, `item`, `element`, `thing`
- `result`, `output`, `temp`, `tmp`
- `list`, `array`, `collection` (without context)
- `manager`, `handler`, `helper`, `util` (vague suffixes)

**Single Letter Names:**
- `x`, `y`, `z` (outside math/coordinates)
- `a`, `b`, `c` (meaningless)
- `i`, `j`, `k` (beyond simple loop counters)
- `e` (for error - should be `error`)

**Unclear Abbreviations:**
- `usr` → `user`
- `cfg` → `config`
- `msg` → `message`
- `btn` → `button`
- `arr` → `array` (or better, describe contents)
- `num` → `number` or specific quantity

**Misleading Names:**
- `getData()` that modifies state → `fetchAndStoreData()`
- `isValid()` with side effects → `validateAndLog()`
- `process()` → be specific about what's processed

**Inconsistent Patterns:**
- Mix of `getUser()` and `fetchProfile()`
- Mix of `userId` and `user_id`
- Mix of `isEnabled` and `hasAccess`

Using native tools:
- **Grep** to find generic identifiers
- **Read** files with poor naming
- **Grep** for naming pattern inconsistencies

## Phase 3: Semantic Name Suggestions

Based on context and usage, I'll suggest better names:

### Variable Naming Improvements

**Before:**
```typescript
// Generic, unclear names
const data = await fetch('/api/users');
const result = data.json();
const list = result.map(item => item.name);
const temp = list.filter(x => x.length > 5);
```

**After:**
```typescript
// Descriptive, intention-revealing names
const usersResponse = await fetch('/api/users');
const users = await usersResponse.json();
const userNames = users.map(user => user.name);
const longUserNames = userNames.filter(name => name.length > 5);
```

### Function Naming Improvements

**Before:**
```typescript
// Vague function names
function process(data) {
  const result = data.filter(x => x.active);
  return result;
}

function handle(item) {
  item.status = 'done';
  save(item);
}

function get() {
  return state.user;
}
```

**After:**
```typescript
// Specific, action-oriented names
function filterActiveUsers(users) {
  return users.filter(user => user.active);
}

function markItemAsCompleteAndSave(item) {
  item.status = 'done';
  save(item);
}

function getCurrentUser() {
  return state.user;
}
```

### Class/Type Naming Improvements

**Before:**
```typescript
// Generic, unclear class names
class Manager {
  handle(data) { }
}

class Helper {
  process(item) { }
}

interface Data {
  info: string;
  stuff: any;
}
```

**After:**
```typescript
// Specific, domain-focused names
class UserSessionManager {
  authenticateUser(credentials) { }
}

class DateFormatter {
  formatToISO(date) { }
}

interface UserProfile {
  displayName: string;
  preferences: UserPreferences;
}
```

## Phase 4: Context-Aware Renaming

I'll analyze how identifiers are used to suggest contextual names:

**Usage Analysis:**
```typescript
// Analyze this code:
const data = await fetchFromDatabase();
const filtered = data.filter(x => x.age > 18);
const sorted = filtered.sort((a, b) => a.name.localeCompare(b.name));
const result = sorted.slice(0, 10);
```

**Context Understanding:**
- `data` is fetched from database → likely users, products, etc.
- Filtered by `age > 18` → adults or eligible users
- Sorted by `name` → alphabetically ordered
- Top 10 results → limited result set

**Improved Version:**
```typescript
const allUsers = await fetchUsersFromDatabase();
const adultUsers = allUsers.filter(user => user.age > 18);
const alphabeticalUsers = adultUsers.sort((a, b) =>
  a.name.localeCompare(b.name)
);
const topTenUsers = alphabeticalUsers.slice(0, 10);

// Or with descriptive pipeline:
const topTenAdultUsersSorted = await fetchUsersFromDatabase()
  .then(users => users.filter(user => user.age > 18))
  .then(adults => adults.sort((a, b) => a.name.localeCompare(b.name)))
  .then(sorted => sorted.slice(0, 10));
```

## Phase 5: Language-Specific Conventions

I'll apply language-specific naming best practices:

### JavaScript/TypeScript

**Conventions:**
- Variables/functions: `camelCase`
- Classes/interfaces: `PascalCase`
- Constants: `UPPER_SNAKE_CASE` or `camelCase`
- Private members: `_prefixWithUnderscore` (legacy) or `#privateField` (modern)
- Boolean variables: `is`, `has`, `should` prefixes

**Examples:**
```typescript
// Variables
const userProfile = getUserProfile();
const isAuthenticated = checkAuth();
const hasPermission = user.permissions.includes('admin');

// Functions
function calculateTotalPrice(items: CartItem[]): number { }
function shouldDisplayNotification(user: User): boolean { }

// Classes
class UserAuthenticationService { }
class ProductInventoryManager { }

// Constants
const MAX_RETRY_ATTEMPTS = 3;
const API_BASE_URL = 'https://api.example.com';

// Interfaces/Types
interface UserProfile { }
type PaymentMethod = 'card' | 'paypal' | 'crypto';
```

### Python

**Conventions:**
- Variables/functions: `snake_case`
- Classes: `PascalCase`
- Constants: `UPPER_SNAKE_CASE`
- Private members: `_prefix_with_underscore`
- Boolean variables: `is_`, `has_`, `should_` prefixes

**Examples:**
```python
# Variables
user_profile = get_user_profile()
is_authenticated = check_auth()
has_permission = 'admin' in user.permissions

# Functions
def calculate_total_price(items: list[CartItem]) -> float:
    pass

def should_display_notification(user: User) -> bool:
    pass

# Classes
class UserAuthenticationService:
    pass

class ProductInventoryManager:
    pass

# Constants
MAX_RETRY_ATTEMPTS = 3
API_BASE_URL = 'https://api.example.com'
```

### Go

**Conventions:**
- Exported: Capitalized (`UserService`)
- Unexported: lowercase (`userService`)
- Acronyms: All caps (`HTTPServer`, `URLParser`)
- Getters: No `Get` prefix (`user.Name()` not `user.GetName()`)

**Examples:**
```go
// Exported
type UserAuthenticationService struct {}
func (s *UserAuthenticationService) AuthenticateUser() {}

// Unexported
var maxRetryAttempts = 3
func calculateTotalPrice(items []CartItem) float64 {}

// Acronyms
type HTTPClient struct {}
type URLParser struct {}

// Getters (no Get prefix)
func (u *User) Name() string { return u.name }
```

## Phase 6: Refactoring Implementation

I'll safely rename identifiers across the codebase:

**Renaming Strategy:**
1. **Local scope first**: Rename within single functions
2. **File scope**: Rename across file
3. **Module scope**: Rename across related files
4. **Global scope**: Rename across entire codebase (most risky)

**Safety Checks:**
- Create git checkpoint before changes
- Use precise string matching (avoid partial matches)
- Verify no external references broken
- Update tests and documentation
- Run tests after each significant rename

**Example Refactoring:**
```typescript
// Before: Poor naming
function proc(d) {
  const r = d.filter(x => x.s === 'a');
  const t = r.length;
  return t > 0;
}

// After: Clear naming
function hasActiveUsers(users) {
  const activeUsers = users.filter(user => user.status === 'active');
  const activeUserCount = activeUsers.length;
  return activeUserCount > 0;
}

// Or even better (more concise):
function hasActiveUsers(users) {
  return users.some(user => user.status === 'active');
}
```

## Token Optimization

**Status:** ✅ Fully Optimized (Phase 2 Batch 4B, 2026-01-27)

**Baseline:** 3,000-5,000 tokens → **Optimized:** 1,200-2,000 tokens (60% reduction)

This skill employs comprehensive token optimization strategies to minimize Claude API costs while maintaining thorough semantic naming analysis and improvement capabilities.

### Core Optimization Strategies

#### 1. Grep-Before-Read Pattern (85% savings)

**Search first, read only what matters:**

```bash
# Instead of reading all files, search for naming patterns
rg --type ts --type js '\b(data|temp|tmp|obj|item|result|info)\b' --files-with-matches

# Find single-letter variables outside loops
rg '\b[a-z]\s*=' --type ts | grep -v 'for\|while'

# Find unclear abbreviations
rg '\b(usr|cfg|msg|btn|arr|num)\b' --type ts --files-with-matches

# Only read files with actual naming issues
# Read specific problematic sections with context
```

**Token Impact:**
- ❌ Before: Reading 20-30 files = 10,000-15,000 tokens
- ✅ After: Grep search + reading 3-5 files = 1,500-2,500 tokens
- **Savings: 85%**

#### 2. Cached Naming Conventions (70% savings)

**Cache project-specific naming patterns to avoid re-analysis:**

```json
// .claude/cache/naming_conventions.json
{
  "language": "typescript",
  "style": "camelCase",
  "conventions": {
    "variables": "camelCase",
    "functions": "camelCase",
    "classes": "PascalCase",
    "constants": "UPPER_SNAKE_CASE"
  },
  "acceptedAbbreviations": ["id", "url", "api", "http", "db"],
  "domainTerms": ["user", "product", "order", "payment"],
  "lastAnalyzed": "2026-01-27T10:30:00Z"
}

// .claude/cache/common_abbreviations.json
{
  "usr": "user",
  "cfg": "config",
  "msg": "message",
  "btn": "button",
  "arr": "array",
  "num": "number",
  "req": "request",
  "res": "response",
  "err": "error",
  "ctx": "context"
}

// .claude/cache/naming_history.json
{
  "improved": [
    {"file": "user.service.ts", "old": "data", "new": "userData", "date": "2026-01-20"},
    {"file": "product.ts", "old": "list", "new": "products", "date": "2026-01-21"}
  ],
  "skipPatterns": ["i", "j", "k"],  // Loop counters
  "lastRun": "2026-01-27T10:30:00Z"
}
```

**Token Impact:**
- ❌ Before: Re-detecting conventions every time = 2,000-3,000 tokens
- ✅ After: Loading cached conventions = 300-500 tokens
- **Savings: 70%**

#### 3. Pattern-Based Detection (60% savings)

**Use regex patterns to identify poorly named identifiers efficiently:**

```bash
# Critical naming anti-patterns
GENERIC_NAMES="(data|temp|tmp|obj|item|result|info|list|array|thing)"
SINGLE_LETTERS="(?<!for|while)\s+([a-z])\s*="
UNCLEAR_ABBRS="(usr|cfg|msg|btn|arr|num|req|res)"

# Search by severity
echo "=== Critical: Generic Names ==="
rg "\b$GENERIC_NAMES\b" --type ts -c | sort -t: -k2 -rn | head -20

echo "=== High: Single Letters ==="
rg "$SINGLE_LETTERS" --type ts -c | sort -t: -k2 -rn | head -20

echo "=== Medium: Abbreviations ==="
rg "\b$UNCLEAR_ABBRS\b" --type ts -c | sort -t: -k2 -rn | head -20
```

**Token Impact:**
- ❌ Before: Reading entire files to find issues = 5,000-8,000 tokens
- ✅ After: Pattern-based searches = 1,000-2,000 tokens
- **Savings: 60%**

#### 4. Progressive Analysis (50% savings)

**Analyze by severity - critical issues first:**

```bash
# Phase 1: Critical issues only (block work)
rg '\b(data|temp|tmp|obj)\b' --type ts --files-with-matches | head -5

# If critical issues found, stop here and fix
# Don't analyze moderate/low until critical fixed

# Phase 2: High-priority (after critical fixed)
rg '\b[a-z]\s*=' --type ts --files-with-matches | head -5

# Phase 3: Medium-priority (after high fixed)
rg '\b(usr|cfg|msg)\b' --type ts --files-with-matches | head -5
```

**Token Impact:**
- ❌ Before: Analyzing all severities = 4,000-6,000 tokens
- ✅ After: Critical issues first, stop if found = 2,000-3,000 tokens
- **Savings: 50%**

#### 5. Batch Renaming Suggestions (40% savings)

**Group similar naming issues together:**

```typescript
// Instead of suggesting one-by-one
// ❌ Before: Suggest individually
// File: user.service.ts
//   Line 10: Rename 'data' to 'userData'
// File: product.service.ts
//   Line 15: Rename 'data' to 'productData'
// File: order.service.ts
//   Line 20: Rename 'data' to 'orderData'

// ✅ After: Batch suggestions by pattern
// Pattern: Generic 'data' variable (3 occurrences)
//   user.service.ts:10    → userData
//   product.service.ts:15 → productData
//   order.service.ts:20   → orderData
```

**Token Impact:**
- ❌ Before: Individual suggestions with full context = 3,000-4,000 tokens
- ✅ After: Batched by pattern = 1,200-1,800 tokens
- **Savings: 40%**

### Optimization Implementation

#### Smart File Discovery

```bash
# Instead of analyzing entire codebase
# Focus on specified scope or recent changes

if [ -n "$ARGUMENTS" ]; then
    # User specified files/directories
    SCOPE="$ARGUMENTS"
else
    # Default: Recently changed files
    SCOPE=$(git diff --name-only HEAD~5..HEAD | grep -E '\.(ts|tsx|js|jsx|py|go|rs)$')
fi

# Count and prioritize
FILE_COUNT=$(echo "$SCOPE" | wc -l)
echo "Analyzing $FILE_COUNT files"

# If too many files, focus on most critical
if [ "$FILE_COUNT" -gt 10 ]; then
    echo "Too many files. Focusing on top 10 with most issues..."
    echo "$SCOPE" | while read file; do
        ISSUE_COUNT=$(rg '\b(data|temp|tmp)\b' "$file" -c 2>/dev/null || echo 0)
        echo "$ISSUE_COUNT:$file"
    done | sort -rn | head -10 | cut -d: -f2-
fi
```

#### Cached Convention Detection

```bash
# Check cache first
CACHE_FILE=".claude/cache/naming_conventions.json"

if [ -f "$CACHE_FILE" ] && [ $(find "$CACHE_FILE" -mtime -7 | wc -l) -gt 0 ]; then
    # Cache is fresh (< 7 days old)
    echo "Using cached naming conventions..."
    LANGUAGE=$(jq -r '.language' "$CACHE_FILE")
    STYLE=$(jq -r '.style' "$CACHE_FILE")
    echo "Language: $LANGUAGE, Style: $STYLE"
else
    # Re-detect and cache
    echo "Detecting naming conventions..."
    # ... detection logic ...
    # Save to cache
    echo "{\"language\": \"$LANGUAGE\", \"style\": \"$STYLE\", ...}" > "$CACHE_FILE"
fi
```

#### Progressive Severity Analysis

```bash
# Analyze by severity, early exit if critical issues found
analyze_critical() {
    echo "=== Critical Naming Issues (Generic Names) ==="
    CRITICAL=$(rg '\b(data|temp|tmp|obj|item|result)\b' --type ts -l | head -5)

    if [ -n "$CRITICAL" ]; then
        echo "Found critical naming issues. Fix these first:"
        echo "$CRITICAL"
        return 1  # Stop here
    fi
    return 0
}

analyze_high() {
    echo "=== High Priority (Single Letters) ==="
    HIGH=$(rg '\b[a-z]\s*=' --type ts -l | grep -v 'for\|while' | head -5)

    if [ -n "$HIGH" ]; then
        echo "Found single-letter variable issues:"
        echo "$HIGH"
        return 1
    fi
    return 0
}

analyze_medium() {
    echo "=== Medium Priority (Abbreviations) ==="
    MEDIUM=$(rg '\b(usr|cfg|msg|btn|arr|num)\b' --type ts -l | head -5)

    if [ -n "$MEDIUM" ]; then
        echo "Found unclear abbreviations:"
        echo "$MEDIUM"
        return 1
    fi
    return 0
}

# Run progressively
if ! analyze_critical; then exit 0; fi
if ! analyze_high; then exit 0; fi
if ! analyze_medium; then exit 0; fi

echo "No major naming issues found!"
```

### Cache Management

```bash
# Initialize cache directory
CACHE_DIR=".claude/cache"
mkdir -p "$CACHE_DIR"

# Cache files
CONVENTIONS_CACHE="$CACHE_DIR/naming_conventions.json"
ABBREVIATIONS_CACHE="$CACHE_DIR/common_abbreviations.json"
HISTORY_CACHE="$CACHE_DIR/naming_history.json"

# Cache freshness check (7 days)
is_cache_fresh() {
    local cache_file=$1
    if [ -f "$cache_file" ]; then
        local age=$(($(date +%s) - $(stat -f %m "$cache_file" 2>/dev/null || stat -c %Y "$cache_file")))
        [ $age -lt 604800 ]  # 7 days in seconds
    else
        return 1
    fi
}

# Load or create conventions cache
if is_cache_fresh "$CONVENTIONS_CACHE"; then
    LANGUAGE=$(jq -r '.language' "$CONVENTIONS_CACHE")
    STYLE=$(jq -r '.style' "$CONVENTIONS_CACHE")
else
    # Detect and cache
    # ... detection logic ...
    echo "{...}" > "$CONVENTIONS_CACHE"
fi

# Load abbreviations (static, rarely changes)
if [ ! -f "$ABBREVIATIONS_CACHE" ]; then
    cat > "$ABBREVIATIONS_CACHE" << 'EOF'
{
  "usr": "user",
  "cfg": "config",
  "msg": "message",
  "btn": "button",
  "arr": "array",
  "num": "number",
  "req": "request",
  "res": "response",
  "err": "error",
  "ctx": "context",
  "doc": "document",
  "elem": "element",
  "fn": "function",
  "val": "value",
  "prev": "previous",
  "curr": "current",
  "idx": "index"
}
EOF
fi
```

### Pattern-Based Naming Suggestions

Instead of analyzing every identifier individually, group by pattern:

```bash
# Batch analysis by pattern
echo "=== Generic 'data' Variables ==="
rg '\bdata\b' --type ts -n | while IFS=: read file line content; do
    # Extract context
    CONTEXT=$(echo "$content" | sed 's/.*data/data/' | head -c 50)
    echo "$file:$line → Suggest specific name based on context"
done | head -10

echo "=== Single-Letter Variables ==="
rg '\b[a-z]\s*=' --type ts -n | grep -v 'for\|while' | head -10

echo "=== Unclear Abbreviations ==="
rg '\b(usr|cfg|msg)\b' --type ts -n | head -10
```

### Optimization Checklist

**Before starting analysis:**
- [ ] Check if user specified files/scope in `$ARGUMENTS`
- [ ] Load cached naming conventions (if < 7 days old)
- [ ] Load cached abbreviations dictionary
- [ ] Check naming history to avoid re-suggesting

**During analysis:**
- [ ] Use Grep to find patterns before reading files
- [ ] Analyze by severity (critical → high → medium → low)
- [ ] Early exit if critical issues found
- [ ] Batch similar issues together
- [ ] Provide context from Grep matches, not full file reads

**After analysis:**
- [ ] Update naming history cache with improvements
- [ ] Cache new conventions if detected
- [ ] Suggest batch renaming for similar patterns

### Expected Token Usage

**Typical naming improvement session:**

| Scenario | Before | After | Savings |
|----------|--------|-------|---------|
| Small project (< 10 files) | 3,000 tokens | 1,200 tokens | 60% |
| Medium project (10-50 files) | 5,000 tokens | 2,000 tokens | 60% |
| Large project (> 50 files) | 8,000 tokens | 3,000 tokens | 62% |
| Focused analysis (specific files) | 2,000 tokens | 800 tokens | 60% |

**Token breakdown (medium project):**
- Convention detection (cached): 300 tokens (was 2,000)
- Pattern searches (Grep): 500 tokens (was 5,000)
- File analysis (targeted): 800 tokens (was 4,000)
- Suggestions (batched): 400 tokens (was 1,500)
- **Total: 2,000 tokens (was 5,000)**

### Optimization Trade-offs

**What we optimize:**
- ✅ Redundant file reads → Grep searches
- ✅ Convention re-detection → Cached results
- ✅ Exhaustive analysis → Progressive severity
- ✅ Individual suggestions → Batched patterns
- ✅ Full context → Targeted excerpts

**What we preserve:**
- ✅ Accurate naming analysis
- ✅ Context-aware suggestions
- ✅ Language-specific conventions
- ✅ Safety and correctness
- ✅ Comprehensive coverage when needed

### Integration with Other Skills

**Suggest lightweight alternatives when appropriate:**

```bash
# If user wants broader refactoring
if [[ "$ARGUMENTS" == *"refactor"* ]]; then
    echo "💡 Consider /refactor for comprehensive code restructuring"
fi

# If formatting issues detected
if rg '^\s{4,}' --type ts -c | grep -q .; then
    echo "💡 Consider /make-it-pretty for overall readability improvements"
fi

# If complexity issues detected
if rg 'if.*if.*if' --type ts -c | grep -q .; then
    echo "💡 Consider /complexity-reduce for simplification"
fi
```

### Cache Invalidation Strategy

**When to invalidate cache:**
- New major dependency added (different framework)
- Language/framework version change
- `.claude/cache/naming_conventions.json` > 7 days old
- User explicitly requests fresh analysis

```bash
# Force fresh analysis
if [[ "$ARGUMENTS" == *"--fresh"* ]] || [ ! -f "$CONVENTIONS_CACHE" ]; then
    echo "Performing fresh naming analysis..."
    rm -f "$CONVENTIONS_CACHE" "$HISTORY_CACHE"
fi
```

### Performance Metrics

**Real-world optimization results:**
- Average session: 3,000-5,000 tokens → 1,200-2,000 tokens
- **60% reduction in token usage**
- Maintains thorough semantic analysis
- Faster initial feedback (Grep vs Read)
- Better focus on actual issues
- Reduced cost per naming improvement session

This optimization strategy enables efficient semantic naming analysis while minimizing Claude API costs through intelligent tool usage, caching, and progressive analysis patterns.

## Integration Points

**Synergistic Skills:**
- `/make-it-pretty` - Overall code readability improvements
- `/refactor` - Broader refactoring including naming
- `/review` - Code review including naming feedback
- `/complexity-reduce` - Simplification often improves naming clarity

Suggests `/make-it-pretty` when:
- Code has other readability issues beyond naming
- Formatting and structure need attention
- Type safety improvements needed

Suggests `/refactor` when:
- Code structure needs reorganization
- Functions need extraction
- Broader refactoring needed

## Naming Guidelines Reference

**Good Naming Principles:**

1. **Intention-Revealing**: Name should explain why it exists
   - Bad: `d` (elapsed time in days)
   - Good: `elapsedTimeInDays`

2. **Avoid Disinformation**: Don't use misleading names
   - Bad: `accountList` for a Map
   - Good: `accountMap` or `accounts`

3. **Make Meaningful Distinctions**: Avoid number series or noise words
   - Bad: `data1`, `data2`, `dataInfo`
   - Good: `rawData`, `processedData`, `dataStatistics`

4. **Pronounceable Names**: Should be readable aloud
   - Bad: `genymdhms` (generation year month day hour minute second)
   - Good: `generationTimestamp`

5. **Searchable Names**: Easy to find with search
   - Bad: `7` (magic number)
   - Good: `DAYS_IN_WEEK = 7`

6. **Avoid Mental Mapping**: Don't require translation
   - Bad: `r` for URL
   - Good: `url`

7. **Class Names**: Nouns or noun phrases
   - Good: `Customer`, `WikiPage`, `Account`, `AddressParser`
   - Avoid: `Manager`, `Processor`, `Data`, `Info`

8. **Method Names**: Verbs or verb phrases
   - Good: `postPayment`, `deletePage`, `save`
   - Accessors/Mutators: `getName`, `setName`, `isPosted`

9. **Pick One Word Per Concept**: Be consistent
   - Don't mix: `fetch`, `retrieve`, `get` for same concept
   - Pick one: `get` for all similar operations

10. **Use Domain Names**: When appropriate
    - Good: `AccountVisitor`, `JobQueue`, `PriorityQueue`

## Safety Mechanisms

**Protection Measures:**
- Create git checkpoint before renaming
- Rename incrementally (local → file → module → global)
- Verify tests pass after each rename
- Use search to find all usages
- Update documentation and comments

**Validation Steps:**
1. Find all occurrences of identifier
2. Verify context matches intended rename
3. Perform rename with exact matching
4. Run linter/type checker
5. Run tests
6. Review changes

**Rollback Procedure:**
```bash
# If renaming introduces issues
git checkout HEAD -- path/to/file
# Or for entire renaming session
git reset --hard HEAD
```

## Expected Improvements

**Code Clarity:**
- 50-80% reduction in cognitive load
- Easier onboarding for new developers
- Better IDE autocomplete suggestions
- Improved searchability
- Self-documenting code

**Naming Quality Metrics:**
- Generic names eliminated
- Single-letter variables reduced to loops only
- Consistent naming patterns
- Domain-appropriate terminology
- Clear intention in all identifiers

## Error Handling

If naming improvements introduce issues:
- I'll identify which rename caused the problem
- Provide specific rollback instructions
- Suggest alternative names
- Explain naming conflicts
- Ensure code functionality preserved

## Important Notes

**I will NEVER:**
- Break working code with renames
- Add AI attribution to files
- Rename without understanding context
- Change public API names without warning
- Ignore language conventions

**Best Practices:**
- Always understand context before renaming
- Preserve functionality exactly
- Follow language-specific conventions
- Be consistent across codebase
- Update tests and documentation

## Credits

**Inspired by:**
- [Clean Code by Robert C. Martin](https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882) - Naming principles
- [Refactoring by Martin Fowler](https://refactoring.com/) - Rename refactoring patterns
- Language-specific style guides (Airbnb, Google, PEP 8)
- Domain-driven design naming practices
- Code review best practices

This skill helps you transform unclear, generic names into clear, intention-revealing identifiers that make code self-documenting.

