{
  "schemaVersion": "1.0",
  "item": {
    "slug": "clean-code-review",
    "name": "Clean Code",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/wpank/clean-code-review",
    "canonicalUrl": "https://clawhub.ai/wpank/clean-code-review",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/clean-code-review",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=clean-code-review",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "README.md",
      "SKILL.md",
      "templates/platforms/claude-knowledge.md",
      "templates/platforms/copilot-instructions.md",
      "templates/platforms/cursorrules.md",
      "references/code-smells.md"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T16:55:25.780Z",
      "expiresAt": "2026-05-07T16:55:25.780Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
        "contentDisposition": "attachment; filename=\"network-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/clean-code-review"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/clean-code-review",
    "agentPageUrl": "https://openagent3.xyz/skills/clean-code-review/agent",
    "manifestUrl": "https://openagent3.xyz/skills/clean-code-review/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/clean-code-review/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "Clean Code",
        "body": "Be concise, direct, and solution-focused. Clean code reads like well-written prose — every name reveals intent, every function does one thing, and every abstraction earns its place."
      },
      {
        "title": "OpenClaw / Moltbot / Clawbot",
        "body": "npx clawhub@latest install clean-code"
      },
      {
        "title": "Core Principles",
        "body": "PrincipleRulePractical TestSRPSingle Responsibility — each function/class does ONE thing\"Can I describe what this does without using 'and'?\"DRYDon't Repeat Yourself — extract duplicates, reuse\"Have I written this logic before?\"KISSKeep It Simple — simplest solution that works\"Is there a simpler way to achieve this?\"YAGNIYou Aren't Gonna Need It — don't build unused features\"Does anyone need this right now?\"Boy ScoutLeave code cleaner than you found it\"Is this file better after my change?\""
      },
      {
        "title": "Naming Rules",
        "body": "Names are the most important documentation. A good name eliminates the need for a comment.\n\nElementConventionBadGoodVariablesReveal intentn, d, tmpuserCount, elapsed, activeUsersFunctionsVerb + nounuser(), calc()getUserById(), calculateTotal()BooleansQuestion formactive, flagisActive, hasPermission, canEditConstantsSCREAMING_SNAKEmax, timeoutMAX_RETRY_COUNT, REQUEST_TIMEOUT_MSClassesNoun, singularManager, DataUserRepository, OrderServiceEnumsPascalCase values'pending' stringStatus.Pending\n\nRule: If you need a comment to explain a name, rename it."
      },
      {
        "title": "Naming Anti-Patterns",
        "body": "Anti-PatternProblemFixCryptic abbreviations (usrMgr, cfg)Unreadable in 6 monthsSpell it out — IDE autocomplete makes long names freeGeneric names (data, info, item, handler)Says nothing about purposeUse domain-specific names that reveal intentMisleading names (getUserList returns one user)Actively deceives readersMatch name to behavior, or change the behaviorHungarian notation (strName, nCount, IUser)Redundant with type systemLet TypeScript/IDE show types; names describe purpose"
      },
      {
        "title": "Function Rules",
        "body": "RuleGuidelineWhySmallMax 20 lines, ideally 5-10Fits in your headOne ThingDoes one thing, does it wellTestable and nameableOne LevelOne level of abstraction per functionReadable top to bottomFew ArgsMax 3 arguments, prefer 0-2Easy to call correctlyNo Side EffectsDon't mutate inputs unexpectedlyPredictable behavior"
      },
      {
        "title": "Guard Clauses",
        "body": "Flatten nested conditionals with early returns. Never nest deeper than 2 levels.\n\n// BAD — 5 levels deep\nfunction processOrder(order: Order) {\n  if (order) {\n    if (order.items.length > 0) {\n      if (order.customer) {\n        if (order.customer.isVerified) {\n          return submitOrder(order);\n        }\n      }\n    }\n  }\n  throw new Error('Invalid order');\n}\n\n// GOOD — guard clauses flatten the structure\nfunction processOrder(order: Order) {\n  if (!order) throw new Error('No order');\n  if (!order.items.length) throw new Error('No items');\n  if (!order.customer) throw new Error('No customer');\n  if (!order.customer.isVerified) throw new Error('Customer not verified');\n\n  return submitOrder(order);\n}"
      },
      {
        "title": "Parameter Objects",
        "body": "When a function needs more than 3 arguments, use an options object.\n\n// BAD — too many parameters, order matters\ncreateUser('John', 'Doe', 'john@example.com', 'secret', 'admin', 'Engineering');\n\n// GOOD — self-documenting options object\ncreateUser({\n  firstName: 'John',\n  lastName: 'Doe',\n  email: 'john@example.com',\n  password: 'secret',\n  role: 'admin',\n  department: 'Engineering',\n});"
      },
      {
        "title": "Code Structure Patterns",
        "body": "PatternWhen to ApplyBenefitGuard ClausesEdge cases at function startFlat, readable flowFlat > NestedAny nesting beyond 2 levelsReduced cognitive loadCompositionComplex operationsSmall, testable piecesColocationRelated code across filesEasier to find and changeExtract FunctionComments separating \"sections\"Self-documenting code"
      },
      {
        "title": "Composition Over God Functions",
        "body": "// BAD — god function doing everything\nasync function processOrder(order: Order) {\n  // Validate... (15 lines)\n  // Calculate totals... (15 lines)\n  // Process payment... (10 lines)\n  // Send notifications... (10 lines)\n  // Update inventory... (10 lines)\n  return { success: true };\n}\n\n// GOOD — composed of small, focused functions\nasync function processOrder(order: Order) {\n  validateOrder(order);\n  const totals = calculateOrderTotals(order);\n  const payment = await processPayment(order.customer, totals);\n  await sendOrderConfirmation(order, payment);\n  await updateInventory(order.items);\n  return { success: true, orderId: payment.orderId };\n}"
      },
      {
        "title": "Return Type Consistency",
        "body": "Functions should return consistent types. Use discriminated unions for multiple outcomes.\n\n// BAD — returns different types\nfunction getUser(id: string) {\n  const user = database.find(id);\n  if (!user) return false;     // boolean\n  if (user.isDeleted) return null; // null\n  return user;                 // User\n}\n\n// GOOD — discriminated union\ntype GetUserResult =\n  | { status: 'found'; user: User }\n  | { status: 'not_found' }\n  | { status: 'deleted' };\n\nfunction getUser(id: string): GetUserResult {\n  const user = database.find(id);\n  if (!user) return { status: 'not_found' };\n  if (user.isDeleted) return { status: 'deleted' };\n  return { status: 'found', user };\n}"
      },
      {
        "title": "Anti-Patterns",
        "body": "Anti-PatternProblemFixComment every lineNoise obscures signalDelete obvious comments; comment why, not whatHelper for one-linerUnnecessary indirectionInline the codeFactory for 2 objectsOver-engineeringDirect instantiationutils.ts with 1 functionJunk drawer filePut code where it's usedDeep nestingUnreadable flowGuard clauses and early returnsMagic numbersUnclear intentNamed constantsGod functionsUntestable, unreadableSplit by responsibilityCommented-out codeDead code confusionDelete it; git remembersTODO sprawlNever gets doneTrack in issue tracker, not codePremature abstractionWrong abstraction is worse than noneWait for 3+ duplicates before abstractingCopy-paste programmingDuplicated bugsExtract shared logicException-driven control flowSlow and confusingUse explicit conditionalsStringly-typed codeTypos and missed casesUse enums or union typesCallback hellPyramid of doomUse async/await"
      },
      {
        "title": "Pre-Edit Safety Check",
        "body": "Before changing any file, answer these questions to avoid cascading breakage:\n\nQuestionWhyWhat imports this file?Dependents might break on interface changesWhat does this file import?You might need to update the contractWhat tests cover this?Tests might fail — update them alongside codeIs this a shared component?Multiple consumers means wider blast radius\n\nFile to edit: UserService.ts\n├── Who imports this? → UserController.ts, AuthController.ts\n├── Do they need changes too? → Check function signatures\n└── What tests cover this? → UserService.test.ts\n\nRule: Edit the file + all dependent files in the SAME task. Never leave broken imports or missing updates."
      },
      {
        "title": "Self-Check Before Completing",
        "body": "Before marking any task complete, verify:\n\nCheckQuestionGoal met?Did I do exactly what was asked?Files edited?Did I modify all necessary files, including dependents?Code works?Did I verify the change compiles and runs?No errors?Do lint and type checks pass?Nothing forgotten?Any edge cases or dependent files missed?"
      },
      {
        "title": "NEVER Do",
        "body": "NEVER add comments that restate the code — if the code needs a comment to explain what it does, rename things until it doesn't\nNEVER create abstractions for fewer than 3 use cases — premature abstraction is worse than duplication\nNEVER leave commented-out code in the codebase — delete it; version control exists for history\nNEVER write functions longer than 20 lines — extract sub-functions until each does one thing\nNEVER nest deeper than 2 levels — use guard clauses, early returns, or extract functions\nNEVER use magic numbers or strings — define named constants with clear semantics\nNEVER edit a file without checking what depends on it — broken imports and missing updates are the most common source of bugs in multi-file changes\nNEVER leave a task with failing lint or type checks — fix all errors before marking complete"
      },
      {
        "title": "References",
        "body": "Detailed guides for specific clean code topics:\n\nReferenceDescriptionAnti-Patterns21 common mistakes with bad/good code examples across naming, functions, structure, and commentsCode SmellsClassic code smells catalog with detection patterns — Bloaters, OO Abusers, Change Preventers, Dispensables, CouplersRefactoring CatalogEssential refactoring patterns with before/after examples and step-by-step mechanics"
      }
    ],
    "body": "Clean Code\n\nBe concise, direct, and solution-focused. Clean code reads like well-written prose — every name reveals intent, every function does one thing, and every abstraction earns its place.\n\nInstallation\nOpenClaw / Moltbot / Clawbot\nnpx clawhub@latest install clean-code\n\nCore Principles\nPrinciple\tRule\tPractical Test\nSRP\tSingle Responsibility — each function/class does ONE thing\t\"Can I describe what this does without using 'and'?\"\nDRY\tDon't Repeat Yourself — extract duplicates, reuse\t\"Have I written this logic before?\"\nKISS\tKeep It Simple — simplest solution that works\t\"Is there a simpler way to achieve this?\"\nYAGNI\tYou Aren't Gonna Need It — don't build unused features\t\"Does anyone need this right now?\"\nBoy Scout\tLeave code cleaner than you found it\t\"Is this file better after my change?\"\nNaming Rules\n\nNames are the most important documentation. A good name eliminates the need for a comment.\n\nElement\tConvention\tBad\tGood\nVariables\tReveal intent\tn, d, tmp\tuserCount, elapsed, activeUsers\nFunctions\tVerb + noun\tuser(), calc()\tgetUserById(), calculateTotal()\nBooleans\tQuestion form\tactive, flag\tisActive, hasPermission, canEdit\nConstants\tSCREAMING_SNAKE\tmax, timeout\tMAX_RETRY_COUNT, REQUEST_TIMEOUT_MS\nClasses\tNoun, singular\tManager, Data\tUserRepository, OrderService\nEnums\tPascalCase values\t'pending' string\tStatus.Pending\n\nRule: If you need a comment to explain a name, rename it.\n\nNaming Anti-Patterns\nAnti-Pattern\tProblem\tFix\nCryptic abbreviations (usrMgr, cfg)\tUnreadable in 6 months\tSpell it out — IDE autocomplete makes long names free\nGeneric names (data, info, item, handler)\tSays nothing about purpose\tUse domain-specific names that reveal intent\nMisleading names (getUserList returns one user)\tActively deceives readers\tMatch name to behavior, or change the behavior\nHungarian notation (strName, nCount, IUser)\tRedundant with type system\tLet TypeScript/IDE show types; names describe purpose\nFunction Rules\nRule\tGuideline\tWhy\nSmall\tMax 20 lines, ideally 5-10\tFits in your head\nOne Thing\tDoes one thing, does it well\tTestable and nameable\nOne Level\tOne level of abstraction per function\tReadable top to bottom\nFew Args\tMax 3 arguments, prefer 0-2\tEasy to call correctly\nNo Side Effects\tDon't mutate inputs unexpectedly\tPredictable behavior\nGuard Clauses\n\nFlatten nested conditionals with early returns. Never nest deeper than 2 levels.\n\n// BAD — 5 levels deep\nfunction processOrder(order: Order) {\n  if (order) {\n    if (order.items.length > 0) {\n      if (order.customer) {\n        if (order.customer.isVerified) {\n          return submitOrder(order);\n        }\n      }\n    }\n  }\n  throw new Error('Invalid order');\n}\n\n// GOOD — guard clauses flatten the structure\nfunction processOrder(order: Order) {\n  if (!order) throw new Error('No order');\n  if (!order.items.length) throw new Error('No items');\n  if (!order.customer) throw new Error('No customer');\n  if (!order.customer.isVerified) throw new Error('Customer not verified');\n\n  return submitOrder(order);\n}\n\nParameter Objects\n\nWhen a function needs more than 3 arguments, use an options object.\n\n// BAD — too many parameters, order matters\ncreateUser('John', 'Doe', 'john@example.com', 'secret', 'admin', 'Engineering');\n\n// GOOD — self-documenting options object\ncreateUser({\n  firstName: 'John',\n  lastName: 'Doe',\n  email: 'john@example.com',\n  password: 'secret',\n  role: 'admin',\n  department: 'Engineering',\n});\n\nCode Structure Patterns\nPattern\tWhen to Apply\tBenefit\nGuard Clauses\tEdge cases at function start\tFlat, readable flow\nFlat > Nested\tAny nesting beyond 2 levels\tReduced cognitive load\nComposition\tComplex operations\tSmall, testable pieces\nColocation\tRelated code across files\tEasier to find and change\nExtract Function\tComments separating \"sections\"\tSelf-documenting code\nComposition Over God Functions\n// BAD — god function doing everything\nasync function processOrder(order: Order) {\n  // Validate... (15 lines)\n  // Calculate totals... (15 lines)\n  // Process payment... (10 lines)\n  // Send notifications... (10 lines)\n  // Update inventory... (10 lines)\n  return { success: true };\n}\n\n// GOOD — composed of small, focused functions\nasync function processOrder(order: Order) {\n  validateOrder(order);\n  const totals = calculateOrderTotals(order);\n  const payment = await processPayment(order.customer, totals);\n  await sendOrderConfirmation(order, payment);\n  await updateInventory(order.items);\n  return { success: true, orderId: payment.orderId };\n}\n\nReturn Type Consistency\n\nFunctions should return consistent types. Use discriminated unions for multiple outcomes.\n\n// BAD — returns different types\nfunction getUser(id: string) {\n  const user = database.find(id);\n  if (!user) return false;     // boolean\n  if (user.isDeleted) return null; // null\n  return user;                 // User\n}\n\n// GOOD — discriminated union\ntype GetUserResult =\n  | { status: 'found'; user: User }\n  | { status: 'not_found' }\n  | { status: 'deleted' };\n\nfunction getUser(id: string): GetUserResult {\n  const user = database.find(id);\n  if (!user) return { status: 'not_found' };\n  if (user.isDeleted) return { status: 'deleted' };\n  return { status: 'found', user };\n}\n\nAnti-Patterns\nAnti-Pattern\tProblem\tFix\nComment every line\tNoise obscures signal\tDelete obvious comments; comment why, not what\nHelper for one-liner\tUnnecessary indirection\tInline the code\nFactory for 2 objects\tOver-engineering\tDirect instantiation\nutils.ts with 1 function\tJunk drawer file\tPut code where it's used\nDeep nesting\tUnreadable flow\tGuard clauses and early returns\nMagic numbers\tUnclear intent\tNamed constants\nGod functions\tUntestable, unreadable\tSplit by responsibility\nCommented-out code\tDead code confusion\tDelete it; git remembers\nTODO sprawl\tNever gets done\tTrack in issue tracker, not code\nPremature abstraction\tWrong abstraction is worse than none\tWait for 3+ duplicates before abstracting\nCopy-paste programming\tDuplicated bugs\tExtract shared logic\nException-driven control flow\tSlow and confusing\tUse explicit conditionals\nStringly-typed code\tTypos and missed cases\tUse enums or union types\nCallback hell\tPyramid of doom\tUse async/await\nPre-Edit Safety Check\n\nBefore changing any file, answer these questions to avoid cascading breakage:\n\nQuestion\tWhy\nWhat imports this file?\tDependents might break on interface changes\nWhat does this file import?\tYou might need to update the contract\nWhat tests cover this?\tTests might fail — update them alongside code\nIs this a shared component?\tMultiple consumers means wider blast radius\nFile to edit: UserService.ts\n├── Who imports this? → UserController.ts, AuthController.ts\n├── Do they need changes too? → Check function signatures\n└── What tests cover this? → UserService.test.ts\n\n\nRule: Edit the file + all dependent files in the SAME task. Never leave broken imports or missing updates.\n\nSelf-Check Before Completing\n\nBefore marking any task complete, verify:\n\nCheck\tQuestion\nGoal met?\tDid I do exactly what was asked?\nFiles edited?\tDid I modify all necessary files, including dependents?\nCode works?\tDid I verify the change compiles and runs?\nNo errors?\tDo lint and type checks pass?\nNothing forgotten?\tAny edge cases or dependent files missed?\nNEVER Do\nNEVER add comments that restate the code — if the code needs a comment to explain what it does, rename things until it doesn't\nNEVER create abstractions for fewer than 3 use cases — premature abstraction is worse than duplication\nNEVER leave commented-out code in the codebase — delete it; version control exists for history\nNEVER write functions longer than 20 lines — extract sub-functions until each does one thing\nNEVER nest deeper than 2 levels — use guard clauses, early returns, or extract functions\nNEVER use magic numbers or strings — define named constants with clear semantics\nNEVER edit a file without checking what depends on it — broken imports and missing updates are the most common source of bugs in multi-file changes\nNEVER leave a task with failing lint or type checks — fix all errors before marking complete\nReferences\n\nDetailed guides for specific clean code topics:\n\nReference\tDescription\nAnti-Patterns\t21 common mistakes with bad/good code examples across naming, functions, structure, and comments\nCode Smells\tClassic code smells catalog with detection patterns — Bloaters, OO Abusers, Change Preventers, Dispensables, Couplers\nRefactoring Catalog\tEssential refactoring patterns with before/after examples and step-by-step mechanics"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/wpank/clean-code-review",
    "publisherUrl": "https://clawhub.ai/wpank/clean-code-review",
    "owner": "wpank",
    "version": "1.0.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/clean-code-review",
    "downloadUrl": "https://openagent3.xyz/downloads/clean-code-review",
    "agentUrl": "https://openagent3.xyz/skills/clean-code-review/agent",
    "manifestUrl": "https://openagent3.xyz/skills/clean-code-review/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/clean-code-review/agent.md"
  }
}