Skip to content

Install

Method Command Needs
mise (recommended) mise use "github:mpyw/[email protected]" Nothing. Installs the prebuilt binary
go tool go get -tool github.com/mpyw/declscope/cmd/declscope@latest Go 1.27+
go install go install github.com/mpyw/declscope/cmd/declscope@latest Go 1.27+
Release archive See below Nothing
declscope ./...
Pin a version, run through go vet, or install from an archive

mise use pins the version in the project's mise.toml, so every checkout and CI run the same one. Add -g to install it for every project on your machine instead.

[tools]
"github:mpyw/declscope" = "0.24.5"

As a tool dependency in go.mod:

go get -tool github.com/mpyw/declscope/cmd/declscope@latest
go tool declscope ./...

Through go vet, which runs it with the same package loading as the rest of your vet checks:

go vet -vettool=$(which declscope) ./...

Warning

go vet does not see changes to config or baseline files. It caches the result of each package, and the cache key does not include these files. After a change to either one, run go vet once with -a:

go vet -a -vettool=$(which declscope) ./...

Without -a, go vet can report the result of the old configuration. New diagnostics can be missing, and old ones can remain. Running declscope directly is not affected.

Without installing anything:

go run github.com/mpyw/declscope/cmd/declscope@latest ./...

From a release archive, verified against the published checksums:

VERSION=0.24.5
curl -LO "https://github.com/mpyw/declscope/releases/download/v${VERSION}/declscope_${VERSION}_darwin_arm64.tar.gz"
curl -LO "https://github.com/mpyw/declscope/releases/download/v${VERSION}/checksums.txt"
shasum -a 256 -c checksums.txt --ignore-missing
tar xzf "declscope_${VERSION}_darwin_arm64.tar.gz"

Flags

Flag Default Effect
-config (discovered) Path to a YAML config file. Skips the .declscope.yaml lookup
-test true Analyze *_test.go files as well
-fix false Apply suggested fixes
-diff false With -fix, print a diff instead of writing files
-V=full Print the version and exit. go run, or a build with -buildvcs=false, answers devel

-test, -fix and -diff come from go/analysis. declscope -help lists the rest.

Subcommands

Command What it does Flags of its own
declscope survey [packages] Report what was checked and what it found, one row per package -format, -test, -config, -allow-errors
declscope inspect <package> Report the shape of one package: its namespaces and the crossings between them -format, -test, -config
declscope baseline [packages] Record the violations a codebase already has, shrink's included -config, -o, -shrink, -merge
declscope shrink [packages] Unexport what no importer uses, inside internal/ -fix, -config
declscope skill install Install the authoring and adoption skills for an AI agent --agent, --scope

declscope <subcommand> -help lists each one's flags.