
sanhe-py-best-practices
Sanhe's Python Best Practices. See https://github.com/MacHu-GWU/sanhe-claude-code-plugins/blob/main/plugins/python/sanhe-py-best-practices/README.md
Install
/plugin install sanhe-py-best-practices@sanhe-claude-code-pluginsRun it inside Claude Code after adding the marketplace with /plugin marketplace add MacHu-GWU/sanhe-claude-code-plugins.
Contents
Discovered from sourceSkills 4
detect-python-version
Runs a script that outputs the Python version in major.minor format (e.g., 3.11, 3.13).
Instructions
Run scripts/detect_version.py to detect the Python version.
The script outputs just the version string in major.minor format, nothing else.
Examples
Output: 3.11
Output: 3.13
path-reference
Create clickable links to paths in a git repository.
Commands
Get web URL (always use -b default for stable links):
uvx --from git-web-url==1.0.1 gwu url -p $path -b default
Get relative path (for display text):
uvx --from git-web-url==1.0.1 gwu relpath -p $path
Link Formats
Markdown:
[relative/path/to/file.py](https://github.com/user/repo/blob/main/relative/path/to/file.py)
reStructuredText:
`relative/path/to/file.py <https://github.com/user/repo/blob/main/relative/path/to/file.py>`_
Supported Platforms
GitHub, GitLab, Bitbucket, AWS CodeCommit (including enterprise variants)
python-project-metadata
Runs uvx --from shai-py==0.1.1 shai-py project-info to automatically detect and display Python project metadata:
- Package name and version from pyproject.toml
- Virtual environment paths (python, pip, pytest executables)
- Project directories (package root, tests, docs)
- Configuration files (Sphinx conf.py, mise.toml)
python-test-strategy
Organized testing strategy for Python projects: test file naming, coverage goals (95%+), and public API testing.
Quick Start
Find test location for any source file:
When being asked to write tests for a specific source file, use the following command to determine the correct test file path based on established naming conventions:
uvx --from shai-py==0.1.1 shai-py test-path /path/to/my_package/subpackage/module.py
Run tests:
- Individual file:
.venv/bin/python tests/subpackage/test_*.py - Package:
.venv/bin/python tests/subpackage/all.py - All:
.venv/bin/python tests/all.py
Key Patterns
- Test files mirror source:
source/<pkg>/<module>.pyβtests/<pkg>/test_<pkg>_<module>.py - Coverage goal: 95%+ for all implementation files
- Public API: Export all public interfaces in
api.py, test intests/test_api.py
References
- π― Naming & File Location
- π Coverage Setup
- π Public API Testing
Commands 2
Use the path-reference agent skill to handle the following document writing request:
$ARGUMENTS
Use the python-test-strategy agent skill to handle the following test writing request:
$ARGUMENTS
Sponsors
Details
- Marketplace
- MacHu-GWU/sanhe-claude-code-plugins
- Source
- plugins/python/sanhe-py-best-practices
- Category
- Community