AgentSkillsCN

refactor-rename-for-clarity

【代码质量】进行系统性重命名以提升代码清晰度:变量、函数、类、文件。当名称不清晰、误导或与用途不符时使用。

SKILL.md
--- frontmatter
name: refactor-rename-for-clarity
description: "[Code Quality] Performs systematic renaming to improve code clarity: variables, functions, classes, files. Use when names are unclear, misleading, or inconsistent with their purpose."

Refactor: Rename for Clarity

Improve code readability through better naming.

Naming Principles

1. Names Should Reveal Intent

swift
// BAD: let d: Int
// GOOD: let elapsedDays: Int

2. Names Should Be Searchable

swift
// BAD: if status == 1 { }
// GOOD: if status == .active { }

3. Names Should Match Abstraction Level

swift
// BAD: func getFromNetworkAndParseJSON()
// GOOD: func fetchUserProfile()

Common Patterns

Bad NameBetter NameWhy
datauserResponseSpecific type
temppreviousValuePurpose clear
flagisEnabledBoolean pattern
doIt()submitForm()Action + target