@codependix/cli

中文文档
0.0.76发布于 2026/11/10MITTypeScriptES Module构建来源已验证近 30 天下载 9278

Command-line tool for exporting and validating Nx, NestJS, and file-level dependency graphs and boundaries

原始使用文档
文档目录13 节
  1. Usage
  2. The two --check names
  3. Which project a boundary finding fails
  4. When no mode is named
  5. The per-project gate
  6. Where the output goes
  7. The boundary report
  8. Packages
  9. Agent skills
  10. Examples
  11. Start
  12. Test
  13. 👔 Conformetry

🕸️ Codependix CLI

npm

Exports a project's dependency graphs — Nx, NestJS, and file-level imports — as JSON and Markdown diagrams, and gates the rules those graphs are judged against.

Codependix reads what each project depends on and renders it four ways: the Nx project graph, a NestJS project's module graph, a TypeScript project's own file-level import graph, and a Python project's own file-level import graph. Each graph is delivered to whichever destinations codependix.config.ts names for that project — a JSON file, a Markdown anchor block spliced into an existing file such as a README.md, or both. The same built graphs are then judged against whatever rules the configuration declares — see @codependix/boundaries.

pnpm add --filter <project> --save-dev @codependix/cli
codependix map --write --config configuration/codependix.config.ts

Usage

One command, map, and no per-graph-type subcommand. Which graphs run for a project, where its export lands, and which rules judge it is entirely a function of the configuration file, which every run names with --config because nothing searches for it and there is no default; see configuration/codependix.config.ts for this repository's own.

FlagMeaning
--check [check]Fail on a comma-separated set drawn from boundaries and reports
--config <config>Required. Path to the codependix configuration file. Omitting it fails the run, naming the flag; nothing is searched for
--dependenciesBuild --check boundaries over the dependencies of the projects --projects or --tags named, reporting their findings as notes (default). No effect without --projects or --tags
--no-dependenciesBuild --check boundaries over only the projects --projects or --tags named, not their dependencies. No effect without --projects or --tags
-d, --directory [directory]Workspace root whose Nx project graph this run reads. Defaults to the working directory
--exclude [exclude]Comma-separated globs overriding the configured exclude. Refused when exclude was never configured
--file-importsBuild, check, and write the fileImports graph type for this run
--no-file-importsSkip the fileImports graph type for this run
-f, --format [format]What to print to standard output, one of json and markdown (default: markdown). A graph type prints only when the run also configured a workspace destination for it, even if its own toggle flag enabled it. A --check boundaries run adds its findings, under a boundaries key in json and a Boundaries section in markdown
--include [include]Comma-separated globs overriding the configured include. Refused when include was never configured
--json-output [jsonOutput]Write every active graph type's data, combined into one JSON file at this path, keyed by graph type name. A type appears only when the run also configured a workspace destination for it. A --check boundaries run adds its findings under a boundaries key
--markdown-output [markdownOutput]Write every active graph type's rendered diagram, combined into one Markdown file at this path. A type appears only when the run also configured a workspace destination for it. A --check boundaries run adds its findings as a Boundaries section
--nestjs-modulesBuild, check, and write the nestjsModules graph type for this run
--no-nestjs-modulesSkip the nestjsModules graph type for this run
--nx-projectsBuild, check, and write the nxProjects graph type for this run
--no-nx-projectsSkip the nxProjects graph type for this run
--projects [projects]Comma-separated project names or roots to export for, as globs, beyond those include already selects. Also narrows the Workspace Graph to the named set, and --check boundaries to failing only on findings charged to it
--tags [tags]Comma-separated Nx tags to export for, beyond what include already selects. Narrows the Workspace Graph and --check boundaries to the tagged projects, as --projects does
--writeWrites every configured export

The two --check names

--check names which finding fails the run, because the two findings belong on opposite sides of a pull request.

--check valueWhat fails the run
boundariesAn edge, or a cycle, breaking a declared rule
reportsA configured destination no longer holding what a fresh run would write

A boundary violation is caused by the branch and fixed by the branch, so it gates every pull request, one project at a time — see The per-project gate. A stale export moves with the workspace it describes and would fail every branch that changed a project graph rather than anything the branch itself did, so it is published on the default branch and gated nowhere. That is the same split callidescope makes between --check depth and --check reports, and reports is deliberately spelled the same in both: it is the same finding, and two names for it would make the two reports unreadable together.

  • --check boundaries reads no destination and writes nothing, so it leaves every committed export exactly as it found it.
  • --write --check boundaries is legal — a boundary has no destination to be stale.
  • --write --check reports is refused: an export cannot be stale in the run that just wrote it.
  • A bare --check, or one whose value is only separators, is refused. Read as "gate nothing" it would be a gate that cannot fail, which is worse than no gate at all because it looks like protection.

Which project a boundary finding fails

Every finding is charged to the project or projects it belongs to: a cycle to every project owning a node on it, a forbidden edge to the project owning its source, a file- or NestJS-level finding to the project whose graph it was found in, and a container that cannot boot to that container's project — its message naming the project that owns the class it failed on, when the stack shows another one.

--projects and --tags name the projects a run judges. Graphs are built over those projects and everything they transitively depend on, and a finding fails the run only when it is charged to a named project. One charged only to a dependency is logged as a note, "in dependency", without failing: the named project is built on it, but it is not that project's to fix. --no-dependencies builds over the named projects alone. With neither flag every project is judged. A --projects/--tags selection that matches no project at all — a misspelled name, a tag nobody carries, or the workspace root — is refused as a rejected command line rather than run as a gate that judges nothing.

When no mode is named

Naming neither --check nor --write is asked about, as a three-item menu — boundaries, reports, write.

There is no flag that turns the prompt off, because there is nothing to turn off where it cannot be answered: a run whose stdin is not a terminal fails immediately, naming the flag it wanted, rather than drawing a menu. That refusal is load-bearing rather than defensive — prompts does not fail on a non-terminal stdin. It renders the menu, never resolves, and lets the process exit 0, which would turn a scripted run that forgot its mode flag into a silent success that wrote nothing. Dismissing the menu at a terminal is reported the same way, as a rejected command line rather than a crash.

No mode is ever inferred, which is the rule codometer's and callidescope's flags follow too.

In an Nx workspace the gate is a per-project codependix-bound target, and publishing is the one workspace-wide write run. This repository's guard-code reaches the first on every pull request, and its release workflow runs the second on the default branch:

nx run <project>:codependix-bound
nx run configuration:codependix:write

One project failing — a missing anchor, or a NestJS project that fails to boot its container — is reported and does not stop the rest: --write either fully succeeds or names exactly which projects failed while still completing every other one.

The per-project gate

--check boundaries --projects <name> is a gate for one project, and needs no task runner. @codependix/nx infers it for an Nx workspace as a cached codependix-bound target on every project but the workspace root, so nx affected -t codependix-bound selects the projects a change touched and a failure names the project it is charged to rather than one workspace-wide task. The target declares no configurations, so guard-code --configuration=check falls through to its defaults, as callidescope-restrict does.

Publishing stays workspace-wide: one --write run produces every project's anchor blocks, which must reflect one commit, so configuration:codependix is write-only and is not part of guard-code.

Where the output goes

Printing and delivering are separate. --format decides what reaches standard output; the destinations under workspace in the configuration and --json-output/--markdown-output decide what reaches a file.

Markdown is the console default because it is the one rendering that reads in a terminal and pastes into an issue. --format json is for a machine reading standard output, so every diagnostic goes to standard error — keeping standard output clean and parseable as data.

The boundary report

--check boundaries logs its findings to standard error and, given --format, --json-output, or --markdown-output, also prints them as a report: under a boundaries key in JSON, and as a ### Boundaries section in Markdown. A --check boundaries-only run, which exports nothing, prints just that report; a run that also exports carries both in one document. Without one of those flags a boundaries-only run prints nothing, and a run that also exports prints its graphs exactly as it did before.

The JSON holds judgedProjects (the projects whose findings fail the run), violations (level, rule, message, source, target, cycle, the charged projects, and a verdict of fail or note) and failures (level, error, the charged projects, an ownerProject when the failing code belongs to another project, and a verdict). A note is a finding that lives in a dependency of a judged project and does not fail the run. The Markdown lists the same findings under each project they are charged to, a note marked as not failing.

Who a finding is charged to is worked through, with the report each case prints, in four examples: a cycle, a forbidden edge, a dependent of either, and a container that cannot boot.

Packages

PackageRole
@codependix/cliOrchestrates the four graph builders and delivers their exports
@codependix/boundariesBuilds each level's graph for a workspace, judges it against the declared rules, and reports what breaks them. --check boundaries delegates to it wholesale
@codependix/configurationReads codependix.config.ts and resolves per-project export destinations and boundary rules
@codependix/examplesTwenty-one subjects built to be graphed, each with the guide codependix renders from it
@codependix/nxNx plugin: infers a per-project codependix-bound target that runs --check boundaries over the project and its Nx dependencies
@codependix/nx-projectsBuilds a project's Nx Neighborhood and the whole-workspace Workspace Graph
@codependix/nestjs-modulesExplores a NestJS project's container and builds its module graph
@codependix/file-importsBuilds a project's file-level import graph — a typescript module walking its own ts.Program, and a python module parsing import/from ... import statements

Agent skills

Agent skills for coding agents working with codependix are published in @codependix/agents:

SkillDescription
codependix-exportExport dependency graphs and run boundary checks
codependix-configureConfigure graph types, export destinations, and boundary rules in codependix.config.ts
codependix-navigateQuery dependency paths and navigate package relationships
codependix-triageTriage boundary violations and report drift

Examples

Every behavior described above — and every one that is not, because it lived only in a JSDoc comment until now — has a worked example rendered by the real tool in @codependix/examples:

  • README — one directory per example, each readable on its own, plus configuring a first export destination and adopting codependix in a workspace with no anchor blocks anywhere yet
  • AGENTS.md — a "codependix said X → open this example" table, weighted toward the refusals and toward --check staleness

Start

nx run codependix-cli:start

Test

nx run codependix-cli:vitest

👔 Conformetry

This project was generated from the nestjs-command-project conformetry template.

版本与发布记录

@codependix/cli 共发布 74 个版本,首次发布于 2026/10/05;过去 12 个月发布了 74 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.0.76latest2026/11/10今天
0.0.752026/11/091 天前
0.0.742026/11/091 天前
0.0.732026/11/091 天前
0.0.722026/11/082 天前
0.0.712026/11/073 天前

关于 @codependix/cli 的常见问题

@codependix/cli 是什么?

Command-line tool for exporting and validating Nx, NestJS, and file-level dependency graphs and boundaries

如何安装 @codependix/cli?

在项目目录运行 npm install @codependix/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 codependix,可以用 npx codependix 直接运行。

@codependix/cli 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@codependix/cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@codependix/cli 可以商用吗?

@codependix/cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@codependix/cli 的下载量有多少?

根据 npm 官方下载统计,@codependix/cli 在 2026/10/10 – 2026/11/08 这 30 天内被下载 9,278 次,日均约 309 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@codependix/cli 还在维护吗?

最新版本 0.0.76 发布于 2026/11/10(今天);至今共发布 74 个版本,其中过去 12 个月发布了 74 个;首次发布于 2026/10/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。