[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7F44JYSKDVW85BTRFEGJZMX":3,"skill-same:01M7F44JYSKDVW85BTRFEGJZMX":45},{"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":28,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7F44JYSKDVW85BTRFEGJZMX","local-first-sync-design",null,"Design the synchronization and conflict-resolution model for systems with authoritative local state, expressing merge semantics as user-visible behavior before any sync machinery is chosen.","cwik-tech\u002Foctopus","cwik-tech","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F54542292?v=4","01M7F42E123GEHVK6RWC5MSWJ9","Tomasz Cwik","01M7F42E1PD4P54MTG8PG32VCV",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fcwik-tech\u002Foctopus\u002Fblob\u002Fmain\u002Fagents\u002Farchitect-data-persistence\u002Fskills\u002Flocal-first-sync-design\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: local-first-sync-design\ndescription: Design the synchronization and conflict-resolution model for systems with authoritative local state, expressing merge semantics as user-visible behavior before any sync machinery is chosen.\n---\n\n# Local-First Sync Design\n\n## Purpose\n\nDecide what happens when the same data exists in two places and both change. This skill forces conflict resolution to be settled as a product and data-modeling decision before it is delegated to a sync library, because the library cannot invent semantics the data model does not support.\n\n## When to use\n\nUse this when a desktop or mobile client holds authoritative local state, when the system must function offline, when the same record can be edited from more than one place, or when reviewing an existing sync design for failure modes.\n\n## Core principle\n\n**Sync is a data model problem, not a library problem.** Last-write-wins is not a default — it is a design decision with user-visible consequences. Choose merge semantics first, then select machinery that can express them.\n\n## Procedure\n\n### Step 1 — Establish the authority model\n\nFor each data domain in scope, name where truth lives:\n\n- **Server-authoritative:** local is a cache; conflicts resolve toward the server. Simplest, but offline edits can be discarded.\n- **Client-authoritative:** local is truth for this user's own data; the server aggregates. Good for personal-workspace data.\n- **Co-authoritative:** both can write meaningfully and neither dominates. The hardest case, and the one that requires real merge semantics.\n\nDifferent domains within one application commonly warrant different models. Do not force a single answer across all data.\n\n### Step 2 — Enumerate concurrent-edit scenarios\n\nList the realistic ways the same data changes in two places. For each, write the scenario in user terms, not in database terms.\n\n| Scenario | Data touched | Realistic frequency | Desired user-visible outcome |\n|---|---|---|---|\n| Edits a note on laptop while phone is offline with an older copy | note body | common | Both edits survive; nothing silently lost |\n| Two users reorder the same list | list ordering | occasional | Deterministic order, no duplication |\n| Deletes an item locally that was edited remotely | item | rare | Prompt, or edit wins over delete |\n\nThe rightmost column is the actual requirement. Everything downstream serves it.\n\n### Step 3 — Choose merge semantics per field, not per record\n\nWhole-record last-write-wins loses data whenever two people edit different fields of the same record. Decompose:\n\n- **Last-write-wins per field:** adequate for independent scalar fields where a later value genuinely supersedes an earlier one.\n- **Additive\u002Fset semantics:** for collections where union is the correct answer — tags, memberships, attachments.\n- **Counter semantics:** for values that accumulate, where increments from both sides must both apply.\n- **Ordered-list semantics:** for sequences where naive merge duplicates or drops entries; requires stable per-item identity and an ordering scheme that tolerates concurrent insertion.\n- **Text-merge semantics:** for prose fields where character-level convergence is required. This is the point where a CRDT or OT library becomes genuinely warranted — and the point at which you should confirm the requirement is real, since it dominates the complexity of the whole design.\n- **Explicit user resolution:** for cases where no automatic merge is defensible. Requires designing the conflict UI, which is product work, not infrastructure work.\n\nModel the data to support the chosen semantics. A field that needs additive merge must not be stored as a replaced blob.\n\n### Step 4 — Define identity and ordering primitives\n\nSync correctness rests on two primitives:\n\n- **Stable identity:** every syncable entity needs an identifier generated client-side that will not collide across devices, assigned before the entity ever reaches a server. Server-assigned sequential identity is incompatible with offline creation.\n- **Causality tracking:** something that lets the system tell \"newer\" from \"concurrent.\" Wall-clock timestamps cannot do this — clock skew across devices makes concurrent edits look ordered. Use logical clocks, version vectors, or per-entity revision chains as the design requires.\n\nIf the design cannot distinguish a concurrent edit from a sequential one, its conflict resolution is guessing.\n\n### Step 5 — Design the failure and reconciliation behavior\n\nSpecify:\n\n- **Divergence tolerance:** how long may a client stay offline before its state is unreconcilable? What happens at that boundary?\n- **Partial sync failure:** if half the changes propagate and the connection drops, is the resulting state coherent? Is sync resumable, or does it restart?\n- **Schema skew:** a client running an older schema syncs against a newer server. Is this rejected, tolerated, or migrated in flight? This is where sync design and schema evolution meet — coordinate with the evolution strategy.\n- **Deletion semantics:** are deletions tombstoned, and for how long? A client offline longer than the tombstone retention will resurrect deleted data.\n- **Reconciliation path:** when state has provably diverged beyond automatic repair, what is the manual recovery? Silent permanent drift is the worst outcome.\n\n### Step 6 — Only now select machinery\n\nWith semantics fixed, evaluate sync approaches against them. Check whether each candidate can express the per-field semantics from Step 3, supports the identity and causality primitives from Step 4, and handles the failure cases from Step 5. Reject any option that requires weakening a semantic decision already made on product grounds.\n\n## Output\n\nProduce:\n\n1. The authority model per data domain.\n2. The concurrent-edit scenario table with desired user-visible outcomes.\n3. Merge semantics per field or field group.\n4. Identity and causality primitives required.\n5. Failure, skew, deletion, and reconciliation behavior.\n6. The sync approach that satisfies all of the above, and what it costs.\n\n## Red lines\n\n- Never accept \"last-write-wins\" without naming which writes get discarded and whether users will notice.\n- Never use wall-clock timestamps as the causality mechanism across devices.\n- Never rely on server-assigned sequential identity for entities that can be created offline.\n- Never select the sync library before the merge semantics are decided.\n- Never leave the permanent-divergence case unspecified.\n","# Local-First Sync Design\n\n## Purpose\n\nDecide what happens when the same data exists in two places and both change. This skill forces conflict resolution to be settled as a product and data-modeling decision before it is delegated to a sync library, because the library cannot invent semantics the data model does not support.\n\n## When to use\n\nUse this when a desktop or mobile client holds authoritative local state, when the system must function offline, when the same record can be edited from more than one place, or when reviewing an existing sync design for failure modes.\n\n## Core principle\n\n**Sync is a data model problem, not a library problem.** Last-write-wins is not a default — it is a design decision with user-visible consequences. Choose merge semantics first, then select machinery that can express them.\n\n## Procedure\n\n### Step 1 — Establish the authority model\n\nFor each data domain in scope, name where truth lives:\n\n- **Server-authoritative:** local is a cache; conflicts resolve toward the server. Simplest, but offline edits can be discarded.\n- **Client-authoritative:** local is truth for this user's own data; the server aggregates. Good for personal-workspace data.\n- **Co-authoritative:** both can write meaningfully and neither dominates. The hardest case, and the one that requires real merge semantics.\n\nDifferent domains within one application commonly warrant different models. Do not force a single answer across all data.\n\n### Step 2 — Enumerate concurrent-edit scenarios\n\nList the realistic ways the same data changes in two places. For each, write the scenario in user terms, not in database terms.\n\n| Scenario | Data touched | Realistic frequency | Desired user-visible outcome |\n|---|---|---|---|\n| Edits a note on laptop while phone is offline with an older copy | note body | common | Both edits survive; nothing silently lost |\n| Two users reorder the same list | list ordering | occasional | Deterministic order, no duplication |\n| Deletes an item locally that was edited remotely | item | rare | Prompt, or edit wins over delete |\n\nThe rightmost column is the actual requirement. Everything downstream serves it.\n\n### Step 3 — Choose merge semantics per field, not per record\n\nWhole-record last-write-wins loses data whenever two people edit different fields of the same record. Decompose:\n\n- **Last-write-wins per field:** adequate for independent scalar fields where a later value genuinely supersedes an earlier one.\n- **Additive\u002Fset semantics:** for collections where union is the correct answer — tags, memberships, attachments.\n- **Counter semantics:** for values that accumulate, where increments from both sides must both apply.\n- **Ordered-list semantics:** for sequences where naive merge duplicates or drops entries; requires stable per-item identity and an ordering scheme that tolerates concurrent insertion.\n- **Text-merge semantics:** for prose fields where character-level convergence is required. This is the point where a CRDT or OT library becomes genuinely warranted — and the point at which you should confirm the requirement is real, since it dominates the complexity of the whole design.\n- **Explicit user resolution:** for cases where no automatic merge is defensible. Requires designing the conflict UI, which is product work, not infrastructure work.\n\nModel the data to support the chosen semantics. A field that needs additive merge must not be stored as a replaced blob.\n\n### Step 4 — Define identity and ordering primitives\n\nSync correctness rests on two primitives:\n\n- **Stable identity:** every syncable entity needs an identifier generated client-side that will not collide across devices, assigned before the entity ever reaches a server. Server-assigned sequential identity is incompatible with offline creation.\n- **Causality tracking:** something that lets the system tell \"newer\" from \"concurrent.\" Wall-clock timestamps cannot do this — clock skew across devices makes concurrent edits look ordered. Use logical clocks, version vectors, or per-entity revision chains as the design requires.\n\nIf the design cannot distinguish a concurrent edit from a sequential one, its conflict resolution is guessing.\n\n### Step 5 — Design the failure and reconciliation behavior\n\nSpecify:\n\n- **Divergence tolerance:** how long may a client stay offline before its state is unreconcilable? What happens at that boundary?\n- **Partial sync failure:** if half the changes propagate and the connection drops, is the resulting state coherent? Is sync resumable, or does it restart?\n- **Schema skew:** a client running an older schema syncs against a newer server. Is this rejected, tolerated, or migrated in flight? This is where sync design and schema evolution meet — coordinate with the evolution strategy.\n- **Deletion semantics:** are deletions tombstoned, and for how long? A client offline longer than the tombstone retention will resurrect deleted data.\n- **Reconciliation path:** when state has provably diverged beyond automatic repair, what is the manual recovery? Silent permanent drift is the worst outcome.\n\n### Step 6 — Only now select machinery\n\nWith semantics fixed, evaluate sync approaches against them. Check whether each candidate can express the per-field semantics from Step 3, supports the identity and causality primitives from Step 4, and handles the failure cases from Step 5. Reject any option that requires weakening a semantic decision already made on product grounds.\n\n## Output\n\nProduce:\n\n1. The authority model per data domain.\n2. The concurrent-edit scenario table with desired user-visible outcomes.\n3. Merge semantics per field or field group.\n4. Identity and causality primitives required.\n5. Failure, skew, deletion, and reconciliation behavior.\n6. The sync approach that satisfies all of the above, and what it costs.\n\n## Red lines\n\n- Never accept \"last-write-wins\" without naming which writes get discarded and whether users will notice.\n- Never use wall-clock timestamps as the causality mechanism across devices.\n- Never rely on server-assigned sequential identity for entities that can be created offline.\n- Never select the sync library before the merge semantics are decided.\n- Never leave the permanent-divergence case unspecified.\n",{"name":5,"description":7},"main","f0f0efe1d4c64b51a51f44427ad147750d29154e","agents\u002Farchitect-data-persistence\u002Fskills\u002Flocal-first-sync-design","https:\u002F\u002Fgithub.com\u002Fcwik-tech\u002Foctopus","www.cuteoctopus.site","https:\u002F\u002Fgithub.com\u002Fcwik-tech","2026-10-27 06:12:19",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add cwik-tech\u002Foctopus --skill local-first-sync-design",{"tool":37,"command":38},"bunx","bunx skills add cwik-tech\u002Foctopus --skill local-first-sync-design",{"tool":40,"command":41},"pnpm","pnpm dlx skills add cwik-tech\u002Foctopus --skill local-first-sync-design","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fcwik-tech\u002Foctopus\u002Fblob\u002Fmain\u002Fagents\u002Farchitect-data-persistence\u002Fskills\u002Flocal-first-sync-design\u002FSKILL.md",true,[],[46,53,60,67,74,81],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":19},"01M7F5MQVQ3CHGM77Q51M4B1AC","twenty-year-land-plan","Apply the Bren discipline of evaluating every land and development decision on a twenty-year horizon, with a comprehensive plan for how the land, the community, and the surrounding public infrastructure evolve together. Deals optimized for a five-year exit are structurally different from deals that compound across generations; insist on knowing which kind you are making. Use when evaluating land, entitlements, master-planned development, or phasing decisions, and when separating five-year exit deals from generational holds.","https:\u002F\u002Fgithub.com\u002Fcwik-tech\u002Foctopus\u002Fblob\u002Fmain\u002Fskills\u002Ftwenty-year-land-plan\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7F5MGQ8JSV27SFDQVVGFQE3","thematic-gut-check","Apply the Gray discipline of identifying the structural theme behind every real estate deal, testing where that theme sits in its capital-flow lifecycle, and insisting that deals without a named theme — or deals late in a crowded theme — clear a higher bar. A mediocre deal in a strong theme usually beats a clever deal in a weak one. Use when naming the structural thesis behind a deal, judging whether that theme is early or crowded, and setting the bar the deal must clear.","https:\u002F\u002Fgithub.com\u002Fcwik-tech\u002Foctopus\u002Fblob\u002Fmain\u002Fskills\u002Fthematic-gut-check\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7F5M8V64Y0ZD8PTPWEJQXJ9","supply-pipeline-gut-check","Apply the Zell discipline of grounding every real estate thesis in the local supply pipeline. Demand counts over adjectives — units under construction, units permitted, units proposed — and convert them into a forward absorption schedule. A deal that ignores the pipeline is a bet on a market you have not actually studied. Use when validating a market thesis, forecasting absorption and rent growth, or counting units under construction, permitted, and proposed.","https:\u002F\u002Fgithub.com\u002Fcwik-tech\u002Foctopus\u002Fblob\u002Fmain\u002Fskills\u002Fsupply-pipeline-gut-check\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7F5M3J2Q146BJC13TD3YCXF","ruin-scenario-mapping","Apply the Taleb discipline of identifying, for every real estate deal, the specific chain of events that produces ruin — permanent, unrecoverable capital loss — and verifying that no single such chain has non-trivial probability. Deals with any plausible ruin path must be restructured or abandoned. Use when sizing leverage, testing refinancing, covenant, and liquidity risk, or checking whether any single failure chain can permanently wipe out the position.","https:\u002F\u002Fgithub.com\u002Fcwik-tech\u002Foctopus\u002Fblob\u002Fmain\u002Fskills\u002Fruin-scenario-mapping\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7F5KZDS0DYD172P6HS0WXEM","revenue-cost-architecture","Design a venture's revenue streams, pricing logic, cost structure, and unit economics so the business model has a coherent theory of value capture, not just value creation. Use after the value proposition and customer segment are set and before financial projections, when choosing a pricing model, calculating contribution margin or CAC payback, or checking whether the unit economics hold at scale.","https:\u002F\u002Fgithub.com\u002Fcwik-tech\u002Foctopus\u002Fblob\u002Fmain\u002Fskills\u002Frevenue-cost-architecture\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7F5KP1CNQMYAVCDTV4EEW3J","replacement-cost-stress-test","Apply the Buffett discipline of pricing every real estate asset against the cost to rebuild it from scratch. The ratio of purchase price to replacement cost sets a ceiling on long-run downside: below replacement cost, new supply cannot profitably undercut you; at or above it, you are buying a liability disguised as an asset. Use when setting a purchase price, judging downside protection, or testing how exposed an asset is to newly built competing supply.","https:\u002F\u002Fgithub.com\u002Fcwik-tech\u002Foctopus\u002Fblob\u002Fmain\u002Fskills\u002Freplacement-cost-stress-test\u002FSKILL.md",[],[]]