[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74XPKXQQXAWKASESJTNDMK4":3,"skill-same:01M74XPKXQQXAWKASESJTNDMK4":43},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":13,"repositoryHtmlUrl":26,"repositoryHomepageUrl":6,"ownerHtmlUrl":27,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":28,"install":29,"resources":42},"01M74XPKXQQXAWKASESJTNDMK4","swiftdata-predicate-optional-coalesce-contains-trap",null,"SwiftData #Predicate like `ids.contains($0.fromBinID ?? sentinelUUID)` compiles fine but throws NSInvalidArgumentException \"unimplemented SQL generation … (bad LHS)\" at fetch time against a real (even in-memory) ModelContext. Use when writing a #Predicate that filters an optional model column (nullable foreign-key \u002F relationship ID) against a caller-supplied Set or Array of candidate IDs.","abhijitbansal\u002Fclaude-skills","abhijitbansal","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F271802621?v=4","01M74XA5M33XYNJ2D2TJDS7W9E","01M74XA5MQ8GMWJW10ZJ4V0NVG",1,"MIT","https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fios-dev\u002Fskills\u002Fswiftdata-predicate-optional-coalesce-contains-trap\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: swiftdata-predicate-optional-coalesce-contains-trap\ndescription: \"SwiftData #Predicate like `ids.contains($0.fromBinID ?? sentinelUUID)` compiles fine but throws NSInvalidArgumentException \\\"unimplemented SQL generation … (bad LHS)\\\" at fetch time against a real (even in-memory) ModelContext. Use when writing a #Predicate that filters an optional model column (nullable foreign-key \u002F relationship ID) against a caller-supplied Set or Array of candidate IDs.\"\n---\n\n# SwiftData #Predicate: coalescing an optional column on the LHS of contains() throws at fetch time\n\n## Symptom\n\nA `#Predicate` such as `ids.contains($0.fromBinID ?? sentinelUUID)` — matching\nan optional model column against a candidate-ID list, the idiom developers\nreach for constantly for nullable foreign keys — compiles cleanly and passes\nany pure-logic unit test built around the predicate closure itself. It only\nfails when actually run against a real `ModelContext` (a live store or an\nin-memory one), throwing at fetch time:\n\n```\nNSInvalidArgumentException: unimplemented SQL generation … (bad LHS)\n```\n\nThis happens identically whether the RHS candidate list is a `Set` or an\n`Array`.\n\n## Root cause\n\nSwiftData's predicate-to-SQL translator cannot generate SQL when the\nleft-hand expression of `contains()` is a *computed* value — specifically an\noptional model column coalesced with `??`. `$0.fromBinID ?? sentinelUUID`\nturns the LHS into an expression the translator has no SQL form for, so it\nthrows rather than falling back to something correct. The predicate is legal\nSwift and legal `#Predicate` syntax; the failure is purely in SwiftData's SQL\ngeneration for this LHS shape, so nothing catches it before a real fetch runs.\n\n## Fix\n\nDon't coalesce the optional column. Instead widen the candidate list itself\nto the optional type — `[UUID?]` instead of `[UUID]` — so the predicate\nbecomes a bare `column IN (…)` comparison against an unmodified, optional\nLHS:\n\n```swift\n\u002F\u002F Throws NSInvalidArgumentException at fetch time (bad LHS):\nlet predicate = #Predicate\u003CItem> { ids.contains($0.fromBinID ?? sentinelUUID) }\n\n\u002F\u002F Works: widen the RHS list to [UUID?] instead, leave the column bare.\nlet optionalIDs: [UUID?] = ids.map { $0 }\nlet predicate = #Predicate\u003CItem> { optionalIDs.contains($0.fromBinID) }\n```\n\n`nil` simply never matches, because `nil` is never a member of `optionalIDs`\n— the same filtering semantics as the coalesced version, achieved without a\ncomputed LHS.\n\n## Evidence\n\nMined from Cubby iOS session logs (0015-2026-07-06-v0.2.2-fix-wave);\nadversarially verified. Checkpoint '2026-07-07 20:20':\n\n> \"SwiftData #Predicate trap (worth remembering): coalescing an optional\n> column on the LHS of contains() (`ids.contains($0.fromBinID ?? sentinel)`)\n> throws NSInvalidArgumentException: unimplemented SQL generation … (bad LHS)\n> at FETCH time — with either a Set or Array. Fix: make the list [UUID?] so\n> the column sits bare (column IN (…)); nil never matches because it's never\n> in the list.\"\n\nThe failure was caught by a TDD RED against a real in-memory `ModelContext`;\nthe log explicitly notes \"a pure-helper test would have missed it\" — the\npredicate closure alone, exercised without a `ModelContext` fetch, never\ntouches SwiftData's SQL generator.\n\n## Related skills\n\n- `swiftdata-inmemory-test-harness` — the in-memory `ModelContext` harness\n  that caught this trap; a pure-logic unit test around the predicate closure\n  would not have.\n- `swiftdata-cloudkit-model-rules` — other SwiftData failures that compile\n  clean and only surface at runtime against a real container\u002Fcontext.\n","# SwiftData #Predicate: coalescing an optional column on the LHS of contains() throws at fetch time\n\n## Symptom\n\nA `#Predicate` such as `ids.contains($0.fromBinID ?? sentinelUUID)` — matching\nan optional model column against a candidate-ID list, the idiom developers\nreach for constantly for nullable foreign keys — compiles cleanly and passes\nany pure-logic unit test built around the predicate closure itself. It only\nfails when actually run against a real `ModelContext` (a live store or an\nin-memory one), throwing at fetch time:\n\n```\nNSInvalidArgumentException: unimplemented SQL generation … (bad LHS)\n```\n\nThis happens identically whether the RHS candidate list is a `Set` or an\n`Array`.\n\n## Root cause\n\nSwiftData's predicate-to-SQL translator cannot generate SQL when the\nleft-hand expression of `contains()` is a *computed* value — specifically an\noptional model column coalesced with `??`. `$0.fromBinID ?? sentinelUUID`\nturns the LHS into an expression the translator has no SQL form for, so it\nthrows rather than falling back to something correct. The predicate is legal\nSwift and legal `#Predicate` syntax; the failure is purely in SwiftData's SQL\ngeneration for this LHS shape, so nothing catches it before a real fetch runs.\n\n## Fix\n\nDon't coalesce the optional column. Instead widen the candidate list itself\nto the optional type — `[UUID?]` instead of `[UUID]` — so the predicate\nbecomes a bare `column IN (…)` comparison against an unmodified, optional\nLHS:\n\n```swift\n\u002F\u002F Throws NSInvalidArgumentException at fetch time (bad LHS):\nlet predicate = #Predicate\u003CItem> { ids.contains($0.fromBinID ?? sentinelUUID) }\n\n\u002F\u002F Works: widen the RHS list to [UUID?] instead, leave the column bare.\nlet optionalIDs: [UUID?] = ids.map { $0 }\nlet predicate = #Predicate\u003CItem> { optionalIDs.contains($0.fromBinID) }\n```\n\n`nil` simply never matches, because `nil` is never a member of `optionalIDs`\n— the same filtering semantics as the coalesced version, achieved without a\ncomputed LHS.\n\n## Evidence\n\nMined from Cubby iOS session logs (0015-2026-07-06-v0.2.2-fix-wave);\nadversarially verified. Checkpoint '2026-07-07 20:20':\n\n> \"SwiftData #Predicate trap (worth remembering): coalescing an optional\n> column on the LHS of contains() (`ids.contains($0.fromBinID ?? sentinel)`)\n> throws NSInvalidArgumentException: unimplemented SQL generation … (bad LHS)\n> at FETCH time — with either a Set or Array. Fix: make the list [UUID?] so\n> the column sits bare (column IN (…)); nil never matches because it's never\n> in the list.\"\n\nThe failure was caught by a TDD RED against a real in-memory `ModelContext`;\nthe log explicitly notes \"a pure-helper test would have missed it\" — the\npredicate closure alone, exercised without a `ModelContext` fetch, never\ntouches SwiftData's SQL generator.\n\n## Related skills\n\n- `swiftdata-inmemory-test-harness` — the in-memory `ModelContext` harness\n  that caught this trap; a pure-logic unit test around the predicate closure\n  would not have.\n- `swiftdata-cloudkit-model-rules` — other SwiftData failures that compile\n  clean and only surface at runtime against a real container\u002Fcontext.\n",{"name":5,"description":7},"main","153711dd9432743d97f0b33b080ada5798ea623c","plugins\u002Fios-dev\u002Fskills\u002Fswiftdata-predicate-optional-coalesce-contains-trap","https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills","https:\u002F\u002Fgithub.com\u002Fabhijitbansal","2026-11-07 12:59:51",{"source":8,"skillName":5,"commands":30,"prompt":40,"zipAvailable":41},[31,34,37],{"tool":32,"command":33},"npx","npx skills add abhijitbansal\u002Fclaude-skills --skill swiftdata-predicate-optional-coalesce-contains-trap",{"tool":35,"command":36},"bunx","bunx skills add abhijitbansal\u002Fclaude-skills --skill swiftdata-predicate-optional-coalesce-contains-trap",{"tool":38,"command":39},"pnpm","pnpm dlx skills add abhijitbansal\u002Fclaude-skills --skill swiftdata-predicate-optional-coalesce-contains-trap","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fios-dev\u002Fskills\u002Fswiftdata-predicate-optional-coalesce-contains-trap\u002FSKILL.md",true,[],[44,51,58,65,72,79],{"skillNo":45,"name":46,"nameZh":6,"description":47,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":48,"categories":49,"keywords":50,"publishedAt":18},"01M74XTV2V7GZM8FDBXQZZ74VX","second-wind","Orchestrate long unattended Claude Code runs across multiple repos with the wind CLI. Use when the user wants to run Claude Code overnight, resume sessions after the 5-hour usage limit, run Claude in many repos at once via tmux, or says \"set up second wind\", \"wind up\", \"overnight run\", \"resume after limit\", \"usage limit orchestrator\".","https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fsecond-wind\u002Fskills\u002Fsecond-wind\u002FSKILL.md",[],[],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":18},"01M74XTPGN1HDQSKGCZZX0AZPC","structured-output-adaptive-thinking-token-bloat","A Claude API call using output_config.format (json_schema structured outputs) with thinking:{type:\"adaptive\"} burns most of its output budget on thinking (observed ~21k of ~24k tokens) without improving JSON quality, making the run up to ~5x more expensive than the same call with thinking omitted — use when calling the Messages API with a json_schema output format for extraction, ranking, classification, or summarization tasks, or when a schema-constrained call's usage.output_tokens is far larger than the returned JSON.","https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprompt-craft\u002Fskills\u002Fstructured-output-adaptive-thinking-token-bloat\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":18},"01M74XTKTRHAMC2JFHQ1P1E6GR","review","Apply a code-review lens to a diff, branch, or file — find correctness bugs, security issues, and quality problems, ranked by severity, with a concrete fix for each. Use when the user says \"review this\", \"review my diff\", \"check this PR\", \"look this over before I commit\", or \"is this safe\". Skip when the user wants the code written, not reviewed.","https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprompt-craft\u002Fskills\u002Freview\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":18},"01M74XTGGCW7GWDDHPEMJQC7Y1","refresh","Rebuild the prompt-craft command registry and usage profile, and print a summary of installed commands and your personalized recommendations. Use when you install or update plugins and want the advisor to pick them up immediately, or say \"refresh prompt-craft\", \"rebuild the command registry\".","https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprompt-craft\u002Fskills\u002Frefresh\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":18},"01M74XTCNGNR4G19P3Z95KTHQJ","refactor","Apply a refactoring lens — restructure code without changing behavior, guarded by tests that pass before and after. Use when the user says \"refactor\", \"clean this up\", \"extract this\", \"simplify this\", \"reduce duplication\", or \"make this readable\" on existing working code. Skip when the change is meant to alter behavior (that's a feature or a fix).","https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprompt-craft\u002Fskills\u002Frefactor\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":18},"01M74XT9FKXN3N106G7Q3X56XR","plan","Decompose a non-trivial task into an explicit, tracked plan with goals and per-step acceptance criteria before writing code. Use when the user says \"plan this\", \"break this down\", \"what's the plan\", or asks for a multi-step feature\u002Frefactor that touches more than one file. Pairs with plan mode. Skip for single-edit changes that need no decomposition.","https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprompt-craft\u002Fskills\u002Fplan\u002FSKILL.md",[],[]]