A fully configured VS Code workspace for agentic Python development with best practices built-in.
python -m venv venv
source venv/bin/activate # macOS/Linux
# or for Windows:
# venv\Scripts\activatepip install -r requirements.txtpre-commit installcp .env.example .env
# Edit .env with your configuration.
βββ src/ # Your Python modules
β βββ __init__.py
βββ tests/ # Test files
β βββ __init__.py
βββ .github/
β βββ instructions/
β β βββ python.instructions.md
β βββ workflows/ # GitHub Actions
βββ .vscode/
β βββ settings.json # VS Code configuration
βββ pyproject.toml # Project metadata & tool config
βββ requirements.txt # Python dependencies
βββ pytest.ini # Pytest configuration
βββ .pre-commit-config.yaml # Pre-commit hooks
βββ .env.example # Environment variables template
βββ README.md
# Format all Python files
ruff format .
# Lint and check for issues
ruff check . --fix
# Type checking
mypy src/# Run all tests
pytest
# Run with coverage
pytest --cov=src --cov-report=html
# Run specific test
pytest tests/test_example.py::test_function_name
# Run tests with markers
pytest -m unit # Only unit tests
pytest -m integration # Only integration tests- Set breakpoints in VS Code (F9 on line)
- Press F5 to start debugger
- Use Run β Run Without Debugging (Ctrl+F5) to run directly
Open Thunder Client (β‘ icon in sidebar) to test HTTP requests without leaving VS Code.
Installed & configured:
- Python - Language support & debugging
- Pylance - Type checking & IntelliSense
- Ruff - Linter & formatter (auto on save)
- Thunder Client - HTTP client for API testing
from typing import Annotated
from dataclasses import dataclass
@dataclass
class ToolResult:
"""Structured result from an agent tool."""
status: str
data: dict
error: str | None = None
def agent_tool(
input_value: Annotated[str, "Input description"],
timeout: Annotated[int, "Timeout in seconds"] = 30,
) -> ToolResult:
"""Tool function for agent execution.
Args:
input_value: Description of the input
timeout: How long to wait
Returns:
ToolResult with status, data, and optional error
"""
try:
# Your logic here
return ToolResult(status="success", data={})
except Exception as e:
return ToolResult(status="error", data={}, error=str(e))import pytest
from src.agent_tools import agent_tool
@pytest.mark.unit
def test_agent_tool():
"""Test agent tool with mocked dependencies."""
result = agent_tool("test input")
assert result.status == "success"
assert isinstance(result.data, dict)Place workflow files in .github/workflows/ to enable:
- Automated testing on push
- Code quality checks
- Coverage reports
- Type checking
pip install <package>
pip freeze > requirements.txtEdit pyproject.toml under [project.optional-dependencies] β dev
- Python version: 3.10+ (configured in
pyproject.toml) - Line length: 100 characters
- Type checking: Pylance standard mode
- Test discovery:
tests/test_*.py - Coverage target: Shown in
pyproject.toml
- Ensure
.vscode/settings.jsonhaseditor.formatOnSave: true - Restart VS Code
- Check Ruff extension is installed:
ruffin Extensions
- Ensure
tests/directory exists - Test files must start with
test_ - Test functions must start with
test_ - Run
pytest --collect-onlyto debug
- Pylance should be installed
- Check
python.analysis.typeCheckingMode: "standard"in settings - Restart Python extension: Cmd+Shift+P β "Developer: Reload Window"
MIT - See LICENSE file for details
Next Steps:
- β Virtual environment created
- β Dependencies installed
- β Pre-commit hooks configured
- Create your first module in
src/ - Add tests in
tests/ - Start building!