> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration

> The loadwise.config.json file, rule levels, overrides and impact levels.

One optional file, `loadwise.config.json`, sets the defaults for every checker. `loadwise check` looks for it in the checked directory and each checker command (`loadwise perf`, `rel`, `maint`, `sec` or `a11y`) in the project folder; `--config <file>` on `check` (`--loadwise-config <file>` on the checker commands) names another one. Add `$schema` for editor completion and validation.

Select a `.jsonc` file explicitly, here or as a `--policy` or `maint --config` policy file, to use `//` line comments or `/* … */` block comments. Keep the rest of the file in strict JSON syntax. Syntax errors identify the file and include the line and column when available.

```json theme={null}
{
  "$schema": "./node_modules/loadwise/schema/loadwise.config.schema.json",
  "checkers": ["perf", "rel", "maint"],
  "ignore": ["generated/**", "scripts/**"],
  "rules": {
    "duplicate-implementation": "warn",
    "array-repeated-find": "off",
    "pg-query-in-loop": { "level": "error" }
  },
  "overrides": [{ "files": ["src/legacy/**"], "rules": { "high-branch-complexity": "off" } }],
  "performance": {
    "parallelReads": [{ "from": "@app/reads", "exports": ["fetchUser", "fetchPosts"] }]
  },
  "maintainability": {
    "exclude": ["vendor"],
    "placement": [{ "suffix": ".controller.ts", "under": ["src/controllers"] }]
  }
}
```

* `checkers` is the default selection for `loadwise check`; `--only` and `--skip` override it.
* `ignore` excludes paths from scanning, reporting and project-wide checks such as duplicate detection. Globs are relative to the config file. `*` matches within a folder, `**` any depth, `?` one character and `{a,b}` alternatives. A folder pattern also covers its descendants. The last matching entry wins, so `["generated", { "include": "generated/reviewed" }]` keeps the reviewed subtree. A leading `!` in a string pattern matches a literal `!`. Git and built-in exclusions still apply.
* `rules` sets each rule to `"off"` (its findings are dropped), `"warn"` (reported, but never changes the exit code) or `"error"` (reported findings always count, even under `--fail-on contract`). A hidden contextual finding is not reported, so it never counts. The object form `{ "level": "warn", "options": { ... } }` sets thresholds for rules that take them, such as `maxDepth` or `maxComplexity`; the [config schema](https://github.com/IbrahimHafez1/loadwise/blob/main/schema/loadwise.config.schema.json) lists each rule's options, and an unknown option exits with code 2.
* `overrides` apply `rules` to the files matching `files`; a later override wins over an earlier one and over `rules`.
* Standalone `perf polyglot`, `rel polyglot`, and `sec polyglot` accept their reported rule IDs in `rules` and `overrides`.
* For JavaScript and TypeScript maintainability checks, `maxDepth`, `maxComplexity`, `maxParams`, `large-module.maxLines`, and `large-class.maxMethods` / `maxLines` are inclusive maxima. A value above the configured maximum triggers the rule. Module and class line limits count lines containing code. Matching file overrides take precedence over top-level rule options, then the legacy `maintainability.limits` settings and built-in defaults apply. With no new options, deep control flow starts at four nested levels, high branch complexity at a weighted score of 15, and class length in lines is unrestricted.
* `performance` holds the query policy (see [Project-defined access policy](https://loadwise.mintlify.site/checkers/performance.md#project-defined-access-policy)), and `maintainability` holds the maintainability policy (see [Project rules](https://loadwise.mintlify.site/checkers/maintainability.md#project-rules)). `--policy file.json` and `--config file.json` name a policy file for one run and beat the config sections.
* `--ignore <rule-id>` (repeatable, on `check` and every checker) adds a rule to `"off"` for one run and beats the config.
* `--workspace <name|path>` (repeatable) limits every checker to some workspace packages.

An unknown key or rule id, a wrong level or a malformed section exits with code 2 and lists each problem. Rule ids come from the registered checkers and the configured rule packs. The config applies to source checks and the `polyglot` commands. `rel contracts` reads `loadwise.config.json` in the current directory, or the file named by `--loadwise-config <file>`, and applies `ignore` and the rule levels in `rules` and `overrides`. An ignored file can still supply inherited properties when an included NestJS DTO extends a class from that file. In that case, any finding points to the included DTO. `rel migrations`, `perf db`, `perf traces` and `perf plan` do not read the config.

## Shared configuration

Set `"extends": "../../config/shared.json"` to load a local parent. Paths are relative to the config that declares them. Each parent's `ignore` and `overrides` patterns match from that parent's directory. Ignore lists are cumulative, and negations apply within their own list.

For rule levels, the child takes precedence over the parent, including matching parent overrides. Matching overrides in a given file take precedence over its base rules. Rule options merge by key. The nearest config that sets `checkers`, `performance`, `maintainability`, or `security` supplies that section. Rule packs load from their declaring files in parent-to-child order. Children can configure inherited rule IDs, and duplicate IDs are rejected.

Missing parents, cycles, absolute paths, and URLs report configuration errors. Editor scans read parents within the opened workspace or its enclosing Git repository. Saving a watched parent refreshes diagnostics. The editor still uses its default checkers unless you enable project checker selection. Cache keys account for the inherited policies.

## Local declarative rule packs

Set `"rulePacks": ["config/team.loadwise-rules.json"]` in `loadwise.config.json` to include a local rule pack in maintainability and unified scans. Each path is relative to the config file and must resolve inside its directory. Pack files contain versioned JSON data.

Source checks validate declared packs while loading the shared configuration. The maintainability cache fingerprints the loaded pack rules before starting a scan and stores the report only when the checker used the same pack rules. An invalid configuration or a missing explicitly selected configuration bypasses the cache so the checker reports the current error.

```json theme={null}
{
  "version": 1,
  "namespace": "shop",
  "rules": [
    {
      "id": "no-legacy-sdk",
      "kind": "forbid-static-import",
      "module": "legacy-sdk",
      "message": "Use the current SDK.",
      "level": "warn"
    }
  ]
}
```

The example reports the exact static JavaScript or TypeScript module specifier with the stable ID `project-shop--no-legacy-sdk`. It appears in unified JSON, SARIF, editor diagnostics, and baselines. `warn` is the default level and `error` fails a scan. Rule packs can define this import matcher with literal strings. Duplicate IDs, unknown fields and unsupported rule kinds fail configuration validation.

Use the full ID in `rules` to change its level, and in `overrides[].rules` to set a level for matching files. Run `loadwise check --ignore project-shop--no-legacy-sdk` to hide it for a single scan.

## Security review guidance

Register organization-specific imports under `security.trustedBindings`. The security checker matches the exact module specifier and exported name in a value import, including aliases and namespace access. Use `default` for a default import.

```json theme={null}
{
  "security": {
    "trustedBindings": [
      { "module": "@team/security", "export": "credentialGate", "use": "auth-route-middleware" },
      { "module": "@team/security", "export": "checkDestination", "use": "redirect-target-predicate" }
    ]
  }
}
```

* `auth-route-middleware` looks for a directly imported middleware value in an argument before the final handler of a credential route. It supports inline placement in the route registration.
* `redirect-target-predicate` looks for a direct call with the same stable target identifier used by the redirect. Reaching the redirect must require a truthy result from that predicate.

Each match adds the import identity and a verification prompt to the existing finding. Finding visibility, severity and exit behavior are unchanged by the registration. Review what the imported code does and whether it provides the expected protection.

Enable `security.trustedBindings` after upgrading every Loadwise CLI that reads the shared config, including CI and editor integrations. Older CLIs reject the top-level `security` section before running any checker. Before rolling back, restore a config without that section for the older CLI. For a one-off run, select a compatible file with `loadwise check --config <file>` or pass `--loadwise-config <file>` to a direct checker command.

## Impact levels

Every finding carries an impact level, shown after the rule in text output, where the most severe finding comes first within each file. JSON findings carry it as `impactLevel` (`impact` is the before/after estimate). `--min-impact <low|medium|high|critical>` reports only findings at that level or above, and the filtered ones do not count toward the exit code; an unknown level exits 2. The rule lists on each checker page give each rule's default level, and dependency findings use the advisory severity.

* `critical`: data loss or corruption, an outage or a lock risk in production.
* `high`: a per-request scaling problem such as an N+1 or query in a loop, a deep offset, a missing foreign-key or filter index, an HTTP call without a timeout, or a dependency cycle with load-time effects.
* `medium`: a measurable but local cost, or significant maintainability debt.
* `low`: a micro-optimization or a readability issue.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.