| name | wsl-development |
| category | tooling |
| description | WSL2 development patterns — file system performance, memory management, Docker integration, and cross-OS workflows. |
When to Use This Skill
- When working on env-optimiser or any WSL2 development tooling
- When debugging performance issues in WSL2
- When configuring Docker Desktop with WSL2 backend
- When managing memory, disk, and process resources in WSL2
File System Performance
Critical rule: Keep project files on the Linux file system, not NTFS mounts.
| Path | Performance | Use For |
|---|
/home/user/... | Fast (ext4) | All project code, node_modules, .git |
/mnt/c/Users/... | Slow (9p/NTFS) | Accessing Windows files only when needed |
/tmp/ | Fast (tmpfs) | Transient build artifacts, test outputs |
cd /mnt/c/Users/me/projects/myapp
npm install
cd ~/projects/myapp
npm install
Memory Management
.wslconfig (Windows-side: %USERPROFILE%.wslconfig)
[wsl2]
memory=12GB
swap=4GB
processors=6
localhostForwarding=true
[experimental]
autoMemoryReclaim=gradual
sparseVhd=true
Monitoring Memory from Inside WSL
free -h
cat /proc/pressure/memory
ps aux --sort=-%mem | head -20
docker stats --no-stream --format "table {{.Name}}\t{{.MemUsage}}"
Graceful Degradation Under Memory Pressure
AVAIL_MB=$(awk '/MemAvailable/ {print int($2/1024)}' /proc/meminfo)
if [ "$AVAIL_MB" -lt 1000 ]; then
echo "Low memory: ${AVAIL_MB}MB available — reducing concurrency"
fi
Docker in WSL2
Architecture
Docker Desktop uses WSL2 as its backend — containers run inside the WSL VM, not a separate VM.
Performance Tips
docker info | grep "Docker Root Dir"
docker-compose.yml for WSL
services:
app:
volumes:
- app-data:/data
- ./src:/app/src
environment:
- PUID=1000
- PGID=1000
Network Considerations
ip addr show eth0 | grep inet
Development Workflow
IDE Integration (VS Code Remote - WSL)
code .
Git Performance in WSL
which git
git config --global credential.helper
Python in WSL (env-optimiser)
which python3
python3 -m venv ~/projects/env-optimiser/.venv
source ~/projects/env-optimiser/.venv/bin/activate
pip config set global.cache-dir ~/.cache/pip
Troubleshooting
| Symptom | Cause | Fix |
|---|
npm install extremely slow | Project on /mnt/c/ | Move to ~/ |
| File watchers miss changes | inotify limit or NTFS mount | echo 65536 > /proc/sys/fs/inotify/max_user_watches |
| Docker eating all memory | No memory cap in .wslconfig | Set memory=12GB |
| WSL process killed randomly | OOM killer | Reduce concurrency, set memory cap |
git status takes 10+ seconds | Large repo on NTFS or Windows git | Move to Linux fs, use /usr/bin/git |
| Port already in use | Windows service on same port | Check with netstat -ano in PowerShell |
Security Notes
- WSL can access all Windows files via
/mnt/c/ — lock down with automount options in /etc/wsl.conf
- SSH keys should be on Linux fs with
chmod 600, not on NTFS (permissions are emulated)
- Windows Defender can slow Linux fs operations — add exclusions for
%LOCALAPPDATA%\Packages\*\LocalState\ext4.vhdx