How It Works
The plugin acts as a transparent proxy between Claude Code and your Python type-checking backend (pyright, ty, or pyrefly). It automatically detects.venv directories and spawns backend processes as needed.
1
Plugin starts with Claude Code
When Claude Code launches, typemux-cc starts automatically. It searches for a fallback
.venv in:- Git repository root (if in a git repo)
- Current working directory
- If neither exists, starts with an empty backend pool
2
Opening Python files triggers detection
When you open a Python file, typemux-cc:
- Searches for
.venvby traversing parent directories from the file location - Stops at git toplevel (repository boundary) if in a git repo
- Verifies that
.venv/pyvenv.cfgexists (strict validation) - Spawns a backend if
.venvis found and not already in the pool
3
Backend spawns with correct environment
Each backend process spawns with:
VIRTUAL_ENVset to the detected.venvpathPATHprefixed with.venv/bin- Unique session ID for tracking
These environment variables are only set for the backend process. Your shell environment and system PATH remain unchanged.
When Backends Are Spawned
Backends spawn automatically in these scenarios:First file open in a project
When you open the first Python file from a project (directory with
.venv), typemux-cc searches for .venv and spawns a backend if found.Switching to a different project
Opening a file from a project with a different
.venv path spawns a new backend. The previous backend stays alive in the pool.Late .venv creation
If you create
.venv after opening files, reopen the file to trigger detection. Cached documents don’t automatically re-search for .venv.Document State and Caching
What Gets Cached
For every opened document, typemux-cc maintains:- URI (file:// URL)
- Language ID (
python) - Version number (incremented on each change)
- Full text content (updated via
textDocument/didChange) - Associated venv path (detected on first open)
Why Caching Matters
1
State restoration when backends spawn
When a new backend spawns, it needs to know about already-open files. typemux-cc automatically resends
textDocument/didOpen for all documents belonging to that .venv.2
Incremental text updates
textDocument/didChange events update the cached text immediately, even if no backend is running for that document.3
Cache invalidation on close
When you close a file, typemux-cc removes it from the cache.
Cache Limitations
Why this design? Re-searching for
.venv on every LSP request would be expensive (filesystem I/O). Caching trades off flexibility for performance. The workaround (reopen files) is simple and rare in practice.Verification
To check if typemux-cc is working:1
Enable logging
2
Restart Claude Code and open a Python file
Open any Python file in a project with
.venv.3
Check the log
Summary
Zero-configuration operation
- Plugin starts automatically with Claude Code
- Detects
.venvwhen you open Python files - Spawns backends as needed
- Maintains document state across backend lifecycle
- No manual intervention required for basic workflows