Skip to main content
Ask your coding agent to run Loadwise. On its first check or fix, the CLI gives a recognized agent the review workflow on stderr: a check lets the agent inspect every scoped finding, earlier edit, caller and test, and a fix request also lets it apply or adapt justified changes. The agent can read the full workflow with loadwise agent instructions. The first run works in a fresh checkout and leaves project instruction files and Git hooks alone. Loadwise recognizes agent shell markers from Codex, Claude Code, Grok Build (formerly Cursor), Devin (formerly Windsurf), Cline, Roo Code, Aider, Gemini CLI and GitHub Copilot, as well as tools that identify themselves with AI_AGENT. An integration that supplies no marker can set LOADWISE_AGENT=1 in its tool subprocess. Set LOADWISE_AGENT=0 on a command to disable detection. Commands typed in plain Git Bash or an ordinary IDE terminal run normally. A shell opened inside an agent can inherit its markers.

Set up a project

Install Loadwise in the project and run one command:
agent init updates the managed section of AGENTS.md, imports it from CLAUDE.md and enables history for manual CLI fixes too. From the installed package, so the version always matches, it also registers two integrations for each AI coding tool it supports:
  • After-edit hook: every tool runs the same launcher, which walks up from the session folder to node_modules/loadwise/agent/hooks/check-edited-file.mjs and does nothing until Loadwise is installed. The script applies the same checks, deadline and feedback text for every tool; only the tool’s payload and response envelope differ. See the edit hook.
  • MCP server: the same local stdio server named loadwise. Project files hold node and a path relative to the project folder (node_modules/loadwise/dist/bin/loadwise.js agent mcp), so they can be committed and shared; the server starts in the project root. Grok Build expands ${workspaceFolder} instead. Codex starts servers from its session folder, so its entry walks up from there to the installed Loadwise instead of naming a path. The Cline file is the one place that keeps absolute paths, because it lives in your home folder.
Claude Code is always configured, since CLAUDE.md imports the instructions. Another tool is configured when one of its detection paths exists, or when you name it with --tools. The command prints each file it writes and a summary of the tools it covered and the ones it did not detect. The Copilot cloud agent takes its MCP servers from the repository settings on GitHub, not from a file in the project. A repository administrator opens Settings, then Copilot, then MCP servers, adds a configuration under “MCP configuration” and saves it. GitHub requires tools and type on each server. This configuration is shared by the cloud agent and Copilot code review, and agent init does not write it. The server only starts if Loadwise is installed in the environment the cloud agent runs in, for example by an npm ci step in .github/workflows/copilot-setup-steps.yml. GitHub does not document the folder the server starts in; the relative path below assumes the repository root:
Hook and MCP files in the project are written for every detected tool in the same run. Cline’s global MCP file is written only with --global. --mcp off removes its loadwise entry with or without --global, and only when that entry points at this project. When two tools read the same hook file (Claude Code’s .claude/settings.json is read by Copilot, Grok Build and Devin), the hook script skips a second run for the same file content within 10 seconds, using a short-lived marker in a private per-user folder under the system temp folder. The run in the tool’s own mode always wins: the Claude-mode run steps aside at once for a Copilot or Grok Build payload when that tool’s own Loadwise hook file (.github/hooks/loadwise.json or .cursor/hooks.json) exists, answers it in Claude Code’s format otherwise, and waits briefly when a native hook file exists, so the answer comes back in the format that tool reads. Set LOADWISE_HOOK_DEDUPE_MS=0 to turn that off. The command merges its entries into existing files and keeps every other setting. Rerunning it changes nothing when the entries are current. It leaves a JSON file that is not a valid object untouched with a warning, and a TOML file that already names loadwise outside its own [mcp_servers.loadwise] table, defines mcp_servers as an inline or dotted key, or writes a server table with an escaped quoted key. Without a local install it sets up only the instructions and explains how to add the rest.
Removal checks every project file agent init can write, and Cline’s global file for an entry that points at this project. It also removes the /loadwise command that earlier versions wrote to .claude/commands/loadwise.md when it still carries its marker or description, and keeps a file you wrote. A Cline hook script is removed only when it carries the loadwise:agent-hook line. Removal works without Loadwise installed. agent init takes these flags for the hooks and MCP servers. --tools copilot,gemini,codex,cursor,devin,cline also configures tools whose project folder does not exist yet, and --global also writes the Cline settings file in your home folder. --no-edit-hooks and --no-mcp leave those files alone, while --edit-hooks off and --mcp off remove only the Loadwise entries (--edit-hooks on and --mcp on are the defaults). --mcp off keeps the MCP file and its mcpServers object even when no other server is left, and keeps Codex’s .codex/config.toml with its comments and other tables even when it ends up empty. A file that is not valid JSON, or whose hooks or mcpServers value has the wrong type, is left unchanged with a warning. Project MCP entries use node with a path relative to the project folder, so the files can be committed and shared. Sources for each format: Copilot hooks reference, VS Code hooks, Grok Build hooks, Devin CLI hooks and Devin Desktop hooks, Cline hooks for the CLI and SDK and for the VS Code extension, and Cline’s user-level MCP file; Claude Code hooks and MCP; GitHub Copilot hooks, Copilot CLI MCP and VS Code MCP; Gemini CLI hooks, tools and MCP; Codex hooks, MCP and the apply_patch grammar; Grok Build hooks, third-party hooks and MCP; Devin hooks, lifecycle hooks and MCP; Cline plugins and MCP. To start a shared rule policy, run npx loadwise agent init --print-config to preview a minimal configuration. Run npx loadwise agent init --write-config to save it when the project has no existing configuration. Both options leave instruction files and Git hooks alone. Loadwise also scans projects without a configuration file. Agent-run CLI fixes save their actual edited hunks locally from the first fix. For earlier fixes and saved review decisions, run loadwise agent history from the checked project, optionally with a checker name such as maintainability. History stays under the user’s local state directory and can include excerpts of project source. For unrecorded edits, including edits made on another machine, use an earlier report or a known diff. If the storage base is a symbolic link or Windows junction, set the appropriate environment variable for the Loadwise command to a direct absolute directory outside the project. Use LOCALAPPDATA on Windows for the inbox, history and temporary handoffs. On macOS and Linux, use XDG_STATE_HOME for the inbox and history, and TMPDIR for a temporary handoff. Choose a directory that follows the same user ownership and permissions requirements as the default. Agents check that every finding has a disposition with the original scan, the relevant history and the rescan. The outcomes file is an object with an outcomes array whose entries supply checker, id, status (fixed, verified, intentional, false-positive or deferred) and specific evidence. For a narrower request, provide only the authorized findings in those reports; put report files in a local scratch directory.
Use the outcomes JSON Schema to check the file structure in your editor or application. For a project with Loadwise installed, the schema is also available at node_modules/loadwise/schema/loadwise.outcomes.schema.json. The verifier checks evidence and accounting against the selected reports. The first command checks coverage. --save also retains successful review decisions for the next session in a recognized agent session or an explicitly initialized checkout. A missing decision or skipped checker is reported as incomplete; a reasoned deferral counts as reviewed and stays visible as deferred. Code review and relevant tests establish whether a change works. For a standalone JSON scan, pass its checker, for example --checker maint: perf for performance and database reports, rel for reliability, migration and contract reports, maint, sec or a11y, one checker per invocation. Combined scans and history keep their original checker selection. Use the handoff command printed by the fix run to preserve its scope. For a project-wide maintainability fix, save the manual findings with npx loadwise fix --handoff maintainability > loadwise-manual.md.

Using Loadwise with an active coding agent

Ask the agent you are already working with to check the project with Loadwise. A shell-capable agent can run npx loadwise check --json and review the findings directly in the conversation. Ask it to verify findings against your code, suggest improvements, or implement the changes you choose. A check is read-only. A request to apply fixes can use npx loadwise fix --yes --json and review the actual edits and remaining findings in the same chat. For an agent that uses Model Context Protocol (MCP), npx loadwise agent init registers the server for the tools in the setup table. For another MCP client, run npx loadwise agent mcp --print-config and register the printed command and arguments as a local stdio server named loadwise. The agent can call loadwise_check to run a fresh offline scan and read larger reports in pages with loadwise_read_report. Loadwise does not start a chat or send findings to another session. Pass one of uncommitted: true, staged: true, or changedSince: "origin/main" to limit loadwise_check to changed lines. Set workspace to an array of package names or paths within the configured project to select workspace packages. If you ran a terminal command yourself and want to share it later, use npx loadwise check --review or npx loadwise fix --yes --review. Paste the printed handoff into the chat you choose, or attach the report. loadwise agent pending and the MCP tool loadwise_list_reports list saved reports for that project. Pass a saved report path from loadwise agent pending directly to loadwise agent verify --outcomes outcomes.json <report-path>.

Generate a review prompt

Copy the output of this command into your coding agent. The prompt asks the agent to review changes since origin/main with the performance and reliability checkers by default.
The prompt’s --report-fp flag adds an instruction to ask for permission before preparing an anonymized false-positive report. To generate a GitHub issue link yourself, run npx loadwise report-fp --rule <rule-id>. Add --open to open the prefilled form in your browser. You submit the issue yourself.

After-edit hook

After an agent edits a file, the hook runs the project’s locally installed loadwise on that file: after Edit, Write or MultiEdit in Claude Code, write_file or replace in Gemini CLI, and every file a Codex apply_patch adds, updates or moves. The checks depend on the file:
  • .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts and .cts files: perf, rel and sec on the file, and maint on the uncommitted changes. a11y also runs on .tsx and .jsx files and on other script files that contain @Component.
  • .html, .htm, .vue and .svelte files: a11y on the file.
  • .py, .go, .java, .cs and .rs files: perf polyglot, rel polyglot and sec polyglot on the file.
  • Dockerfiles, recognized by file name (Dockerfile, <name>.Dockerfile or Dockerfile.<suffix>, in any letter case): sec dockerfile on the file.
  • .sql files in a migrations directory, or beside a Drizzle meta/_journal.json: rel migrations on the file. SQL files under node_modules, dist, build, coverage, fixtures, __fixtures__, test, tests, __tests__ or a dot-directory are skipped.
In a workspace package with its own package.json, the hook also finds a Loadwise install hoisted to the workspace or git root, never above it, and runs the checks from the package folder. The hook keeps only the findings for the edited file. Findings go back to the agent with their ids: as a blocking reason in Claude Code, as additionalContext in Gemini CLI, Codex, Copilot and Devin, as additional_context in Grok Build and as context or contextModification in Cline. Fixable findings from the JavaScript and TypeScript checks include --fix --only <id> commands; non-fixable findings and polyglot, migration and Dockerfile findings are listed as manual findings. A clean file prints nothing. All checks for one hook run share one deadline of 20 seconds, and up to two checkers run at once. Set LOADWISE_HOOK_TIMEOUT_MS to a positive whole number of milliseconds to change the deadline; other values use the default. A checker that runs past its share of the deadline, or prints more than 16 MiB, is stopped along with the processes it started, and the other checkers can still report. The hook never downloads anything: without a local install, outside a project, on other file types, or when a run fails or times out before any checker reports, it exits silently; if a single checker errors or times out, the other checkers can still return partial feedback. To turn the hooks off, run npx loadwise agent init --edit-hooks off. The Claude Code plugin that earlier releases offered through /plugin install loadwise@loadwise is removed. If you installed it, run /plugin uninstall loadwise in Claude Code and then npx loadwise agent init; until then agent init skips the Claude Code hook so edits are not checked twice. To troubleshoot a quiet edit hook, set LOADWISE_HOOK_DEBUG=1 in the environment that launches the agent. The hook writes short status messages to stderr for a missing local launcher, checker timeouts, invalid output and completed single-file scans with no findings. It keeps findings on stdout as before. Unset the variable to restore the quiet default.

Git pre-commit hook

The hook runs loadwise check --staged from the project folder, so every tool that commits through git sees findings from the selected checkers on the staged lines. It writes a marked block into the hooks folder (honouring core.hooksPath) or into .husky/pre-commit when .husky/ exists, appends to a hook you already have, and rerunning it replaces only its own block, including blocks written by earlier releases. With lefthook it edits nothing and prints the command to add. git commit --no-verify skips the hook.

Linked Git worktrees

Git’s default hooks directory is shared between linked worktrees. To change the hook for every checkout that inherits it, run the installer in the corresponding project in the primary checkout if its hooks directory is inside that checkout. A primary checkout created with an external --separate-git-dir can also refuse this operation. Keep the hook manager’s existing routing in managed checkouts. For installation with a detected Lefthook configuration, Loadwise prints the command to add to that configuration. Otherwise, when .husky/ exists, the installer updates .husky/pre-commit even if a command temporarily overrides core.hooksPath. For unmanaged Git hooks, prepare the replacement before changing Git’s persistent settings.
  1. From the linked checkout root, use git rev-parse --git-path hooks to identify the active hooks directory. Add /.loadwise-hooks/ to your local Git excludes. Check that git ls-files -- .loadwise-hooks prints no paths and git check-ignore -- .loadwise-hooks/ shows the directory is ignored. Prepare an operator-owned .loadwise-hooks directory there with trusted copies of every active hook and helper. Preserve executable permissions and keep the copies under your control. Changing core.hooksPath redirects every Git hook in that checkout.
  2. From the project directory, run the installer with a temporary override. For example, in Git Bash or a POSIX shell with Loadwise installed locally:
    To remove Loadwise only from this checkout when it inherits a shared hook, use --hook off with the same temporary override on the copied hook set. A removal from the shared hook affects every checkout that inherits it.
  3. Coordinate with the owners of the shared hooks to pause updates to hooks and helpers through verification and activation. Compare the final copies with the paused shared files, including executable permissions, and bring over changes while retaining your intended Loadwise block or removal. From the checkout root, run git -c core.hooksPath=.loadwise-hooks hook run pre-commit and verify the expected checks. Exercise the other active hooks with their normal checks. If you cannot coordinate the pause, keep inherited routing.
  4. Check and record the repository setting with git config --local --get extensions.worktreeConfig before changing it. If the extension is off or absent, ask the repository owner to enable it following Git’s worktree configuration instructions, and record any settings moved out of the common config. Use git config --worktree only after the extension is enabled. Before changing the linked checkout’s routing, record its current core.hooksPath using git config --worktree --get core.hooksPath, including when no value is set. Then run git config --worktree core.hooksPath .loadwise-hooks in the linked checkout. Confirm the active directory with git rev-parse --git-path hooks and verify the active checks before shared updates resume.
The local copies are a snapshot. Bring over later changes to shared checks and their helpers, retain your intended Loadwise setting, and retest the hooks. Keep the directory ignored and untracked. Before checking out a different commit, require git ls-tree -r --name-only --full-tree <commit> -- .loadwise-hooks to succeed and print no paths for the exact commit you will check out. The check covers the checkout-root directory even from a nested project. If the command fails or lists a path, restore the prior hook routing before checkout. Cleanup that removes ignored files can delete .loadwise-hooks while Git still points to it. Preview Git cleanup from the checkout root with git clean -ndx. If Git or another cleanup tool would remove the local hook copies, restore and verify the previous routing before cleanup. If the copies were already removed, restore and verify routing before committing. To restore the linked checkout’s previous hook routing, first confirm worktree-specific configuration is still enabled. If there was no prior local override, run git config --worktree --unset core.hooksPath. Otherwise restore the recorded value with git config --worktree core.hooksPath <previous-path>. Verify the resolved directory and rerun its checks before relying on the restored routing. Restoring hook routing leaves the repository-wide extensions.worktreeConfig setting in place, including after an interruption. If you enabled it and need to undo that separately, have the repository owner check for worktree entries in git config --show-scope --name-only --list in every checkout while the extension is enabled. Coordinate with every affected worktree and use Git’s worktree configuration instructions to restore any moved settings. Restore the original shared setting only when no checkout still depends on the extension. If it was absent, remove it with git config --local --unset extensions.worktreeConfig. If it was explicitly off, restore that value.

pre-commit framework

For repositories using the Python pre-commit framework, add this entry to .pre-commit-config.yaml. Use the v0.9.0 tag after it has been pushed. Until then, pin commit b4f57b8c1ac938a9f757bf0ccb12d6e3f16303b8, which contains the hook manifest.
Use pre-commit 3.2 or later and Node.js 22.13 or later on PATH. Install the published loadwise package as a dev dependency in the repository root’s node_modules. The hook invokes that installation directly. The framework temporarily shelves unstaged edits, and Loadwise checks staged lines using the Git index. If your repository has one checkout, uses Git’s default hooks directory, and has no framework hook there, run pre-commit install --hook-type pre-commit. Linked worktrees share the default hooks directory. Coordinate any shared installation or removal with the other hook owners, or use the existing-hook approach below for a rollout by checkout. If git config --get core.hooksPath returns a path, keep that setting. Have the hook owner add pre-commit run --hook-stage pre-commit to the existing hook or hook manager and propagate a failing exit status. If the existing command already runs the framework, verify that it selects Loadwise at the pre-commit stage. A command that selects only another hook needs a separate pre-commit run loadwise --hook-stage pre-commit step. Keep an existing direct Loadwise check until the configured framework step runs Loadwise in that checkout. Then use the framework step alone to avoid scanning twice. For a shared hook, designate the participating checkouts and use pre-commit run loadwise --hook-stage pre-commit as their Loadwise step. Propagate its failure if the config is missing or no longer includes Loadwise at that stage. Keep the direct check in other checkouts that already use it. To roll back a manually added framework step, restore the direct check in the hook you manage before removing the step or changing its configuration. To roll back a wrapper installed with pre-commit install, run pre-commit uninstall --hook-type pre-commit first. Then verify the restored hook still has the direct check, or restore it to the active hook before resuming commits.