← ClaudeAtlas

cosid-manual-integrationlisted

Integrate CosId programmatically into Java or Kotlin applications without Spring Boot auto-configuration. Use for direct construction of SnowflakeId, CosIdGenerator, DefaultSegmentId, or SegmentChainId; machine-ID allocation and guarding; backend distributor factories; lifecycle ownership; custom IdConverter wiring; tests; or integration into another framework. Do not use for cosid-spring-boot-starter YAML or feature capabilities.
Ahoo-Wang/skills · ★ 3 · AI & Automation · score 76
Install: claude install-skill Ahoo-Wang/skills
# Integrate CosId Programmatically Provide code that compiles against the user's CosId version. Prefer direct constructors for fixed local inputs and backend factories for distributed state. ## Workflow 1. Confirm the target version and chosen strategy. Use `$cosid-strategy-guide` only when the strategy is undecided. 2. Identify the uniqueness authority: fixed machine ID, StatefulSet ordinal, distributed machine-ID backend, or segment backend. 3. Construct the smallest generator that satisfies the requirement. 4. Own every created client, guarder, executor, and distributor for its full lifecycle. 5. Add one focused check for uniqueness, local monotonicity, parsing, restart, or clock rollback. When a CosId checkout is available, verify signatures in `cosid-core/src/main/java/me/ahoo/cosid/` and use existing backend factories and tests as examples. Do not copy older README snippets without checking the current source. ## SnowflakeId with a Fixed Machine ID Use this only when deployment automation guarantees a unique value per live instance. ```java int machineId = 1; SnowflakeId idGenerator = new ClockSyncSnowflakeId( new MillisecondSnowflakeId(machineId) ); long id = idGenerator.generate(); ``` Use `SecondSnowflakeId` only for a deliberate second-based bit layout. Use `SafeJavaScriptSnowflakeId.ofMillisecond(machineId)` when a numeric ID must stay within JavaScript's safe integer range; otherwise serialize ordinary IDs as strings. ## Distributed Machine-ID Alloca