Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Project switching implementation in sidecar: project discovery, state management, UI flow, modal rendering, filtering, theme preview, and plugin reinitialization. Use when working on the project switcher feature, project management, worktree switching, or the project configuration system.
.claude/skills/marcus-project-switching/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 7% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 55% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 8% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 39% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 6% | 0% |
Switch between git repositories without restarting sidecar. Press @ to open the project switcher modal.
The project switcher uses the app's declarative modal library (internal/modal/) for rendering and mouse handling.
| File | Contents | |------|----------| | internal/app/model.go | State, init, reset, filter, switch, theme preview | | internal/app/update.go | Keyboard and mouse handlers | | internal/app/view.go | Modal building and section rendering | | internal/modal/ | Modal library (builder, sections, layout) | | internal/config/types.go | ProjectConfig struct | | internal/config/loader.go | Config loading with path validation |
go// internal/app/model.go showProjectSwitcher bool projectSwitcherCursor int projectSwitcherScroll int projectSwitcherInput textinput.Model projectSwitcherFiltered []config.ProjectConfig projectSwitcherModal *modal.Modal // Cached modal instance projectSwitcherModalWidth int // Width for cache invalidation projectSwitcherMouseHandler *mouse.Handler
@): Switch between configured projects from config.json (arbitrary repos)W): Switch between git worktrees within the current repositoryProjects are configured in ~/.config/sidecar/config.json:
json{ "projects": { "list": [ {"name": "sidecar", "path": "~/code/sidecar"}, {"name": "td", "path": "~/code/td", "theme": "dark"} ] } }
Paths support ~ expansion. Projects can have per-project themes.
@ key)gocase "@": m.showProjectSwitcher = !m.showProjectSwitcher if m.showProjectSwitcher { m.activeContext = "project-switcher" m.initProjectSwitcher() } else { m.resetProjectSwitcher() m.updateContext() }
model.go:433-454)initProjectSwitcher() clears cached modal, creates text input with "Filter projects..." placeholder, loads all projects, pre-selects current project, and previews its theme.
model.go:413-423)resetProjectSwitcher() resets all state, clears modal cache, and restores current project's theme (undoing any live preview).
Uses internal/modal/ with a builder pattern and lazy caching.
+-------------------------------------------+
| Switch Project | <- Title
| [Filter projects... ] | <- Input section
| 3 of 10 projects | <- Count section
| ^ 2 more above | <- Scroll indicator
| > sidecar | <- Selected item
| ~/code/sidecar |
| td (current) | <- Current project (green)
| v 5 more below | <- Scroll indicator
| enter switch up/down navigate esc close | <- Hints section
+-------------------------------------------+view.go:114-137)ensureProjectSwitcherModal() builds modal only when it does not exist or width changed. Call clearProjectSwitcherModal() when content changes (filter input, cursor movement with scroll).
| Type | Factory | Purpose | |------|---------|---------| | Input | modal.Input() | Text input with focus | | Custom | modal.Custom() | Complex content with focusables | | Text | modal.Text() | Static text | | Buttons | modal.Buttons() | Button row |
update.go:600-690)Priority: KeyType switch (special keys) -> String switch (named keys) -> Fallthrough to textinput.
| Key | Action | |-----|--------| | Esc | Clear filter (if set) or close modal | | Enter | Switch to selected project | | Up/Down | Arrow navigation | | ctrl+n/ctrl+p | Emacs-style navigation | | Other keys | Forwarded to text input for filtering |
First Esc clears filter if set. Second Esc (or first with empty filter) closes modal.
Cursor movement updates projectSwitcherCursor and calls projectSwitcherEnsureCursorVisible() to maintain scroll window (max 8 visible items).
model.go:457-470)filterProjects() does case-insensitive substring match on both Name and Path fields. On filter change: clear modal cache, clamp cursor, reset scroll, preview theme.
update.go:1073-1115)Uses modal library's HandleMouse(). Each project item has a focusable ID (project-switcher-item-N). Click on item triggers switch. Hover state managed by modal library via hoverID string.
model.go:580-586)previewProjectTheme() applies the selected project's theme live. Called on init, cursor movement, and filter changes. Theme is restored in resetProjectSwitcher().
model.go:485-577)switchProject() performs:
m.ui.WorkDir and repo namem.registry.Reinit(targetPath)WindowSizeMsg for layout recalculationPer-project state saved in ~/.config/sidecar/state.json:
clearProjectSwitcherModal() when content changesresetProjectSwitcher()See references/implementation-details.md for detailed implementation patterns including adding keyboard shortcuts, project metadata, filter algorithms, and new modal sections.
Other measured skills in the registry, with their headline benchmark lift.