get_class_hierarchy β
Walks extends and implements edges in both directions. With a symbolId, returns the ancestor and descendant chains for that class or interface. Without one, returns every hierarchy tree in the project rooted at its base classes.
When to use
Any time an interface change could ripple to many implementers, or you need to understand an OOP inheritance chain before overriding a method. This is a specialized (cheaper) counterpart to find_importers for structural inheritance only.
Parameters β
| Name | Type | Required | Description |
|---|---|---|---|
symbolId | string | no | Root the query at this class/interface. Omit for project-wide trees. |
direction | "ancestors" | "descendants" | "both" | no | Which way to walk. Default "both" |
Examples β
Rooted query -- who implements this interface?
json
{
"symbolId": "packages/cli/src/ports/i-storage-port.ts::IStoragePort::interface",
"direction": "descendants"
}Full project inheritance forest:
json
{}Response (rooted) β
json
{
"symbolId": "packages/cli/src/ports/i-storage-port.ts::IStoragePort::interface",
"ancestors": [],
"descendants": [
{
"symbolId": "packages/cli/src/adapters/storage/sqlite.ts::SqliteStorageAdapter::class",
"name": "SqliteStorageAdapter",
"kind": "class",
"file": "packages/cli/src/adapters/storage/sqlite.ts",
"edgeKind": "implements",
"depth": 1
}
],
"_meta": { "totalItems": 1, "returnedItems": 1, "truncated": false }
}Response (full project) β
json
{
"hierarchies": [
{
"symbolId": "packages/cli/src/ports/i-storage-port.ts::IStoragePort::interface",
"name": "IStoragePort",
"kind": "interface",
"file": "packages/cli/src/ports/i-storage-port.ts",
"children": [
{
"symbolId": "packages/cli/src/adapters/storage/sqlite.ts::SqliteStorageAdapter::class",
"name": "SqliteStorageAdapter",
"kind": "class",
"file": "packages/cli/src/adapters/storage/sqlite.ts",
"edgeKind": "implements",
"children": []
}
]
}
],
"totalClasses": 14,
"totalEdges": 13,
"_meta": { "totalItems": 5, "returnedItems": 5, "truncated": false }
}When to use β
- Changing an interface -- list every implementer before you edit the contract.
- Understanding an abstract class -- walk
descendantsto see concrete subclasses. - Architecture review -- full-project mode visualises every inheritance tree; pair with
get_architectural_overlayfor layer context.
Notes β
Edge kinds
Only extends and implements edges are followed. For imports/calls/uses reverse walks, use find_importers.
- Roots in full-project mode are nodes that are the target of an
extends/implementsedge but never the source -- i.e., true base classes or interfaces. If cycles exist, all involved nodes become candidate roots. - Requires
ctxo index.