Skip to content

feat(route): guide golangci-lint through forbidigo and depguard - #722

Merged
aibex-agent[bot] merged 2 commits into
mainfrom
aibex/t_Xj9VO97SFjZFYcrgQtLmkz4g
Nov 30, 2026
Merged

aibex-agent[bot] merged 2 commits into
mainfrom
aibex/t_Xj9VO97SFjZFYcrgQtLmkz4g

Conversation

@aibex-agent

@aibex-agent aibex-agent Bot commented Nov 29, 2026

Copy link
Copy Markdown

#712 reports that detect --json found no linter in a Go repository with a golangci-lint v2 config, so the legacy ladder was skipped and had to be re-derived by hand.

The detection half does not reproduce. LINTER_SIGNALS has carried a golangci-lint entry (all four config spellings, the go.mod tool/require dependency, the golangci-lint invocation) since v0.10.0. Built from both v0.13.7 and HEAD, detect --json on the issue's exact repository (go.mod plus the .golangci.yml with version: "2", forbidigo, gosec) reports golangci-lint with evidence .golangci.yml. It also holds for a nested module and for a scan root under a directory named build, bin or vendor. countCustomRules already falls through to default for it, as the issue asks.

The ladder half does reproduce. route named golangci-lint only on its "also detected, with no guide of their own" line and sent the agent to the generic create-legacy-rule recipe, which names catch-alls for ESLint, Ruff, Biome and pylint and none for Go. That is the "re-derived by hand" in the report.

Changes

  • create-legacy-rule.golangci-lint.md: check forbidigo and depguard first; find a bundled linter with golangci-lint help linters; confirm with golangci-lint linters; write settings in the config's own version (linters.settings for v2, linters-settings for v1) without migrating it; verify with golangci-lint config verify. detect counts no golangci-lint custom rules, so it never authors a ruleguard rule or module plugin.
  • A golangci-lint paragraph in route's per-linter passage.
  • Tests: detection from each of .golangci.{yml,yaml,toml,json}, from the issue's v2 config and its v1 form (with no custom-rule count), and no linter for a Go repo without a config; the route paragraph; the recipe's catch-all order and v1/v2 keys.
  • OpenSpec golangci-lint-legacy-recipe, archived: MODIFIED deltas to cli-legacy-rule-recipes and cli-rule-routing, restated in full. Checked that every prior scenario survives the archive.
  • One patch changeset.

The recipe's claims were checked against golangci-lint's documentation (configuration file, CLI, linter settings, migration guide). Two corrected assumptions: forbidigo has a default pattern list, and depguard with no rules allows only the standard library, so the recipe says neither is a no-op when unconfigured. Not run against a real golangci-lint binary; there is no vendor-contract test for it like the Python and JS linters have.

pnpm typecheck, pnpm lint, and the CLI suite (3426 tests) pass locally.

Fixes #712

detect has recognized golangci-lint since v0.10.0, but route named it
only as a tool with no guide of its own, so an agent in a Go repository
had to work out golangci-lint's catch-alls and its v1/v2 config layout
by hand. Add a create-legacy-rule recipe and a route paragraph for it,
and pin detection for each config spelling and for v1 and v2 configs.
@aibex-agent

aibex-agent Bot commented Nov 29, 2026

Copy link
Copy Markdown
Author

@claude /review

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @aibex-agent[bot]'s task in 2m 11s —— View job


Review complete

Review mode: incremental — read 0 prior review thread(s) before reviewing. The .prior-review.json snapshot contained no prior reviews, review threads, or top-level comments beyond the trigger itself, so this is the first review of this PR; nothing is being treated as already addressed.

  • Read prior review data (none found)
  • Fetch PR diff and metadata
  • Review recipe file create-legacy-rule.golangci-lint.md
  • Review route changes in recipes.ts
  • Review detection/ladder/prompts tests
  • Review OpenSpec deltas
  • Post final summary

Findings

One [New] low-severity nit, posted inline on packages/cli/src/agent/create-legacy-rule.golangci-lint.md:27: the pkg-matching example ^v1.Dump$ has an unescaped ., which as a regex matches any character — inconsistent with the correctly-escaped ^fmt\.Print.*$ example a few lines below, and self-undermining given the paragraph's point is precise package disambiguation.

What I checked and why I found it sound

  • Detection claims verified against the code. packages/cli/src/detect/scan.ts:317-328 already carries the golangci-lint signal (all four config spellings, the go.mod dep, the invocation regex) exactly as the PR body describes, and countCustomRules in custom-rules.ts falls through to default: return undefined for golangci-lint — confirming detect.test.ts's customRules).toBeUndefined() assertions are testing real behavior, not something the diff invented.
  • New recipe file is correctly wired. recipes.ts loads ../agent/*.md via import.meta.glob, so the new create-legacy-rule.golangci-lint.md is picked up with no manifest change needed, and its filename matches the --tool=golangci-lint variant-lookup convention documented at recipes.ts:230-231.
  • route paragraph integrates generically. The new LEGACY_LINTER_GUIDE entry (recipes.ts:707-713) needs no special-casing in legacyLintersBlock — the existing filter/guided-set logic at recipes.ts:753-759 already handles any new entry, and golangci-lint is correctly left out of NOT_A_LEGACY_HOST since it is a real legacy rule host.
  • Recipe content cross-checked for internal consistency. The v1/v2 config-key split (linters.settings vs linters-settings), the "don't auto-migrate" caution, and the "neither catch-all is a no-op unconfigured" claims are all self-consistent with the OpenSpec deltas and the test assertions in legacy-ladder.test.ts.
  • Tests are adequate. Config-spelling coverage (.yml/.yaml/.toml/.json), the v1/v2 reproduction of detect: recognize golangci-lint #712's exact scenario, the no-config-no-linter case, the route paragraph content/ordering, and the catch-all-before-bundled-linter ordering in the recipe text are all exercised.
  • No CLAUDE.md exists in this repo to check against.

Not independently verified (no network access, consistent with the PR's own "not run against a real golangci-lint binary" caveat): the real-world accuracy of golangci-lint config verify, golangci-lint config path, linters.default's sets, and the exact bundled-default pattern list for forbidigo.

- `forbidigo`: bans identifiers matched by a regular expression, each
with its own message, through `forbid` entries of `pattern` and
`msg`. With `analyze-types: true`, a `pkg` pattern matches the
import path, so `^v1.Dump$` can mean one package's `Dump` and not

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[New] Minor doc nit: ^v1.Dump$ has an unescaped ., which as a regex matches any character, not just a literal dot (so it would also match e.g. v1xDump). The same recipe correctly escapes the dot elsewhere (^fmt\.Print.*$ at line 66), and this paragraph's own point is precision ("one package's Dump and not another's"), so the unescaped example undercuts itself if an agent copies it literally into a real forbidigo pattern.

Suggested change
import path, so `^v1.Dump$` can mean one package's `Dump` and not
import path, so `^v1\.Dump$` can mean one package's `Dump` and not

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d81147d: the example is now ^v1\.Dump$.

@aibex-agent
aibex-agent Bot merged commit 1a18290 into main Nov 30, 2026
6 checks passed
@aibex-agent
aibex-agent Bot deleted the aibex/t_Xj9VO97SFjZFYcrgQtLmkz4g branch November 30, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

detect: recognize golangci-lint

1 participant