What used to be four scripts copied by hand between projects, now one package with one CLI.
What this is
Somnus's project-agnostic Python dev tooling — production-readiness
diagnostics, an AST class/definition indexer, bytecode-cache cleanup, and a
portable single-test harness scaffold — packaged as one real pip-installable
CLI instead of loose scripts.
Zero runtime dependencies beyond pyyaml, and that's only for
pycache-clean — doctor and structure are stdlib-only.
Install
git clone <this repo>
cd somnus-debug
pip install -e .
pip install somnus-debug isn't live yet — the package is publish-ready
(MIT-licensed, real PEP 621 metadata, verified build) but hasn't actually
been uploaded anywhere. See docs/PUBLISHING.md for what that takes and
what's still open before it happens.
The tools
| Command | What it does |
|---|---|
somnus-debug doctor ... |
AST-based production-readiness diagnostics: stubs, placeholder returns, silent exception handling, dependency cycles, docstring/type-hint coverage, security-risk patterns, TODOs. |
somnus-debug structure <file.py> |
Class-by-class, definition-by-definition AST index of a single Python file, with source line spans. Never imports or executes the target. |
somnus-debug pycache-clean ... |
Configurable removal of __pycache__ dirs and *.pyc/*.pyo files across one or more directory trees. Dry-run by default via --dry-run. |
somnus-debug init-test-harness [dir] |
Copies the CONTRACT.md-governed single-test harness (run_test.py) into a target repository. |
Every tool is also installed as its own script for muscle memory:
somnus-doctor, somnus-structure, somnus-pycache-clean.
somnus-debug · quickstart ·
SESSION
daeron@somnus:~$ pip install -e .
Successfully installed somnus-debug-0.1.0
daeron@somnus:~$ somnus-debug doctor init-config -o python_doctor.yaml
Wrote default configuration: python_doctor.yaml
daeron@somnus:~$ somnus-debug doctor scan . -o report.md
Scan complete: files=42, issues=118, critical=0, serious=9
daeron@somnus:~$ somnus-debug structure src/core.py -o CORE_INDEX.md
Class Index for `core.py` written to CORE_INDEX.md
daeron@somnus:~$ somnus-debug pycache-clean --config config.yaml --dry-run
Summary: deleted 6 directories, 0 files; freed 2.10 MiB # dry run — nothing actually removed
daeron@somnus:~$ █
Full flag reference and worked examples for every command:
docs/MANUAL.md.
Build status
Honest, not aspirational — this reflects what's actually been verified, not what's planned.
somnus-debug · build status — 2026-09-01 ·
STATUS
| Component | Progress | Status |
|---|---|---|
| Package skeleton | ██████████ 100% |
✅ verified |
| doctor / structure / pycache-clean | ██████████ 100% |
✅ verified |
| init-test-harness | ██████████ 100% |
✅ verified |
| Wheel build + install | ██████████ 100% |
✅ verified |
| public release synchronization | ████████░░ 80% |
release candidate verified |
| PyPI publish | ░░░░░░░░░░ 0% |
❌ not started |
| doctor / structure feature expansion | ░░░░░░░░░░ 0% |
❌ not started |
Open items.
pip install somnus-debugmeans an actual PyPI upload, which has not happened — the required TestPyPI-first release gate is indocs/PUBLISHING.md. The old root-level scripts (python_production_doctor.py,analyze_python_structure.py,pycache_cleaner.py,run_test.py,python_doctor.yaml) are still sitting next tosrc/somnus_debug/pending cleanup — harmless, just redundant.
Using it as a library
from somnus_debug.structure.core import build_index
from somnus_debug.doctor.core import ProjectScanner, ConfigManager
from somnus_debug.pycache_cleaner.core import PycacheCleaner, CleanerConfig
Each core.py is the original single-file implementation, moved into the
package rather than rewritten — anything importable from the standalone
script is importable from somnus_debug.<tool>.core too.
Repository layout
pyproject.toml package metadata, deps, entry points
LICENSE MIT
README.md this file
src/somnus_debug/
cli.py `somnus-debug <command>` dispatcher
doctor/core.py = old python_production_doctor.py
doctor/default_config.yaml = old python_doctor.yaml
structure/core.py = old analyze_python_structure.py
pycache_cleaner/core.py = old pycache_cleaner.py
test_harness/scaffold.py + templates/{run_test.py, CONTRACT.md}
tests/test_cli_smoke.py 10 real subprocess CLI smoke tests
docs/
MANUAL.md full command reference (start here for usage)
PUBLISHING.md the real-PyPI-release checklist
CONTRACT.md governs run_test.py's artifact contract
OPSEC.md Somnus agent operational security protocol
Python_Doctor_QUICKSTART.md deep config-field reference for `doctor`
Documentation index
- STATE.md — what actually exists and works right now, verified not assumed.
- PLAN.md — what's next, in dependency order.
- docs/MANUAL.md — day-to-day command reference, every flag, worked examples, troubleshooting.
- docs/AGENTS_APPENDIX.md — pasteable global or repository-local agent guidance; installation and instruction hydration are intentionally separate.
- docs/PUBLISHING.md — the checklist for actually shipping this to PyPI.
- docs/Python_Doctor_QUICKSTART.md —
full
python_doctor.yamlfield reference. - docs/CONTRACT.md — what
run_test.pydoes and does not own. - docs/OPSEC.md — SUPREME-authority agent security posture for this codebase.
Metadata
Release files for somnus-debug 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| somnus_debug-0.1.0.tar.gz | 66.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| somnus_debug-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 126.5 kB
Release files / somnus_debug-0.1.0.tar.gz
| Download URL | somnus_debug-0.1.0.tar.gz |
|---|---|
| Size | 66.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4dd3fd5a6b74a5e1d05d16ec60bc1a8eb43bfd13789395187ca9f5d8cb8615d4
|
|
BLAKE2b-256 checksum How to use checksums |
d27604b588607330e37819a66ed924b306609f6ac991625daecef4b791bd788e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / somnus_debug-0.1.0-py3-none-any.whl
| Download URL | somnus_debug-0.1.0-py3-none-any.whl |
|---|---|
| Size | 60.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e6913e1216fc167c007479b8547e65d685e56c0461d6bf669a1e59a2eed4139
|
|
BLAKE2b-256 checksum How to use checksums |
bf213fccb250f83d9a267508f9d33457826ba1eab0c9c0f4da60f1ea4e0a3164
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for somnus-debug 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.