Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/marcus/sidecar/worktree-switchingnpx skills add marcus/sidecar --skill worktree-switchinggit clone --depth 1 https://github.com/marcus/sidecarWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00074 | $0.01563 |
| Opus 5 | $0.00037 | $0.00781 |
| Sonnet 5 | $0.00015 | $0.00313 |
| Haiku 4.5 | $0.00007 | $0.00156 |
Grade A, and why
worktree-switching scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 217 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Worktree Switching
Sidecar supports seamless switching between git worktrees. When switching:
- All plugins are stopped, reinitialized with the new WorkDir, and restarted
- Per-worktree state (active plugin, sidebar selections) is saved/restored
- Project-specific themes are applied
- If a worktree is deleted externally, sidecar gracefully falls back to main
Core Mechanism
Project Switching
Worktree switching uses Model.switchProject() in internal/app/model.go:
m.switchProject(worktreePath)
This triggers in order:
- Save active plugin for old WorkDir
- Update
m.ui.WorkDirto new path - Apply resolved theme for new path
- Call
registry.Reinit(newWorkDir)-- stops all plugins, updates context, reinits all - Send
WindowSizeMsgto all plugins for layout recalculation - Restore saved active plugin for new WorkDir
- Show toast notification
Registry Reinitialization
Registry.Reinit() in internal/plugin/registry.go:
func (r *Registry) Reinit(newWorkDir string) []tea.Cmd {
// Stop all plugins (reverse order)
for i := len(r.plugins) - 1; i >= 0; i-- {
r.safeStop(r.plugins[i])
}
// Update context
r.ctx.WorkDir = newWorkDir
// Reinit all plugins
for _, p := range r.plugins {
r.safeInit(p)
}
// Collect and return start commands
return startCmds
}
Plugin Responsibilities on Worktree Switch
Handle Reinitialization Cleanly
Your plugin will be stopped and reinitialized on worktree switch. Ensure:
Stop()releases all resources (watchers, goroutines, channels)Init(ctx)resets state and reads from newctx.WorkDirStart()kicks off fresh async work for the new context
func (p *Plugin) Stop() {
p.stopOnce.Do(func() {
if p.watcher != nil {
p.watcher.Close()
}
close(p.done)
})
}
func (p *Plugin) Init(ctx *plugin.Context) error {
p.ctx = ctx
p.items = nil // Reset state
p.stopOnce = sync.Once{} // Reset stop guard
p.done = make(chan struct{})
return nil
}
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3d ago First seen · 217 lines · 74 tokens per session scan A b9aba13b8e04
worktree-switching is a skill published in the GitHub repository marcus/sidecar (1,049 stars, last pushed 3d ago), licensed MIT. It adds 74 tokens to every session and 1,563 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
pre-merge
The CI gate. Takes a feature branch from "eng says done" to "PR open against staging with green checks". Runs the project's preflight-resolved pipeline from devkit/policy.json components[]: sync → parallel correctness + security waves → coverage → regression tail → security/migration → PRD-consistency → open PR. Emits…
intake
The planning front-door. Captures feature ideas and bugs as graded rows in the root INTAKE.md ledger. Use it when the user says "log an idea", "capture a bug", "add to the backlog", "note this down", "track this feature", or invokes /intake. Owns the requirements interview — fleshes out thin ideas, proactively…
merge
The ship gate — the only skill that merges. --staging merges the feature→staging PR on green CI, deploys, verifies, emits a human test script and stamps the staging sign-off on approval. --production ships the double-confirmed release to main and deploys production. Never self-certifies staging; nothing reaches main…
msg
Root menu for msg skills, plus harness modes. --init is the one-time project bootstrap — use it when the user says "initialise project", "bootstrap repo", "set up the framework", "start a new project", or asks to set up project structure in an empty repo. Other modes: --init-staging (add a staging branch), --update…
lorekeeper-reconcile
Reconcile and fact-check Lorekeeper memories against source materials, existing documentation, and internal consistency. Use when (1) the user provides reference materials to verify against, (2) the user requests a general knowledge audit, or (3) the user wants to verify specific topics. Updates memory scores and…
lorekeeper-search
Search the Lorekeeper knowledge base and provide relevance feedback with confidence ratings. Use when the agent needs to recall domain knowledge, look up facts, or query the memory store. Ensures every search ends with a loreupdate feedback call (including confidence) to improve knowledge quality over time.