| name | repl |
| description | Persistent Python REPL server that avoids reloading heavy packages (torch, transformers, nnterp, vllm). Use when running multiple Python commands with heavy imports, loading ML models, or doing iterative testing where variables should persist between executions. |
Python REPL - Persistent Session
Keeps Python interpreter running between commands, avoiding 20+ second package reload overhead.
When to use this skill
Use the REPL when you're about to:
- Import heavy packages: torch, transformers, nnterp, vllm, diffusers
- Run multiple Python commands that share state
- Do iterative testing/debugging with ML models
- Execute multi-step workflows (load model → compile config → query)
Don't use for one-off simple Python commands.
Setup (once per project)
uv add --editable ~/projects/research-libs/claude-repl
Quick check: Is server running?
echo '{"action":"ping"}' | timeout 2 nc -U /run/user/$(id -u)/claude-repl.sock
Start server
uv run claude-repl server &
Create session with imports
cat > /run/user/$(id -u)/session.json << 'EOF'
{
"action": "create_session",
"session_id": "main",
"python_path": ["./src"],
"preload_code": "import torch\nfrom mylib import Model\nprint('Ready')"
}
EOF
cat /run/user/$(id -u)/session.json | nc -U /run/user/$(id -u)/claude-repl.sock
Execute code
For simple code:
echo '{"action":"execute","session_id":"main","code":"print(model.num_layers)"}' | nc -U /run/user/$(id -u)/claude-repl.sock
For complex code (avoids shell escaping issues):
cat > /run/user/$(id -u)/code.py << 'EOF'
result = model.forward(x)
print(result.shape)
EOF
uv run python -c "
import json
code = open('/run/user/$(id -u)/code.py').read()
print(json.dumps({'action': 'execute', 'session_id': 'main', 'code': code}))
" | nc -U /run/user/$(id -u)/claude-repl.sock
Export to Jupyter notebook
Convert your session history to a notebook for sharing/reproducibility:
echo '{"action":"export_notebook","session_id":"main","path":"./experiment.ipynb"}' | nc -U /run/user/$(id -u)/claude-repl.sock
Key points