Skip to content
guidePhase: VerifyQualityGuide 6 of 16

Roles: developer · qa · security

Guide: Linters & Static Analysis ​

Decision: Which classic code-quality and security validators to run, where to run them, and how they complement AI-generated code.

Related: qa-guardrails.md · ai-guardrails-security.md · developer-workflow.md · SOP-005


Why this matters with AI-assisted development ​

AI tools generate code quickly but do not guarantee:

  • Consistent style or idioms
  • Type correctness
  • Security patterns (SQL injection, hardcoded secrets)
  • Dependency CVEs
  • Valid OpenAPI/spec syntax

Classic linters and static analyzers are the non-negotiable baseline. They are deterministic, auditable, and should run before AI PR review and human merge — locally, at commit, and in CI.


text
Editor (on save)  →  pre-commit (commit)  →  CI (PR + main)  →  CD (release image scan)
StagePurposeFail fast?
Editor / IDELint, format, typecheck on saveDeveloper feedback
pre-commitSame checks + secrets before pushBlock commit
CIFull suite on clean runnerBlock merge
CDContainer/IaC scan on artifactBlock deploy

Pitfall: CI-only checks → developers push broken code repeatedly and waste pipeline time. Mirror critical checks in pre-commit.


Tool categories ​

1. Linters (style, bugs, complexity) ​

Catch stylistic drift and common bug patterns. Essential when AI output varies in style.

LanguageCommon toolsProsCons
JavaScript / TypeScriptESLint, BiomeESLint: huge ecosystem; Biome: fast all-in-oneTwo formatters if ESLint + Prettier overlap
PythonRuff, Pylint, Flake8Ruff: fast; replaces many Flake8 pluginsPylint slower; strict defaults annoy teams
Gogolangci-lint (meta-linter)Single entry; many lintersConfig complexity
Java / KotlinCheckstyle, SpotBugs, detektMature in enterprise JavaGradle/Maven setup overhead
RustClippyIdiomatic Rust enforcement—
Shell / YAML / MarkdownShellCheck, yamllint, markdownlintCI/config hygieneNoise on generated YAML

Suggested starting point: One linter per language; share config in repo root; extend gradually.


2. Formatters (auto-fix layout) ​

ToolLanguagesProsCons
PrettierJS/TS/CSS/JSON/MDDe facto standardLess control over style debates
BiomeJS/TSLint + format in oneNewer ecosystem
BlackPythonZero configConflicts with older Pylint rules
Ruff formatPythonBlack-compatible; fastTeams on Black already may duplicate
gofmt / goimportsGoBuilt-in culture—
rustfmtRustStandard—

Pitfall: Formatter wars in PRs. Pick one; run in CI; AI agents should use same config via .editorconfig + checked-in config files.


3. Type checkers (static typing) ​

ToolLanguagesProsCons
TypeScript (tsc)TSCatches API shape errors earlyany bypasses checks
mypy / pyrightPythonCatches AI wrong-type assignmentsGradual typing migration pain
Java compilerJavaStrong typing built-in—

With AI: Require typed public APIs; AI often omits types or uses overly broad types. Typecheck in CI catches this before runtime.


4. SAST (security static analysis) ​

Find vulnerability patterns in source code.

ToolProsCons
SemgrepCustom rules; fast; good for CIRule tuning needed
CodeQL (GitHub)Deep analysis; query languageHeavier; GitHub-centric
SonarQubeDashboard; quality gate historyServer to operate
Checkmarx / VeracodeEnterprise complianceCost; slower feedback
BanditPython-focusedPython only

Suggested starting point: Semgrep OSS rules + language-specific (Bandit for Python) in CI; block Critical/High.

Pitfall: AI generates plausible but insecure code (string SQL, path traversal). SAST catches patterns humans miss in fast review.


5. SCA (software composition analysis) ​

Scan dependencies for known CVEs and license issues.

ToolProsCons
DependabotGitHub-native; PRs for bumpsGitHub-only
RenovateMulti-platform; flexibleConfig learning curve
SnykDev-friendly; container tooCost at scale
AWS InspectorAWS-native for ECR/Lambda depsAWS-centric
OWASP Dependency-CheckOpen sourceFalse positives

Pitfall: AI adds dependencies casually (import obscure-lib). SCA must run on every PR that touches lockfiles.


6. Secret scanners ​

ToolProsCons
gitleaksFast; pre-commit hookFalse positives in tests
GitGuardianEnterprise policyCost
TruffleHogDeep history scanSlower
detect-secretsBaseline allowlistMaintenance of baseline

With AI: Models occasionally emit fake or real-looking keys. Block merge on any new secret pattern; never rely on human eyeballing diffs.


7. License compliance ​

ToolProsCons
FOSSAPolicy dashboardsCost
Snyk LicenseBundled with SCA—
license-checker (npm)Simple npmnpm only
pip-licenses / go-licensesCLI per ecosystemManual aggregation

Pitfall: AI imports GPL library into proprietary service. Automate license scan on dependency changes.


8. IaC & config validators ​

ToolTargetsProsCons
CheckovTerraform, CloudFormation, K8sBroadVerbose defaults
tfsec / Trivy (IaC)TerraformFastOverlap with Checkov
cfn-lintCloudFormationAWS-nativeCFN only
CDK NagAWS CDKAspect-based rulesCDK only
kubeconform / kube-linterKubernetes manifestsK8s hygiene—
OPA / ConftestCustom policyLinks to ADRsWrite policies

Suggested starting point: Checkov or CDK Nag for AWS teams; Conftest for org-specific rules referencing ADRs.


9. Container & image scanners ​

ToolProsCons
TrivyOS + app CVEs; IaC—
ECR enhanced scanningAWS-nativeAWS-only
Grype / SyftSBOM + scanExtra tooling
Snyk ContainerUnified with SCACost

Run at image build and block Critical CVEs on deploy (tier-dependent exceptions via SOP-012).


10. API & spec validators ​

ToolPurposeProsCons
SpectralOpenAPI/AsyncAPI lintCustom rules (e.g. require x-adr)Rule authoring
openapi-diffBreaking change detectionProtects consumersNeeds baseline spec
bufProtobuf breaking changesStrong for gRPCNot for OpenAPI-only shops
SchemathesisProperty-based API testingFinds spec violationsNot a linter — pairs with spec

With AI: AI drafts OpenAPI with subtle errors. Spectral in spec PR CI; Schemathesis in service CI.


11. Orchestration: pre-commit ​

ApproachProsCons
pre-commit frameworkLanguage-agnostic hooks; shared configDevelopers must install hooks
Husky + lint-stagedJS ecosystem standardJS-centric
CI onlyNo local setupSlow feedback loop

Suggested hooks (minimum): secrets (gitleaks) → formatter → linter → typecheck (if applicable).

Example hook categories for your project (implement in your repo, not here):

text
gitleaks protect
ruff check / eslint
ruff format --check / prettier --check
mypy / tsc --noEmit
spectral lint specs/openapi/*.yaml   # on spec changes only

CI gate matrix (reference) ​

Adapt severity by service tier (GOVERNANCE.md).

CheckLocal / pre-commitCI merge gateTypical block threshold
FormatterYesYesAny diff
LinterYesYesErrors (warnings advisory)
TypecheckYesYesAny error
Unit testsOptional localYesAny failure
Secret scanYesYesAny finding
SASTOptionalYesCritical/High
SCA—YesCritical CVE (configurable)
IaC scan—Yes (IaC changes)High+
Container scan—Yes (deploy stage)Critical
OpenAPI lint—Yes (spec changes)Errors
AI PR review—Advisory → blockingTeam policy

AI + classic tools: division of labor ​

ConcernClassic toolAI review
Formatting / styleFormatter + linterUnreliable for consistency
Known CVE patternsSCA, container scanMay miss new CVEs
OWASP top 10 patternsSASTMay miss context
Secret leakagegitleaksPitfall: AI invents keys
Business logic bugsTests + human reviewAI review helps
Architecture fitADR + OPA + humanAI may suggest wrong pattern

Rule: Never drop classic validators because AI review is enabled. AI review stacks on top, not replaces.


Pitfalls ​

PitfallWhy it hurtsMitigation
Lint only in CISlow iteration; noisy PRspre-commit + editor
Different configs per developerAI + human code clashSingle checked-in config
Warning fatigueReal issues ignoredFix or disable rule explicitly
Grandfathering entire repoNew code clean; old rot remainsRatchet or phased fix
AI bypasses type systemRuntime errors in prodStrict typecheck CI
No lockfile scanCVE in transitive depSCA on every lockfile change
Secrets in test fixturesgitleaks false positives or real leaksSynthetic fixtures; allowlist baseline
Duplicate toolsESLint + Biome + Prettier overlapConsolidate
Spec lint missingAI OpenAPI invalidSpectral on spec PRs
Container scan only at deployLate surpriseScan in CI after build

Suggested starting point (minimal enterprise set) ​

LayerTools
JS/TS serviceESLint + Prettier + tsc + Jest/Vitest
Python serviceRuff (lint+format) + mypy + pytest
Go servicegolangci-lint + go test
All reposgitleaks (pre-commit) + Dependabot/Renovate
CISemgrep + Snyk or Inspector + Checkov/CDK Nag
SpecsSpectral + Schemathesis in service CI
DeployTrivy or ECR scan on image

Add SonarQube or CodeQL when compliance or scale demands central quality dashboards.


Reference template only — no production code. Adapt in your own project.