hunter-party-py/boundary-hunter-py/SKILL.md
Audit Python packages and modules for black-box boundary violations — leaked internals via exports, coupling through shared types, Law of Demeter chains, missing abstraction layers around externals, and over-exported APIs. Use when: reviewing package structure, shrinking public API surface, enforcing encapsulation, preparing modules for replacement, or untangling tight coupling between layers.
npx skillsauth add skyosev/agent-skills boundary-hunter-pyInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Audit Python code for module boundary violations — places where implementation details leak through exports, where modules reach into each other's internals, or where coupling makes replacement impossible. The goal: every package is a black box, replaceable from its interface alone.
A package is its interface. The public API is defined by a combination of __all__, __init__.py re-exports,
naming conventions (_ prefix for private), and documentation. Everything not part of the public API is an
implementation detail. Exports should describe what the package does, never how it does it. If a consumer must
understand internals to use the API correctly, the boundary is broken.
Minimal public surface. Export only what is consumed or serves as a deliberate extension point. Every additional
export is a coupling point that constrains future changes. Use __all__, explicit __init__.py re-exports, or
_ prefix naming to signal the intended public surface. Not every package needs __all__ — but the boundary
should be inferable without reading internals.
Depend on abstractions, not concretions. Modules should depend on protocols (ABCs, typing.Protocol) owned by
the consumer or a shared kernel — not on concrete implementations from other packages. If module A imports a class
from module B, A is coupled to B's implementation. If A imports a Protocol that B happens to implement, A is coupled
only to the protocol contract.
Dependency direction must follow architectural intent. In a layered architecture, dependencies flow inward:
infrastructure → application → domain. A domain module importing a concrete implementation from infrastructure is a
boundary violation. Exception: type-only imports (under TYPE_CHECKING) from a shared kernel or contracts layer
that both sides depend on are not violations — this is standard DDD practice. Runtime import cycles are always
violations.
Wrap externals — don't let them leak. Third-party types and APIs should not appear in domain or application layer interfaces. Wrap them behind owned types so the external can be replaced without changing consumers. Infrastructure/adapter modules are the wrapping layer — they may use external types in their implementation and even in their own interface when they serve as the system edge. The rule is strict for inward layers, relaxed at the boundary with the outside world.
One reach, not a chain. A consumer should call a module's API directly — not reach through it into a transitive
dependency's API. a.get_b().get_c().do_thing() (Law of Demeter violation) exposes B's and C's existence to A's
caller. If a consumer needs something from a transitive dependency, the immediate dependency should expose it through
its own API.
Primitives flow; implementation types stay home. Data that flows between packages should be expressed as
primitive types, dataclasses, TypedDicts, or shared domain types — not as package-internal classes that force
consumers to import from the implementation. NewType wrappers (e.g., UserId, Millimetres) are fine to cross
boundaries when they represent domain contracts; they are violations when they encode implementation details
(e.g., internal cache keys, serialization formats).
Internal helpers, intermediate types, constants, or utility functions that are exported but serve no external consumer.
Signals:
__all__ or __init__.py that has zero external import sites_private names)Action: Remove from __all__ / __init__.py, or if consumed externally, evaluate whether the consumer should own
the concept.
__init__.py Files__init__.py that re-exports everything from every internal module, turning the entire package into a public API.
Signals:
from .internal_module import * patterns__init__.py re-exports symbols that no external package importspackage.internal.helper) bypassing the __init__.py__all__ in packages with ambiguous public surface — entire module namespace is implicitly public
(note: __all__ is one way to define the boundary; _ prefix naming and explicit __init__.py re-exports are
also valid)Action: Replace from .x import * with explicit named imports of the public API. Define the public surface
via __all__, explicit re-exports, or _ prefix naming. Block deep imports via conventions or package structure.
Two packages that share a type where neither owns it, or where one package's internal type appears in another package's function signatures.
Signals:
Action: Move shared types to a shared kernel / contracts layer owned by neither package. Or, define the type in the consumer and have the producer conform to it (dependency inversion via Protocol).
Long chains of attribute access or method calls that traverse multiple levels of abstraction.
Signals:
a.b.c.d chains accessing nested attributes across package boundariesAction: Expose a direct API on the immediate dependency. If the consumer needs c.d, then the module owning c
should provide a method or property for it.
Third-party library types or APIs used directly in domain or application layer interfaces, coupling consumers to a specific library.
Signals:
django.http.HttpRequest, flask.Request, sqlalchemy.Session) in domain or
application layersAcceptable: Infrastructure/adapter modules using external types in their own interface — they are the wrapping layer. Flag only when these types leak inward into domain/application consumers.
Action: Define an owned Protocol or ABC that wraps the external type. The wrapping module is the only place that imports from the external. Consumers depend on the owned interface.
Two or more packages that import from each other, directly or transitively.
Signals:
__init__.py files that create implicit cycles by re-exporting across boundariesImportError at runtime due to circular importsAction: Runtime cycles are must-fix — break by extracting the shared concept into a third module, or inverting the
dependency direction. TYPE_CHECKING-guarded import cycles between co-evolving modules may be acceptable if explicitly
justified.
A lower-level module importing from a higher-level module, breaking the intended layering.
Signals:
Action: Invert the dependency. Define a Protocol or ABC in the lower layer; implement it in the higher layer. Wire via dependency injection, factory, or configuration.
main/master)BASE=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo main)
SCOPE=$(git diff --name-only $(git merge-base HEAD $BASE)...HEAD)
Constrain all subsequent scans to the resolved surface.__init__.py, but also consider PEP 420
namespace packages (directories without __init__.py that still function as packages). If the project uses
pyproject.toml, setup.cfg, or setup.py to define package boundaries, use those as the source of truth.
List all packages and their public API surface.__init__.py, __all__, and naming
conventions). Classify each as: class, function, constant, type alias, Protocol/ABC.For each package:
# Find all __all__ definitions and public exports
rg '__all__\s*=' --type py
rg 'from\s+\.\w+\s+import' --type py --glob '**/__init__.py'
# For each exported symbol, check external usage
rg 'from\s+package_path\s+import.*SymbolName' --type py
rg 'import\s+package_path\..*SymbolName' --type py
This misses wildcard imports, aliased imports, and dynamic imports. Verify each candidate finding manually before
reporting — a grep miss is not proof of zero usage.For each package's consumers:
__init__.py)?
EXCLUDE='--glob !**/*_test.py --glob !**/test_*.py --glob !**/tests/** --glob !**/venv/** --glob !**/.venv/**'
# Deep imports bypassing __init__.py (substitute actual package names)
rg --pcre2 'from\s+package\.internal' --type py $EXCLUDE
rg --pcre2 'from\s+package\._' --type py $EXCLUDE
# Find deep attribute chains (3+ levels)
rg --pcre2 '\w+\.\w+\.\w+\.\w+' --type py $EXCLUDE
For each package, answer:
Produce a single report. Save as YYYY-MM-DD-boundary-hunter-audit-{$LLM-name}.md in the project's docs folder (or
project root if no docs folder exists).
# Boundary Hunter Audit — {date}
## Scope
- Surface: {diff / path / codebase}
- Files: {count or list}
- Exclusions: {list}
## Package Map
| Package | Public Exports | External Deps | Fan-In | Fan-Out |
| ------------- | -------------- | ------------- | ------ | ------- |
| domain/shapes | 5 types, 2 fns | 0 | 8 | 1 |
| infra/svg | 3 fns | 1 (svgwrite) | 2 | 4 |
## Dependency Graph Issues
### Cycles
- A → B → A (via {symbols})
### Direction Violations
- domain/X imports from infra/Y ({symbol}, {file:line})
## Export Surface Issues
### Dead Exports
| # | Package | Export | Type | External Consumers |
| - | ----------- | ---------- | -------- | ------------------ |
| 1 | package/path | `helper_fn` | function | 0 |
### Leaked Internals
| # | Package | Export | Why Internal | Action |
| - | ----------- | --------------- | --------------------- | ------------- |
| 1 | package/path | `_InternalCache` | Implementation detail | Remove export |
### External Type Leaks
| # | Package | Export / Signature | External Type | Action |
| - | ----------- | -------------------------- | -------------- | ---------------------- |
| 1 | package/path | `process(input: LibType)` | `lib.LibType` | Wrap behind owned type |
## Consumer Access Violations
### Deep Imports (Bypassing `__init__.py`)
| # | Consumer | Imported Path | Should Use |
| - | ------------ | -------------------------- | ---------- |
| 1 | file.py:line | `package.internal.helper` | `package` |
### Law of Demeter Violations
| # | Location | Chain | Depth | Action |
| - | ------------ | --------- | ----- | ----------------- |
| 1 | file.py:line | `a.b.c.d` | 4 | Expose API on `a` |
## Replaceability Assessment
### {Package Name}
- Replaceable from interface? {yes/no — why}
- Implicit contracts: {ordering, side effects, timing, etc.}
- Coupling risk: {low/med/high}
## Recommendations (Priority Order)
1. **Must-fix**: {runtime cycles, direction violations, external leaks in domain layer}
2. **Should-fix**: {dead exports, leaked internals, deep imports}
3. **Consider**: {replaceability improvements, `__init__.py` cleanup, train wrecks}
file/path.py:line with the exact code or import statement.rg and import analysis to count actual consumers, not hypothetical ones.development
Transforms vague feature ideas into precise, codebase-grounded technical requirements. Use when requirements are ambiguous/incomplete, the user struggles to describe behavior, terminology is unclear, or multiple concepts are mixed. Output is a requirements spec—NOT an implementation plan.
tools
Audit TypeScript type definitions for design debt — duplicated shapes, missing derivations, over-engineered generics, under-constrained type parameters, reinvented utility types, and disorganized type architecture. Type structure and maintainability, not type enforcement. Use when: reviewing type definitions for maintainability, reducing type duplication, simplifying over-engineered type-level logic, or reorganizing type architecture after growth.
development
Audit TypeScript test code for quality gaps — missing coverage on critical paths, brittle tests coupled to implementation, over-mocking, assertion-free tests, missing edge cases, and duplicated test setup. Focuses on test effectiveness, not production code structure. Use when: reviewing TypeScript test suites for reliability, reducing false-positive test failures, improving coverage of critical business logic, or cleaning up test debt.
tools
Audit TypeScript class and interface design for SOLID violations — god classes, rigid extension points, broken substitutability, fat interfaces, and concrete dependency chains. Focuses on responsibility assignment and abstraction fitness. Use when: reviewing class hierarchies, preparing for extension with new variants, reducing coupling between services, or improving testability of class-heavy code.