On this pageStart from the mistakes
Coding assistants and agents write plausible code at a speed no reviewer can match line by line. Most of it is fine. The rest fails in predictable ways: unused imports and variables, names that do not exist, exceptions caught far too broadly, shell=True and string-built SQL, dead code left behind after a refactor. A linter catches exactly this class of mistake, in seconds, every time. The trick is to make it a gate rather than a suggestion, including against an agent that "fixes" a warning by silencing it.
Start from the mistakes
Tune the rules from the mistakes you actually see in generated code, and make sure each one has a rule that fails the build:
| Typical mistake | Python (Ruff) | TypeScript (ESLint) | Go (golangci-lint) |
|---|---|---|---|
| Unused import or variable | F401, F841 |
@typescript-eslint/no-unused-vars |
unused |
| Name or method that does not exist | F821, plus a type checker |
the TypeScript compiler | the compiler, govet |
| Error silently ignored | BLE001 (blind except) |
@typescript-eslint/no-floating-promises |
errcheck |
| Shell command built from input | S602 |
plugin rules, if you add them | gosec G204 |
| SQL assembled from strings | S608 |
plugin rules, if you add them | gosec G201, G202 |
| Hard-coded secret | S105 |
plugin rules, if you add them | gosec G101 |
The empty spots in the TypeScript column are a reminder that ESLint's core and typescript-eslint focus on correctness; security patterns need extra plugins or a separate scanner.
Where the gate runs
| Layer | Runs | Purpose | Can be skipped? |
|---|---|---|---|
| Editor or agent hook | After each edit | Instant feedback while code is written | Yes |
| pre-commit | On git commit |
Stop obvious problems before they leave the laptop | Yes, with --no-verify |
| CI required check | On every push and pull request | The real gate | No, if branch protection requires it |
All three should read the same configuration files from the repository. Then the rules are identical whether a person, an assistant in an editor or an autonomous agent wrote the code.
Rule sets that catch them
Each language below gets a configuration aimed at the mistakes table above, plus the commands to run it by hand.
Ruff for Python
Ruff is a fast linter and formatter that implements rules from many older tools. The default rule set is conservative, so select more. This configuration in pyproject.toml targets the mistakes generated code tends to make:
[tool.ruff]
line-length = 100
target-version = "py312"
[tool.ruff.lint]
select = ["E", "F", "B", "UP", "S", "BLE", "ERA", "T20", "PGH", "RUF", "C90", "I"]
[tool.ruff.lint.per-file-ignores]
"tests/**" = ["S101"]
[tool.ruff.lint.mccabe]
max-complexity = 10
What the less obvious groups catch: S brings security checks such as subprocess with a shell and SQL assembled from strings; BLE flags blind except Exception; ERA finds commented-out code; T20 catches leftover print() calls; C90 limits function complexity. Two rules police suppressions themselves: PGH004 rejects a blanket # noqa without a rule code, and RUF100 reports noqa comments that no longer suppress anything.
ruff check . # lint
ruff check --fix . # apply safe fixes
ruff format --check . # formatting, without rewriting files
Ruff does not check types. Generated code often calls methods that do not exist on an object, which only a type checker such as mypy or Pyright catches, so run one alongside it.
ESLint 10 for TypeScript
ESLint 10 removed the old .eslintrc format for good: configuration lives only in eslint.config.* files, and it needs Node.js 20.19, 22.13, 24 or newer. With typescript-eslint's type-aware rules, an eslint.config.mjs looks like this:
import js from '@eslint/js';
import { defineConfig } from 'eslint/config';
import tseslint from 'typescript-eslint';
import comments from '@eslint-community/eslint-plugin-eslint-comments/configs';
export default defineConfig(
{
files: ['**/*.ts'],
extends: [js.configs.recommended, tseslint.configs.recommendedTypeChecked],
languageOptions: { parserOptions: { projectService: true } },
linterOptions: { reportUnusedDisableDirectives: 'error' },
},
comments.recommended,
{
rules: {
'@eslint-community/eslint-comments/require-description': 'error',
},
},
);
Type-aware rules catch floating promises, unsafe any flows and misused async functions, which are frequent in generated TypeScript. reportUnusedDisableDirectives turns stale eslint-disable comments into errors, and the eslint-comments plugin requires every directive to explain itself after a -- separator. Run it with zero tolerance for warnings, plus the compiler for type errors:
npx eslint . --max-warnings 0
npx tsc --noEmit
golangci-lint v2 for Go
golangci-lint bundles dozens of Go linters behind one configuration. Version 2 changed the file format, so start from the v2 layout in .golangci.yml:
version: "2"
linters:
default: standard
enable:
- gosec
- errorlint
- nolintlint
settings:
nolintlint:
require-explanation: true
require-specific: true
formatters:
enable:
- gofmt
- goimports
The standard set covers the essentials, including govet, staticcheck and errcheck, which catches the ignored error returns generated Go code is fond of. gosec adds security checks, and nolintlint forces every //nolint to name the linter it silences and say why. The project recommends installing a release binary rather than using go install:
curl -sSfL https://golangci-lint.run/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.15.0
golangci-lint run
golangci-lint fmt
One hook file for three languages
The pre-commit framework runs hooks on staged files before each commit. One .pre-commit-config.yaml can cover all three languages:
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.17.5
hooks:
- id: ruff-check
args: [--fix]
- id: ruff-format
- repo: local
hooks:
- id: eslint
name: eslint
entry: npx eslint --max-warnings 0
language: system
files: \.(js|mjs|cjs|ts|tsx)$
- id: golangci-lint
name: golangci-lint
entry: golangci-lint run --new-from-rev HEAD
language: system
types: [go]
pass_filenames: false
Run pre-commit install once per clone. The --new-from-rev HEAD flag limits Go findings to changed code, which makes adopting strict rules on an existing codebase bearable.
In CI, run the same file against the whole repository with pre-commit run --all-files --show-diff-on-failure, after installing Node dependencies and the golangci-lint binary. One configuration then drives both the local hook and the server-side check, so they cannot drift apart.
Close the loopholes
Anyone, human or agent, can skip local hooks with git commit --no-verify. The gate that counts runs in CI:
- Make the lint job a required status check on the protected branch, so nothing merges while it fails.
- Protect the rules themselves. An agent asked to make the build pass may relax the configuration instead of fixing code. Assign the config files to a reviewer group with
CODEOWNERS:
pyproject.toml @acme/platform
eslint.config.mjs @acme/platform
.golangci.yml @acme/platform
.pre-commit-config.yaml @acme/platform
- Watch the suppression count. A pull request that adds ten
noqacomments deserves a question. This prints the current total, which CI can compare with the main branch:
git grep -nE "noqa|eslint-disable|nolint" -- '*.py' '*.ts' '*.go' | wc -l
- Tell the agent the rules. An instructions file in the repository, such as
AGENTS.md, which several coding agents read, should say to run the linters before finishing and never to add suppressions without a stated reason.
The limits of linting
Linters find patterns, not intent. Wrong business logic, a misunderstood requirement, an outdated API that still compiles and code copied with an incompatible license all pass cleanly. Lint gates free reviewers from spotting unused imports so they can spend attention on those questions. Tests and review remain the rest of the safety net.
FAQ
Should the agent apply fixes automatically?
Safe fixes, yes: ruff check --fix and eslint --fix only apply changes their authors consider safe. Ruff keeps riskier rewrites behind a separate --unsafe-fixes flag; leave that to a human.
Will strict rules slow development down?
Briefly. The first week brings a wave of findings, then the rules mostly guide code into shape as it is written. Using --new-from-rev or a baseline for legacy code keeps the initial wave small.
What about shell scripts and Dockerfiles?
Lint them too, because generated scripts often forget quoting and error handling. ShellCheck flags unquoted variables and other classic shell traps, and Hadolint checks Dockerfiles for problems such as unpinned package versions. Both run fine as pre-commit hooks and CI steps.
Is formatting part of the gate?
Yes. Run ruff format --check, gofmt through golangci-lint, or Prettier for JavaScript in check mode. Consistent formatting keeps diffs small, which makes reviewing generated code faster.
Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.




