What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
declscope is a Go static analyzer that flags when code in one file uses a helper or field that a team meant to keep inside another file or its own file. It is a narrow boundary checker. It does not measure or prove that it makes AI-generated Go code better overall, and no published study currently supports a “dramatic” quality gain.
Why Go’s visibility rules don’t stop an AI agent from crossing files
Go has two visibility levels. Capitalized names are exported and usable from other packages. Lowercase names are unexported, and they are visible to every file in the package that declares them. The compiler does not know about file ownership, so a convention such as “this helper belongs to parser.go” is invisible to it.
As an Amazon Associate I earn from qualifying purchases.
That gap matters more when an AI coding agent is editing the code. An agent that sees an unexported helper in scope may call it from another file, or reach into an unexported struct field. The result usually compiles and passes the tests, yet it violates the boundary the team intended. Nothing in the standard toolchain reports that violation.
The project behind declscope frames the underlying tension the same way. Teams often split a package only to enforce a boundary, and that split brings costs of its own: import cycles, interfaces added only to break those cycles, and names that have to become exported. A per-file convention keeps the package flat, but only a checker can enforce it.
#1 Best Overall
What declscope adds: private and package scopes
declscope adds two pseudo-scopes on top of Go’s existing rules. A declaration marked private stays within its file. A declaration marked package is deliberately shared across the files of its package, without splitting the package into subpackages. The scopes are expressed with directives, //declscope:private and //declscope:package, and they are checked during static analysis at each use site.
| Visibility level | How it is set | Where a use is allowed | Who enforces it |
|---|---|---|---|
| Exported (capitalized name) | Capitalization | Any package that imports this one | Go compiler |
| Unexported (lowercase name) | Lowercase name | Any file in the declaring package | Go compiler |
| declscope private | //declscope:private directive |
Its own file | declscope |
| declscope package | //declscope:package directive |
Files in the same package, as a deliberate shared scope | declscope |
The directive is a record of intent. A reader of the code can see that a helper is meant to stay in one file, and the linter can report any call that crosses that line.
How the boundary rule reports a crossing
The boundary rule detects a use from a different file or namespace than the one a declaration’s scope allows. Each diagnostic names the namespace that was crossed. From there there are two outcomes, and the choice is yours:
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitches- Sharing is intended. Run the
-fixoption to add a widening scope directive, so the declaration becomes package-scoped and the cross-file call is legitimate. - The boundary should hold. Move the call into the owning namespace. The project’s guidance is to restructure the code rather than widen the scope.
The project also documents configuration for defaults, naming, boundary checks, and detection of unused directives. Those options are documented in the project’s package page, linked below.
How do I install declscope?
The README lists several routes: mise (recommended), Go tool dependencies, go install, go run, and prebuilt release archives. The current README states that the go tool and go install routes require Go 1.27 or later. Go’s own dependency guide describes a broader feature floor: since Go 1.24, developer tools can be tracked with go get -tool and run with go tool. Check the project’s release notes before you publish an installation snippet, because both the tool version and the toolchain requirement can change.
- Confirm your toolchain is at least the version the README names for your route. Run
go version. - Add declscope as a tool dependency in the module:
go get -tool github.com/mpyw/declscope/cmd/declscope@latestThis records the tool in
go.mod. Because@latestis a moving reference, replace it with a specific release, such as v0.18.0 (the version current as of early October 2026), before using it for team builds. - Run the linter across the module:
go tool declscope ./...
For reproducible team use, the project also shows pinning the version in mise.toml. Use one pinning method across the team so every developer and CI job runs the same analyzer version.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCan an AI coding agent call unexported Go functions from another file?
Yes. Lowercase names are visible throughout their package, so an agent can call them from any file and the compiler will accept the call. declscope does not prevent the edit. It reports the crossing when it is a use that violates a declared scope, and it can suggest a fix. That makes it a guardrail that runs after the agent writes code, not a restriction on what the agent can type.
The project recommends running the linter both in continuous integration and inside the agent’s edit loop, so the crossing is reported before it reaches review. Treat the report as the first check, followed by human review and tests.
Adopting declscope in an existing codebase
A large existing package will usually have violations on day one. The project’s approach is to record them rather than fix them all at once.
- Record the baseline. Run
declscope baseline ./.... Existing violations are recorded, and new ones remain visible. The README says to regenerate the baseline rather than edit it by hand. - Survey the results. Run
declscope surveyto see what was checked and found in each package. - Inspect the crossings. Run
declscope inspect <package>to see the namespaces and the crossings between them. - Use JSON for agent work. When an AI agent is helping you introduce the tool, use the JSON output the README describes, and rank crossings by the
crossings[].clearsfield so the agent works on the highest-value items first. - Run in CI and in the edit loop. Keep the check in continuous integration so that new violations fail in the same way for people and agents.
If you run it through go vet with -vettool, be aware of caching. The README notes that go vet may cache results without configuration and baseline files in its cache key. After changing either file, run with -a, or run declscope directly.
Recommended Free Tools
Where declscope does not look
The analyzer reads one package at a time and counts a use when a name is written in source. It does not see the following cases, so a clean report does not cover them:
Rank #4
- Uses from outside the package.
- Whole-value operations on a struct, such as copies, comparisons, or zeroing, that do not name a field.
- Reflection.
//go:linknamereferences.- Generated files.
- Declarations with no uses. An unused declaration produces no boundary diagnostic, so the README points to a separate unused-code linter for that job.
declscope is therefore not a general code-quality, correctness, security, or dead-code analyzer. It is useful only where a team has file-level ownership conventions worth enforcing and is willing to adopt and configure them deliberately.
Does declscope measurably improve AI-written Go code?
The available evidence does not show it. The project describes its purpose as a guardrail for agent edits, and it does not publish a study measuring defect rates, productivity, or review effort for AI-written code. The Google Developers Blog article “Why Go is an Ideal Language for AI-Assisted Software Engineering,” by Cameron Balahan (Group Product Manager, Go) and Richard Seroter (Chief Evangelist, Google Cloud), published August 11, 2026, makes a related point about human responsibility. It states: “What matters now is reviewing, verifying, and maintaining that code once it’s already written.” The article does not evaluate declscope.
The fair claim is narrower: declscope can detect a specific kind of cross-file use that the compiler accepts, and it can do so before that use reaches a reviewer. Whether that reduces defects in your codebase is a question for your own measurements.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →declscope compared with adjacent Go tools
The project names two neighbouring tools to clarify scope. They differ mainly in the boundary they examine.
Best Value
| Tool | Boundary it examines | What it checks |
|---|---|---|
| declscope | Uses inside one package, across files | Whether a use crosses a declaration’s private or package scope |
| depguard | Imports between packages | Which packages may import which |
| deadcode | Whole program | Whether code is reachable at all |
When choosing among them, compare the boundary scale, whether the tool checks declarations or package imports, how it fits your existing CI and Go tooling, and what each one leaves uncovered.
Licensing and source
declscope is released under the MIT License. Its package documentation and README are on the project’s pkg.go.dev page, which describes version v0.18.0, published October 2, 2026. The project’s own tagline is: “Keep your Go packages flat without letting them turn into a free-for-all.” That is the maintainers’ description of their goal, not an independent assessment.
Source for the Go toolchain and dependency guidance: Managing dependencies, The Go Programming Language.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Sources: declscope package documentation and README; Why Go is an Ideal Language for AI-Assisted Software Engineering, Google Developers Blog, August 11, 2026.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




