[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71VC4NJHP8DSDT0NPK22E2E":3,"skill-same:01M71VC4NJHP8DSDT0NPK22E2E":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":22,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":49,"commitSha":50,"skillDirectory":51,"forksCount":52,"repositoryHtmlUrl":53,"repositoryHomepageUrl":6,"ownerHtmlUrl":54,"ownerBlogUrl":6,"ownerDescription":55,"updatedAt":56,"install":57,"resources":69},"01M71VC4NJHP8DSDT0NPK22E2E","code-simplification",null,"Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity. Use when asked to simplify, clean up, or reduce the nesting of a function or module that already works, even when the code is pasted inline and nothing else needs to change.","mamahoos\u002Fdot-files","mamahoos","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F62762296?v=4","01M71VB2X9CZAQ28WPHV6VQKCP","01M71VB2Y2BC8YW9F2TWF96WRW",5,"MIT","https:\u002F\u002Fgithub.com\u002Fmamahoos\u002Fdot-files\u002Fblob\u002Fmain\u002Fhome\u002F.cursor\u002Fskills\u002Fcode-simplification\u002FSKILL.md",[17],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"code","code simplification","simplification","needs","change","when","extend","inline","reduce","for","true","maintain","but","clean","complexity","up","read","clarity","refactoring","simplify","2026-11-10 13:02:02",false,"---\nname: code-simplification\ndescription: Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity. Use when asked to simplify, clean up, or reduce the nesting of a function or module that already works, even when the code is pasted inline and nothing else needs to change.\ndisable-model-invocation: true\n---\n\n# Code Simplification\n\n> Inspired by the [Claude Code Simplifier plugin](https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-plugins-official\u002Fblob\u002Fmain\u002Fplugins\u002Fcode-simplifier\u002Fagents\u002Fcode-simplifier.md). Adapted here as a model-agnostic, process-driven skill for any AI coding agent.\n\n## Overview\n\nSimplify code by reducing complexity while preserving exact behavior. The goal is not fewer lines — it's code that is easier to read, understand, modify, and debug. Every simplification must pass a simple test: \"Would a new team member understand this faster than the original?\"\n\n## When to Use\n\n- After a feature is working and tests pass, but the implementation feels heavier than it needs to be\n- During code review when readability or complexity issues are flagged\n- When you encounter deeply nested logic, long functions, or unclear names\n- When refactoring code written under time pressure\n- When consolidating related logic scattered across files\n- After merging changes that introduced duplication or inconsistency\n\n**When NOT to use:**\n\n- Code is already clean and readable — don't simplify for the sake of it\n- You don't understand what the code does yet — comprehend before you simplify\n- The code is performance-critical and the \"simpler\" version would be measurably slower\n- You're about to rewrite the module entirely — simplifying throwaway code wastes effort\n\n## The Five Principles\n\n### 1. Preserve Behavior Exactly\n\nDon't change what the code does — only how it expresses it. All inputs, outputs, side effects, error behavior, and edge cases must remain identical. If you're not sure a simplification preserves behavior, don't make it.\n\n```\nASK BEFORE EVERY CHANGE:\n→ Does this produce the same output for every input?\n→ Does this maintain the same error behavior?\n→ Does this preserve the same side effects and ordering?\n→ Do all existing tests still pass without modification?\n```\n\n### 2. Follow Project Conventions\n\nSimplification means making code more consistent with the codebase, not imposing external preferences. Before simplifying:\n\n```\n1. Read CLAUDE.md \u002F project conventions\n2. Study how neighboring code handles similar patterns\n3. Match the project's style for:\n   - Import ordering and module system\n   - Function declaration style\n   - Naming conventions\n   - Error handling patterns\n   - Type annotation depth\n```\n\nSimplification that breaks project consistency is not simplification — it's churn.\n\n### 3. Prefer Clarity Over Cleverness\n\nExplicit code is better than compact code when the compact version requires a mental pause to parse.\n\n```typescript\n\u002F\u002F UNCLEAR: Dense ternary chain\nconst label = isNew ? 'New' : isUpdated ? 'Updated' : isArchived ? 'Archived' : 'Active';\n\n\u002F\u002F CLEAR: Readable mapping\nfunction getStatusLabel(item: Item): string {\n  if (item.isNew) return 'New';\n  if (item.isUpdated) return 'Updated';\n  if (item.isArchived) return 'Archived';\n  return 'Active';\n}\n```\n\n```typescript\n\u002F\u002F UNCLEAR: Chained reduces with inline logic\nconst result = items.reduce((acc, item) => ({\n  ...acc,\n  [item.id]: { ...acc[item.id], count: (acc[item.id]?.count ?? 0) + 1 }\n}), {});\n\n\u002F\u002F CLEAR: Named intermediate step\nconst countById = new Map\u003Cstring, number>();\nfor (const item of items) {\n  countById.set(item.id, (countById.get(item.id) ?? 0) + 1);\n}\n```\n\n### 4. Maintain Balance\n\nSimplification has a failure mode: over-simplification. Watch for these traps:\n\n- **Inlining too aggressively** — removing a helper that gave a concept a name makes the call site harder to read\n- **Combining unrelated logic** — two simple functions merged into one complex function is not simpler\n- **Removing \"unnecessary\" abstraction** — some abstractions exist for extensibility or testability, not complexity\n- **Optimizing for line count** — fewer lines is not the goal; easier comprehension is\n\n### 5. Scope to What Changed\n\nDefault to simplifying recently modified code. Avoid drive-by refactors of unrelated code unless explicitly asked to broaden scope. Unscoped simplification creates noise in diffs and risks unintended regressions.\n\n## The Simplification Process\n\n### Step 1: Understand Before Touching (Chesterton's Fence)\n\nBefore changing or removing anything, understand why it exists. This is Chesterton's Fence: if you see a fence across a road and don't understand why it's there, don't tear it down. First understand the reason, then decide if the reason still applies.\n\n```\nBEFORE SIMPLIFYING, ANSWER:\n- What is this code's responsibility?\n- What calls it? What does it call?\n- What are the edge cases and error paths?\n- Are there tests that define the expected behavior?\n- Why might it have been written this way? (Performance? Platform constraint? Historical reason?)\n- Check git blame: what was the original context for this code?\n```\n\nIf you can't answer these, you're not ready to simplify. Read more context first.\n\n### Step 2: Identify Simplification Opportunities\n\nScan for these patterns — each one is a concrete signal, not a vague smell:\n\n**Structural complexity:**\n\n| Pattern | Signal | Simplification |\n|---------|--------|----------------|\n| Deep nesting (3+ levels) | Hard to follow control flow | Extract conditions into guard clauses or helper functions |\n| Long functions (50+ lines) | Multiple responsibilities | Split into focused functions with descriptive names |\n| Nested ternaries | Requires mental stack to parse | Replace with if\u002Felse chains, switch, or lookup objects |\n| Boolean parameter flags | `doThing(true, false, true)` | Replace with options objects or separate functions |\n| Repeated conditionals | Same `if` check in multiple places | Extract to a well-named predicate function |\n\n**Naming and readability:**\n\n| Pattern | Signal | Simplification |\n|---------|--------|----------------|\n| Generic names | `data`, `result`, `temp`, `val`, `item` | Rename to describe the content: `userProfile`, `validationErrors` |\n| Abbreviated names | `usr`, `cfg`, `btn`, `evt` | Use full words unless the abbreviation is universal (`id`, `url`, `api`) |\n| Misleading names | Function named `get` that also mutates state | Rename to reflect actual behavior |\n| Comments explaining \"what\" | `\u002F\u002F increment counter` above `count++` | Delete the comment — the code is clear enough |\n| Comments explaining \"why\" | `\u002F\u002F Retry because the API is flaky under load` | Keep these — they carry intent the code can't express |\n\n**Redundancy:**\n\n| Pattern | Signal | Simplification |\n|---------|--------|----------------|\n| Duplicated logic | Same 5+ lines in multiple places | Extract to a shared function |\n| Dead code | Unreachable branches, unused variables, commented-out blocks | Remove (after confirming it's truly dead) |\n| Unnecessary abstractions | Wrapper that adds no value | Inline the wrapper, call the underlying function directly |\n| Over-engineered patterns | Factory-for-a-factory, strategy-with-one-strategy | Replace with the simple direct approach |\n| Redundant type assertions | Casting to a type that's already inferred | Remove the assertion |\n\n### Step 3: Apply Changes Incrementally\n\nMake one simplification at a time. Run tests after each change. **Submit refactoring changes separately from feature or bug fix changes.** A PR that refactors and adds a feature is two PRs — split them.\n\n```\nFOR EACH SIMPLIFICATION:\n1. Make the change\n2. Run the test suite\n3. If tests pass → commit (or continue to next simplification)\n4. If tests fail → revert and reconsider\n```\n\nAvoid batching multiple simplifications into a single untested change. If something breaks, you need to know which simplification caused it.\n\n**The Rule of 500:** If a refactoring would touch more than 500 lines, invest in automation (codemods, sed scripts, AST transforms) rather than making the changes by hand. Manual edits at that scale are error-prone and exhausting to review.\n\n### Step 4: Verify the Result\n\nAfter all simplifications, step back and evaluate the whole:\n\n```\nCOMPARE BEFORE AND AFTER:\n- Is the simplified version genuinely easier to understand?\n- Did you introduce any new patterns inconsistent with the codebase?\n- Is the diff clean and reviewable?\n- Would a teammate approve this change?\n```\n\nIf the \"simplified\" version is harder to understand or review, revert. Not every simplification attempt succeeds.\n\n## Language-Specific Guidance\n\n### TypeScript \u002F JavaScript\n\n```typescript\n\u002F\u002F SIMPLIFY: Unnecessary async wrapper\n\u002F\u002F Before\nasync function getUser(id: string): Promise\u003CUser> {\n  return await userService.findById(id);\n}\n\u002F\u002F After\nfunction getUser(id: string): Promise\u003CUser> {\n  return userService.findById(id);\n}\n\n\u002F\u002F SIMPLIFY: Verbose conditional assignment\n\u002F\u002F Before\nlet displayName: string;\nif (user.nickname) {\n  displayName = user.nickname;\n} else {\n  displayName = user.fullName;\n}\n\u002F\u002F After\nconst displayName = user.nickname || user.fullName;\n\n\u002F\u002F SIMPLIFY: Manual array building\n\u002F\u002F Before\nconst activeUsers: User[] = [];\nfor (const user of users) {\n  if (user.isActive) {\n    activeUsers.push(user);\n  }\n}\n\u002F\u002F After\nconst activeUsers = users.filter((user) => user.isActive);\n\n\u002F\u002F SIMPLIFY: Redundant boolean return\n\u002F\u002F Before\nfunction isValid(input: string): boolean {\n  if (input.length > 0 && input.length \u003C 100) {\n    return true;\n  }\n  return false;\n}\n\u002F\u002F After\nfunction isValid(input: string): boolean {\n  return input.length > 0 && input.length \u003C 100;\n}\n```\n\n### Python\n\n```python\n# SIMPLIFY: Verbose dictionary building\n# Before\nresult = {}\nfor item in items:\n    result[item.id] = item.name\n# After\nresult = {item.id: item.name for item in items}\n\n# SIMPLIFY: Nested conditionals with early return\n# Before\ndef process(data):\n    if data is not None:\n        if data.is_valid():\n            if data.has_permission():\n                return do_work(data)\n            else:\n                raise PermissionError(\"No permission\")\n        else:\n            raise ValueError(\"Invalid data\")\n    else:\n        raise TypeError(\"Data is None\")\n# After\ndef process(data):\n    if data is None:\n        raise TypeError(\"Data is None\")\n    if not data.is_valid():\n        raise ValueError(\"Invalid data\")\n    if not data.has_permission():\n        raise PermissionError(\"No permission\")\n    return do_work(data)\n```\n\n### React \u002F JSX\n\n```tsx\n\u002F\u002F SIMPLIFY: Verbose conditional rendering\n\u002F\u002F Before\nfunction UserBadge({ user }: Props) {\n  if (user.isAdmin) {\n    return \u003CBadge variant=\"admin\">Admin\u003C\u002FBadge>;\n  } else {\n    return \u003CBadge variant=\"default\">User\u003C\u002FBadge>;\n  }\n}\n\u002F\u002F After\nfunction UserBadge({ user }: Props) {\n  const variant = user.isAdmin ? 'admin' : 'default';\n  const label = user.isAdmin ? 'Admin' : 'User';\n  return \u003CBadge variant={variant}>{label}\u003C\u002FBadge>;\n}\n\n\u002F\u002F SIMPLIFY: Prop drilling through intermediate components\n\u002F\u002F Before — consider whether context or composition solves this better.\n\u002F\u002F This is a judgment call — flag it, don't auto-refactor.\n```\n\n## Common Rationalizations\n\n| Rationalization | Reality |\n|---|---|\n| \"It's working, no need to touch it\" | Working code that's hard to read will be hard to fix when it breaks. Simplifying now saves time on every future change. |\n| \"Fewer lines is always simpler\" | A 1-line nested ternary is not simpler than a 5-line if\u002Felse. Simplicity is about comprehension speed, not line count. |\n| \"I'll just quickly simplify this unrelated code too\" | Unscoped simplification creates noisy diffs and risks regressions in code you didn't intend to change. Stay focused. |\n| \"The types make it self-documenting\" | Types document structure, not intent. A well-named function explains *why* better than a type signature explains *what*. |\n| \"This abstraction might be useful later\" | Don't preserve speculative abstractions. If it's not used now, it's complexity without value. Remove it and re-add when needed. |\n| \"The original author must have had a reason\" | Maybe. Check git blame — apply Chesterton's Fence. But accumulated complexity often has no reason; it's just the residue of iteration under pressure. |\n| \"I'll refactor while adding this feature\" | Separate refactoring from feature work. Mixed changes are harder to review, revert, and understand in history. |\n\n## Red Flags\n\n- Simplification that requires modifying tests to pass (you likely changed behavior)\n- \"Simplified\" code that is longer and harder to follow than the original\n- Renaming things to match your preferences rather than project conventions\n- Removing error handling because \"it makes the code cleaner\"\n- Simplifying code you don't fully understand\n- Batching many simplifications into one large, hard-to-review commit\n- Refactoring code outside the scope of the current task without being asked\n\n## Verification\n\nAfter completing a simplification pass:\n\n- [ ] All existing tests pass without modification\n- [ ] Build succeeds with no new warnings\n- [ ] Linter\u002Fformatter passes (no style regressions)\n- [ ] Each simplification is a reviewable, incremental change\n- [ ] The diff is clean — no unrelated changes mixed in\n- [ ] Simplified code follows project conventions (checked against CLAUDE.md or equivalent)\n- [ ] No error handling was removed or weakened\n- [ ] No dead code was left behind (unused imports, unreachable branches)\n- [ ] A teammate or review agent would approve the change as a net improvement\n","# Code Simplification\n\n> Inspired by the [Claude Code Simplifier plugin](https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-plugins-official\u002Fblob\u002Fmain\u002Fplugins\u002Fcode-simplifier\u002Fagents\u002Fcode-simplifier.md). Adapted here as a model-agnostic, process-driven skill for any AI coding agent.\n\n## Overview\n\nSimplify code by reducing complexity while preserving exact behavior. The goal is not fewer lines — it's code that is easier to read, understand, modify, and debug. Every simplification must pass a simple test: \"Would a new team member understand this faster than the original?\"\n\n## When to Use\n\n- After a feature is working and tests pass, but the implementation feels heavier than it needs to be\n- During code review when readability or complexity issues are flagged\n- When you encounter deeply nested logic, long functions, or unclear names\n- When refactoring code written under time pressure\n- When consolidating related logic scattered across files\n- After merging changes that introduced duplication or inconsistency\n\n**When NOT to use:**\n\n- Code is already clean and readable — don't simplify for the sake of it\n- You don't understand what the code does yet — comprehend before you simplify\n- The code is performance-critical and the \"simpler\" version would be measurably slower\n- You're about to rewrite the module entirely — simplifying throwaway code wastes effort\n\n## The Five Principles\n\n### 1. Preserve Behavior Exactly\n\nDon't change what the code does — only how it expresses it. All inputs, outputs, side effects, error behavior, and edge cases must remain identical. If you're not sure a simplification preserves behavior, don't make it.\n\n```\nASK BEFORE EVERY CHANGE:\n→ Does this produce the same output for every input?\n→ Does this maintain the same error behavior?\n→ Does this preserve the same side effects and ordering?\n→ Do all existing tests still pass without modification?\n```\n\n### 2. Follow Project Conventions\n\nSimplification means making code more consistent with the codebase, not imposing external preferences. Before simplifying:\n\n```\n1. Read CLAUDE.md \u002F project conventions\n2. Study how neighboring code handles similar patterns\n3. Match the project's style for:\n   - Import ordering and module system\n   - Function declaration style\n   - Naming conventions\n   - Error handling patterns\n   - Type annotation depth\n```\n\nSimplification that breaks project consistency is not simplification — it's churn.\n\n### 3. Prefer Clarity Over Cleverness\n\nExplicit code is better than compact code when the compact version requires a mental pause to parse.\n\n```typescript\n\u002F\u002F UNCLEAR: Dense ternary chain\nconst label = isNew ? 'New' : isUpdated ? 'Updated' : isArchived ? 'Archived' : 'Active';\n\n\u002F\u002F CLEAR: Readable mapping\nfunction getStatusLabel(item: Item): string {\n  if (item.isNew) return 'New';\n  if (item.isUpdated) return 'Updated';\n  if (item.isArchived) return 'Archived';\n  return 'Active';\n}\n```\n\n```typescript\n\u002F\u002F UNCLEAR: Chained reduces with inline logic\nconst result = items.reduce((acc, item) => ({\n  ...acc,\n  [item.id]: { ...acc[item.id], count: (acc[item.id]?.count ?? 0) + 1 }\n}), {});\n\n\u002F\u002F CLEAR: Named intermediate step\nconst countById = new Map\u003Cstring, number>();\nfor (const item of items) {\n  countById.set(item.id, (countById.get(item.id) ?? 0) + 1);\n}\n```\n\n### 4. Maintain Balance\n\nSimplification has a failure mode: over-simplification. Watch for these traps:\n\n- **Inlining too aggressively** — removing a helper that gave a concept a name makes the call site harder to read\n- **Combining unrelated logic** — two simple functions merged into one complex function is not simpler\n- **Removing \"unnecessary\" abstraction** — some abstractions exist for extensibility or testability, not complexity\n- **Optimizing for line count** — fewer lines is not the goal; easier comprehension is\n\n### 5. Scope to What Changed\n\nDefault to simplifying recently modified code. Avoid drive-by refactors of unrelated code unless explicitly asked to broaden scope. Unscoped simplification creates noise in diffs and risks unintended regressions.\n\n## The Simplification Process\n\n### Step 1: Understand Before Touching (Chesterton's Fence)\n\nBefore changing or removing anything, understand why it exists. This is Chesterton's Fence: if you see a fence across a road and don't understand why it's there, don't tear it down. First understand the reason, then decide if the reason still applies.\n\n```\nBEFORE SIMPLIFYING, ANSWER:\n- What is this code's responsibility?\n- What calls it? What does it call?\n- What are the edge cases and error paths?\n- Are there tests that define the expected behavior?\n- Why might it have been written this way? (Performance? Platform constraint? Historical reason?)\n- Check git blame: what was the original context for this code?\n```\n\nIf you can't answer these, you're not ready to simplify. Read more context first.\n\n### Step 2: Identify Simplification Opportunities\n\nScan for these patterns — each one is a concrete signal, not a vague smell:\n\n**Structural complexity:**\n\n| Pattern | Signal | Simplification |\n|---------|--------|----------------|\n| Deep nesting (3+ levels) | Hard to follow control flow | Extract conditions into guard clauses or helper functions |\n| Long functions (50+ lines) | Multiple responsibilities | Split into focused functions with descriptive names |\n| Nested ternaries | Requires mental stack to parse | Replace with if\u002Felse chains, switch, or lookup objects |\n| Boolean parameter flags | `doThing(true, false, true)` | Replace with options objects or separate functions |\n| Repeated conditionals | Same `if` check in multiple places | Extract to a well-named predicate function |\n\n**Naming and readability:**\n\n| Pattern | Signal | Simplification |\n|---------|--------|----------------|\n| Generic names | `data`, `result`, `temp`, `val`, `item` | Rename to describe the content: `userProfile`, `validationErrors` |\n| Abbreviated names | `usr`, `cfg`, `btn`, `evt` | Use full words unless the abbreviation is universal (`id`, `url`, `api`) |\n| Misleading names | Function named `get` that also mutates state | Rename to reflect actual behavior |\n| Comments explaining \"what\" | `\u002F\u002F increment counter` above `count++` | Delete the comment — the code is clear enough |\n| Comments explaining \"why\" | `\u002F\u002F Retry because the API is flaky under load` | Keep these — they carry intent the code can't express |\n\n**Redundancy:**\n\n| Pattern | Signal | Simplification |\n|---------|--------|----------------|\n| Duplicated logic | Same 5+ lines in multiple places | Extract to a shared function |\n| Dead code | Unreachable branches, unused variables, commented-out blocks | Remove (after confirming it's truly dead) |\n| Unnecessary abstractions | Wrapper that adds no value | Inline the wrapper, call the underlying function directly |\n| Over-engineered patterns | Factory-for-a-factory, strategy-with-one-strategy | Replace with the simple direct approach |\n| Redundant type assertions | Casting to a type that's already inferred | Remove the assertion |\n\n### Step 3: Apply Changes Incrementally\n\nMake one simplification at a time. Run tests after each change. **Submit refactoring changes separately from feature or bug fix changes.** A PR that refactors and adds a feature is two PRs — split them.\n\n```\nFOR EACH SIMPLIFICATION:\n1. Make the change\n2. Run the test suite\n3. If tests pass → commit (or continue to next simplification)\n4. If tests fail → revert and reconsider\n```\n\nAvoid batching multiple simplifications into a single untested change. If something breaks, you need to know which simplification caused it.\n\n**The Rule of 500:** If a refactoring would touch more than 500 lines, invest in automation (codemods, sed scripts, AST transforms) rather than making the changes by hand. Manual edits at that scale are error-prone and exhausting to review.\n\n### Step 4: Verify the Result\n\nAfter all simplifications, step back and evaluate the whole:\n\n```\nCOMPARE BEFORE AND AFTER:\n- Is the simplified version genuinely easier to understand?\n- Did you introduce any new patterns inconsistent with the codebase?\n- Is the diff clean and reviewable?\n- Would a teammate approve this change?\n```\n\nIf the \"simplified\" version is harder to understand or review, revert. Not every simplification attempt succeeds.\n\n## Language-Specific Guidance\n\n### TypeScript \u002F JavaScript\n\n```typescript\n\u002F\u002F SIMPLIFY: Unnecessary async wrapper\n\u002F\u002F Before\nasync function getUser(id: string): Promise\u003CUser> {\n  return await userService.findById(id);\n}\n\u002F\u002F After\nfunction getUser(id: string): Promise\u003CUser> {\n  return userService.findById(id);\n}\n\n\u002F\u002F SIMPLIFY: Verbose conditional assignment\n\u002F\u002F Before\nlet displayName: string;\nif (user.nickname) {\n  displayName = user.nickname;\n} else {\n  displayName = user.fullName;\n}\n\u002F\u002F After\nconst displayName = user.nickname || user.fullName;\n\n\u002F\u002F SIMPLIFY: Manual array building\n\u002F\u002F Before\nconst activeUsers: User[] = [];\nfor (const user of users) {\n  if (user.isActive) {\n    activeUsers.push(user);\n  }\n}\n\u002F\u002F After\nconst activeUsers = users.filter((user) => user.isActive);\n\n\u002F\u002F SIMPLIFY: Redundant boolean return\n\u002F\u002F Before\nfunction isValid(input: string): boolean {\n  if (input.length > 0 && input.length \u003C 100) {\n    return true;\n  }\n  return false;\n}\n\u002F\u002F After\nfunction isValid(input: string): boolean {\n  return input.length > 0 && input.length \u003C 100;\n}\n```\n\n### Python\n\n```python\n# SIMPLIFY: Verbose dictionary building\n# Before\nresult = {}\nfor item in items:\n    result[item.id] = item.name\n# After\nresult = {item.id: item.name for item in items}\n\n# SIMPLIFY: Nested conditionals with early return\n# Before\ndef process(data):\n    if data is not None:\n        if data.is_valid():\n            if data.has_permission():\n                return do_work(data)\n            else:\n                raise PermissionError(\"No permission\")\n        else:\n            raise ValueError(\"Invalid data\")\n    else:\n        raise TypeError(\"Data is None\")\n# After\ndef process(data):\n    if data is None:\n        raise TypeError(\"Data is None\")\n    if not data.is_valid():\n        raise ValueError(\"Invalid data\")\n    if not data.has_permission():\n        raise PermissionError(\"No permission\")\n    return do_work(data)\n```\n\n### React \u002F JSX\n\n```tsx\n\u002F\u002F SIMPLIFY: Verbose conditional rendering\n\u002F\u002F Before\nfunction UserBadge({ user }: Props) {\n  if (user.isAdmin) {\n    return \u003CBadge variant=\"admin\">Admin\u003C\u002FBadge>;\n  } else {\n    return \u003CBadge variant=\"default\">User\u003C\u002FBadge>;\n  }\n}\n\u002F\u002F After\nfunction UserBadge({ user }: Props) {\n  const variant = user.isAdmin ? 'admin' : 'default';\n  const label = user.isAdmin ? 'Admin' : 'User';\n  return \u003CBadge variant={variant}>{label}\u003C\u002FBadge>;\n}\n\n\u002F\u002F SIMPLIFY: Prop drilling through intermediate components\n\u002F\u002F Before — consider whether context or composition solves this better.\n\u002F\u002F This is a judgment call — flag it, don't auto-refactor.\n```\n\n## Common Rationalizations\n\n| Rationalization | Reality |\n|---|---|\n| \"It's working, no need to touch it\" | Working code that's hard to read will be hard to fix when it breaks. Simplifying now saves time on every future change. |\n| \"Fewer lines is always simpler\" | A 1-line nested ternary is not simpler than a 5-line if\u002Felse. Simplicity is about comprehension speed, not line count. |\n| \"I'll just quickly simplify this unrelated code too\" | Unscoped simplification creates noisy diffs and risks regressions in code you didn't intend to change. Stay focused. |\n| \"The types make it self-documenting\" | Types document structure, not intent. A well-named function explains *why* better than a type signature explains *what*. |\n| \"This abstraction might be useful later\" | Don't preserve speculative abstractions. If it's not used now, it's complexity without value. Remove it and re-add when needed. |\n| \"The original author must have had a reason\" | Maybe. Check git blame — apply Chesterton's Fence. But accumulated complexity often has no reason; it's just the residue of iteration under pressure. |\n| \"I'll refactor while adding this feature\" | Separate refactoring from feature work. Mixed changes are harder to review, revert, and understand in history. |\n\n## Red Flags\n\n- Simplification that requires modifying tests to pass (you likely changed behavior)\n- \"Simplified\" code that is longer and harder to follow than the original\n- Renaming things to match your preferences rather than project conventions\n- Removing error handling because \"it makes the code cleaner\"\n- Simplifying code you don't fully understand\n- Batching many simplifications into one large, hard-to-review commit\n- Refactoring code outside the scope of the current task without being asked\n\n## Verification\n\nAfter completing a simplification pass:\n\n- [ ] All existing tests pass without modification\n- [ ] Build succeeds with no new warnings\n- [ ] Linter\u002Fformatter passes (no style regressions)\n- [ ] Each simplification is a reviewable, incremental change\n- [ ] The diff is clean — no unrelated changes mixed in\n- [ ] Simplified code follows project conventions (checked against CLAUDE.md or equivalent)\n- [ ] No error handling was removed or weakened\n- [ ] No dead code was left behind (unused imports, unreachable branches)\n- [ ] A teammate or review agent would approve the change as a net improvement\n",{"name":5,"description":7,"disable-model-invocation":48},true,"main","f5079c29c332b831168f6d7571d2598e98fe8e64","home\u002F.cursor\u002Fskills\u002Fcode-simplification",0,"https:\u002F\u002Fgithub.com\u002Fmamahoos\u002Fdot-files","https:\u002F\u002Fgithub.com\u002Fmamahoos","DevOps \u002F Platform Engineer","2026-11-10 03:01:53",{"source":8,"skillName":5,"commands":58,"prompt":68,"zipAvailable":48},[59,62,65],{"tool":60,"command":61},"npx","npx skills add mamahoos\u002Fdot-files --skill code-simplification",{"tool":63,"command":64},"bunx","bunx skills add mamahoos\u002Fdot-files --skill code-simplification",{"tool":66,"command":67},"pnpm","pnpm dlx skills add mamahoos\u002Fdot-files --skill code-simplification","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmamahoos\u002Fdot-files\u002Fblob\u002Fmain\u002Fhome\u002F.cursor\u002Fskills\u002Fcode-simplification\u002FSKILL.md",[],[71,104,124,152,175,200],{"skillNo":72,"name":73,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":74,"licenseFileUrl":75,"sourceHtmlUrl":76,"categories":77,"keywords":86,"publishedAt":43},"01M71VCZ7RGA06SS6KY978AZTS","discernment-nudge","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmamahoos\u002Fdot-files\u002Fblob\u002Fmain\u002Fhome\u002F.cursor\u002Fskills\u002Fdiscernment-nudge\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fmamahoos\u002Fdot-files\u002Fblob\u002Fmain\u002Fhome\u002F.cursor\u002Fskills\u002Fdiscernment-nudge\u002FSKILL.md",[78,83],{"categoryNo":79,"categoryName":80,"taxonomyType":81,"taxonomyTypeDesc":82},"01JBSEEDCAT000000000000018","写作与文案","SCENARIO","使用场景",{"categoryNo":84,"categoryName":85,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000036","内容创作者",[87,88,89,90,91,38,92,93,94,28,95,96,23,97,98,99,100,101,102,103],"discernment nudge","nudge","conversation","interpretation","short","only","writing","invoke","you","analysis","review","claims","argument","assemble","how","run","recommendations",{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":43},"01M71VCTTZ4V9HGZF6E0HCJW7T","diagnosing-bugs","Diagnosis loop for hard bugs and performance regressions. Use when the user says \"diagnose\"\u002F\"debug this\", or reports something broken\u002Fthrowing\u002Ffailing\u002Fslow.","https:\u002F\u002Fgithub.com\u002Fmamahoos\u002Fdot-files\u002Fblob\u002Fmain\u002Fhome\u002F.cursor\u002Fskills\u002Fdiagnosing-bugs\u002FSKILL.md",[],[111,112,113,114,32,115,116,33,117,118,119,120,28,121,122,123],"bugs","diagnosing bugs","broken","diagnose","performance","failing","regressions","use","loop","debug","reports","diagnosis","user",{"skillNo":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":136,"publishedAt":43},"01M71VCQZJWH05YTPC61MAGRNF","deprecation-and-migration","Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand\u002Fcontract). Use when deciding whether to maintain or sunset existing code.","https:\u002F\u002Fgithub.com\u002Fmamahoos\u002Fdot-files\u002Fblob\u002Fmain\u002Fhome\u002F.cursor\u002Fskills\u002Fdeprecation-and-migration\u002FSKILL.md",[130,133],{"categoryNo":131,"categoryName":132,"taxonomyType":81,"taxonomyTypeDesc":82},"01JBSEEDCAT000000000000010","后端与接口",{"categoryNo":134,"categoryName":135,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000037","律师与法务",[137,138,139,140,141,34,142,28,23,143,144,33,145,146,118,147,148,149,150,151],"deprecation","deprecation and migration","migration","expand","database schema","database","features","as","contract","schema","Existing","one","users","systems","column",{"skillNo":153,"name":154,"nameZh":6,"description":155,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":156,"categories":157,"keywords":158,"publishedAt":43},"01M71VCMZA9VYSWXX396XRPP1Z","debugging-and-error-recovery","Guides systematic root-cause debugging. Use when tests fail, builds break, something that worked yesterday broke, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need to figure out what broke and why — a systematic approach to finding and fixing the root cause rather than guessing.","https:\u002F\u002Fgithub.com\u002Fmamahoos\u002Fdot-files\u002Fblob\u002Fmain\u002Fhome\u002F.cursor\u002Fskills\u002Fdebugging-and-error-recovery\u002FSKILL.md",[],[159,160,161,162,163,28,95,164,165,166,167,168,169,33,170,118,171,172,173,174],"error","error recovery","debugging","debugging and error recovery","recovery","guides","why","break","systematic","encounter","root cause","tests","root-cause","behavior","match","root",{"skillNo":176,"name":177,"nameZh":6,"description":178,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":179,"categories":180,"keywords":184,"publishedAt":43},"01M71VCGKVYAEHPKH569NVC8ZB","context-engineering","Optimizes agent context setup. Use when starting a new session, when agent output quality degrades, when switching between tasks, or when you need to configure rules files and context for a project.","https:\u002F\u002Fgithub.com\u002Fmamahoos\u002Fdot-files\u002Fblob\u002Fmain\u002Fhome\u002F.cursor\u002Fskills\u002Fcontext-engineering\u002FSKILL.md",[181],{"categoryNo":182,"categoryName":183,"taxonomyType":81,"taxonomyTypeDesc":82},"01JBSEEDCAT000000000000023","Skill与智能体开发",[185,186,187,188,189,190,191,192,193,28,194,95,195,196,197,32,198,33,118,199],"context","context engineering","engineering","project","context setup","new","files","agent context","switching","configure","tasks","agent context setup","new session","session","Rules",{"skillNo":201,"name":202,"nameZh":6,"description":203,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":204,"categories":205,"keywords":206,"publishedAt":43},"01M71VCARZSNE9Y80192V5FTZK","constraint-driven-development","Establishes a project's quality bar as a written contract and stops agents quietly lowering it. Interviews the user on which dimensions matter, supplies sane default thresholds when they have no number in mind, records everything in CONSTRAINTS.md, and watches the diff for a weakened bar — new @ts-ignore or eslint-disable suppressions, skipped or deleted tests, assertions stripped out, unimplemented stubs, thresholds edited down. Use when no quality bar is written down, when the user says \"set up constraints\" or \"define our standards\", when the user wants dimensions they care about — accessibility, web performance, coverage — set up as enforced constraints, when an agent keeps silencing checks or skipping tests to get to green, when you need a coverage or performance threshold and don't know what number to pick, or when an agent writes more code than anyone will read.","https:\u002F\u002Fgithub.com\u002Fmamahoos\u002Fdot-files\u002Fblob\u002Fmain\u002Fhome\u002F.cursor\u002Fskills\u002Fconstraint-driven-development\u002FSKILL.md",[],[207,208,209,210,211,212,213,214,215,188,115,216,217,38,190,28,218,95,23,219],"development","constraint driven development","constraint","driven","coverage","SET","which","get","green","default","pick","number","dimensions"]