Development Setup¶
This guide walks through setting up a local development environment for contributing to Code Scalpel.
Prerequisites¶
- Python 3.10+ (3.13 also supported)
- Git
- Virtual environment (venv or conda)
Clone the Repository¶
# Clone via HTTPS
git clone https://github.com/your-org/code-scalpel.git
# Or via SSH
git clone git@github.com:your-org/code-scalpel.git
cd code-scalpel
Create Virtual Environment¶
Install Dependencies¶
# Install in development mode with all extras
pip install -e ".[dev]"
# This installs:
# - Core dependencies
# - Test dependencies (pytest, pytest-cov, etc.)
# - Lint tools (ruff, black, pyright)
# - Documentation tools
Verify Installation¶
# Run tests
pytest tests/ -v
# Check linting
ruff check src/ tests/
# Check formatting
black --check src/ tests/
# Type checking
pyright src/
IDE Setup¶
VS Code¶
Install recommended extensions:
// .vscode/extensions.json
{
"recommendations": [
"ms-python.python",
"ms-python.vscode-pylance",
"charliermarsh.ruff",
"ms-python.black-formatter"
]
}
Settings for the project:
// .vscode/settings.json
{
"python.defaultInterpreterPath": "./venv/bin/python",
"editor.formatOnSave": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"python.analysis.typeCheckingMode": "basic"
}
PyCharm¶
- Open project folder
- Configure interpreter:
venv/bin/python - Enable Black formatter
- Enable Ruff linter
Project Structure¶
code-scalpel/
├── src/code_scalpel/ # Main source code
│ ├── mcp/ # MCP server and tools
│ │ ├── server.py # Main MCP server
│ │ └── tools/ # Tool implementations
│ ├── core/ # Core analysis engine
│ ├── parsers/ # Language parsers
│ └── licensing/ # Tier management
├── tests/ # Test suite
│ ├── tools/ # Tool tests
│ └── core/ # Core engine tests
├── docs/ # Documentation
├── .code-scalpel/ # Configuration files
└── website/ # Website docs (this site)
Running the MCP Server¶
Common Tasks¶
Run Specific Tests¶
# Single test file
pytest tests/tools/test_analyze.py
# Single test function
pytest tests/tools/test_analyze.py::test_analyze_python
# With pattern
pytest -k "analyze" tests/
Run with Coverage¶
Auto-Format Code¶
Troubleshooting¶
"Module not found" errors¶
Make sure you installed in development mode:
Test failures due to tier¶
Some tests require Pro/Enterprise license files. Community tests run by default:
Import errors in IDE¶
Ensure your IDE is using the correct Python interpreter from the virtual environment.