CLI Reference
Full option reference for graph commands. Read more
Unfault builds a graph of your codebase: which files import which, which functions call which, which libraries are used where. The unfault graph command lets you query this graph to understand your code’s structure and plan changes safely.
Before changing code, you want to know what might break. The graph answers questions like:
auth.py, what else needs to change?”requests library?”These questions are hard to answer by grepping. The graph understands imports, function calls, and transitive dependencies.
Before refactoring a file, see what depends on it:
unfault graph impact src/api/auth.pyOutput:
🔍 Impact Analysis: src/api/auth.py
→ This file is used by 15 file(s) 10 direct, 5 through transitive dependencies
Direct DependenciesFiles that import this directly — changes here affect them first──────────────────────────────────────────────────────────── • src/api/routes/users.py [Python] • src/api/routes/admin.py [Python] • src/api/middleware/auth.py [Python] • src/services/payments.py [Python] ...
Transitive DependenciesFiles that depend on this indirectly — ripple effects──────────────────────────────────────────────────────────── →→ src/api/routes/orders.py [Python] (2 hops) →→ src/api/routes/checkout.py [Python] (2 hops) ...
💡 This is a hub file. Consider extra care when modifying.The direct dependents are files that import from auth.py. Transitive dependencies show files that depend on those dependents. Changes ripple outward.
By default, transitive analysis goes 5 levels deep. For large codebases, you might want to limit this:
unfault graph impact --max-depth 2 src/core/models.pyOr expand it for a fuller picture:
unfault graph impact --max-depth 10 src/core/models.pySometimes you’re changing a single function, not a whole file. The graph can be more precise:
unfault graph function-impact src/api/auth.py:validate_tokenThis shows only the files and functions that call validate_token, not everything that imports auth.py.
Auditing a dependency? See where it’s used:
unfault graph library requestsOutput:
📚 Library Usage: requests
→ 'requests' is used in 7 file(s)
Usage LocationsThese files import this library directly──────────────────────────────────────────────────────────── • src/clients/payment.py [Python] • src/clients/shipping.py [Python] • src/scripts/migrate.py [Python] • src/services/notifications.py [Python] ...
💡 This library is used widely. Consider its stability and versioning.This is useful when:
requests to httpx)The inverse question: what does this file depend on?
unfault graph deps src/api/routes/payments.pyOutput:
Dependencies for src/api/routes/payments.py
Internal imports (5): ← src/api/auth.py ← src/core/models.py ← src/services/stripe.py ← src/services/notifications.py ← src/utils/logging.py
External libraries (4): ← fastapi ← sqlalchemy ← pydantic ← structlogThis helps when:
Every codebase has hub files: highly connected, imported by many others. These are your most critical files. Changes to them have wide impact.
unfault graph criticalOutput:
🎯 Hub Files AnalysisFiles with the most connections — changes here have the widest impact
→ Analyzing 185 files, showing top 10
# File In Out Libs Score ───────────────────────────────────────────────────────────────── 1 src/__init__.py 56 0 0 112 2 src/database.py 47 1 11 106 3 src/dependencies/database.py 28 1 2 59 4 src/config.py 27 0 4 58 5 src/schemas.py 19 0 3 41 ...
💡 '__init__.py' is a major hub. Consider extra review for changes.
Legend: In: dependents | Out: dependencies | Libs: external packages Higher score = more central to the codebaseThese are files to handle with care. Changes here ripple widely.
You can sort by different metrics:
# Files most imported by others (default)unfault graph critical --sort-by in-degree
# Files that import the most (sprawling dependencies)unfault graph critical --sort-by out-degree
# Total connectivity (hubs)unfault graph critical --sort-by total-degree
# Most external library usageunfault graph critical --sort-by library-usage# Top 20 critical filesunfault graph critical --limit 20
# Just the top 3unfault graph critical --limit 3For a high-level view of your codebase structure:
unfault graph statsOutput:
🗺️ Code Graph OverviewA map of your codebase structure and connections
→ 723 code units across 185 files
Structure───────────────────────────────────────────── 📄 Files 185 ⚙️ Functions 723 📦 Classes 0 📚 External Libraries 69───────────────────────────────────────────── Total nodes 978
Connections───────────────────────────────────────────── 🔗 File imports 409 📍 File→function/class 731 📚 Library usage 656 ➡️ Function calls 628───────────────────────────────────────────── Total edges 2680All graph commands support --json for programmatic use:
unfault graph impact --json src/api/auth.pyunfault graph critical --json --limit 5This is useful for:
Check what depends on the file you’re changing:
unfault graph impact src/core/models.pyIf the impact is large, consider whether to:
After making changes, run a review to catch issues:
unfault reviewFind all usage of the library:
unfault graph library requestsCheck each file for patterns (timeouts, retries):
unfault review --dimension stabilityIf migrating, you now have a complete list of files to update.
Get the overall shape:
unfault graph statsFind the critical files (these are the “load-bearing walls”):
unfault graph critical --limit 10Pick a critical file and see what depends on it:
unfault graph impact src/core/models.py