Code graph for large repositories and monorepos. Use it, before grep or reading files, when the question is what a change will break (blast radius, impact analysis), who uses a file, function, type or package, where a feature is implemented, which files to read first, or how modules and packages depend on each other; before a refactor, a cross-package change or any non-trivial edit; and when exploring an unfamiliar codebase. Builds and queries architecture-aware code search, dependency graphs...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of wingbox?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/aileron-tech-wingbox)
---
name: wingbox
description: >
Code graph for large repositories and monorepos. Use it, before grep or
reading files, when the question is what a change will break (blast radius,
impact analysis), who uses a file, function, type or package, where a feature
is implemented, which files to read first, or how modules and packages depend
on each other; before a refactor, a cross-package change or any non-trivial
edit; and when exploring an unfamiliar codebase. Builds and queries architecture-aware code search,
dependency graphs, call flows, module boundaries and architecture violations
for Python, TypeScript, TSX, Rust, C, C++, C#, Java, Go, Ruby, Ruby on Rails,
PHP, Laravel, Blade, Livewire, Eloquent, Dart and Flutter.
---
# Wingbox -- Code Graph Architecture Discovery
Query `.wingbox/index.sexp` to discover modules, boundaries, and dependencies before reading source files. Never read code blindly -- query the graph first.
## /wingbox
When the user types `/wingbox` (in Codex `$wingbox`), do this before anything else:
(when `command -v wingbox` finds nothing, read "Running the commands" below first)
- `/wingbox` with no argument: find the graph (`.wingbox/index.sexp` in the
project root; every `wingbox` command finds it from a subfolder too). Build
it with `wingbox build .` when it is missing or stale. The graph is stale
when a file of the project was modified after the graph file; this check
finds one:
```bash
G=.wingbox/index.sexp
[ ! -f "$G" ] || find . -type f -newer "$G" -not -path './.git/*' \
-not -path './.wingbox/*' -not -path '*/node_modules/*' -print -quit
```
A rebuild re-parses only the files whose content changed. Then read
`.wingbox/REPORT.md` and give the user its "Key findings", the most
depended-on modules and where to start reading, and say that the map is
`.wingbox/map.html` (`wingbox open` shows it in a browser, offline).
- `/wingbox <file>`: run `wingbox impact <file> 2` and summarize what depends
on the file and which files to read first.
- `/wingbox <command> ...`: run `wingbox <command> ...` (for example
`/wingbox quick "file upload"`, `/wingbox analyze src/billing/invoice`).
## Running the commands
When the `wingbox` command is installed (`command -v wingbox`), run
`wingbox <command> ...` for every query below and `wingbox build PATH` to build;
they take the same arguments as the scripts. A skill installed by
`wingbox install` has no `scripts/` folder and always uses the command.
When the command is missing and this skill has no `scripts/` folder (a skill
installed from a plugin directory), install the program before the first
query. Tell the user in one line that Wingbox needs its open-source program
(MIT, it runs on this machine), then run the first of these the machine has:
```bash
pipx install wingbox
uv tool install wingbox
```
With neither pipx nor uv, ask the user to install one of them
([pipx](https://pipx.pypa.io/stable/installation/),
[uv](https://docs.astral.sh/uv/getting-started/installation/)) and stop there.
After the install run `wingbox build .` in the project: it writes only the
`.wingbox/` folder. Leave `wingbox install` to the user: it changes their own
assistant settings.
The package installs the parsers of every language, and Wingbox opens no
network connection. Where a parser is missing all the same (Dart on Windows
arm64, a broken install), a build warns that files were skipped and every
answer carries `(skipped-language dart :files 214 :add "pip install \"wingbox[dart]\"")`:
the graph does not hold those files. Tell the user in one line; with their
approval run the command of `:add` in the environment that runs Wingbox, then
`wingbox build`. Until then, search the files of that language with `rg`.
| Command | Purpose |
|---|---|
| `wingbox install [--assistant NAME ...] [--without ITEM,...] [--global-gitignore] [--yes] [--dry-run]` | Set up the assistants in the user's settings: this skill, the always-on block in CLAUDE.md / AGENTS.md, the Claude Code hooks. Items: `skill`, `block`, `search-hook`, `edit-hook`, `session-hook` (refresh a stale graph at session start), `git-hook` (refresh after git switch/pull/merge...); `--without` leaves items out (`ITEM` or `ASSISTANT:ITEM`, comma separated), and the choice is remembered. Select **Global Git ignore** or pass `--global-gitignore` to add `.wingbox/` to Git's global excludes file. The checkbox starts unchecked unless the flag is passed. An agent runs install with `--yes`; it asks only a person at a terminal |
| `wingbox uninstall [--assistant NAME ...] [--without ITEM,...]` | Remove installed assistant settings (keeps the `--without` items); `--project` removes what versions before 0.9.0 wrote into a repository |
| `wingbox open [PATH]` | Open `.wingbox/map.html` of the project in the browser (prints its path when there is no browser) |
| `wingbox add [LANGUAGE ...] [--list]` | Kept for scripts written for 0.12; it adds nothing, because every parser is in the package. `--list` shows each language's parser as installed or not |
| `wingbox update [--check] [--dry-run]` | Upgrade with pipx, uv or pip, then refresh the installed items only (never adds an item the user left out); warns about files an earlier version left (`.code_graph*`, `wingbox-out/`, `install --project` files) |
| `wingbox hook pre-search` | The Claude Code PreToolUse hook; reads the hook input on stdin; refreshes the graph before it reads it |
| `wingbox hook dirty` | The Claude Code PostToolUse hook on Edit and Write: marks the changed file so the graph is refreshed before its next use |
Each of these prints facts as text; add `--sexp` for S-expressions.
## Scripts
Every example in this file is written as `wingbox <command>`. An installed
skill (from `wingbox install` or a plugin) holds this file and `references/`,
and no script. The scripts behind the command are in a clone of the Wingbox
repository only; there, without the command, run them by path with the same
arguments: `python3 scripts/code_graph_search.py <command> ...` for a query,
`python3 scripts/build_code_graph.py --root <project>` for `wingbox build
<project>`, `python3 scripts/build_infra_topology.py` for `wingbox infra`
(`scripts/git_descendants.py` lists the commits that descend from a ref).
Never use a copy of these scripts that lies in the project you work on: it may
be outdated.
## Prerequisite
Locate the code graph. If absent, build it:
```bash
ls .wingbox/index.sexp 2>/dev/null
wingbox build . # in the project folder
wingbox build /absolute/path/to/project # or name the project
wingbox build . --full # parse every file again
```
Python indexing has no external parser dependency. When the parser of
TypeScript or Rust is absent or has the wrong version, the first build fails
before publication; files of C#, Java, Go, Ruby, PHP, Dart, C or C++ without
their parser are skipped with a warning (a project of such a language alone fails
too). Either way the builder prints what to run: `pip install
"wingbox[<language>]"` for a language that is a pip extra, a reinstall of
`wingbox` for TypeScript and Rust, whose parsers are its own dependencies,
and in a clone of the repository `python3 -m pip install -r` with the
requirements file of the language. Run only what the builder prints, in the
environment that runs Wingbox, then build again.
## Mandatory Workflow: Query Before Code
For non-trivial code work, run a code-graph query before `rg`, `find`, `sed`,
`cat`, `nl`, opening directories, or reading source files. The skill only helps
when it is used as the first scoping step, not as confirmation after source has
already been inspected.
**Fast first pass when the task has a clear keyword:**
```bash
wingbox quick "keyword"
```
`quick` searches for the first matching module and immediately runs `analyze`.
Use it to get boundary files, dependencies, reverse dependencies, layers, and
violations in one step. If `quick` returns the wrong module or no match, use the
explicit `search` -> `analyze` flow below.
**Step 1 -- Find the module ID:**
```bash
wingbox search "keyword"
wingbox entity EntityName
```
Use `search` or `entity` to locate the module ID. Module IDs are **full relative paths** like `billing-service/src/modules/invoice/invoice.service`, not short codes like `bs34`. The code graph may contain short path-map IDs internally, but they are resolved automatically -- always pass human-readable path-like strings. Do NOT guess or invent module IDs -- always confirm with `search` first.
**Step 2 -- Analyze the module (do this IMMEDIATELY, not optionally):**
```bash
wingbox analyze <module-id>
```
`analyze` is the PRIMARY command. It returns the full context: boundary files, dependencies, reverse dependencies, architecture layer, and violations. Always run it before reading any source.
**Step 3 -- Read only the boundary files listed in the analyze output.**
**Step 4 -- Do NOT read entire directories.** If the boundary shows 2-3 relevant files, read only those files. Ignore everything else in the directory.
## Command Reference
| Command | Purpose | Example |
|---|---|---|
| `search "<pattern>" [--lines]` | Safe literal/`.*` search on graph; `--lines`: the facts as stored, with the source lines of `imports` and `refs` and the `built-from` fact | `search "operative.*service"` |
| `analyze <id>` | Full module analysis (PRIMARY command); ends with the `(advice ...)` that concerns the module | `analyze drive/modules/drive/drive_schema` |
| `quick <keyword>` | Search + analyze first match (shortcut) | `quick operatives` |
| `boundary <id>` | Files to read for a change | `boundary operatives.service` |
| `boundary <id> --files-only` | File paths only (compact) | `boundary operatives.service --files-only` |
| `entity <Name> [--positions]` | Find definitions + the modules that use them; `--positions`: every use with line and column | `entity DrivePath --positions` |
| `usages <symbol>` | Every use of one symbol (`Name`, `<file>::Name`, `<file>::Class.method`) through re-exports and aliases, by file, `line:col` and kind (import, re-export, call, type, extends, reference; `unresolved-call` for a method call whose receiver type is not in sight); a name defined in several files lists the candidates | `usages src/billing/invoice.ts::Invoice` |
| `deps <id> [depth]` | Outgoing dependency tree | `deps operatives.service 3` |
| `rdeps <id> [depth]` | Blast radius (who depends on this) | `rdeps drive_schema 2` |
| `impact <file\|id> [<file\|id> ...] [depth] [--only tests] [--summary]`, `impact --diff [ref]` | Blast radius of each file asked, one answer per file in the order given: dependents by shortest depth, each with the reason it is listed (the import, the item names, the file it is reached through) + files to read first; a last argument that is a number is the depth; with several files the answer opens with `(graph :built ... :files N :stale N)`; a file that is not in the graph gives `(error no-match ...)` in its place and exit status 1; ends with the advice that concerns the file. `--only tests` keeps the test files (the tests to run) and, where the CMake files state targets and tests, adds `(affected-targets <file> <target> ...)` and `(affected-tests <file> <test> ...)`, and `(unread-targets <file> <target> ...)` for the targets whose source list was not all read; `--summary` answers in a few lines for a file with hundreds of dependents: `(impact-summary <file> :direct N :total M ...)` with the counts by depth and kind, the folders, twenty files to look at first and the command of the complete list; `--diff [ref]` answers for the files a diff changes (default: the working tree against `HEAD`) and adds `(changed <file>::<name> :line N :used-by (...))` per changed function; a C or C++ source file is answered through its header, rows marked `:basis paired-header` | `impact src/billing/invoice.service.ts src/billing/tax.ts 2`, `impact --diff --only tests` |
| `flow <id> <fn>` | Trace call/data flow | `flow drive_api fetchFiles` |
| `module <id> [--lines]` | Single module with edges; `--lines`: each `imports` and `refs` fact names the line of the statement it is read from (`:line 7`, `:lines 3 9`), in the file of its source module | `module operatives.controller --lines` |
| `wingbox init --from-folders PART [--force] [--sexp]` | For a part no layer style fits (`.` is the repository, or a folder): read the graph and write the part into `.wingbox/config.yaml` with `style: declared` and `order:`, one layer per folder, lowest first; adds `/.wingbox/` to the project ignore file and prints the order and upward imports. Then `wingbox build .`, `wingbox boundaries`; `wingbox align --learn` accepts today's upward imports | `wingbox init --from-folders engine/src` |
| `wingbox init [PATH] [--force] [--sexp]` | Split the repository into parts, judge the architecture style of each (with score, evidence and sources), write `.wingbox/config.yaml` (kept unless `--force`) and `.wingbox/assistant-setup.md` (the lines a team may add by hand to AGENTS.md, CLAUDE.md and .claude/settings.json), and add `/.wingbox/` to the project's `.gitignore`. In an empty folder `--language L --style S --yes [--scaffold]` starts a new project (without them it prints the choices and exits 2) | `wingbox init --sexp` |
| `wingbox advice [--learned]` / `wingbox advice accept\|reject <id> [--reason TEXT]` | Open recommendations of the last build (move, fix-violation, missing-folder) without the rejected or long-ignored ones; a recommendation to fix a finding (`fix-violation`, `fix-capability`, `fix-pattern`) is never hidden by inaction and is rejected only with `--reason`; record a decision in `.wingbox/decisions.sexp` | `wingbox advice` |
| `wingbox align [PART] [--to STYLE] [--learn]` | Gaps of each part against its style (placed files, rules followed, unplaced folders, broken rules); `--to` against another style; `--learn` writes learned folders and a baseline so that only new violations are reported; a baseline entry may state `:owner "<who>" :reason "<why>" :expires YYYY-MM-DD` (written by the person who accepts the break, never by you on your own), and past that day the break is a violation again | `wingbox align` |
| `wingbox place "<what>" [--part PART]` | Layer and folder for new code by the placement rules of the part's style (`:new` when the folder does not exist yet) and what it may import | `wingbox place "repository for invoices"` |
| `wingbox compare` | Parts of a monorepo per language: style, layers, differences (missing layers, a folder name meaning another layer, a style unlike the majority) and advice for the part that deviates | `wingbox compare` |
| `wingbox learn --agent [PART] [--sexp]` / `wingbox learn --apply [FILE]` | `/wingbox learn`: run `wingbox learn --agent`, read the files it names, answer only in its format (`(layer <part> <folder> <layer> :because "...")`, `(unknown ...)`, at most one `(style ...)`), pipe the answer to `wingbox learn --apply`, show the result; on errors fix the named lines and send the whole answer again. When the code does not decide a folder, ask the user in the chat and answer with `:because "operator: <their words>"`; never guess. To change `.wingbox/config.yaml`, follow the instructions at its top | `wingbox learn --agent` |
| `boundaries [id\|all]` | Check the boundary rules of each part's style (or of rules the part declares); each line names `:part`, `:style` and `:rule`; type-only imports and guessed layers are reported apart; then what files do that their layer may not (`capability-violation`: SQL outside the repositories, outbound HTTP outside infrastructure, the framework in the domain, with `:line` and `:evidence`) and the style's pattern checks (`pattern-violation`). `boundaries-ok` only when every part was checked and nothing breaks a rule; a part whose declared rules were not read or without a determined style, files in no part, a part with no file in a layer and source files in a language without a parser are `boundaries-not-checked` (with the `:reason`) with `boundaries-partial` instead of ok. `:checked` counts the files a rule places; files of a checked part in no layer are counted apart (`boundaries-no-layer`, `:no-layer N`). `boundaries-rules-changed`: a rule file changed after the build, rebuild. Exit status: 2 not checked (declared rules not read, or a scope that matches no module), 1 violations, 0 otherwise - never report a pass on exit 2. For a gate add `--strict`: the last line is `(boundaries-result :status pass\|fail\|incomplete\|error :checked N :not-checked N :violations N :known N [:no-layer N] [:reason R])`, each checked part has a `(boundaries-checked :part P :style S :modules N)` fact, and the exit status is 0 pass, 1 violation, 2 incomplete (anything not checked or not read, a graph older than the files or the rule files, or no file checked), 3 error (no graph or a graph that cannot be read) | `boundaries all`, `boundaries all --strict` |
| `invariants [id\|all]` | Check naming convention violations | `invariants all` |
| `layers` | Show all modules by layer, with the part, style and rule that set each layer | `layers` |
| `cycles [folder]` | What the import graph says without a layer style: `(cycle ...)` groups of files that depend on each other, `(hub ...)` files with ten or more dependents and dependencies, `(folder-cycle a b ...)` folders that depend on each other, `(folder-order ...)` the folders from dependents to dependencies; with a folder, its files and subfolders | `cycles`, `cycles engine/src` |
| `find_function <name>` | Find function/method definitions | `find_function createOrder` |
| `find_type <name>` | Find type/class/module/interface/enum definitions | `find_type DriveDbCommitResponse` |
| `find_callchain <src> <tgt> [depth]` | Trace call path between functions | `find_callchain createOrder processPayment` |
| `find_callers <fn> [depth]` | Who calls this function | `find_callers handleRequest 3` |
| `find_calls <fn> [depth]` | What does this function call | `find_calls createOrder 2` |
| `grep_functions <pattern>` | Search function bodies in source | `grep_functions "validate.*input"` |
| `diff_functions [ref]` | Changed functions in git diff | `diff_functions HEAD~3` |
| `files [pattern]` | The source files of the graph: path, module, language, layer | `files "tests/.*pricing"` |
| `source <file\|Name\|file::Name> [first] [last]` | The lines of a source file of the graph or of one definition, numbered (400 a call) | `source createOrder` |
| `grep <text> [path-pattern] [--first N]` | The lines of the source files of the graph that hold a text, with file and line (200 a call, `--first` goes on); every character literal but `.*`, `^` first and `$` last | `grep "Basket is empty"` |
| `query '<sexp>'` | Composable Scheme query | `query '(count (boundary "X"))'` |
| `repl` | Interactive Scheme REPL | `repl` |
| `wingbox mcp [--root DIR]` | Run these commands as tools of an MCP server on stdio (`build_graph`, `list_files`, `describe_module`, `read_source`, `search_source`, `find_definitions`, `find_usages`, `analyze_impact`, `list_dependencies`, `trace_calls`, `list_layers`, `check_boundaries`, `list_changes`, `query_graph`) for MCP clients | `claude mcp add wingbox -- wingbox mcp` |
`impact` accepts ordinary file paths, several in one call.
Every command of this table and `advice`, `align`, `place` and `compare` print
S-expressions by default: the compact form to read, complete. `--human` prints
the text for people, whose long lists stop at a limit unless `--all`; `--json`
prints the same answer as one JSON object.
`wingbox init` and `wingbox learn` print text (facts with `--sexp`). The commands
that took `--sexp` up to 0.13 still take it and print the flat facts of that version.
### Use from code
A script gets everything about several files in one call and reads it as JSON:
```python
answer = json.loads(subprocess.run(["wingbox", "impact", *files, "2", "--json"], capture_output=True, text=True).stdout)
dependents = {a["file"]: [row["file"] for row in a.get("rows", [])] for a in answer["impact"]}
```
`answer["graph"]["stale"]` is 0 when the graph is up to date. Each row carries
the reason it is listed: `depth`, `via` (the relation), `through` (the file it
is reached through), `basis` (`declared` or `inferred`, present only when the code does not state
the edge) and `reasons` (the names it takes). A file that is not in
the graph has `error` in place of `rows`. The rows are complete (each dependent
once, the list not cut, test files included). In Claude Code's Code Mode follow
[references/code-mode.md](references/code-mode.md): one call in one block of
code whose value is the answer.
## Quick Reference: Targeted Lookups
Do not search `.wingbox/index.sexp` for a path with `rg`. The graph file
names every module by a short ID and maps the paths to those IDs once, in its
`(paths ...)` form, so an import is stored as `(imports q21 q24 :line 1)`:
`rg 'imports .* src/billing/tax' .wingbox/index.sexp` finds nothing, and
nothing found there does not mean that nothing imports the module. Ask the
commands, which print full paths:
```bash
# One module: its entities and edges, each import and ref with its line
wingbox module drive/modules/drive_db/api/drive_db_api --lines
# Who imports a module, and what it imports (one hop)
wingbox rdeps drive/modules/commons/result 1
wingbox deps drive/modules/drive_db/api/drive_db_api 1
# Where an entity is defined and which modules refer to it
wingbox entity DriveDbCommitResponse
# The classes, interfaces and types whose name matches
wingbox find_type "Drive.*Response"
# The stored facts of one kind, as the graph file holds them
wingbox search "data-flow" --lines
wingbox search "registry-wires" --lines # Python modules loaded by a name read from a configuration file
# A text in the source files of the graph
wingbox grep "Basket is empty"
```
`search <pattern>` answers with module IDs when the pattern matches a module
path; otherwise it prints the stored facts that match, with `--lines` as the
file holds them. Those facts name modules by short ID: `wingbox module <short
id>` prints the module of one. A short ID belongs to one build of the graph,
so never keep one or pass one on.
## Output Notation
The default output is S-expressions: fact lines, and for `impact` and `usages` one compact form per answer. See [references/sexp-notation.md](references/sexp-notation.md) for the full format.
Key patterns:
```scheme
(boundary <mod> :lang py :file <path> :purpose "<desc>")
(boundary-dep <mod> <dep> :lang ts :file <path> :relation imports)
(boundary-rdep <mod> <rdep> :lang tsx :file <path> :relation imports)
(boundary-summary <mod> :total 10 :deps 7 :rdeps 2)
(impact <file> :direct 2 :total 3 (1 <file> <file> (:use Name)) (2 (:through <file> <file> :more 1)) (read-first <file> ...))
(usages <Name> cls :at <file>:<line> :uses 7 :files 2 (<file> import 1:17 call 8:11) ...)
(entity-def cls <mod> <Name> <line> :lang py :file <path>)
(violation <src> <tgt> :src-layer domain :tgt-layer api :via imports :lang ts "<reason>")
(result <module-or-path>)
(result-count 42)
```
**`:lang` values**: `py` = Python (snake_case), `ts` = TypeScript
(camelCase), `tsx` = TSX (PascalCase), `rs` = Rust (snake_case), `cs` = C#,
`java` = Java, `go` = Go, `rb` = Ruby/Rails, `php` = PHP/Laravel (PascalCase),
`blade` = Blade templates, `dart` = Dart/Flutter, `cpp` = C++ (and every
`.h` file), and `c` = C.
## Scheme Query Language
Compose queries for complex analysis. See [references/scheme-queries.md](references/scheme-queries.md) for full reference.
**Essentials:**
```scheme
(boundary "id") ; target + deps + rdeps (change boundary)
(entity "Name") ; modules defining entity
(deps "id" depth) ; outgoing dependencies
(rdeps "id" depth) ; reverse dependencies
(find-function "name") ; modules with matching function defs
(find-type "name") ; modules with matching type defs
(find-callers "fn" depth) ; modules calling a function
(find-calls "fn" depth) ; modules a function calls
(intersect A B) ; set intersection
(filter SET "pattern") ; safe literal/.* filter
(files SET) ; resolve to file paths
(count SET) ; count members
(violations) ; modules with boundary violations
(layer "id") ; architecture layer of a module
```
## Analysis Plan Pattern
Before modifying code, compose a plan from queries:
```scheme
; 1. Scope
(boundary "operatives.service")
(count (boundary "operatives.service"))
; 2. Architecture constraints
(violations "operatives.service")
(layer "operatives.service")
; 3. Cross-language boundaries
(filter (refs-to "DrivePath") "app-service")
; 4. Narrow to actionable files
(filter (boundary "operatives.service") "dto")
(intersect (deps "controller" 2) (deps "service" 2))
; 5. After changes: verify
(violations "operatives.service")
```
## Trigger Examples
Use this skill before reading source for:
- Root-cause investigations that mention services, APIs, jobs, events, UI flows, or failing behavior.
- Cross-service or cross-module questions, including "how does X call Y?" and "where is this stored?"
- Redmine clarification when the answer depends on code behavior.
- Architecture reviews, impact analysis, public contract changes, or blast-radius checks.
- Reviews of non-trivial staged changes when dependency direction or module ownership matters.
Do not force it for commit-only tasks, git-log summaries, manual demo/server runs, pure browser testing, or session-log analysis.
## Error Recovery
If an answer starts with `(skipped-language <language> :files N :add "<command>")`,
or a build prints `WARNING: ... files are skipped`: the parser of that language
is not installed and its N files are not in the graph, so dependents and usages
in those files are missing from every answer. Say so, ask the user to approve
the command of `:add`, run it, then run `wingbox build` and query again.
A row with `:via generated` is a generated file listed under its generator or
its input, `:via runs` a file that launches the script as a process, `:via
reads` a generator under the input it reads. `:basis declared` comes from
`generators:` of `.wingbox/config.yaml`; `:basis inferred` from a `Generated
by <path>` line at the head of the generated file, from `add_custom_command`
of a CMake file, from a `subprocess` call with a literal script path, or from
a C or C++ include found without a compilation database. Treat an inferred
row as likely, and read the file before relying on it. To make a generation
link certain, declare it:
```yaml
generators:
- run: tools/make_layouts.py
inputs: [schema/formats.yaml]
outputs: [depot/layouts.py, native/src/layouts.h]
```
If a command returns `(error not-in-graph <file> :reason ...)`: the file is in
the repository and the graph does not cover it. Do not look for another ID.
`not-parsed-language` (Wingbox has no parser for that language) and
`not-source` (a document, a data file): search the text with `wingbox grep` or
`rg`, read the file, and say that its dependents are not known to the graph.
`excluded`: the build left the file out (a skipped folder such as `build/`, a
path Git ignores). `skipped-language`: the parser is not installed, see the
`(skipped-language ...)` line. When an `impact` answer starts with
`(graph ... :not-parsed ("CMake" 683 ...))`, files of those languages may
depend on the file as well: the list is complete for the files of the graph
only. For a small change in such code, or in a file outside the graph, a plain
text search is the right tool.
If a command returns `(error no-match ...)`:
1. Do NOT retry with the same ID or guess another ID
2. Run `search` with a broader keyword to find the correct module ID
3. Use the `:suggestions` field if present -- it lists similar module IDs
```bash
# Wrong: guessing IDs until one answers
wingbox analyze invoices_service
wingbox analyze bs34 # a short ID of the graph file: after the next build it names another module
# Right: search first, then use the full path from results
wingbox search "invoice.*service"
# Output shows: (result billing-service/src/modules/invoice/invoice.service)
wingbox analyze billing-service/src/modules/invoice/invoice.service
```
## Anti-patterns
- **Guessing module IDs.** Module IDs are full relative paths (e.g., `billing-service/src/modules/invoice/invoice.service`). Short codes like `bs34` are the IDs of one build of the graph file: the next build may give them to other modules. Always `search` first.
- **Build but never query.** Building the code graph and then never running `search`, `analyze`, or `boundary` provides zero value.
- **Querying after reading source.** The first source-code read should come from the `boundary-file` lines and the `:file` of the `analyze-dependent` lines in `analyze` output.
- **Reading `.wingbox/index.sexp` as a whole file, or searching it for a path with `rg`.** The file names modules by short ID, so a path is not in its facts. Use `search`, `analyze` or `module` to query specific facts.
- **Skipping the code graph for cross-module tasks.** Always query the graph to understand boundaries before reading source files.
- **Reading all files in a directory.** When the boundary shows 2-3 files, read only those.
- **Using project-local scripts.** Always use the `wingbox` command. A copy of its scripts inside a project may be outdated.
## Rebuilding the Graph
```bash
wingbox build . # parse the files that changed
wingbox build . --full # parse every file again
wingbox build . --lsp # add the edges a language server finds
wingbox build . --exclude-dir review-bundles
```
`--lsp` starts the language servers installed on the machine. Such a server
can run the build of the project and fetch its dependencies from a package
registry, so use `--lsp` only when the user asks for it: it is the one build
option under which the code of the project may run and the network may be
reached.
Use repeatable `--exclude-dir NAME` options for tracked snapshots, generated
fixtures, or other source-shaped trees that are not part of the live product.
Each value is a directory basename and applies at any depth. Changing exclusions
invalidates the incremental cache so excluded files cannot leak from an earlier
build.
Targets inside Git worktrees also use Git's repository ignore rules. The same
resolved policy filters source files, TypeScript aliases and packages, Go and
Rust package manifests, Ruby project configuration, and LSP project discovery.
Git is invoked with index checks disabled so tracked snapshot paths that match
`.gitignore` remain excluded from the code graph.
Rebuild after structural changes (add/remove files, change imports, add classes).
Search patterns support literals, `.*`, boundary `^`/`$` anchors, and
backslash escapes. Other regex operators are rejected.
The TypeScript AST contract covers TS/TSX imports and re-exports, literal
`import()`/`require()`, `import = require()`, literal template imports, emitted
`.js`/`.jsx` specifiers, project-scoped path aliases (of `tsconfig.json`,
`jsconfig.json` and the project files their `references` name) including `paths`
inherited through a relative `extends` chain inside the repository, and imports that name a package
of the repository: the package entry (`exports`, `source`, `types`, `module`,
`main`) and its subpaths resolve to the TypeScript source, also when the entry
points at build output. Packages outside the repository stay external. It does
not promise aliases from an `extends` preset that lives in a package or
`baseUrl`-only resolution.
JavaScript files (`.js`, `.jsx`, `.mjs`, `.cjs`) are modules under the same
contract. An import written as `./x.js` names `x.ts` when it exists and the
real `x.js` otherwise; `.mjs` and `.cjs` are matched by their own extension.
Minified files (`*.min.js`, or any line longer than 5,000 characters) and
bundles (`bundle` in the file name) are left out, like everything in excluded
or ignored directories. A build names the files it left out for a long line.
An import that goes through the `outDir` of a `tsconfig*.json`, written as a
relative path, through an alias or as a package entry, resolves to the file
under `rootDir` that it is compiled from. Without `rootDir` the source is
looked up next to that tsconfig, then in its `src` folder.
Python indexing follows `import` and `from` imports and modules loaded at run
time: a literal name given to `importlib.import_module` or `__import__` is an
import; a name built from a literal package path and one variable
(`f".plugins.{name}"`) is a `registry-wires` edge to each module of that
package named by a string of a JSON, YAML or TOML file in the folder of the
loader. A method called in a loop on an object such a registry returns for the
loop variable is a `calls ... :registry` edge to each wired module that defines
it, and `data-flow ... :pipeline` when the call replaces its own argument
(`data = stage.process(data)`), in the order of the configuration list. Names
computed any other way stay unlinked. An absolute import is looked up at the
repository root, beside a script (never beside a module of a package), in the
`src/` folders above the importing file and then in the source roots of the
repository: a folder with a `pyproject.toml`, `setup.py` or `setup.cfg`, its
`src/` and the folders those files name. A name that several source roots hold
stays unlinked.
C# indexing follows namespaces and referenced local types: a name binds as the
compiler searches (the own namespace, the usings written in it, each enclosing
namespace, the global namespace, then the usings of the file and the `global
using` directives of its project folder), a type declared `partial` in several
files of one project links each of them, and a name that two namespaces of one
step declare stays unlinked. Java indexing follows packages, explicit imports,
and referenced wildcard types, also a class used only through static members,
`::` or `@`, and the default package. Unused namespace or wildcard imports do
not create guessed edges. Go indexing resolves local module imports to the
source files that make up the imported package, and links the files of one
package (its `_test.go` files too) through the package-level names they use
of each other; a name that two files of the package declare stays unlinked,
and a method called on a value links no file.
Standard .NET `bin`/`obj` output and Go `vendor` dependencies are excluded.
Ruby indexing discovers `.rb` and `.rake` files and resolves explicit requires,
local constants, Rails application roots, statically configured autoload roots,
project acronyms, concerns, associations (their names made singular by the
rules of Rails), callbacks, jobs, mailers, and spec references; a scoped
constant that resolves nowhere links the file of its scope. It never boots
Rails. Reopened or otherwise ambiguous constants and
polymorphic associations remain unlinked instead of producing guessed edges.
Rails relation flags are preserved as `:association`, `:concern`, `:callback`,
`:job`, `:mailer`, or `:spec` in the generated map.
PHP 8 indexing discovers `.php` files and `.blade.php` templates. It resolves
classes through the `autoload.psr-4` and `autoload-dev.psr-4` prefixes of every
`composer.json` in the repository, longest prefix first, and follows `use`
aliases, inheritance, traits, Blade `@extends`/`@include*`/`@component`/`@each`
directives, `<x-*>` components, Livewire aliases and registrations, Eloquent
associations, events and jobs. Functions and constants declared outside a
class are entities: `use function`, `use const`, a call of a function one file
declares and `require __DIR__ . '/...'` are edges, and so are the classes a
Blade template names (`@inject`, `@use`, a qualified name before `::`), the
class of an `<x-*>` component, `$this->view()` and a route action written
`'Controller@method'`. `view()` references resolve through
`resources/views` and through view namespaces registered with `loadViewsFrom`
or `View::addNamespace`. It never boots Laravel. Unresolved or ambiguous class,
view and component names remain unlinked, and a duplicate class declaration
such as an IDE-helper stub does not shadow the PSR-4 file.
C and C++ indexing reads `.c .cc .cpp .cxx .h .hh .hpp .hxx .inl .ipp` files
with one tree-sitter grammar: `#include` dependencies, classes, structs,
unions, enums, type aliases, functions, methods, macros with a value and base
classes. A module ID keeps the extension, so `stage.h` and `stage.cpp` are two
modules: query the header to see who includes it (`wingbox impact
studio/src/scene/stage.h`); `impact` of a source file lists the includers of
its header (`:basis paired-header`), and says `(impact-no-includers ...)` when
it has no header: an empty list there does not mean nothing uses it. An include is
looked for beside the including file (a quoted name), then in the include
folders of `compile_commands.json` (at the root, in `build/` or one level
below), without that file, or for a file that no entry of it covers, in the
folders the CMake files name, and last, for a quoted name, as the one file
whose path ends with the written name, the case of the letters not compared
when nothing else answers. An include found without the folders a compiler
was given is marked `inferred`. A system
header, a library outside the repository and an ambiguous name create no
edge. `wingbox usages <header>::<name>` lists the uses of a function, type,
macro or enum in the files that include the header; a method called on an
object is listed as an unresolved call, because the type of the object is not
derived. The preprocessor is not run: every branch of an `#if` is read, and a
header that a build step generates outside the repository is no dependency.
Dart indexing discovers `.dart` files and reads each one with a tree-sitter
Dart grammar: classes, mixins, enums, extension types, extensions, type
aliases, top-level functions, the members of each type, and `extends`, `with`,
`implements` and `on`. It resolves `import` and `export` directives and
`part`/`part of` pairs, a `part of` that names its library included. A `package:<name>/path.dart` URI whose name is the
top-level `name:` of a `pubspec.yaml` in the repository resolves to
`lib/path.dart` of that package, the nearest owning pubspec first, so a Dart
monorepo links across its packages. A relative URI resolves to the neighbouring
file. `dart:` core libraries and `package:` names that no local pubspec
declares are external and create no edge. A directive whose file is missing,
such as a `*.g.dart` or `*.freezed.dart` part that `build_runner` has not
written yet, adds nothing and fails nothing. Flutter needs no separate handling:
widgets are ordinary classes. Runtime wiring is not visible to static analysis:
what a `get_it` locator registers, the pages a `go_router` configuration builds
and the clients `retrofit` generates are bound at runtime, so expect no edge for
them and start an impact query from the concrete file instead. `.dart_tool/` is
excluded by its name, and so is `build/`, the default skip folder in every
language that holds Flutter output.
Pascal indexing discovers `.pas`, `.pp`, `.lpr`, and `.inc` files. It extracts
units, programs, `uses`/`contains`/`requires` clauses, include directives,
classes, records, interfaces, inheritance, methods, and routines. Unit names
and paths resolve case-insensitively; explicit `UnitName in 'path.pas'` paths
take precedence, followed by a unique unit in the importing file's directory.
Other ambiguous unit names remain unlinked. Conditional compiler branches are
indexed conservatively. Pascal has no LSP enrichment yet. Pascal files inside
conventional Lazarus `backup/` directories are excluded; other supported
languages in directories with that name remain indexable.
## Infrastructure Topology
Extract service topology from Kustomize, Helm, and Terraform files (`PyYAML`, which the command needs, is installed with the package).
```bash
wingbox infra # auto-detect all IaC
wingbox infra --kustomize . # kustomize only
wingbox infra --helm ./charts # helm charts only
wingbox infra --terraform ./infra # terraform only
wingbox infra --append .wingbox/index.sexp # merge into graph
```
Emits `infra-node`, `k8s-depends`, `k8s-service`, `helm-depends`, `tf-depends`, and `infra-maps` edges. These facts name services, not modules, so they are stored as they are printed. Query with:
```bash
wingbox search "infra-node" --lines # all services
wingbox search "k8s-depends" --lines # service dependencies
wingbox search "infra-node.*:component database" --lines # all databases
wingbox search "infra-maps.*app-service" --lines # infra -> source code mapping
```