Canonical worktree path normalization

From ychampion/cskill-agents · View interactive version

Canonical worktree path normalization is an AI agent skill from the GitHub repository ychampion/cskill-agents. Resolve repo-relative paths against the canonical checkout root so shared state stays stable across Git worktrees.

How to use this skill

Skill file

SKILL: Canonical Worktree Path Normalization

Domain: git-worktree

Trigger: Use when repo-relative paths are written into shared or user-global state and the same project may be opened from multiple worktrees.

Source Pattern: Distilled from reviewed permission, shell-safety, and worktree-management implementations.

Core Method

Normalize relative paths against the repository’s canonical root rather than the current worktree directory before persisting them into shared state. This prevents each worktree session from rewriting the same logical source to a different absolute path, and it avoids leaving dead install locations behind when a temporary worktree disappears. Keep the normalization local to the persistence boundary so upstream callers can continue using project-relative configuration naturally.

Key Rules

Example Application

If plugin sources are declared as marketplace inside repository settings but stored in a global config file as absolute paths, resolve them against the main checkout root. Opening the repo from a feature worktree then compares equal to the existing entry instead of churning the stored path on every session.

Anti-Patterns (What NOT to do)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.