VS Code β NHS Quickstart
VS Code gives you a single, lightweight IDE that works across Trust Windows builds (with WSL2), supports Python/R/SQL/JS, and has first-party tooling for GitHub, Docker, and Dev Containers.
Great for: Developer Β· Data Engineer Β· Data Scientist Β· BI Analyst Β· Clinician-Researcher.
βοΈ 10-minute installβ
- Windows (with WSL2)
- macOS / Linux
1) Install VS Code from code.visualstudio.com
2) Install WSL2 + Ubuntu (optional but recommended)
3) Open VS Code β install extensions (below)
4) Set the Python interpreter from your projectβs .venv
# Create a virtual environment in your project
py -3.11 -m venv .venv
.\.venv\Scriptsctivate
python -V
1) Install VS Code
2) Create & activate a .venv for Python projects
3) Install extensions (below)
python3 -m venv .venv && source .venv/bin/activate
python --version
π Recommended extensionsβ
- Python (Microsoft) β language support, debugging, testing
- Pylance β fast Python IntelliSense
- Jupyter β notebooks in VS Code
- SQL Server (mssql) β connect to SQL Server/MI
- SQLTools (+ drivers) β PostgreSQL / SQLite convenience
- Docker β build & run containers, push to registries
- YAML β schemas & validation (Kubernetes, CI)
- GitHub Pull Requests & Issues β PR reviews in editor
- Dev Containers β reproducible environments
- R (REditorSupport) β R console & R Markdown/Quarto helpers (optional)
Tip: create an extensions profile (e.g., Data Science vs Web Dev) and switch per project.
π βHello NHSβ tasksβ
- A) Run a notebook
- B) Query SQL Server
- C) Debug a FastAPI service
1) New File β Jupyter Notebook
2) Select Python kernel (your .venv)
3) Run the cell:
import pandas as pd
df = pd.DataFrame({"date": pd.date_range("2025-01-01", periods=3),
"admissions": [120,135,128]})
df.describe()
1) Install the SQL Server (mssql) extension
2) Ctrl/Cmd+Shift+P β MS SQL: Connect
3) New query:
SELECT TOP (10) * FROM dbo.vw_PracticeKPI ORDER BY total_appointments DESC;
1) Create app.py and install fastapi uvicorn
2) Add a launch config (below)
3) Press F5 to debug with auto-reload
π§© Useful settings (copy to settings.json)β
Note: pure JSON (no comments). On Windows, set
python.defaultInterpreterPathto.venv\Scripts\python.exe.
{
"python.defaultInterpreterPath": ".venv/bin/python",
"python.analysis.typeCheckingMode": "basic",
"editor.formatOnSave": true,
"python.formatting.provider": "black",
"python.linting.enabled": true,
"jupyter.askForKernelRestart": false,
"jupyter.sendSelectionToInteractiveWindow": true,
"mssql.connections": [
{
"server": "YOURSERVER",
"database": "NHS_Analytics",
"authenticationType": "Integrated",
"encrypt": "true",
"trustServerCertificate": true
}
],
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.exclude": { "**/.venv": true, "**/__pycache__": true },
"telemetry.telemetryLevel": "off"
}
βΆοΈ Run & Debugβ
.vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "FastAPI (uvicorn)",
"type": "python",
"request": "launch",
"module": "uvicorn",
"args": ["app:app", "--host", "0.0.0.0", "--port", "8000", "--reload"],
"jinja": true,
"envFile": "${workspaceFolder}/.env"
},
{
"name": "Dash app",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/app.py",
"console": "integratedTerminal",
"envFile": "${workspaceFolder}/.env"
}
]
}
.vscode/tasks.json (optional helpers)
{
"version": "2.0.0",
"tasks": [
{ "label": "Install deps", "type": "shell", "command": "pip install -r requirements.txt" },
{ "label": "Run extract", "type": "shell", "command": "python extract_kpi.py", "problemMatcher": [] }
]
}
π³ Dev Containers (reproducible environment)β
.devcontainer/devcontainer.json
{
"name": "nhs-python",
"image": "mcr.microsoft.com/devcontainers/python:3.11",
"features": { "ghcr.io/devcontainers/features/docker-in-docker:2": {} },
"postCreateCommand": "pip install -r requirements.txt",
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-azuretools.vscode-docker",
"ms-vscode.vscode-node-azure-pack"
]
}
}
}
Open folder β Reopen in Container to get a clean, consistent toolchain.
πͺ WSL2 (Linux on NHS Windows)β
- Enable Windows Subsystem for Linux
- Install Ubuntu from the Store
- In VS Code, click the green corner indicator and choose Connect to WSL
- Create your
.venvinside the Linux filesystem (/home/you/project)
WSL2 avoids Windows-specific package issues and speeds up many Python builds.
π IG & safety checklistβ
- Workspace Trust: only trust folders you control.
- Keep secrets in .env (local) and a secret store in prod; add
.envto .gitignore. - Use restricted DB roles from the SQL extension; never connect as admin for adβhoc work.
- Turn off telemetry per Trust policy.
- Prefer Dev Containers/WSL2 to avoid local installs of sensitive tooling.
π Measuring impactβ
- Dev setup time: new laptop β first run.
- Reproducibility: runs from a clean clone using the provided launch/tasks/devcontainer files.
- Quality: % of repos with formatβonβsave + lint passing.
- Adoption: number of teams using profiles/containers.
π See alsoβ
Whatβs next?
Youβve completed the Learn β VS Code stage. Keep momentum: