$npx -y skills add contentful/skills --skill optimization-sdk-syncSynchronize the Contentful Optimization SDK's public API, behavior, and implementation guidance into concise, runtime-specific references for the contentful-personalization skill. Use when the optimization repository or SDK documentation changes, when modern SDK guidance appears
| 1 | # Optimization SDK Sync |
| 2 | |
| 3 | Update the modern Optimization SDK knowledge in `contentful-personalization` from a verified upstream revision. Optimize the result for an agent solving implementation tasks: concise, explicit, runtime-specific, and grounded in public API and maintained examples. |
| 4 | |
| 5 | Do not copy upstream guides wholesale. Treat this as a knowledge compilation workflow. |
| 6 | |
| 7 | ## Scope |
| 8 | |
| 9 | This skill owns modern `@contentful/optimization*` guidance. Preserve legacy `@ninetailed/*` guidance unless upstream evidence requires a compatibility correction. |
| 10 | |
| 11 | Supported runtime references: |
| 12 | |
| 13 | - shared concepts and behavior |
| 14 | - React Web |
| 15 | - Next.js App Router |
| 16 | - Next.js Pages Router |
| 17 | - browser Web |
| 18 | - Node.js |
| 19 | - React Native |
| 20 | |
| 21 | Do not synthesize iOS or Android guidance until upstream provides equivalent knowledge-base facts, public API declarations, and guide blueprints. |
| 22 | |
| 23 | ## Source resolution |
| 24 | |
| 25 | Use the public repository by default: |
| 26 | |
| 27 | ```text |
| 28 | https://github.com/contentful/optimization.git |
| 29 | ``` |
| 30 | |
| 31 | Resolve sources in this order: |
| 32 | |
| 33 | 1. An explicit local path supplied by the user. |
| 34 | 2. An existing reusable clone at `.docs/optimization-sdk-sync/repository`. |
| 35 | 3. A fresh clone of the official HTTPS repository into that cache. |
| 36 | |
| 37 | The cache is repo-local working state for the sync process. It is not committed or distributed. |
| 38 | Reusing it avoids cloning the public repository on every run while still allowing the skill to |
| 39 | fetch and inspect an exact upstream commit. |
| 40 | |
| 41 | For the default remote flow: |
| 42 | |
| 43 | 1. Inspect the managed cache's origin and worktree status before checkout. |
| 44 | 2. Verify `origin` is exactly the official HTTPS repository before fetching. |
| 45 | 3. If the origin differs or the cache has local changes, do not repoint, reset, delete, or clean it. |
| 46 | Stop and report the conflict, or use a separately approved clean cache. |
| 47 | 4. Fetch the requested ref, defaulting to `main`. |
| 48 | 5. Resolve it to a full immutable commit SHA. |
| 49 | 6. Inspect a detached checkout of that SHA. Do not use `git pull` or merge upstream history. |
| 50 | |
| 51 | For an explicit local path: |
| 52 | |
| 53 | 1. Resolve and record `HEAD`. |
| 54 | 2. Record the origin URL when present. |
| 55 | 3. If tracked or untracked files are present, treat the run as preview-only unless the user explicitly asks to use dirty state. |
| 56 | 4. Never edit, clean, stash, reset, or otherwise mutate the source repository. |
| 57 | |
| 58 | ## Read repository policy first |
| 59 | |
| 60 | Before interpreting upstream files, read every applicable `AGENTS.md` from the repository root down to each source directory. Follow upstream-generated-file and validation rules. |
| 61 | |
| 62 | ## Evidence hierarchy |
| 63 | |
| 64 | Use all four evidence layers. Knowledge-base facts and types alone are not sufficient for complete agent guidance. |
| 65 | |
| 66 | 1. **Knowledge base** — behavioral contracts, caveats, lifecycle, architecture, platform differences, and source pointers under `documentation/internal/sdk-knowledge/`. |
| 67 | 2. **Public exports and types** — exact import paths, names, signatures, option shapes, return values, and deprecations under `packages/`. |
| 68 | 3. **Guide blueprints** — task coverage, prerequisite ordering, validation expectations, and troubleshooting branches under `documentation/authoring/blueprints/`. |
| 69 | 4. **Maintained implementations and public docs** — canonical composition, file boundaries, realistic usage, edge cases, and completeness checks. |
| 70 | |
| 71 | Resolve conflicts using the most authoritative source for the claim: |
| 72 | |
| 73 | - exact API shape: public exports and types |
| 74 | - behavioral semantics: knowledge-base fact backed by its source pointer |
| 75 | - implementation topology: maintained first-party implementation |
| 76 | - task completeness: blueprint |
| 77 | - public wording: public docs, only after checking the layers above |
| 78 | |
| 79 | Never infer an API from prose when an exported type or implementation is available. |
| 80 | |
| 81 | Treat repository knowledge and guide validators as structural integrity gates. They verify pointers, |
| 82 | templates, links, and planned structure; they do not prove that two valid sources agree semantically. |
| 83 | When a knowledge fact conflicts with an exported public type, record the discrepancy and follow the |
| 84 | public type for downstream API guidance. |
| 85 | |
| 86 | ## Validate upstream inputs |
| 87 | |
| 88 | From the resolved checkout, run the repository's documented dependency setup if required, then: |
| 89 | |
| 90 | ```bash |
| 91 | pnpm knowledge:check |
| 92 | pnpm guides:check |
| 93 | ``` |
| 94 | |
| 95 | Record each result as `passed`, `failed`, or `blocked`. A sandbox, dependency, or runtime restriction |
| 96 | is `blocked`, not `failed`, but both are non-passing. Stop authoritative downstream writes unless |
| 97 | both checks pass; report the immutable SHA, command, status, and concrete failure or blocking reason. |
| 98 | |
| 99 | ## Determine the delta |
| 100 | |
| 101 | Read `src/skills/contentful-personalizat |