chainsaw install-hook
Wire chainsaw into a package manager
Wire chainsaw into a package manager
chainsaw install-hook [manager] [flags]
Aliases: wire
Insert the chainsaw-managed configuration block into a supported package manager’s user config file. Supported clients: npm, yarn, bun, pip, uv, cargo, maven, gradle, sbt, nuget, go, docker, brew, bundler, gem, composer.
bundler sets mirror.https://rubygems.org (and the proxy host’s credential)
in ~/.bundle/config; Gemfile.lock keeps naming rubygems.org. gem replaces
RubyGems’ default :sources: entry in ~/.gemrc. Both tools rewrite their file
on every bundle config set / gem sources --add, so chainsaw records
what it wrote in <file>.chainsaw and uninstall-hook removes only those values.
Both need a server URL and support –scope user only.
composer adds a “chainsaw” repository and “packagist.org”: false to the GLOBAL $COMPOSER_HOME/config.json (Composer merges it into every project) and the credential to $COMPOSER_HOME/auth.json as http-basic. It refuses project scope, since composer.json is committed.
The npm wirer writes ~/.npmrc, which pnpm reads too; it counts as installed for –all when either npm or pnpm is on PATH.
uv does not read pip.conf, so wire it separately: install-hook uv writes a default [[index]] to uv.toml (~/.config/uv/uv.toml, or $UV_CONFIG_FILE). A project’s own [[tool.uv.index]] with default = true overrides it.
brew writes HOMEBREW_API_DOMAIN, HOMEBREW_ARTIFACT_DOMAIN and
HOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK=1 (plus the credential as
HOMEBREW_DOCKER_REGISTRY_BASIC_AUTH_TOKEN) to ~/.homebrew/brew.env. That
routes bottles only; source builds, casks and taps go direct, so pair it with
chainsaw guard init (the brew shim) and chainsaw brew env.
The Chainsaw server URL baked into the block comes from the standard config
chain: the root –server flag, the CHAINSAW_SERVER environment variable, or
the saved config (set via chainsaw auth login). If no server is
configured, the block is still written but without a server URL.
The generated URLs are <server>/repository/@<org-slug>/<ecosystem>/, matching
the dashboard’s “Save this secret now” snippet exactly. Any base path comes
from the configured server URL itself, so the hosted service
(--server https://chain305.com/chainproxy) and a proxy you run yourself at
the root of a host (--server http://localhost:8787) each get a URL their own
proxy serves.
The org slug is resolved from –org when set, then from your account after
chainsaw auth login, and finally falls back to a visible placeholder so a
misconfigured install fails loud: the proxy rejects SLUG-less URLs with
CHW-4314 (“legacy URLs without the org slug are disabled”). An explicit –org
is recorded as org_slug in the CLI config when none is recorded yet, so
doctor --strict checks the wiring against that org.
Exit 13 means install-hook changed nothing because your own config already chooses where that manager resolves from; –json keeps every exit code. Registries listed in hook_trusted_sources (or CHAINSAW_HOOK_TRUSTED_SOURCES) are kept beside chainsaw instead of refused.
Examples: chainsaw install-hook npm chainsaw install-hook –all chainsaw –server https://chain305.com/chainproxy install-hook npm –org acme-corp
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--all | bool | — | Wire every installed manager |
--credentials | string | — | Embed the given “client_id:client_secret” pair in the generated config. When unset the CLI offers to issue a fresh pair for you on a TTY. |
--no-credentials | bool | — | Skip the credentials prompt and emit an unauthenticated block (the pre-2026-04 behaviour). |
--org | string | — | Org slug to splice into the generated URLs (e.g. acme-corp). Auto-discovered from your account when unset and you are logged in. Required by the proxy — slug-less URLs fail with CHW-4314. |
--scope | string | — | Where to write config: “user” (global) or “project” (current dir). Prompts when unset on a TTY. |
The global flags apply here too.