{"record":{"id":"db16cdc1e5bf94a4","repo":"sickn33/agentic-awesome-skills","slug":"price-and-quantity-must-be-non-negative","errorCode":null,"errorMessage":"Price and quantity must be non-negative","messagePattern":"Price and quantity must be non-negative","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"skills/kaizen/SKILL.md","lineNumber":80,"sourceCode":"    total += items[i].price * items[i].quantity;\n  }\n  return total;\n};\n\n// Iteration 2: Make it clear (refactor)\nconst calculateTotal = (items: Item[]): number => {\nreturn items.reduce((total, item) => {\nreturn total + (item.price \\* item.quantity);\n}, 0);\n};\n\n// Iteration 3: Make it robust (add validation)\nconst calculateTotal = (items: Item[]): number => {\nif (!items?.length) return 0;\n\nreturn items.reduce((total, item) => {\nif (item.price < 0 || item.quantity < 0) {\nthrow new Error('Price and quantity must be non-negative');\n}\nreturn total + (item.price \\* item.quantity);\n}, 0);\n};\n\n````\nEach step is complete, tested, and working\n</Good>\n\n<Bad>\n```typescript\n// Trying to do everything at once\nconst calculateTotal = (items: Item[]): number => {\n  // Validate, optimize, add features, handle edge cases all together\n  if (!items?.length) return 0;\n  const validItems = items.filter(item => {\n    if (item.price < 0) throw new Error('Negative price');\n    if (item.quantity < 0) throw new Error('Negative quantity');","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/sickn33/agentic-awesome-skills/blob/58d857988fcfac6986206bca2b2fe223aa437e4b/skills/kaizen/SKILL.md#L62-L98","documentation":"Error \"Price and quantity must be non-negative\" thrown in sickn33/agentic-awesome-skills.","triggerScenarios":"Thrown at skills/kaizen/SKILL.md:80 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"58d857988fcfac6986206bca2b2fe223aa437e4b","analyzedAt":"2026-08-26T11:55:59.350Z","schemaVersion":2},"datasetVersion":"2026-08-26T14:46:13.012Z"}