Atlas / Skills / marcus / Project Switching

Project SwitchingSAFE

skills/marcus/project-switching

Use sidecar next to CLI agents for diffs, file trees, conversation history, and task management with td

Verdict
SAFE
Grade
B
Trust score
89 /100
Version
—
Hosts
1 documented
License
MIT
Stars
1,086
01

Overview

Use sidecar next to CLI agents for diffs, file trees, conversation history, and task management with td

Read from source at commit a69114b893d1OBSERVED · 2026-10-10
02

Host compatibility

What the documentation claims. We have not run a compatibility test.

HostStatusNotes
cursormentioned
03

What it tells the agent

The instruction file, verbatim from the audited commit — this is the text the model reads, and the surface the audit's instruction layer examines. Quoted here so you can judge it without cloning anything.

---
name: project-switching
description: >
  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.
user-invocable: false
---

# 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

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

### Model State

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

## 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`:

```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)

```go
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

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

## Keyboard Handling (`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 |

### 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. Previ
04

Trust audit

SAFEgrade B · trust 89/100 Nothing in the source contradicts what it says it does. Grade A is reserved for packages that have also passed the behavioural sandbox.

LayerWhat it checksResult
L0Provenance & inventoryWARN
L1Static analysis of the codeNA
L2Instruction surface (what it tells the agent)PASS
L3Class-specific surfacePASS
L4Behavioural (sandbox)SKIPPED

What the source does

Filesystem
none-observed
Network
none-observed
Shell
none-observed
Dependencies
pinned
Secrets in source
none-found

Findings (2)

MEDIUMInventory / provenance · inv.symlink · CWE-1104
.codex/skills
.codex/skills
Why it matters. link not followed
LOWInventory / provenance · inv.symlink · CWE-1104
GEMINI.md
GEMINI.md
Why it matters. link not followed

Gates applied: no_behavioural_pass.

Audited 2026-10-10 · audit v0.4.1 · source sha a69114b893d1full audit observations/trust-audit/skill/marcus__project-switching.json · Report an issue / request a re-scan
05

Audit history

Every audit this skill has had.

DateSourceVerdictGradeScoreChange
2026-10-10a69114b893d1SAFEB89first audit
06

Questions

What does the Project Switching skill do?

Use sidecar next to CLI agents for diffs, file trees, conversation history, and task management with td

Is Project Switching safe to install?

The audit found nothing in the source that contradicts what it says it does, and graded it B (89/100). Grade A is held back for packages that have also passed a sandboxed behavioural run, which is why a clean skill reads B.

What can Project Switching access on my machine?

The audit observed no filesystem, network or shell use at all in its source.

Which assistants does Project Switching work with?

Its documentation mentions cursor. That is what the text claims, not a compatibility test we ran.

How current is this page?

The grade is for one exact copy of the source (a69114b893d1), read on 2026-10-10. The repository is watched, and a new audit runs when it changes — this is the first audit.

Advertisement