[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7512T5BJQ4HJ0WAJCJWFN39":3,"skill-same:01M7512T5BJQ4HJ0WAJCJWFN39":44},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7512T5BJQ4HJ0WAJCJWFN39","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.","chrisbarrantes\u002Fmandrel","chrisbarrantes","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F4534419?v=4","01M7511VXT2H7WE09JE4ZMBESG","Chris Barrantes","01M7511VYGPFHQCE9HNVKES0QN",0,"MIT","https:\u002F\u002Fgithub.com\u002Fchrisbarrantes\u002Fmandrel\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcore\u002Fcode-simplification\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: code-simplification\ndescription:\n  Simplifies code for clarity. Use when refactoring code for clarity without\n  changing behavior. Use when code works but is harder to read, maintain, or\n  extend than it should be. Use when reviewing code that has accumulated\n  unnecessary complexity.\n---\n\n# Code Simplification\n\n## Policy Capsule\n\n- Preserve behaviour **exactly**: inputs, outputs, side effects, error semantics, and ordering must be identical. If you're not sure a change preserves behaviour, don't make it.\n- Every simplification MUST leave existing tests passing without modification; if tests need to change, the refactor changed behaviour and is no longer a simplification.\n- Follow project conventions (CLAUDE.md, neighbour-code patterns, import style, naming, error handling). Simplification that breaks consistency is churn, not improvement.\n- Prefer clarity over cleverness: explicit code beats compact code whenever the compact form requires a mental pause to parse.\n- Comprehend before you simplify — never refactor code you don't yet fully understand.\n- Do not simplify for its own sake: skip when code is already clean, when performance would measurably regress, or when the module is about to be rewritten.\n- Lines-of-code is **not** the goal. The metric is \"would a new team member understand this faster than the original?\".\n- Make each simplification an isolated commit, not a drive-by inside a feature change (see `git-workflow-and-versioning`).\n- Verify behaviourally: run the full test suite, exercise affected paths, and diff the runtime output against the original before claiming the simplification is safe.\n\n> Inspired by the\n> [Claude Code Simplifier plugin](https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-plugins-official\u002Fblob\u002Fmain\u002Fplugins\u002Fcode-simplifier\u002Fagents\u002Fcode-simplifier.md).\n> Adapted here as a model-agnostic, process-driven skill for any AI coding\n> agent.\n\n## Overview\n\nSimplify code by reducing complexity while preserving exact behavior. The goal\nis not fewer lines — it's code that is easier to read, understand, modify, and\ndebug. Every simplification must pass a simple test: \"Would a new team member\nunderstand this faster than the original?\"\n\n## When to Use\n\n- After a feature is working and tests pass, but the implementation feels\n  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\n  slower\n- You're about to rewrite the module entirely — simplifying throwaway code\n  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,\nside effects, error behavior, and edge cases must remain identical. If you're\nnot sure a simplification preserves behavior, don't make it.\n\n```text\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\nexternal preferences. Before simplifying:\n\n```text\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\nchurn.\n\n### 3. Prefer Clarity Over Cleverness\n\nExplicit code is better than compact code when the compact version requires a\nmental pause to parse.\n\n```typescript\n\u002F\u002F UNCLEAR: Dense ternary chain\nconst label = isNew\n  ? 'New'\n  : isUpdated\n    ? 'Updated'\n    : isArchived\n      ? 'Archived'\n      : '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(\n  (acc, item) => ({\n    ...acc,\n    [item.id]: { ...acc[item.id], count: (acc[item.id]?.count ?? 0) + 1 },\n  }),\n  {},\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\n  makes the call site harder to read\n- **Combining unrelated logic** — two simple functions merged into one complex\n  function is not simpler\n- **Removing \"unnecessary\" abstraction** — some abstractions exist for\n  extensibility or testability, not complexity\n- **Optimizing for line count** — fewer lines is not the goal; easier\n  comprehension is\n\n### 5. Scope to What Changed\n\nDefault to simplifying recently modified code. Avoid drive-by refactors of\nunrelated code unless explicitly asked to broaden scope. Unscoped simplification\ncreates 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\nChesterton's Fence: if you see a fence across a road and don't understand why\nit's there, don't tear it down. First understand the reason, then decide if the\nreason still applies.\n\n```text\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\nfirst.\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\nrefactoring changes separately from feature or bug fix changes.** A PR that\nrefactors and adds a feature is two PRs — split them.\n\n```text\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\nsomething 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\nautomation (codemods, sed scripts, AST transforms) rather than making the\nchanges by hand. Manual edits at that scale are error-prone and exhausting to\nreview.\n\n### Step 4: Verify the Result\n\nAfter all simplifications, step back and evaluate the whole:\n\n```text\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\nsimplification 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\n  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\n      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## Policy Capsule\n\n- Preserve behaviour **exactly**: inputs, outputs, side effects, error semantics, and ordering must be identical. If you're not sure a change preserves behaviour, don't make it.\n- Every simplification MUST leave existing tests passing without modification; if tests need to change, the refactor changed behaviour and is no longer a simplification.\n- Follow project conventions (CLAUDE.md, neighbour-code patterns, import style, naming, error handling). Simplification that breaks consistency is churn, not improvement.\n- Prefer clarity over cleverness: explicit code beats compact code whenever the compact form requires a mental pause to parse.\n- Comprehend before you simplify — never refactor code you don't yet fully understand.\n- Do not simplify for its own sake: skip when code is already clean, when performance would measurably regress, or when the module is about to be rewritten.\n- Lines-of-code is **not** the goal. The metric is \"would a new team member understand this faster than the original?\".\n- Make each simplification an isolated commit, not a drive-by inside a feature change (see `git-workflow-and-versioning`).\n- Verify behaviourally: run the full test suite, exercise affected paths, and diff the runtime output against the original before claiming the simplification is safe.\n\n> Inspired by the\n> [Claude Code Simplifier plugin](https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-plugins-official\u002Fblob\u002Fmain\u002Fplugins\u002Fcode-simplifier\u002Fagents\u002Fcode-simplifier.md).\n> Adapted here as a model-agnostic, process-driven skill for any AI coding\n> agent.\n\n## Overview\n\nSimplify code by reducing complexity while preserving exact behavior. The goal\nis not fewer lines — it's code that is easier to read, understand, modify, and\ndebug. Every simplification must pass a simple test: \"Would a new team member\nunderstand this faster than the original?\"\n\n## When to Use\n\n- After a feature is working and tests pass, but the implementation feels\n  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\n  slower\n- You're about to rewrite the module entirely — simplifying throwaway code\n  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,\nside effects, error behavior, and edge cases must remain identical. If you're\nnot sure a simplification preserves behavior, don't make it.\n\n```text\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\nexternal preferences. Before simplifying:\n\n```text\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\nchurn.\n\n### 3. Prefer Clarity Over Cleverness\n\nExplicit code is better than compact code when the compact version requires a\nmental pause to parse.\n\n```typescript\n\u002F\u002F UNCLEAR: Dense ternary chain\nconst label = isNew\n  ? 'New'\n  : isUpdated\n    ? 'Updated'\n    : isArchived\n      ? 'Archived'\n      : '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(\n  (acc, item) => ({\n    ...acc,\n    [item.id]: { ...acc[item.id], count: (acc[item.id]?.count ?? 0) + 1 },\n  }),\n  {},\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\n  makes the call site harder to read\n- **Combining unrelated logic** — two simple functions merged into one complex\n  function is not simpler\n- **Removing \"unnecessary\" abstraction** — some abstractions exist for\n  extensibility or testability, not complexity\n- **Optimizing for line count** — fewer lines is not the goal; easier\n  comprehension is\n\n### 5. Scope to What Changed\n\nDefault to simplifying recently modified code. Avoid drive-by refactors of\nunrelated code unless explicitly asked to broaden scope. Unscoped simplification\ncreates 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\nChesterton's Fence: if you see a fence across a road and don't understand why\nit's there, don't tear it down. First understand the reason, then decide if the\nreason still applies.\n\n```text\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\nfirst.\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\nrefactoring changes separately from feature or bug fix changes.** A PR that\nrefactors and adds a feature is two PRs — split them.\n\n```text\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\nsomething 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\nautomation (codemods, sed scripts, AST transforms) rather than making the\nchanges by hand. Manual edits at that scale are error-prone and exhausting to\nreview.\n\n### Step 4: Verify the Result\n\nAfter all simplifications, step back and evaluate the whole:\n\n```text\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\nsimplification 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\n  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\n      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},"main","22b1847659cc2a98f4fb8c24858f2199d91fda66",".agents\u002Fskills\u002Fcore\u002Fcode-simplification","https:\u002F\u002Fgithub.com\u002Fchrisbarrantes\u002Fmandrel","https:\u002F\u002Fgithub.com\u002Fchrisbarrantes","2026-05-27 08:16:47",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add chrisbarrantes\u002Fmandrel --skill code-simplification",{"tool":36,"command":37},"bunx","bunx skills add chrisbarrantes\u002Fmandrel --skill code-simplification",{"tool":39,"command":40},"pnpm","pnpm dlx skills add chrisbarrantes\u002Fmandrel --skill code-simplification","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fchrisbarrantes\u002Fmandrel\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcore\u002Fcode-simplification\u002FSKILL.md",true,[],[45,52,59,66,73,80],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":19},"01M75171YZD373TXY5ZWJNXGS9","no-capsule-skill","Fixture without a Policy Capsule section.","https:\u002F\u002Fgithub.com\u002Fchrisbarrantes\u002Fmandrel\u002Fblob\u002Fmain\u002Ftests\u002Forchestration\u002Ffixtures\u002Fskill-capsule\u002Fno-capsule-skill\u002FSKILL.md",[],[],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M7516ZA88ESAAY3JWXBNA56K","backend-security-patterns","Combined backend protocols for authentication (Clerk JWT verification) and PII-safe observability. Use when handling auth on the server, verifying Clerk webhooks via `svix`, scoping metadata via `publicMetadata`\u002F `privateMetadata`, or sanitizing logs to keep emails, tokens, and request bodies out of telemetry.","https:\u002F\u002Fgithub.com\u002Fchrisbarrantes\u002Fmandrel\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fstack\u002Fsecurity\u002Fbackend-security-patterns\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M7516WFQMKD2NGFMDNFG6C4A","vitest","Writes fast, isolated unit and integration tests with Vitest. Use when each test must run on file-save without shared state — `vi.mock()` for external deps, `vi.spyOn()` for call monitoring, AAA structure, and edge-case coverage for null\u002Fundefined\u002Fboundary inputs.","https:\u002F\u002Fgithub.com\u002Fchrisbarrantes\u002Fmandrel\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fstack\u002Fqa\u002Fvitest\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7516T8FX7B0B0D510EE2FAP","playwright","Robust E2E browser testing with Playwright. Use when writing browser-driven tests — leverage auto-waiting (no `waitForTimeout`), prefer user-visible locators (`getByRole`, `getByText`, `getByLabel`) over CSS\u002FXPath, reuse `storageState` for auth, and enable trace-on-first-retry for CI debugging.","https:\u002F\u002Fgithub.com\u002Fchrisbarrantes\u002Fmandrel\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fstack\u002Fqa\u002Fplaywright\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7516PHY868BJXHHZJ0FRYSX","playwright-bdd","Wires Gherkin `.feature` files to Playwright via the `playwright-bdd` library. Use when running BDD scenarios on a Playwright runtime — pairs with the `gherkin-authoring` skill (scenario prose) and the `playwright` skill (browser conventions). Drives execution by tag expression with trace-first debugging and Playwright-native sharding.","https:\u002F\u002Fgithub.com\u002Fchrisbarrantes\u002Fmandrel\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fstack\u002Fqa\u002Fplaywright-bdd\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M7516KEGSBBFJXRZWYBKYM4P","lighthouse-baseline","Codifies the capture-and-check baseline pattern for long-running quality signals (Lighthouse scores, bundle size, p95 latency, runtime memory). Use when wiring a new metric that needs a baseline file, paired :capture \u002F :check npm scripts, a tolerance-bounded gate, and a weekly refresh cadence — the goal is a hard CI signal that ratchets only with intent.","https:\u002F\u002Fgithub.com\u002Fchrisbarrantes\u002Fmandrel\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fstack\u002Fqa\u002Flighthouse-baseline\u002FSKILL.md",[],[]]