Skip to content
Unofficial community docs. Content pulled on 2026-10-24 from Trail-Code@d205ac3. For the latest, see the official repo.

Work with monorepos

The graft map supports one repo with many packages, submodules, nested clones, and folders of separate repos.

A pnpm-workspace.yaml/package.json workspaces, or per-package go.mod/pyproject.toml/Cargo.toml. No flags needed:

Terminal window
trail build

trail build discovers each sub-project as a ranking scope. ask/map rank every scope on its own terms and fuse the results, so the biggest sub-project can’t drown a small one; hits carry [scope/] labels, and trail map groups its directory clusters by scope first.

Submodules stay excluded by default. To fold initialized gitlinks into one graph:

Terminal window
trail build --follow-submodules

Child paths are prefixed (for example, deps/parser/src/index.ts), and each submodule’s own Git ignore rules are honored. Visible untracked files are included too; uninitialized submodules remain absent until git submodule update --init checks them out.

The choice is saved in .graft/config.json, so later no-flag builds and MCP automatic refreshes behave the same way. To restore and persist the default boundary:

Terminal window
trail build --no-follow-submodules

A git repo with other repos cloned inside it

Section titled “A git repo with other repos cloned inside it”

No gitlink, no index entry: the shape multi-repo manifest tools like west, repo, gclient and tsrc check dependencies out into, and the shape you get by cloning an upstream into the tree to patch it locally. --follow-submodules cannot reach these: they have no 160000 index entry to follow. Instead:

Terminal window
trail build --follow-nested-repos

Child paths are prefixed (for example, external/parser/src/index.ts), and each clone’s own Git ignore rules are honored. A clone at a git-ignored path stays absent, since Git never reports it.

The choice is saved in .graft/config.json and is independent of --follow-submodules; neither flag implies the other. To restore and persist the default boundary:

Terminal window
trail build --no-follow-nested-repos

No .git at the top. trail build auto-splits: each child gets its own (git-ignored) graft/, and the parent gets a graft/workspace.json index. Queries from the parent federate across every child, always labeled <child>/. Run trail build inside a child to work on just that repo.

trail init at the parent of a multi-repo folder wires every child repo too, not just the parent. An agent session opens at a repo root and reads its instruction files from there, so each child needs its own. A session started in the parent gets the federated view; one started in a child sees that repo alone.

In every layout, narrow to one sub-project once you know where you’re working:

Terminal window
trail ask "<task>" --in <scope>/

Commands also find the graph from a subdirectory: with no [dir] argument they walk up to the nearest graft/, so trail ask works from src/deep/inside/ without a cd to the repo root.