archy
v0.59.0Architectural sensor for Python codebases.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
archy_score Score project structure
Compute the composite quality score (modularity, acyclicity, depth, equality, complexity - geometric mean of five axes) for a Python project. `view='current'` (the DEFAULT) returns the five-axis score payload; optionally append the result to .archy/history.jsonl (record=True) and/or compare against the most recent same-scope run as a regression gate (strict=True). Without a match, the newest legacy row is used with a scope-unknown reason; history with only opposite-scope rows fails unless record=True. Empty history passes without a comparison. `strict_tolerance` must be in [0, 1] (default 0.02…
| Parameter | Type | Description |
|---|---|---|
path * | string | |
internal_only | boolean | |
last_n | integer | |
record | boolean | |
strict | boolean | |
strict_tolerance | number | |
view | string |
archy_cycles Find import cycles
Find import cycles (Tarjan SCCs of size >= min_size, plus self-loops) in a Python project. Returns cycles sorted largest-first. Each cycle's `type_checking_edges` counts edges that exist only under `if TYPE_CHECKING:` (they never run); when it is non-zero, pass `exclude_type_checking=true` to leave them out. With it on the result is an object, `{cycles, excluded_type_checking_edges}`, so a clean result that is clean only because of the exclusion says so. Unset, it follows archy.yaml's `exclude_type_checking_imports`, else off.
| Parameter | Type | Description |
|---|---|---|
path * | string | |
exclude_type_checking | ||
internal_only | boolean | |
min_size | integer |
archy_check Check layer boundaries
**Call after any Python edit that adds, removes, or changes an import statement.** Returns forbidden direct edges between layers declared in archy.yaml under `violations`, plus Stable Dependencies Principle violations (when `sdp.enabled: true` in archy.yaml) under `sdp_violations`. Empty lists on both mean no direct boundary crossings. `required_violations` reports the INVERSE constraint: `required:` rules in archy.yaml declare that every module matching `source` must TRANSITIVELY reach `must_reach` (e.g. every standalone entrypoint must reach a model registry that has to be imported before th…
| Parameter | Type | Description |
|---|---|---|
path * | string | |
config_path | ||
contracts | boolean | |
contracts_config_path |
archy_impact Compute change blast radius
Given a list of changed file paths, return what they affect. Relative `files` are tried under `path` first; missing paths are retried at its git work-tree root and used if they exist there, inside `path`. `mode='blast'` (the DEFAULT) returns the internal modules that transitively import any of them (the blast radius): use before refactoring or removing a module to see what would break. An empty `impacted` means no STATIC importer was found, not that removal is safe: archy cannot see importlib.import_module / __import__ with a computed or relative name, entry points and plugin registries, Djang…
| Parameter | Type | Description |
|---|---|---|
files * | array | |
path * | string | |
co_change | boolean | |
depth | integer | |
max_chains | integer | |
mode | string | |
test_filter |
archy_snapshot Snapshot baseline
Capture score, cycles, and layer violations to .archy/baseline.json as a baseline that archy_diff will compare against. Call at the start of an editing session. Also returns `invariant_brief`: the constraints to know before your first edit (declared layers, forbidden inter-layer edges, whether the graph is acyclic, the baseline score per axis, and the top load-bearing / highest-risk modules). Read it up front to avoid proposing a cross-layer or cycle-introducing edit, rather than being told after the diff. See the `loop` prompt for full usage.
| Parameter | Type | Description |
|---|---|---|
path * | string |
archy_diff Diff against baseline
Compare the current project state to the last snapshot. Returns a risk-weighted `summary` (headline + top regressions / improvements), per-component score deltas, and the cycles and layer violations that have been added or resolved since the baseline. Use after edits to localize regressions; see the `loop` prompt. `strict=True` with `baseline` (a committed file, relative to `path`) adds `strict`. `passed` is false when a cycle, layer violation or required-reach violation is new, or when archy.yaml removes or narrows a rule the baseline fingerprint records. `reason` names it. A baseline with no…
| Parameter | Type | Description |
|---|---|---|
path * | string | |
baseline | ||
strict | boolean |
archy_simulate Simulate import-edge change
Counterfactual pre-edit check: given a proposed import-edge delta (`add` / `remove` lists of {from, to} module-or-path pairs), return the structural consequence BEFORE any file is written -- new/resolved cycles, cycle-closing edges, new layer/SDP violations, per-axis score delta, and the propagation_cost change -- with a risk-ranked `summary` phrased conditionally ('would form a cycle'). Use it to test a refactoring hypothesis and reshape the plan before editing. Endpoints matching no internal module are returned in `applied.unresolved` with a `did you mean` in `applied.unresolved_hints`; a sp…
| Parameter | Type | Description |
|---|---|---|
path * | string | |
add | ||
remove |
archy_graph Inspect dependency graph
Inspect the dependency graph. With no `focus`, `response_format='summary'` (the DEFAULT, replaces the removed archy_graph_summary) returns a compact top-N overview (modules by fan-in, fan-out, PageRank, and edit-risk, plus top external deps; `top_n` controls N) so a routine call doesn't dump the whole graph into context; `response_format='full'` returns the complete node/edge dump matching `archy graph --format json`, but refuses graphs larger than `max_nodes` (default 500, must be >= 1) with a GraphTooLargePayload (bump it explicitly, or narrow with `focus`). Pass `focus=[<qualname or path>]`…
| Parameter | Type | Description |
|---|---|---|
path * | string | |
depth | integer | |
direction | string | |
focus | ||
internal_only | boolean | |
max_nodes | integer | |
response_format | string | |
top_n | integer |
archy_what_to_refactor_next Rank refactor priorities
Ranked refactor-priority list (replaces the removed archy_hotspots and archy_high_risk_modules via `lens`). `lens='fused'` (the DEFAULT) merges the behavioral lens (cyclomatic complexity x git churn) and the structural lens (the edit-risk composite: central and fragile) into one summed priority, so a module flagged by both generally outranks a single-lens one. `lens='behavioral'` ranks CC x churn hotspots only, those scoring at least 5% of the project maximum (needs git; answers 'where is the refactoring leverage?'); `lens='structural'` ranks the edit-risk composite only (git-free; answers 'is…
| Parameter | Type | Description |
|---|---|---|
path * | string | |
lens | string | |
min_risk | number | |
since | ||
top_n | integer |
archy_dsm Design Structure Matrix
Design Structure Matrix view of the import graph. `response_format='summary'` (the DEFAULT) returns a compact overview -- block structure (group labels + sizes), counts, the back-edges (source later than target in the ordering = the cycle signal), and inter-block coupling -- without the full cell list, so a routine call stays small. `response_format='full'` returns the full matrix the agent reads positionally: cell (row=source, col=target) is non-empty when source imports target; it refuses matrices with more than 2000 cells with a DSMTooLargePayload (narrow with `focus`/`package`, or read the…
| Parameter | Type | Description |
|---|---|---|
path * | string | |
baseline_path | ||
focus | ||
focus_depth | integer | |
group_by | string | |
package | ||
response_format | string | |
weight | string |
archy_duplicates Duplicate-function clusters
Cluster functions with an identical normalized body shape (identifiers/literals folded to placeholders). Returns two tiers: `duplicates` (the primary 'likely duplicate' list to investigate) and `variants` (demoted clusters that are likely intentional: same-class siblings, boilerplate, copies wholly in test suites or vendoring/isolation dirs, and - with `co_change` (the DEFAULT) - `independent` copies whose files are actively maintained yet never co-change in git, i.e. deliberately parallel implementations; each carries a `variant_reason`). Within the primary tier, `exact=true` marks byte-ident…
| Parameter | Type | Description |
|---|---|---|
path * | string | |
co_change | boolean | |
members | integer | |
min_nodes | integer | |
near_miss | boolean | |
response_format | string | |
top_n | integer |
archy_conventions Report the project's house style
**Call before adding a new class, field, or command to an unfamiliar project.** Derives the repository's own conventions from its source instead of leaving you to infer them by reading. Returns five censuses: `naming` (class-name suffix families GROUPED BY HOME MODULE, so the module you are about to edit shows its own patterns - the answer to 'what do I call a new one and where does it go'), `surfaces` (mirrored helper sets like `_x_to_text`/`_x_to_json` and names defined in several modules - the answer to 'how many places must I wire a new field'), `gates` (sites where a FAILED FINDING exits…
| Parameter | Type | Description |
|---|---|---|
path * | string | |
include_tests | boolean | |
min_family | integer |
archy_module_view Everything known about ONE module, complete and unranked
**Call when the question is a NEGATIVE.** `archy_conventions` ranks and truncates, so a module's absence from it means nothing; every list here is COMPLETE for the one `module` named, so absence IS the answer, about STATIC edges only: an empty `imported_by` does not rule out importlib.import_module / __import__ with a computed or relative name, entry points, plugin registries, INSTALLED_APPS, pytest plugins or config-driven dispatch, so `rg` for those before calling a module dead. Use it for `does risk import hotspots`, `does anything still reach layers`, `is this module dead`. Returns `import…
| Parameter | Type | Description |
|---|---|---|
module * | string | |
path * | string | |
include_tests | boolean |
archy_brief One bounded briefing before touching an unfamiliar repository
**Call once, before starting on an unfamiliar repository.** Composes `archy_conventions` (naming, mirrored surfaces, gates, export and doc gaps), the layer `coverage` of `archy.yaml` and, with `contracts=True`, the transitive import-linter verdict, into one answer to 'what do I need to know before I touch this'. `top_n` (default 8) bounds the ranked sections and `conventions.totals` says how many were dropped; `gates`, `errors`, `export_gaps` and `doc_gaps` are never truncated. `coverage` is null when there is no usable archy.yaml; `coverage_error` carries the error when one parsed but its lay…
| Parameter | Type | Description |
|---|---|---|
path * | string | |
contracts | boolean | |
include_tests | boolean | |
top_n | integer |