[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-1e9bc81d-54d7-4a3b-9790-8a2558ea0772":3,"$fR8cjQkmgrfwMPu4wF0jcbsmlMUF9xf-S6F_N4yBRuJc":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"1e9bc81d-54d7-4a3b-9790-8a2558ea0772","clean-code","这种技能体现了罗伯特·C·马丁（Uncle Bob）的“清晰代码”原则。用它将“能工作的代码”转变为“清晰的代码”。","cat_life_career","mod_other","sickn33,other","---\nname: clean-code\ndescription: \"This skill embodies the principles of \\\"Clean Code\\\" by Robert C. Martin (Uncle Bob). Use it to transform \\\"code that works\\\" into \\\"code that is clean.\\\"\"\nrisk: safe\nsource: \"ClawForge (https:\u002F\u002Fgithub.com\u002Fjackjin1997\u002FClawForge)\"\ndate_added: \"2026-02-27\"\n---\n\n# Clean Code Skill\n\nThis skill embodies the principles of \"Clean Code\" by Robert C. Martin (Uncle Bob). Use it to transform \"code that works\" into \"code that is clean.\"\n\n## 🧠 Core Philosophy\n> \"Code is clean if it can be read, and enhanced by a developer other than its original author.\" — Grady Booch\n\n## When to Use\nUse this skill when:\n- **Writing new code**: To ensure high quality from the start.\n- **Reviewing Pull Requests**: To provide constructive, principle-based feedback.\n- **Refactoring legacy code**: To identify and remove code smells.\n- **Improving team standards**: To align on industry-standard best practices.\n\n## 1. Meaningful Names\n- **Use Intention-Revealing Names**: `elapsedTimeInDays` instead of `d`.\n- **Avoid Disinformation**: Don't use `accountList` if it's actually a `Map`.\n- **Make Meaningful Distinctions**: Avoid `ProductData` vs `ProductInfo`.\n- **Use Pronounceable\u002FSearchable Names**: Avoid `genymdhms`.\n- **Class Names**: Use nouns (`Customer`, `WikiPage`). Avoid `Manager`, `Data`.\n- **Method Names**: Use verbs (`postPayment`, `deletePage`).\n\n## 2. Functions\n- **Small!**: Functions should be shorter than you think.\n- **Do One Thing**: A function should do only one thing, and do it well.\n- **One Level of Abstraction**: Don't mix high-level business logic with low-level details (like regex).\n- **Descriptive Names**: `isPasswordValid` is better than `check`.\n- **Arguments**: 0 is ideal, 1-2 is okay, 3+ requires a very strong justification.\n- **No Side Effects**: Functions shouldn't secretly change global state.\n\n## 3. Comments\n- **Don't Comment Bad Code—Rewrite It**: Most comments are a sign of failure to express ourselves in code.\n- **Explain Yourself in Code**: \n  ```python\n  # Check if employee is eligible for full benefits\n  if employee.flags & HOURLY and employee.age > 65:\n  ```\n  vs\n  ```python\n  if employee.isEligibleForFullBenefits():\n  ```\n- **Good Comments**: Legal, Informative (regex intent), Clarification (external libraries), TODOs.\n- **Bad Comments**: Mumbling, Redundant, Misleading, Mandated, Noise, Position Markers.\n\n## 4. Formatting\n- **The Newspaper Metaphor**: High-level concepts at the top, details at the bottom.\n- **Vertical Density**: Related lines should be close to each other.\n- **Distance**: Variables should be declared near their usage.\n- **Indentation**: Essential for structural readability.\n\n## 5. Objects and Data Structures\n- **Data Abstraction**: Hide the implementation behind interfaces.\n- **The Law of Demeter**: A module should not know about the innards of the objects it manipulates. Avoid `a.getB().getC().doSomething()`.\n- **Data Transfer Objects (DTO)**: Classes with public variables and no functions.\n\n## 6. Error Handling\n- **Use Exceptions instead of Return Codes**: Keeps logic clean.\n- **Write Try-Catch-Finally First**: Defines the scope of the operation.\n- **Don't Return Null**: It forces the caller to check for null every time.\n- **Don't Pass Null**: Leads to `NullPointerException`.\n\n## 7. Unit Tests\n- **The Three Laws of TDD**:\n  1. Don't write production code until you have a failing unit test.\n  2. Don't write more of a unit test than is sufficient to fail.\n  3. Don't write more production code than is sufficient to pass the failing test.\n- **F.I.R.S.T. Principles**: Fast, Independent, Repeatable, Self-Validating, Timely.\n\n## 8. Classes\n- **Small!**: Classes should have a single responsibility (SRP).\n- **The Stepdown Rule**: We want the code to read like a top-down narrative.\n\n## 9. Smells and Heuristics\n- **Rigidity**: Hard to change.\n- **Fragility**: Breaks in many places.\n- **Immobility**: Hard to reuse.\n- **Viscosity**: Hard to do the right thing.\n- **Needless Complexity\u002FRepetition**.\n\n## 🛠️ Implementation Checklist\n- [ ] Is this function smaller than 20 lines?\n- [ ] Does this function do exactly one thing?\n- [ ] Are all names searchable and intention-revealing?\n- [ ] Have I avoided comments by making the code clearer?\n- [ ] Am I passing too many arguments?\n- [ ] Is there a failing test for this change?\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,68,209,"2026-05-16 13:11:09",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"其他","other","mdi-page-next-outline","其他类型Skill",5,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"职场发展","career","mdi-briefcase-outline","面试准备、简历优化、职业规划",4,575,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"900205ce-37dc-46a0-bcb3-bf87d6163b77","1.0.0","clean-code.zip",2427,"uploads\u002Fskills\u002F1e9bc81d-54d7-4a3b-9790-8a2558ea0772\u002Fclean-code.zip","7e81171d55431b9bfb8aeccf801c1513689a960f06448a8379d315b72634e119","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":4669}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]