Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ronaldjdev/forge/llms.txt

Use this file to discover all available pages before exploring further.

chain builds the complete multi-layer dependency graph for your project. It maps every import relationship across all four architectural layers — platform, features, shared, and infra — then computes a topological sort (the safe build and migration order), detects global dependency cycles, and identifies isolated components that have no inbound or outbound connections. Use chain before migrating a feature (to understand what it depends on), when diagnosing excessive coupling, or any time you need to reason about the full dependency topology of the system.

Usage

"cadena"
"grafo"
"acoplamiento"
Use chain --json to pipe the dependency graph into external visualization tools, custom analysis scripts, or documentation generators.

What chain Analyzes

chain performs a comprehensive dependency analysis across all layers:

Intra-layer dependencies

Dependencies within each layer: components inside platform/ that depend on each other, use cases that reference domain entities, adapters that reference application services.

Cross-layer dependencies

Dependencies between layers: which features consume which platform components, which adapters use which infra implementations, which cross-feature imports exist (valid or in violation of R8).

Topological ordering

The safe build order derived from the dependency graph — components with no dependencies first, then components that depend only on already-listed components. Critical for understanding migration sequencing.

Global dependency cycles

Circular dependency chains anywhere in the graph (regardless of layer). Cycles make the topological sort undefined and are reported as R9 ERROR violations.

Illegal dependency chains

Sequences of individually allowed edges that together violate architectural intent — for example, a path from a feature to infra that passes through a shared component, effectively smuggling a prohibited dependency.

Isolated components

Components that have no inbound or outbound edges — neither consumed by anything nor consuming anything. Often indicates dead code or a component that was scaffolded but never wired.

Output

The --json output contains a structured dependency graph object:
{
  "nodes": [
    { "id": "feature:users", "type": "feature", "layer": "features" },
    { "id": "platform:di", "type": "platform", "layer": "platform" },
    { "id": "infra:prisma", "type": "infra", "layer": "infra" }
  ],
  "edges": [
    {
      "source": "feature:users",
      "target": "platform:di",
      "type": "allowed"
    },
    {
      "source": "feature:users",
      "target": "infra:prisma",
      "type": "violation",
      "rule": "R1"
    }
  ],
  "topologicalOrder": ["platform:di", "infra:prisma", "feature:users"],
  "cycles": [],
  "isolated": ["feature:notifications"]
}
FieldDescription
nodesAll components found, with their layer type
edgesEvery dependency edge, tagged as allowed or violation with the violated rule
topologicalOrderSafe build/migration order — components with no dependencies appear first
cyclesArray of cycle chains; empty array means the graph is acyclic
isolatedComponents with no inbound or outbound edges

Relationship to inspect

chain is not a standalone tool in isolation — it feeds directly into Forge’s architecture audit. The dependency data computed by chain contributes to two inspect scoring categories:
  • Dependencies (15 pts): valid vs. invalid edge ratio, direction violations, cycle detection
  • Graph (20 pts): overall graph health, risk score, and rule violations surfaced by the graph engine
When Forge’s boot sequence runs, chain executes as step 5 so that every subsequent operation — including inspect and inscribe — has up-to-date dependency data.

Dependency Rules Quick Reference

The following dependency directions are allowed in the graph:
feature    → platform   ✅
feature    → shared     ✅
platform   → infra      ✅
adapter    → infra      ✅
feature    → domain     ✅
The following are prohibited and appear as violations in chain output:
feature    → infra      ❌ R1
platform   → feature    ❌ R2
shared     → feature    ❌ R3
shared     → infra      ❌ R4
domain     → infra      ❌ R5
domain     → platform   ❌ R6
infra      → feature    ❌ R7
feature    → feature    ❌ R8 (direct cross-feature import)

Build docs developers (and LLMs) love