.agents/skills/native-dependency-update/SKILL.md
Update native dependencies in SkiaSharp's Skia fork (mono/skia).
You MUST complete ALL phases in order. Do not skip phases to save time.
Before starting, confirm you will:
externals/skia submodule, AND cgmanifest.json🛑 STOP AND ASK before: Creating PRs, Merging PRs, Force pushing, Any destructive git operations
⛔ POLICY VIOLATION: Direct commits to protected branches are prohibited.
This rule applies to BOTH repositories:
| Repository | Protected Branches | Action Required |
|---|---|---|
| mono/SkiaSharp (parent repo) | main, release/* | Create feature branch first |
mono/skia (externals/skia submodule) | main, skiasharp | Create feature branch first |
Before ANY commit in either repository:
dev/update-{dep}All dependency updates are assumed security-sensitive. These rules apply to EVERY bump:
Commit message: Update {dep} to {version} — NOTHING else (plus Co-authored-by trailer)
PR title: Update {dep} to {version}
PR body: Version numbers, file changes, build verification results ONLY
Branch name: dev/update-{dep} — NEVER include CVE IDs
Prohibited in ALL public artifacts (PRs, commits, branches, PR comments):
Security analysis goes in the session conversation ONLY — report to the user:
| Shortcut | Why It's Wrong |
|---|---|
| Push directly to protected branches | Bypasses PR review and CI |
| Skip native build phase | CI is too slow; must verify locally first |
| Manually close issues | Breaks audit trail; PR merge auto-closes |
Skip cgmanifest.json update | Security compliance requires it |
Skip externals/skia submodule update | SkiaSharp won't use the new dependency version |
| Revert/undo pushed commits | Fix forward with new commit instead |
| Merge both PRs without updating submodule in between | Squash-merge creates new SHA; submodule points to orphaned commit; BREAKS USERS |
| Include security details in public artifacts | Leaks vulnerability info before users can update |
These do NOT persist across bash tool calls. Prefix every relevant command:
| Command | Prefix |
|---|---|
dotnet | export PATH="/usr/local/share/dotnet:/opt/homebrew/bin:$PATH" && |
gh pr create, gh pr edit, etc. | unset GH_TOKEN && |
grep (pattern matching) | Use grep -E not grep -P (BSD grep on macOS) |
Run the setup script before any other work. It initializes submodules, unshallows the dependency, creates the skia feature branch, and verifies the environment:
bash .agents/skills/native-dependency-update/scripts/setup.sh {dep} {skia_target_branch} {skiasharp_target_branch}
Arguments:
| Arg | Default | Examples |
|---|---|---|
dep | (required) | libpng, expat, zlib, libwebp, freetype |
skia_target_branch | skiasharp | skiasharp, release/3.119.x |
skiasharp_target_branch | main | main, release/3.119.x |
⚠️ NEVER assume the skia target branch. It depends on what the user is asking:
| User request | skiasharp_target_branch | skia_target_branch |
|---|---|---|
| Update on main | main | skiasharp |
| Backport to release branch | release/3.119.x | Ask the user |
If you're unsure which skia branch to target, ask the user. Do not guess.
After the script completes, proceed to Phase 1.
externals/skia/DEPSgit rev-parse {tag}^{commit}Source File Verification (MANDATORY):
cd externals/skia/third_party/externals/{dep}
git diff {old}..{new} --diff-filter=AD --name-only # Added/Deleted files
Cross-reference against externals/skia/third_party/{dep}/BUILD.gn — new source files may need to be added.
👉 See references/breaking-changes.md for risk assessment.
externals/skia/DEPS with new commit hashcgmanifest.json with new version (required for CVE detection)👉 See documentation/dev/dependencies.md for the cgmanifest format.
🛑 MANDATORY: Build locally before creating PRs.
See documentation/dev/building.md for platform-specific build commands.
dotnet cake --target=externals-macos --arch=arm64 # Example
# Run all tests (core + Vulkan + Direct3D — backends self-skip if unavailable)
dotnet test tests/SkiaSharp.Tests.Console.sln
Common transient failure: HTTP 429 from chromium.googlesource.com
When running dotnet cake --target=externals-macos, the git-sync-deps step fetches 10+ dependencies from Google's mirrors in parallel. If multiple sessions run concurrently, you'll hit rate limits:
error: RPC failed; HTTP 429 curl 22 The requested URL returned error: 429
Exception: Thread failure detected
Strategy:
Do NOT attempt to manually clone dependencies from other repos — you may pick wrong versions or SHAs.
Other common build issues:
fetch-gn network abort → retry (transient)--no-restore flag on dotnet test → remove it, let NuGet restore runtail -50 to read resultsThe cgmanifest.json uses different structures per component type:
"other": component.other.name, component.other.version"git": component.git.repositoryUrl, component.git.commitHashDo NOT assume all entries use the same schema. Check component.type first.
🛑 STOP AND ASK FOR APPROVAL before creating PRs.
Both PRs must be created together — CI requires both.
Both repos use branch name dev/update-{dep}. The skia branch was already created by the setup script.
The branch dev/update-{dep} already exists in externals/skia (created by setup script).
Update {dep} to {version}
Co-authored-by: Copilot <[email protected]>
{skia_target_branch}:
unset GH_TOKEN && gh pr create --repo mono/skia --base {skia_target_branch} --title "Update {dep} to {version}" --body "..."
Do NOT commit-then-amend. Every amend requires a force-push which re-triggers CI (wasting 2+ hours of compute).
⚠️ CRITICAL: You MUST update the submodule reference, not just cgmanifest.json
externals/skia, fetch and checkout the branch you just pushed in Step 1git add externals/skia cgmanifest.json (the submodule AND the manifest){skiasharp_target_branch}:
main: use the create_pull_request toolcreate_pull_request tool, then immediately fix the base:
unset GH_TOKEN && gh pr edit {number} --repo mono/SkiaSharp --base {skiasharp_target_branch}
Edit both PRs to reference each other:
unset GH_TOKEN && gh pr edit {skia_pr_number} --repo mono/skia --body "...Required SkiaSharp PR: https://github.com/mono/SkiaSharp/pull/{number}..."
unset GH_TOKEN && gh pr edit {skiasharp_pr_number} --repo mono/SkiaSharp --body "...Required skia PR: https://github.com/mono/skia/pull/{number}..."
Before proceeding, verify ALL of these:
dev/update-{dep} convention{skia_target_branch} branch{skiasharp_target_branch} branchexternals/skia submodule points to the mono/skia PR branch (check with git submodule status)cgmanifest.json updated with new versionSkiaSharp uses Azure DevOps. mono/skia has no CI — relies on SkiaSharp's.
🛑 STOP AND ASK FOR APPROVAL before each merge.
🚨 CRITICAL: SQUASH MERGE CREATES NEW COMMITS
When you squash-merge mono/skia PR, GitHub creates a NEW commit SHA on the target branch. The original commits on
dev/update-{dep}become orphaned when the branch is deleted.If SkiaSharp's submodule still points to the old (orphaned) commit, it will BREAK:
- New clones will fail
- Submodule updates will fail
- Users cannot build SkiaSharp
YOU MUST UPDATE THE SUBMODULE BEFORE MERGING SKIASHARP PR.
{skia_target_branch}{skia_target_branch} and note the new commit SHABefore proceeding past each step, verify:
{skia_target_branch} to get new SHAcd externals/skia && git checkout {new-sha})❌ NEVER merge both PRs in quick succession without updating the submodule in between. ❌ NEVER assume the submodule reference is correct after squash-merging mono/skia.
If you must amend a commit in externals/skia:
git add externals/skia (picks up new SHA)git commit --amend --no-edit⚠️ NEVER amend the skia commit without also updating the parent submodule reference. The old SHA becomes orphaned after force-push.
{skiasharp_target_branch}{skia_target_branch} — fetch the target branch, check that externals/skia commit exists on it (not orphaned)| Dependency | DEPS Key |
|---|---|
| libpng | third_party/externals/libpng |
| libexpat | third_party/externals/expat |
| zlib | third_party/externals/zlib |
| libwebp | third_party/externals/libwebp |
| harfbuzz | third_party/externals/harfbuzz |
| freetype | third_party/externals/freetype |
| libjpeg-turbo | third_party/externals/libjpeg-turbo |
For cgmanifest names and upstream URLs, see documentation/dev/dependencies.md.