agentleFS
marcusmarcus/sidecar/.claude/skills/project-switching/SKILL.md

project-switching

Skill1.1k starsChanged 56 days agoMITView on GitHub

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.

Trending

Less talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 2 mentionsMar 2026: 5 mentionsApr 2026: 2 mentionsMay 2026: 0 mentionsJun 2026: 1 mentionJul 2026: 5 mentionsAug 2026: 26 mentionsSep 2026: 4 mentionsOct 2026: 3 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the marcus/sidecar repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about marcus/sidecar

The biggest 5 of 48 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 48

Talked about on GitHub and Bluesky (48 times).

On GitHub · 47

  • Oct 5, 2026sidecar 1.16.0 — chenrui333/homebrew-tap1 reaction · 1 comment
  • Sep 23, 2026sidecar 1.14.0 — chenrui333/homebrew-tap1 reaction · 2 comments
  • Sep 3, 2026sidecar 1.13.0 — chenrui333/homebrew-tap1 reaction · 1 comment
  • Aug 31, 2026sidecar 1.11.2 — chenrui333/homebrew-tap1 reaction · 1 comment
  • Aug 27, 2026sidecar 1.9.0 — chenrui333/homebrew-tap1 reaction · 1 comment
42 more on GitHub

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Check for saved worktree to restore

    line 161
  2. Very specific:

    Update m.ui.WorkDir and repo name

    line 162
  3. Distinctive:

    All plugins stop (file watchers, git commands, etc.)

    line 171
  4. Distinctive:

    All plugins reinitialize with new path

    line 173

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Project Switching

Switch between git repositories without restarting sidecar. Press @ to open the project switcher modal.

Architecture Overview

The project switcher uses the app's declarative modal library (internal/modal/) for rendering and mouse handling.

Key Files

FileContents
internal/app/model.goState, init, reset, filter, switch, theme preview
internal/app/update.goKeyboard and mouse handlers
internal/app/view.goModal building and section rendering
internal/modal/Modal library (builder, sections, layout)
internal/config/types.goProjectConfig struct
internal/config/loader.goConfig loading with path validation

Model State

// 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

Project vs Worktree Switching

  • Project Switching (@): Switch between configured projects from config.json (arbitrary repos)
  • Worktree Switching (W): Switch between git worktrees within the current repository

Configuration

Projects are configured in ~/.config/sidecar/config.json:

{
  "projects": {
    "list": [
      {"name": "sidecar", "path": "~/code/sidecar"},
      {"name": "td", "path": "~/code/td", "theme": "dark"}
    ]
  }
}

Paths support ~ expansion. Projects can have per-project themes.

Core Flow

Opening (@ key)

case "@":
    m.showProjectSwitcher = !m.showProjectSwitcher
    if m.showProjectSwitcher {
        m.activeContext = "project-switcher"
        m.initProjectSwitcher()
    } else {
        m.resetProjectSwitcher()
        m.updateContext()
    }

Initialization (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.

Cleanup (model.go:413-423)

resetProjectSwitcher() resets all state, clears modal cache, and restores current project's theme (undoing any live preview).

Modal Rendering

Uses internal/modal/ with a builder pattern and lazy caching.

Modal Structure

+-------------------------------------------+
| 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
+-------------------------------------------+

Caching (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).

Section Types

TypeFactoryPurpose
Inputmodal.Input()Text input with focus
Custommodal.Custom()Complex content with focusables
Textmodal.Text()Static text
Buttonsmodal.Buttons()Button row

Keyboard Handling (update.go:600-690)

Priority: KeyType switch (special keys) -> String switch (named keys) -> Fallthrough to textinput.

KeyAction
EscClear filter (if set) or close modal
EnterSwitch to selected project
Up/DownArrow navigation
ctrl+n/ctrl+pEmacs-style navigation
Other keysForwarded to text input for filtering

Esc Behavior

First Esc clears filter if set. Second Esc (or first with empty filter) closes modal.

Navigation

Cursor movement updates projectSwitcherCursor and calls projectSwitcherEnsureCursorVisible() to maintain scroll window (max 8 visible items).

Filtering (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.

Mouse Handling (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.

Theme Preview (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().

Project Switching (model.go:485-577)

switchProject() performs:

  1. Skip if same project (show toast)
  2. Save active plugin state for old workdir
  3. Check for saved worktree to restore
  4. Update m.ui.WorkDir and repo name
  5. Apply project-specific theme
  6. Reinitialize all plugins via m.registry.Reinit(targetPath)
  7. Send WindowSizeMsg for layout recalculation
  8. Restore previously active plugin for new workdir
  9. Return toast notification

What Happens on Switch

  1. All plugins stop (file watchers, git commands, etc.)
  2. Plugin context updates to new working directory
  3. All plugins reinitialize with new path
  4. Previously active plugin for that project is restored
  5. Toast notification confirms the switch

State Persistence

Per-project state saved in ~/.config/sidecar/state.json:

  • Active plugin per project
  • File browser cursor position and expanded directories
  • Sidebar widths and view preferences

Common Pitfalls

  1. Forgetting updateContext() -- Call after closing modal to restore app context
  2. Stale modal cache -- Call clearProjectSwitcherModal() when content changes
  3. Cursor out of bounds -- Always clamp after filtering
  4. Printable keys vs navigation -- Keep printable characters routed to textinput
  5. Theme preview cleanup -- Always restore theme in resetProjectSwitcher()
  6. Focusable coordinates -- Each project takes 2 lines (name + path)

Adding Features

See references/implementation-details.md for detailed implementation patterns including adding keyboard shortcuts, project metadata, filter algorithms, and new modal sections.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.